How to determine arbitrary constants with "Solve?"

  • Mathematica
  • Thread starter aheight
  • Start date
  • Tags
    Constants
In summary, The user is trying to solve a system of linear equations with more unknowns than equations. They have attempted to use the Solve function, but have encountered some issues with determining which variables are arbitrary. They have found a workaround by manually checking the equations and have also received suggestions to approach the problem using linear algebra. They have made progress in this direction by using the MatrixRank function to determine if there are at most N-1 linearly independent equations in the system.
  • #1
321
109
Hi,

I am using Solve to solve a system of linear equations with more unknowns than equations. For example, I have 36 variables and Solve returns 30 equations. Six of the variables I can assign a value of one. But I can only figure out which ones are arbitrary by manually looking at the equations. In the example below, the subscripts 0, 1,2, 10, 11, and 12 are arbitrary. But I would want to solve larger systems and manually looking for the arbitrary variables is not practical. Just to make the notation clear, the subscripts are 0,1,2,3,4,5,10,11,12,13,14,15,20,21,22,23 24,25 and so on for a total of 36.

Would someone know of a way that I can programatically determine which ones are arbitrary and then assign them for example a value of one and then get the rest of them?

Thanks for reading.

##\left\{\left\{s_3\to -10 s_0-6 s_1-3 s_2,s_4\to 15 s_0+8 s_1+3 s_2,s_5\to -6 s_0-3 s_1-s_2,s_{13}\to -40 s_0-16 s_1-4 s_2-10 s_{10}-6 s_{11}-3 s_{12},s_{14}\to 80 s_0+32 s_1+8 s_2+15 s_{10}+8 s_{11}+3 s_{12},s_{15}\to -40 s_0-16 s_1-4 s_2-6 s_{10}-3 s_{11}-s_{12},s_{20}\to -10 s_0-4 s_{10},s_{21}\to -20 s_0-10 s_1-4 s_{10}-4 s_{11},s_{22}\to -30 s_0-20 s_1-10 s_2-4 s_{10}-4 s_{11}-4 s_{12},s_{23}\to 220 s_0+94 s_1+26 s_2+36 s_{10}+20 s_{11}+8 s_{12},s_{24}\to -160 s_0-64 s_1-16 s_2-24 s_{10}-12 s_{11}-4 s_{12},s_{25}\to 0,s_{30}\to 20 s_0+6 s_{10},s_{31}\to 60 s_0+20 s_1+12 s_{10}+6 s_{11},s_{32}\to 120 s_0+60 s_1+20 s_2+18 s_{10}+12 s_{11}+6 s_{12},s_{33}\to -240 s_0-96 s_1-24 s_2-36 s_{10}-18 s_{11}-6 s_{12},s_{34}\to 0,s_{35}\to 0,s_{40}\to -15 s_0-4 s_{10},s_{41}\to -61 s_0-15 s_1-12 s_{10}-4 s_{11},s_{42}\to -154 s_0-61 s_1-15 s_2-24 s_{10}-12 s_{11}-4 s_{12},s_{43}\to 0,s_{44}\to 0,s_{45}\to 0,s_{50}\to 4 s_0+s_{10},s_{51}\to 16 s_0+4 s_1+3 s_{10}+s_{11},s_{52}\to 40 s_0+16 s_1+4 s_2+6 s_{10}+3 s_{11}+s_{12},s_{53}\to 0,s_{54}\to 0,s_{55}\to 0\right\}\right\}
##

And here is what I get when I assign the arbitrary ones to a value of one:

##\left\{\left\{s_3\to -19,s_4\to 26,s_5\to -10,s_{13}\to -79,s_{14}\to 146,s_{15}\to -70,s_{20}\to -14,s_{21}\to -38,s_{22}\to -72,s_{23}\to 404,s_{24}\to -280,s_{25}\to 0,s_{30}\to 26,s_{31}\to 98,s_{32}\to 236,s_{33}\to -420,s_{34}\to 0,s_{35}\to 0,s_{40}\to -19,s_{41}\to -92,s_{42}\to -270,s_{43}\to 0,s_{44}\to 0,s_{45}\to 0,s_{50}\to 5,s_{51}\to 24,s_{52}\to 70,s_{53}\to 0,s_{54}\to 0,s_{55}\to 0\right\}\right\}
##
 
Physics news on Phys.org
  • #2
Assuming the equations are linearly independent, then any set of 6 should be arbitrary.
 
  • #3
Dale said:
Assuming the equations are linearly independent, then any set of 6 should be arbitrary.

Hi Dale,

I tried using the first six, s0 through s5 but they must not be linearly independent then because Mathematica then returns an incomplete solution set (containing some s_i's). I have been working on the problem and have reduced it to coding in Mathematica, selecting from two lists, those elements that are not in both lists. This code:

val1 = theSolution // Flatten
val2 = Association[val1]
Keys[val2]
Flatten[theCoefficients]
iList = Intersection[Flatten[theCoefficients], Keys[val2]]

returns two lists: all the coefficients, and all the explicit solutions returned by Solve:

##\left\{s_0,s_1,s_2,s_3,s_4,s_5,s_{10},s_{11},s_{12},s_{13},s_{14},s_{15},s_{20},s_{21},s_{22},s_{23},s_{24},s_{25},s_{30},s_{31},s_{32},s_{33},s_{34},s_{35},s_{40},s_{41},s_{42},s_{43},s_{44},s_{45},s_{50},s_{51},s_{52},s_{53},s_{54},s_{55}\right\} ##

##\left\{s_3,s_4,s_5,s_{13},s_{14},s_{15},s_{20},s_{21},s_{22},s_{23},s_{24},s_{25},s_{30},s_{31},s_{32},s_{33},s_{34},s_{35},s_{40},s_{41},s_{42},s_{43},s_{44},s_{45},s_{50},s_{51},s_{52},s_{53},s_{54},s_{55}\right\}
##

note the second list is missing s0, s1, s2, s10,s11, and s12. Would you know of a compact way of selecting which elements of the two list are not in both of the list? I suppose I could do this by brute force checking each one (not exactly sure how) but I was just wondering if there is a more rule-oriented way of doing it?
 
Last edited:
  • #4
aheight said:
Hi Dale,

I tried using the first six, s0 through s5 but they must not be linearly independent then because Mathematica then returns an incomplete solution set (containing some s_i's).
For this type of problem, I would strongly recommend casting it as a matrix so that you can use the many existing linear algebra routines.

You can use CoefficientArray to cast it into matrix form. Then you should look at functions like NullSpace
 
  • Like
Likes aheight
  • #5
Dale said:
For this type of problem, I would strongly recommend casting it as a matrix so that you can use the many existing linear algebra routines.

You can use CoefficientArray to cast it into matrix form. Then you should look at functions like NullSpace

Yes, of course Dale. I should analyze the problem from the perspective of linear algebra.
 
Last edited:
  • #6
aheight said:
Would you know of a compact way of selecting which elements of the two list are not in both of the list?
By the way, although I recommend the linear algebra approach, if you ever need to do this the function you want is Complement.
 
  • Like
Likes aheight
  • #7
Dale said:
By the way, although I recommend the linear algebra approach, if you ever need to do this the function you want is Complement.

Thanks. That does the trick! Also I've made progress since you recommended the linear algebra approach: What I have is a homogeneous system of M equations in N unknowns. That system will have a set of infinite solutions (the kind I'm looking for) only if there exists at most N-1 linearly independent equations and I can easily determine this by using MatrixRank of the coefficient matrix. Here's the code I use:

theNormalForm =
Normal[CoefficientArrays[#, Flatten[theCoefficients]]] & /@
theEquations;
theCMatrix = #[[2]] & /@ theNormalForm;
Print["number of equations", Length[theEquations]];
Print["number of variables: ", Length[Flatten[theCoefficients]]];
Print["Matrix Rank: ", MatrixRank[theCMatrix]];

When the MatrixRank is at most one less than the number of variables, I know I have a good (non-trivial) solution.
 
Last edited by a moderator:
  • #9
By the way, Solve is often capable of working out which variables can be arbitrary. You can give it something like this

Code:
Solve[a+b+c == 7, {a,b,c}]
It will throw a warning, but it will spit out a solution, probably this one:

Code:
{{a -> 7-b-c}}
Then any variables that remain on the right-hand-side of the list of Rules returned can be considered arbitrary.
 

1. What is the purpose of using "Solve" to determine arbitrary constants?

The "Solve" function is used to solve equations and systems of equations, including those with arbitrary constants. It helps to find the specific values of these constants that satisfy the given equations.

2. How does "Solve" determine the arbitrary constants?

"Solve" uses algebraic methods to manipulate the equations and isolate the variables with arbitrary constants. It then solves for these variables using the given conditions and returns their values.

3. Can "Solve" be used for equations with multiple arbitrary constants?

Yes, "Solve" can handle equations with multiple arbitrary constants. It will return a list of solutions, each corresponding to a different combination of values for the constants.

4. Are there any limitations to using "Solve" for determining arbitrary constants?

One limitation is that "Solve" may not be able to find a solution if the equations are too complex or if there are not enough conditions given to uniquely determine the constants.

5. How can I check if the solution obtained from "Solve" is correct?

The simplest way to check the solution is to plug the values of the arbitrary constants back into the original equations and see if they satisfy them. You can also use graphing or other mathematical techniques to verify the solution.

Suggested for: How to determine arbitrary constants with "Solve?"

Replies
2
Views
1K
Replies
8
Views
1K
Replies
7
Views
1K
Replies
7
Views
2K
Replies
6
Views
2K
Replies
5
Views
919
Replies
2
Views
1K
Replies
2
Views
1K
Back
Top