First time here? Check out the FAQ!

Ask Your Question
1

Syntax for numerically solve differential equation

asked 8 years ago

jaebond gravatar image

updated 8 years ago

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}]
Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 8 years ago

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.

Preview: (hide)
link

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: 8 years ago

Seen: 601 times

Last updated: Jul 16 '16