Ask Your Question
1

Syntax for numerically solve differential equation

asked 2016-07-15 13:16:23 -0500

jaebond gravatar image

updated 2016-07-15 13:30:25 -0500

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

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-07-15 19:12:49 -0500

calc314 gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-07-15 13:16:23 -0500

Seen: 62 times

Last updated: Jul 15 '16