ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 09 Jan 2017 20:35:24 +0100solve maxima?https://ask.sagemath.org/question/36083/solve-maxima/The following in Jupyter (and sage cloud) produces the wrong output. I do have an (extremely similar) maxima batch file that works fine. I sort of presume that maxima "solve" is not really called. If needed I can provide all files and stuff; either link or inline. Or if the correct way to use maxima/solve isn't obvious I can shorten up the generation of the solve argument by direct assignment.
The last commented line is to prove that simpler problems yield the correct same answers in sagemath and maxima; when sagemath feels like.
jupyter:
******
%display latex
var('A B C D M r')
T =matrix([[A,B],[C,D]]);
m=1-2*M/r
G =matrix([[-m,0],[0,1/m]])
k = T.transpose()*G*T
eq1=k[0,0];
eq2=k[0,1];
eq3=k[1,0];
eq4=k[1,1];
eqd=A*D-B*C-1
eqd
sol=solve([eq1+m==0,eq3-sqrt(2*M/r)==0,eq4-1==0,eqd==0],[A,B,C,D]);
sol
####-comment---solve([eq1+m==0,eq3-sqrt(2*M/r)==0],[A,B])
****
Produces:
$\newcommand{\Bold}[1]{\mathbf{#1}}\left[-B C + A D - 1 = 0, A^{2} {\left(\frac{2 \cdot M}{r} - 1\right)} - \frac{C^{2}}{\frac{2 \cdot M}{r} - 1} - \frac{2 \, M}{r} + 1 = 0, A B {\left(\frac{2 \cdot M}{r} - 1\right)} - \frac{C D}{\frac{2 \cdot M}{r} - 1} - \sqrt{2} \sqrt{\frac{M}{r}} = 0, B^{2} {\left(\frac{2 \, M}{r} - 1\right)} - \frac{D^{2}}{\frac{2 \, M}{r} - 1} - 1 = 0\right]$
Whereas : a maxima script produces
${\\left[ \left[ A=-1 , B={{\sqrt{2} \cdot r \cdot \sqrt{{{M}\over{r}}}}\over{r-2\cdot M}} , C=0 , D=-1 \right] , \left[ A=1 , B=-{{\sqrt{2} \cdot r \cdot \sqrt{{{M}\over{r}}}}\over{r-2\cdot M}}, C=0 , D=1 \right] \right] }$
Sat, 24 Dec 2016 16:28:49 +0100https://ask.sagemath.org/question/36083/solve-maxima/Answer by paulmasson for <p>The following in Jupyter (and sage cloud) produces the wrong output. I do have an (extremely similar) maxima batch file that works fine. I sort of presume that maxima "solve" is not really called. If needed I can provide all files and stuff; either link or inline. Or if the correct way to use maxima/solve isn't obvious I can shorten up the generation of the solve argument by direct assignment.
The last commented line is to prove that simpler problems yield the correct same answers in sagemath and maxima; when sagemath feels like.
jupyter: </p>
<hr>
<p>%display latex <br>
var('A B C D M r') <br>
T =matrix([[A,B],[C,D]]); <br>
m=1-2<em>M/r <br>
G =matrix([[-m,0],[0,1/m]]) <br>
k = T.transpose()</em>G<em>T <br>
eq1=k[0,0]; <br>
eq2=k[0,1]; <br>
eq3=k[1,0]; <br>
eq4=k[1,1]; <br>
eqd=A</em>D-B<em>C-1 <br>
eqd <br>
sol=solve([eq1+m==0,eq3-sqrt(2</em>M/r)==0,eq4-1==0,eqd==0],[A,B,C,D]); <br>
sol </p>
<h4>-comment---solve([eq1+m==0,eq3-sqrt(2*M/r)==0],[A,B])</h4>
<hr>
<p>Produces: <br>
$\newcommand{\Bold}[1]{\mathbf{#1}}\left[-B C + A D - 1 = 0, A^{2} {\left(\frac{2 \cdot M}{r} - 1\right)} - \frac{C^{2}}{\frac{2 \cdot M}{r} - 1} - \frac{2 \, M}{r} + 1 = 0, A B {\left(\frac{2 \cdot M}{r} - 1\right)} - \frac{C D}{\frac{2 \cdot M}{r} - 1} - \sqrt{2} \sqrt{\frac{M}{r}} = 0, B^{2} {\left(\frac{2 \, M}{r} - 1\right)} - \frac{D^{2}}{\frac{2 \, M}{r} - 1} - 1 = 0\right]$ </p>
<p>Whereas : a maxima script produces </p>
<p>${\left[ \left[ A=-1 , B={{\sqrt{2} \cdot r \cdot \sqrt{{{M}\over{r}}}}\over{r-2\cdot M}} , C=0 , D=-1 \right] , \left[ A=1 , B=-{{\sqrt{2} \cdot r \cdot \sqrt{{{M}\over{r}}}}\over{r-2\cdot M}}, C=0 , D=1 \right] \right] }$</p>
https://ask.sagemath.org/question/36083/solve-maxima/?answer=36099#post-id-36099Your system of equations is underdetermined, so Sage is doing its job by not returning any solution. If you
1) use `eq1` and `eq4` to eliminate `C` and `D`
2) add and subtract the remaining equations
3) rearrange by factoring
you'll see that the remaining two equations are algebraic inverses of each other, i.e., the same equation. You can't get a solution without additional constraints on the functions.Mon, 26 Dec 2016 20:47:47 +0100https://ask.sagemath.org/question/36083/solve-maxima/?answer=36099#post-id-36099Comment by rrogers for <p>Your system of equations is underdetermined, so Sage is doing its job by not returning any solution. If you</p>
<p>1) use <code>eq1</code> and <code>eq4</code> to eliminate <code>C</code> and <code>D</code> <br>
2) add and subtract the remaining equations <br>
3) rearrange by factoring</p>
<p>you'll see that the remaining two equations are algebraic inverses of each other, i.e., the same equation. You can't get a solution without additional constraints on the functions.</p>
https://ask.sagemath.org/question/36083/solve-maxima/?comment=36220#post-id-36220You are saying that sagemath can't give multiple solutions? Or is maxima wrong? In other words: what is the semantic difference between solve in sagemath and maxima? I know that maxima doesn't always find all the answers but I haven't had it give me a wrong one.
I do know that underdetermined equation sets yield parametric or multiple solutions.Sun, 08 Jan 2017 00:03:28 +0100https://ask.sagemath.org/question/36083/solve-maxima/?comment=36220#post-id-36220Comment by paulmasson for <p>Your system of equations is underdetermined, so Sage is doing its job by not returning any solution. If you</p>
<p>1) use <code>eq1</code> and <code>eq4</code> to eliminate <code>C</code> and <code>D</code> <br>
2) add and subtract the remaining equations <br>
3) rearrange by factoring</p>
<p>you'll see that the remaining two equations are algebraic inverses of each other, i.e., the same equation. You can't get a solution without additional constraints on the functions.</p>
https://ask.sagemath.org/question/36083/solve-maxima/?comment=36235#post-id-36235`solve` in SageMath calls Maxima's `solve` by default (here's where it [happens](https://github.com/sagemath/sage/blob/master/src/sage/symbolic/relation.py#L839) in the source code), so they're the same.Mon, 09 Jan 2017 20:35:24 +0100https://ask.sagemath.org/question/36083/solve-maxima/?comment=36235#post-id-36235Answer by ndomes for <p>The following in Jupyter (and sage cloud) produces the wrong output. I do have an (extremely similar) maxima batch file that works fine. I sort of presume that maxima "solve" is not really called. If needed I can provide all files and stuff; either link or inline. Or if the correct way to use maxima/solve isn't obvious I can shorten up the generation of the solve argument by direct assignment.
The last commented line is to prove that simpler problems yield the correct same answers in sagemath and maxima; when sagemath feels like.
jupyter: </p>
<hr>
<p>%display latex <br>
var('A B C D M r') <br>
T =matrix([[A,B],[C,D]]); <br>
m=1-2<em>M/r <br>
G =matrix([[-m,0],[0,1/m]]) <br>
k = T.transpose()</em>G<em>T <br>
eq1=k[0,0]; <br>
eq2=k[0,1]; <br>
eq3=k[1,0]; <br>
eq4=k[1,1]; <br>
eqd=A</em>D-B<em>C-1 <br>
eqd <br>
sol=solve([eq1+m==0,eq3-sqrt(2</em>M/r)==0,eq4-1==0,eqd==0],[A,B,C,D]); <br>
sol </p>
<h4>-comment---solve([eq1+m==0,eq3-sqrt(2*M/r)==0],[A,B])</h4>
<hr>
<p>Produces: <br>
$\newcommand{\Bold}[1]{\mathbf{#1}}\left[-B C + A D - 1 = 0, A^{2} {\left(\frac{2 \cdot M}{r} - 1\right)} - \frac{C^{2}}{\frac{2 \cdot M}{r} - 1} - \frac{2 \, M}{r} + 1 = 0, A B {\left(\frac{2 \cdot M}{r} - 1\right)} - \frac{C D}{\frac{2 \cdot M}{r} - 1} - \sqrt{2} \sqrt{\frac{M}{r}} = 0, B^{2} {\left(\frac{2 \, M}{r} - 1\right)} - \frac{D^{2}}{\frac{2 \, M}{r} - 1} - 1 = 0\right]$ </p>
<p>Whereas : a maxima script produces </p>
<p>${\left[ \left[ A=-1 , B={{\sqrt{2} \cdot r \cdot \sqrt{{{M}\over{r}}}}\over{r-2\cdot M}} , C=0 , D=-1 \right] , \left[ A=1 , B=-{{\sqrt{2} \cdot r \cdot \sqrt{{{M}\over{r}}}}\over{r-2\cdot M}}, C=0 , D=1 \right] \right] }$</p>
https://ask.sagemath.org/question/36083/solve-maxima/?answer=36086#post-id-36086The answer given by sage is not wrong. It just returns the system of equations (unchanged disregarding the order).
If you add `C==0` to the system of equations, sages gives the answer you got from maxima. But if you add `D==x`, sage gives a general solution that shows `A,B,C` dependent from `x`.
May be, there are some (hidden) restrictions in the maxima code producing only two solutions.Sun, 25 Dec 2016 17:16:35 +0100https://ask.sagemath.org/question/36083/solve-maxima/?answer=36086#post-id-36086