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.Fri, 08 Feb 2019 22:01:44 -0600No Output Given : []http://ask.sagemath.org/question/44790/no-output-given/Hi all and thank you in advance for helping me. It shouldn't be a bad issue but when I try to find the solution to the following system of linear equations sage can't give me any solution, and gives the output "[ ]". The problem is that I have checked several times if I made something wrong on the formal aspect, but I don't find anything wrong (indeed sage doesn't tell me there is an error). I've set the system this way :
b, v, k, B, V, W, c, x, y, E, Q, H, S, P = var('b, v, k, B, V, W, c, x, y, E, Q, H, S, P')
eq1 = c*(S+P)==(1-(y-x))(S)+(y-x)(S+P*B)
eq2 = c*(S+P)+(1-c)*((2*S+P)((V-c)/(1-c)))==(1-(y-x))((2*S+P)(x/(1-(y-x))))+(y-x)(S+P*W)
eq3 = (2*S+P)*(x/(1-(y-x)))==S
eq4 = (S+P)*k==S+P*E
eq5 = (S+P)k+(1-k)((2*S+P)*((Q-k)/(1-k)))==S+P*H
eq6 = (2*S+P)*((b)/(1-(v-b)))==S
solve([eq1,eq2,eq3,eq4,eq5,eq6],b,v,k,c,x,y)
Output : []
I see that not all the operators will be visible, but anyway I've put them all, so that's not the problem. Do you have any idea about it? Thank you very much :)Thu, 27 Dec 2018 05:21:11 -0600http://ask.sagemath.org/question/44790/no-output-given/Comment by John Palmieri for <p>Hi all and thank you in advance for helping me. It shouldn't be a bad issue but when I try to find the solution to the following system of linear equations sage can't give me any solution, and gives the output "[ ]". The problem is that I have checked several times if I made something wrong on the formal aspect, but I don't find anything wrong (indeed sage doesn't tell me there is an error). I've set the system this way :</p>
<pre><code>b, v, k, B, V, W, c, x, y, E, Q, H, S, P = var('b, v, k, B, V, W, c, x, y, E, Q, H, S, P')
eq1 = c*(S+P)==(1-(y-x))(S)+(y-x)(S+P*B)
eq2 = c*(S+P)+(1-c)*((2*S+P)((V-c)/(1-c)))==(1-(y-x))((2*S+P)(x/(1-(y-x))))+(y-x)(S+P*W)
eq3 = (2*S+P)*(x/(1-(y-x)))==S
eq4 = (S+P)*k==S+P*E
eq5 = (S+P)k+(1-k)((2*S+P)*((Q-k)/(1-k)))==S+P*H
eq6 = (2*S+P)*((b)/(1-(v-b)))==S
solve([eq1,eq2,eq3,eq4,eq5,eq6],b,v,k,c,x,y)
Output : []
</code></pre>
<p>I see that not all the operators will be visible, but anyway I've put them all, so that's not the problem. Do you have any idea about it? Thank you very much :)</p>
http://ask.sagemath.org/question/44790/no-output-given/?comment=44796#post-id-44796Are you sure there solutions? Also, many of your equations are missing * for multiplication. In `eq1`, for example, you should change `(1-(y-x))(S)` to `(1-(y-x))*(S)`.Thu, 27 Dec 2018 15:32:04 -0600http://ask.sagemath.org/question/44790/no-output-given/?comment=44796#post-id-44796Answer by rburing for <p>Hi all and thank you in advance for helping me. It shouldn't be a bad issue but when I try to find the solution to the following system of linear equations sage can't give me any solution, and gives the output "[ ]". The problem is that I have checked several times if I made something wrong on the formal aspect, but I don't find anything wrong (indeed sage doesn't tell me there is an error). I've set the system this way :</p>
<pre><code>b, v, k, B, V, W, c, x, y, E, Q, H, S, P = var('b, v, k, B, V, W, c, x, y, E, Q, H, S, P')
eq1 = c*(S+P)==(1-(y-x))(S)+(y-x)(S+P*B)
eq2 = c*(S+P)+(1-c)*((2*S+P)((V-c)/(1-c)))==(1-(y-x))((2*S+P)(x/(1-(y-x))))+(y-x)(S+P*W)
eq3 = (2*S+P)*(x/(1-(y-x)))==S
eq4 = (S+P)*k==S+P*E
eq5 = (S+P)k+(1-k)((2*S+P)*((Q-k)/(1-k)))==S+P*H
eq6 = (2*S+P)*((b)/(1-(v-b)))==S
solve([eq1,eq2,eq3,eq4,eq5,eq6],b,v,k,c,x,y)
Output : []
</code></pre>
<p>I see that not all the operators will be visible, but anyway I've put them all, so that's not the problem. Do you have any idea about it? Thank you very much :)</p>
http://ask.sagemath.org/question/44790/no-output-given/?answer=44795#post-id-44795When there are parameters in the equations (variables which are not variables to-solve-for), I believe SageMath assumes these to be *free* parameters ([as mentioned by a Sage developer on StackOverflow](https://stackoverflow.com/a/22181162/268113)), and so it searches only for solutions which are valid for *any* value of these parameters. (This seems to be not documented.)
There are no such solutions in this case, so Sage yields the empty list of solutions.
What you can try is solve for *all* the variables first (to find whether there are solutions at all), and then start removing variables to-solve-for, i.e. turning variables into parameters, particularly those whose values are arbitrary.
In this case you can narrow it down to e.g.
solve([eq1,eq2,eq3,eq4,eq5,eq6],[b,v,k,c,x,y,E])
which reveals in particular the relation between parameters
E == -((H - Q)*P^2 + (H - 3*Q + 1)*P*S - 2*(Q - 1)*S^2)/(P*S)
which shows that not all the parameters are free.Thu, 27 Dec 2018 15:23:13 -0600http://ask.sagemath.org/question/44790/no-output-given/?answer=44795#post-id-44795Comment by kcrisman for <p>When there are parameters in the equations (variables which are not variables to-solve-for), I believe SageMath assumes these to be <em>free</em> parameters (<a href="https://stackoverflow.com/a/22181162/268113">as mentioned by a Sage developer on StackOverflow</a>), and so it searches only for solutions which are valid for <em>any</em> value of these parameters. (This seems to be not documented.)</p>
<p>There are no such solutions in this case, so Sage yields the empty list of solutions.</p>
<p>What you can try is solve for <em>all</em> the variables first (to find whether there are solutions at all), and then start removing variables to-solve-for, i.e. turning variables into parameters, particularly those whose values are arbitrary.</p>
<p>In this case you can narrow it down to e.g.</p>
<pre><code>solve([eq1,eq2,eq3,eq4,eq5,eq6],[b,v,k,c,x,y,E])
</code></pre>
<p>which reveals in particular the relation between parameters</p>
<pre><code>E == -((H - Q)*P^2 + (H - 3*Q + 1)*P*S - 2*(Q - 1)*S^2)/(P*S)
</code></pre>
<p>which shows that not all the parameters are free.</p>
http://ask.sagemath.org/question/44790/no-output-given/?comment=45385#post-id-45385I think it is implicitly documented for solve, but perhaps only in the `.solve()` documentation. At any rate Maxima would usually ask for whether these free parameters are positive or zero etc. in interactive mode, and this still provides the solve functionality, if I recall correctly.Fri, 08 Feb 2019 22:01:44 -0600http://ask.sagemath.org/question/44790/no-output-given/?comment=45385#post-id-45385Answer by jipilab for <p>Hi all and thank you in advance for helping me. It shouldn't be a bad issue but when I try to find the solution to the following system of linear equations sage can't give me any solution, and gives the output "[ ]". The problem is that I have checked several times if I made something wrong on the formal aspect, but I don't find anything wrong (indeed sage doesn't tell me there is an error). I've set the system this way :</p>
<pre><code>b, v, k, B, V, W, c, x, y, E, Q, H, S, P = var('b, v, k, B, V, W, c, x, y, E, Q, H, S, P')
eq1 = c*(S+P)==(1-(y-x))(S)+(y-x)(S+P*B)
eq2 = c*(S+P)+(1-c)*((2*S+P)((V-c)/(1-c)))==(1-(y-x))((2*S+P)(x/(1-(y-x))))+(y-x)(S+P*W)
eq3 = (2*S+P)*(x/(1-(y-x)))==S
eq4 = (S+P)*k==S+P*E
eq5 = (S+P)k+(1-k)((2*S+P)*((Q-k)/(1-k)))==S+P*H
eq6 = (2*S+P)*((b)/(1-(v-b)))==S
solve([eq1,eq2,eq3,eq4,eq5,eq6],b,v,k,c,x,y)
Output : []
</code></pre>
<p>I see that not all the operators will be visible, but anyway I've put them all, so that's not the problem. Do you have any idea about it? Thank you very much :)</p>
http://ask.sagemath.org/question/44790/no-output-given/?answer=45373#post-id-45373Since your system is linear, I would use matrices to model this. Perhaps I made a typing mistake while translating from what you wrote, but then I get the following. It seems that your system does not have a solution, the matrix is not full-rank over the polynomials ring over the parameters.
sage: PR1 = PolynomialRing(QQ,var('B,V,W,E,Q,H,S,P'))
sage: M = matrix(PR1,[[0,0,0,S+P,B*P,-B*P],[0,0,0,-S,(W*P - S - P),(-W*P - S)],[0,0,0,0,S+P,S],[0,0,S+P,0,0,0],[0,0,-S,0,0,0],[S+P,S,0,0,0,0]])
sage: M
[ 0 0 0 S + P B*P -B*P]
[ 0 0 0 -S W*P - S - P -W*P - S]
[ 0 0 0 0 S + P S]
[ 0 0 S + P 0 0 0]
[ 0 0 -S 0 0 0]
[ S + P S 0 0 0 0]
sage: v = vector(PR1,[-S,2*V*S + V*P,-S,- E*P - S,2*Q*S + Q*P - H*P - S,-S])
sage: M.solve_right(v)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-30-52655db42454> in <module>()
----> 1 M.solve_right(v)
/home/jplabbe/sage/local/lib/python2.7/site-packages/sage/matrix/matrix2.pyx in sage.matrix.matrix2.Matrix.solve_right (build/cythonized/sage/matrix/matrix2.c:7907)()
446
447 if self.rank() != self.nrows():
--> 448 X = self._solve_right_general(C, check=check)
449 else:
450 X = self._solve_right_nonsingular_square(C, check_rank=False)
/home/jplabbe/sage/local/lib/python2.7/site-packages/sage/matrix/matrix2.pyx in sage.matrix.matrix2.Matrix._solve_right_general (build/cythonized/sage/matrix/matrix2.c:9035)()
562 # Have to check that we actually solved the equation.
563 if self*X != B:
--> 564 raise ValueError("matrix equation has no solutions")
565 return X
566
ValueError: matrix equation has no solutions
sage: M.rank()
5Fri, 08 Feb 2019 08:14:26 -0600http://ask.sagemath.org/question/44790/no-output-given/?answer=45373#post-id-45373