Ask Your Question
0

Solving this differential equation

asked 2024-09-02 23:49:15 +0100

Graph Karl gravatar image

I'm trying to solve this de but get an error which I don't understand.

x = var('x')
y = function('y')(x)
de = diff(y, x) == tan(y) * (y^3 - y)
desolve(de, y)
TypeError: ECL says: changevar: fourth argument must be an atom; found: 'y(_SAGE_VAR_x)

I would also like to plot a maximum solution \phi(0) = 0.5.

Thank you

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2024-09-03 06:47:15 +0100

tolga gravatar image

updated 2024-09-03 06:52:55 +0100

The following code solves your equation numerically (with 4th order Runge-Kutta method) for y(0)=0.5 and plots the solution:

x,y=var('x,y')
mynumericalsolution=desolve_rk4(tan(y) * (y^3 - y), dvar=y, ivar=x, ics=[0,0.5],end_points=10, step=0.1)
myplot=line(mynumericalsolution,axes_labels=[x,y])
myplot.show()

I think SageMath cannot solve it symbolically.

edit flag offensive delete link more

Comments

I think SageMath cannot solve it symbolically.

FWIW, neither Fricas, Mathematica (gratis-but-not-free Wolfram Engine) nor Sympy can :

sage: desolve(de, y(x), ivar=x, algorithm="fricas")
x + integral(-1/((y(x)^3 - y(x))*sqrt(tan(y(x))^2 + 1)*sqrt(tan(y(x))^2/(tan(y(x))^2 + 1))), y(x))
sage: mathematica("DSolve[y'[x]==Tan[y[x]]*(y[x]^3-y[x]), y[x], x]")
{{y[x] -> InverseFunction[Inactive[Integrate][
       Cot[K[1]]/((-1 + K[1])*K[1]*(1 + K[1])), {K[1], 1, #1}] & ][x + C[1]]}}
sage: import sympy
sage: sympy.dsolve(*map(sympy.sympify, (de, y(x))))
Eq(-Integral(1/(_y*(_y - 1)*(_y + 1)*tan(_y)), (_y, y(x))), C1 - x)

HTH,

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-09-03 18:04:00 +0100 )edit

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: 2024-09-02 23:49:15 +0100

Seen: 208 times

Last updated: Sep 03