Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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) = (8x^3(1 + x))/(-1/8 + x) sage: eq = diff(g, t) - 2piIbeta(x=g)/diff(beta, x)(x=g) sage: desolve_rk4(eq, g, ics=[0, 0.139202795060905 + 0.0642260199336103I], 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 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}]

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) = (8x^3(1 (8*x^3*(1 + x))/(-1/8 + x)
sage: eq = diff(g, t) - 2piIbeta(x=g)/diff(beta, 2*pi*I*beta(x=g)/diff(beta, x)(x=g)
sage: desolve_rk4(eq, g, ics=[0, 0.139202795060905 + 0.0642260199336103I], end_points=[1])

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

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

x) NDSolve[{g'[t] == 2 Pi I beta[g[t]]/beta'[g[t]], g[0] == -0.363218465306351}, g, {t, 0, 1}]

1}]