# Syntax for numerically solve differential equation

I am having trouble using the desolve_rk4 function and I assume I am messing up the syntax somewhere. I tried

sage: t = var('t')
sage: g = function('g')(t)
sage: beta(x) = (8*x^3*(1 + x))/(-1/8 + x)
sage: eq = diff(g, t) - 2*pi*I*beta(x=g)/diff(beta, x)(x=g)
sage: desolve_rk4(eq, g, ics=[0, 0.139202795060905 + 0.0642260199336103*I], end_points=[1])


but it just gives me back a constant solution:

[[0, -0.363218465306351],
[0.1, -0.363218465306351],
[0.2, -0.363218465306351],
[0.3, -0.363218465306351],
[0.4, -0.363218465306351],
[0.5, -0.363218465306351],
[0.6000000000000001, -0.363218465306351],
[0.7000000000000001, -0.363218465306351],
[0.8, -0.363218465306351],
[0.9, -0.363218465306351],
[1.0, -0.363218465306351]]


The only other thing I have seen is that Sage maybe can't handle complex functions.

If it helps, the corresponding Mathematica code is

beta[x_] := 8 x^3 (1 + x)/(-1/8 + x)
NDSolve[{g'[t] == 2 Pi I beta[g[t]]/beta'[g[t]], g[0] == -0.363218465306351}, g, {t, 0, 1}]

edit retag close merge delete

Sort by ยป oldest newest most voted

A good source of information is this question: http://ask.sagemath.org/question/8714...

Your best bet is likely either to convert to real differential equations or use Scipy's scipy.integrate.ode zvode which can be done within Sage.

more