Ask Your Question
2

No Output Given : []

asked 2018-12-27 12:27:19 +0100

giuseppe gravatar image

updated 2018-12-27 19:31:53 +0100

tmonteil gravatar image

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 :)

edit retag flag offensive close merge delete

Comments

Are 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).

John Palmieri gravatar imageJohn Palmieri ( 2018-12-27 22:32:04 +0100 )edit

2 Answers

Sort by ยป oldest newest most voted
3

answered 2018-12-27 22:23:13 +0100

rburing gravatar image

When 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), 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.

edit flag offensive delete link more

Comments

I 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.

kcrisman gravatar imagekcrisman ( 2019-02-09 05:01:44 +0100 )edit
2

answered 2019-02-08 15:14:26 +0100

jipilab gravatar image

Since 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()
5
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-12-27 12:21:11 +0100

Seen: 1,313 times

Last updated: Feb 08 '19