ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 16 Mar 2015 14:40:52 -0500Questions about the parameters in the output of solvehttp://ask.sagemath.org/question/26205/questions-about-the-parameters-in-the-output-of-solve/I am writing a program that, among other things, has to solve many systems of polynomial equations (of degree <= 3) determined by the data entered by the user. Each system of equations consists of 3 equations in 3 variables. Sometimes the equations in a given system are redundant, and therefore the output of solve contains parameters (free variables). Is there any way to know which variables in the output of solve are the parameters (without having to look at the actual output in Sage)?
Here is a simple example.
x,y=var('x,y',domain=RR);
eqn1=x+y==1;eqn2=2*x+2*y==2;
soln=solve([eqn1,eqn2],x,y,solution_dict=True);
soln
The output is
[{x: -r6 + 1, y: r6}]
How do I know which variable is the free variable in this case (without looking at the output)? Is it true that the free variable(s) in the output of solve will always be the "last variable(s)" (in the alphabetical order), `y` in this case? Is there a `is_free_variable` function (similar to the `is_integer` function)? In my program, I need to be able to identify the free variables in the solution of solve, `y` in this case, without looking at the output, and substitute those variables by a few numerical values.
I understand that the `solve` function in Sage uses the corresponding Maxima function. It seems that Sage does not recognize the Maxima function `%rnum_list` (which gives the list of parameters introduced in the solutions by `solve` and `algsys`). Is there a Sage function that does the same as `%rnum_list`?
Thanks,
Aldo
Mon, 16 Mar 2015 11:06:26 -0500http://ask.sagemath.org/question/26205/questions-about-the-parameters-in-the-output-of-solve/Comment by kcrisman for <p>I am writing a program that, among other things, has to solve many systems of polynomial equations (of degree <= 3) determined by the data entered by the user. Each system of equations consists of 3 equations in 3 variables. Sometimes the equations in a given system are redundant, and therefore the output of solve contains parameters (free variables). Is there any way to know which variables in the output of solve are the parameters (without having to look at the actual output in Sage)?</p>
<p>Here is a simple example.</p>
<pre><code>x,y=var('x,y',domain=RR);
eqn1=x+y==1;eqn2=2*x+2*y==2;
soln=solve([eqn1,eqn2],x,y,solution_dict=True);
soln
</code></pre>
<p>The output is</p>
<pre><code>[{x: -r6 + 1, y: r6}]
</code></pre>
<p>How do I know which variable is the free variable in this case (without looking at the output)? Is it true that the free variable(s) in the output of solve will always be the "last variable(s)" (in the alphabetical order), <code>y</code> in this case? Is there a <code>is_free_variable</code> function (similar to the <code>is_integer</code> function)? In my program, I need to be able to identify the free variables in the solution of solve, <code>y</code> in this case, without looking at the output, and substitute those variables by a few numerical values.</p>
<p>I understand that the <code>solve</code> function in Sage uses the corresponding Maxima function. It seems that Sage does not recognize the Maxima function <code>%rnum_list</code> (which gives the list of parameters introduced in the solutions by <code>solve</code> and <code>algsys</code>). Is there a Sage function that does the same as <code>%rnum_list</code>?</p>
<p>Thanks,</p>
<p>Aldo</p>
http://ask.sagemath.org/question/26205/questions-about-the-parameters-in-the-output-of-solve/?comment=26206#post-id-26206With respect to your last question, possible `maxima_calculus("%rnum_list")`?Mon, 16 Mar 2015 12:46:20 -0500http://ask.sagemath.org/question/26205/questions-about-the-parameters-in-the-output-of-solve/?comment=26206#post-id-26206Comment by nbruin for <p>I am writing a program that, among other things, has to solve many systems of polynomial equations (of degree <= 3) determined by the data entered by the user. Each system of equations consists of 3 equations in 3 variables. Sometimes the equations in a given system are redundant, and therefore the output of solve contains parameters (free variables). Is there any way to know which variables in the output of solve are the parameters (without having to look at the actual output in Sage)?</p>
<p>Here is a simple example.</p>
<pre><code>x,y=var('x,y',domain=RR);
eqn1=x+y==1;eqn2=2*x+2*y==2;
soln=solve([eqn1,eqn2],x,y,solution_dict=True);
soln
</code></pre>
<p>The output is</p>
<pre><code>[{x: -r6 + 1, y: r6}]
</code></pre>
<p>How do I know which variable is the free variable in this case (without looking at the output)? Is it true that the free variable(s) in the output of solve will always be the "last variable(s)" (in the alphabetical order), <code>y</code> in this case? Is there a <code>is_free_variable</code> function (similar to the <code>is_integer</code> function)? In my program, I need to be able to identify the free variables in the solution of solve, <code>y</code> in this case, without looking at the output, and substitute those variables by a few numerical values.</p>
<p>I understand that the <code>solve</code> function in Sage uses the corresponding Maxima function. It seems that Sage does not recognize the Maxima function <code>%rnum_list</code> (which gives the list of parameters introduced in the solutions by <code>solve</code> and <code>algsys</code>). Is there a Sage function that does the same as <code>%rnum_list</code>?</p>
<p>Thanks,</p>
<p>Aldo</p>
http://ask.sagemath.org/question/26205/questions-about-the-parameters-in-the-output-of-solve/?comment=26210#post-id-26210The "free variable" in your example is r6, and the solution is described by giving how both x and y depend on it. It is certainly not the case that the "alphabetically largest" variable can always be chosen as a free variable, as the system [x==x, y==0] shows.Mon, 16 Mar 2015 14:40:52 -0500http://ask.sagemath.org/question/26205/questions-about-the-parameters-in-the-output-of-solve/?comment=26210#post-id-26210