Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
0

Maxima wants to know whether %k1 is positive or negative

asked 4 years ago

Dr. Banana gravatar image

updated 0 years ago

FrédéricC gravatar image

Trying to solve a differential equation in Sage:

sage:  de = -diff(y, x, 2) - G*M/y^2
sage: desolve(de, y, ics=[0, 1000])

I get a type error and a question:

 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?

But when I use assume(%k1>0) I get a syntax error, saying that there's something wrong with the percent sign.

Preview: (hide)

Comments

It's just a syntax. In place of %k1 substitute an actual parameter from your equation. For example, assume(G>0).

Max Alekseyev gravatar imageMax Alekseyev ( 4 years ago )

It's not just a syntax : Maxima asks for the sign of a constant it has itself introduced. This is, IMHO, a bug.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 4 years ago )

I also think that it is a bug. SageMath does not send the assumptions to Maxima solver.

tolga gravatar imagetolga ( 4 years ago )

SageMath does not send the assumptions to Maxima solver.

Nope. See my answer below. When the assumptions on G and M are omitted, Maxima's question is about of the sign of GM%k1`.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 4 years ago )

Then what is the problem with the following code?

var('G,M')

y=function('y')(x)

assume(G*M>0)

de = -diff(y, x, 2) - G*M/y^2

desolve(de, y, ivar=x, ics=[0, 1000])

tolga gravatar imagetolga ( 4 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 4 years ago

Emmanuel Charpentier gravatar image

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 :

2(GMarctan(GMK1y(x)GMy(x)GMK1)+GMK1GMK1y(x)GMy(x)y(x))2GMK1GMK1=K2+x

2(GMarctan(GMK1y(x)GMy(x)GMK1)+GMK1GMK1y(x)GMy(x)y(x))2GMK1GMK1=K2+x

2(GMlog(2GMK12GMK1y(x)GMy(x)2GMK1+2GMK1y(x)GMy(x))+2GMK1GMK1y(x)GMy(x)y(x))4GMK1GMK1=K2+x

2(GMlog(2GMK12GMK1y(x)GMy(x)2GMK1+2GMK1y(x)GMy(x))+2GMK1GMK1y(x)GMy(x)y(x))4GMK1GMK1=K2+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 :

Solve[(y(x)c1+2GMy(x)c1GMlog(c1y(x)c1+2GMy(x)+c1y(x)+GM)c3/21)2=(c2+x)2,y(x)]

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

Preview: (hide)
link

Comments

So I tried solving this in wxmaxima: eq: 'diff(y, x, 2)=-G*M/y^2 sol2: ode2(eq, y, x) bc2(sol2, x=0, y=1000, x=pi*sqrt(1000^3/8*G*M), y=5) wxmaxima just returns []

Dr. Banana gravatar imageDr. Banana ( 4 years ago )

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: 4 years ago

Seen: 680 times

Last updated: Apr 08 '21