# Solving this differential equation

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 close merge delete

Sort by ยป oldest newest most voted

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.

more

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,

( 2024-09-03 18:04:00 +0200 )edit