1 | initial version |
As said in comment, the problem is that Maxima introduces a arbitrary constant %k1
and asks the user an hypothesis about it :
sage: G,M=var("G,M")
sage: y=function("y")
sage: with assuming(G>0, M>0): Sol=desolve(de, y(x), ivar=x)
[ Snip.. ]
TypeError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume(%k1>0)', see `assume?` for more details)
Is %k1 positive or negative?
The workaround to this problem is to add this assumption to what Maxima uses. This leads to another problem : there's no way to define a variable whose Maxima name would be %k1
. The workaround is to ruin this directly in Sage's default Maxima interpreter :
sage: maxima_calculus("assume(%k1>0);")
[%k1>0]
sage: with assuming(G>0, M>0): Sp=desolve(de, y(x), ivar=x)
sage: maxima_calculus("forget(%k1>0);")
[%k1>0]
sage: maxima_calculus("assume(%k1<0);")
[%k1<0]
sage: with assuming(G>0, M>0): Sn=desolve(de, y(x), ivar=x)
One gets implicit answers, woese getting explicit solutions is ... problematic :
sage: Sp+Sn
[1/2*sqrt(2)*(G*M*arctan(sqrt(-(G*M*_K1*y(x) - G*M)/y(x))/sqrt(G*M*_K1)) + sqrt(G*M*_K1)*sqrt(-(G*M*_K1*y(x) - G*M)/y(x))*y(x))/(sqrt(G*M*_K1)*G*M*_K1) == _K2 + x,
-1/2*sqrt(2)*(G*M*arctan(sqrt(-(G*M*_K1*y(x) - G*M)/y(x))/sqrt(G*M*_K1)) + sqrt(G*M*_K1)*sqrt(-(G*M*_K1*y(x) - G*M)/y(x))*y(x))/(sqrt(G*M*_K1)*G*M*_K1) == _K2 + x,
1/4*sqrt(2)*(G*M*log(-(sqrt(2)*sqrt(-G*M*_K1) - sqrt(2)*sqrt(-(G*M*_K1*y(x) - G*M)/y(x)))/(sqrt(2)*sqrt(-G*M*_K1) + sqrt(2)*sqrt(-(G*M*_K1*y(x) - G*M)/y(x)))) + 2*sqrt(-G*M*_K1)*sqrt(-(G*M*_K1*y(x) - G*M)/y(x))*y(x))/(sqrt(-G*M*_K1)*G*M*_K1) == _K2 + x,
-1/4*sqrt(2)*(G*M*log(-(sqrt(2)*sqrt(-G*M*_K1) - sqrt(2)*sqrt(-(G*M*_K1*y(x) - G*M)/y(x)))/(sqrt(2)*sqrt(-G*M*_K1) + sqrt(2)*sqrt(-(G*M*_K1*y(x) - G*M)/y(x)))) + 2*sqrt(-G*M*_K1)*sqrt(-(G*M*_K1*y(x) - G*M)/y(x))*y(x))/(sqrt(-G*M*_K1)*G*M*_K1) == _K2 + x]
More readably :
$$ \frac{\sqrt{2} {\left(G M \arctan\left(\frac{\sqrt{-\frac{G M K_{1} y\left(x\right) - G M}{y\left(x\right)}}}{\sqrt{G M K_{1}}}\right) + \sqrt{G M K_{1}} \sqrt{-\frac{G M K_{1} y\left(x\right) - G M}{y\left(x\right)}} y\left(x\right)\right)}}{2 \, \sqrt{G M K_{1}} G M K_{1}} = K_{2} + x $$
$$ -\frac{\sqrt{2} {\left(G M \arctan\left(\frac{\sqrt{-\frac{G M K_{1} y\left(x\right) - G M}{y\left(x\right)}}}{\sqrt{G M K_{1}}}\right) + \sqrt{G M K_{1}} \sqrt{-\frac{G M K_{1} y\left(x\right) - G M}{y\left(x\right)}} y\left(x\right)\right)}}{2 \, \sqrt{G M K_{1}} G M K_{1}} = K_{2} + x $$
$$\frac{\sqrt{2} {\left(G M \log\left(-\frac{\sqrt{2} \sqrt{-G M K_{1}} - \sqrt{2} \sqrt{-\frac{G M K_{1} y\left(x\right) - G M}{y\left(x\right)}}}{\sqrt{2} \sqrt{-G M K_{1}} + \sqrt{2} \sqrt{-\frac{G M K_{1} y\left(x\right) - G M}{y\left(x\right)}}}\right) + 2 \, \sqrt{-G M K_{1}} \sqrt{-\frac{G M K_{1} y\left(x\right) - G M}{y\left(x\right)}} y\left(x\right)\right)}}{4 \, \sqrt{-G M K_{1}} G M K_{1}} = K_{2} + x $$
$$ -\frac{\sqrt{2} {\left(G M \log\left(-\frac{\sqrt{2} \sqrt{-G M K_{1}} - \sqrt{2} \sqrt{-\frac{G M K_{1} y\left(x\right) - G M}{y\left(x\right)}}}{\sqrt{2} \sqrt{-G M K_{1}} + \sqrt{2} \sqrt{-\frac{G M K_{1} y\left(x\right) - G M}{y\left(x\right)}}}\right) + 2 \, \sqrt{-G M K_{1}} \sqrt{-\frac{G M K_{1} y\left(x\right) - G M}{y\left(x\right)}} y\left(x\right)\right)}}{4 \, \sqrt{-G M K_{1}} G M K_{1}} = K_{2} + x $$
Neither Sympy nor Fricas can solve thos ODE ; Mathematica also returns an implicit solution :
sage: mathematica("DSolve[-y''[x]-G*M/y[x]^2==0, y[x], x]")
Solve[
(-((G*M*Log[G*M + C[1]*y[x] + Sqrt[C[1]]*Sqrt[C[1] + (2*G*M)/y[x]]*y[x]])/
C[1]^(3/2)) + (Sqrt[C[1] + (2*G*M)/y[x]]*y[x])/C[1])^2 == (x + C[2])^2,
y[x]]
i. e., more readibly :
$$ \text{Solve}\left[\left(\frac{y(x) \sqrt{c_1+\frac{2 G M}{y(x)}}}{c_1}-\frac{G M \log \left(\sqrt{c_1} y(x) \sqrt{c_1+\frac{2 G M}{y(x)}}+c_1 y(x)+G M\right)}{c_1^{3/2}}\right){}^2=\left(c_2+x\right){}^2,y(x)\right] $$
Note : since your ODE is of the second order, you need two boundary conditions uin order to determine your solution ; your ics
gives only one...