# Revision history [back]

### Numerical Integration Causes Errors

I have a 4 ODE model of a chemical oscillator. desolve_system_rk4 and desolve_odeint give different, equally strange errors. My source and the errors are pasted below. Any ideas what could be causing this?

------Cell 1-------

var('x y z u t')

m=.4

a=.3

h=.16

k1=(2e6)*h

k2=2(h^2)a

k3=3000

k4=42ha

k7=29*m

if m>=.1: k9=.1*m

else: k9=.07*m

k10=0.05*m

kr=2e8

kred=5e6

d=1e-5

c0=3e-3

cmin=sqrt((2kr(k9+k10)*c0)/(kred^2))

rhs=[]

rhs.append(-k1xy+k2y-2k3(x^2)+k4x*((c0-z)/(c0-z+cmin)))

rhs.append(-3k1xy-2k2y-k3(x^2)+k7u+k9*z)

rhs.append(2k4x((c0-z)/(c0-z+cmin))-k9z-k10*z)

rhs.append(2k1xy+k2y+k3(x^2)-k7u)

-------Cell 2-------

P=desolve_odeint(rhs,[0,.1,.5,0,0],srange(0,.28,.01),[x,y,z,u],t)

print P

---------Cell 2 Error-----

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]


File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]


File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]


File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]


File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]


File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]


File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]


File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

Traceback (most recent call last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func

return [dec(*v) for dec in desc]


File "wrapper_rdf.pyx", line 73, in

sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func

[[ 0.00000000e+000 1.00000000e-001 5.00000000e-001 0.00000000e+000

0.00000000e+000]


[ 1.91816300e-273 1.00000000e-001 5.00000000e-001 -3.33812103e-313

0.00000000e+000]


[ 4.77937088e-268 1.00000000e-001 5.00000000e-001 5.69304317e-311

0.00000000e+000]


[ 2.00438470e-267 1.00000000e-001 5.00000000e-001 2.35773229e-310

0.00000000e+000]


[ 2.36867914e-267 1.00000000e-001 5.00000000e-001 2.78367228e-310

0.00000000e+000]


[ 2.38572583e-267 1.00000000e-001 5.00000000e-001 2.80306160e-310

0.00000000e+000]


[ 2.39510579e-267 1.00000000e-001 5.00000000e-001 2.81360368e-310

0.00000000e+000]


[ 2.39681901e-267 1.00000000e-001 5.00000000e-001 2.81529855e-310

0.00000000e+000]


[ 2.39086550e-267 1.00000000e-001 5.00000000e-001 2.80814619e-310

0.00000000e+000]


[ 2.37724526e-267 1.00000000e-001 5.00000000e-001 2.79214662e-310

0.00000000e+000]


[ 2.35595828e-267 1.00000000e-001 5.00000000e-001 2.76729981e-310

0.00000000e+000]


[ 2.32700457e-267 1.00000000e-001 5.00000000e-001 2.73360579e-310

0.00000000e+000]


[ 2.29038413e-267 1.00000000e-001 5.00000000e-001 2.69106454e-310

0.00000000e+000]


[ 2.24609696e-267 1.00000000e-001 5.00000000e-001 2.63967607e-310

0.00000000e+000]


[ 2.19414306e-267 1.00000000e-001 5.00000000e-001 2.57944037e-310

0.00000000e+000]


[ 2.13452242e-267 1.00000000e-001 5.00000000e-001 2.51035746e-310

0.00000000e+000]


[ 2.06896087e-267 1.00000000e-001 5.00000000e-001 2.43444676e-310

0.00000000e+000]


[ 2.12162851e-267 1.00000000e-001 5.00000000e-001 2.49700403e-310

0.00000000e+000]


[ 2.36901260e-267 1.00000000e-001 5.00000000e-001 2.78752969e-310

0.00000000e+000]


[ 2.81111315e-267 1.00000000e-001 5.00000000e-001 3.30602374e-310

0.00000000e+000]


[ 3.44793016e-267 1.00000000e-001 5.00000000e-001 4.05248617e-310

0.00000000e+000]


[ 4.27946362e-267 1.00000000e-001 5.00000000e-001 5.02691698e-310

0.00000000e+000]


[ 5.30571354e-267 1.00000000e-001 5.00000000e-001 6.22931619e-310

0.00000000e+000]


[ 6.52667991e-267 1.00000000e-001 5.00000000e-001 7.65968378e-310

0.00000000e+000]


[ 7.94236274e-267 1.00000000e-001 5.00000000e-001 9.31801975e-310

0.00000000e+000]


[ 9.55276203e-267 1.00000000e-001 5.00000000e-001 1.12043241e-309

0.00000000e+000]


[ 1.13578778e-266 1.00000000e-001 5.00000000e-001 1.33185969e-309

0.00000000e+000]


[ 1.33577100e-266 1.00000000e-001 5.00000000e-001 1.56608380e-309

0.00000000e+000]]


------Cell 3------

P=desolve_system_rk4(rhs,[x,y,z,u],[0,.1,.5,0,0],t,.28)

print P

------Cell 3 Error-----

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

File "_sage_input_31.py", line 10, in <module>

exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" +


_support_.preparse_worksheet_cell(base64.b64decode("UD1kZXNvbHZlX3N5c3RlbV9yazQocmhzL

Ft4LHkseix1XSxbMCwuMSwuNSwwLDBdLHQsLjI4KQpwcmludCBQ"),globals())+"\n");

execfile(os.path.abspath("___code___.py"))

File "", line 1, in <module>

File "/tmp/tmpBY363j/___code___.py", line 3, in <module>

P=desolve_system_rk4(rhs,[x,y,z,u],[_sage_const_0 ,_sage_const_p1


,_sage_const_p5 ,_sage_const_0 ,_sage_const_0 ],t,_sage_const_p28 )

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1342, in desolve_system_rk4

sol_2=maxima(cmd).sage()


File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/interface.py", line 868, in sage

return self._sage_()


File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima_abstract.py", line 1224, in _sage_

maxima=self.parent())


File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/calculus.py", line 1634, in symbolic_expression_from_maxima_string

s = maxima._eval_line('_tmp_;')


File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima.py", line 787, in _eval_line

self._error_check(line, out)


File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima.py", line 924, in _error_check

self._error_msg(cmd, out)


File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima.py", line 941, in _error_msg

raise TypeError, "Error executing code in Maxima\nCODE:\n\t%s\nMaxima ERROR:\n


\t%s"%(cmd, out.replace('-- an error. To debug this try debugmode(true);',''))

TypeError: Error executing code in Maxima

CODE:

_tmp_;


Maxima ERROR:

(%o52)

Maxima encountered a Lisp error:

#

Automatically continuing.

To enable the Lisp debugger set debugger-hook to nil.

 2 formatted code snippets benjaminfjones 2775 ●8 ●44 ●76 http://bfj7.com/

### Numerical Integration Causes Errors

I have a 4 ODE model of a chemical oscillator. desolve_system_rk4 and desolve_odeint give different, equally strange errors. My source and the errors are pasted below. Any ideas what could be causing this?

------Cell 1-------

var('x y z u t') m=.4 a=.3 h=.16 k1=(2e6)*h k2=2(h^2)a k3=3000 k4=42ha k7=29*m t')

m=.4

a=.3

h=.16

k1=(2e6)*h

k2=2*(h^2)*a

k3=3000

k4=42*h*a

k7=29*m

if m>=.1: k9=.1*m k9=.1*m

else:    k9=.07*m k10=0.05*m kr=2e8 kred=5e6 d=1e-5 c0=3e-3 cmin=sqrt((2kr(k9+k10)*c0)/(kred^2)) rhs=[] rhs.append(-k1xy+k2y-2k3(x^2)+k4x*((c0-z)/(c0-z+cmin))) rhs.append(-3k1xy-2k2y-k3(x^2)+k7u+k9*z) rhs.append(2k4x((c0-z)/(c0-z+cmin))-k9z-k10*z) rhs.append(2k1xy+k2y+k3(x^2)-k7u)k9=.07*m

k10=0.05*m

kr=2e8

kred=5e6

d=1e-5

c0=3e-3

cmin=sqrt((2*kr*(k9+k10)*c0)/(kred^2))

rhs=[]

rhs.append(-k1*x*y+k2*y-2*k3*(x^2)+k4*x*((c0-z)/(c0-z+cmin)))

rhs.append(-3*k1*x*y-2*k2*y*-k3*(x^2)+k7*u+k9*z)

rhs.append(2*k4*x*((c0-z)/(c0-z+cmin))-k9*z-k10*z)

rhs.append(2*k1*x*y+k2*y+k3*(x^2)-k7*u)


-------Cell 2-------

P=desolve_odeint(rhs,[0,.1,.5,0,0],srange(0,.28,.01),[x,y,z,u],t)

P=desolve_odeint(rhs,[0,.1,.5,0,0],srange(0,.28,.01),[x,y,z,u],t)

print PP


---------Cell 2 Error-----

Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func func

return [dec(*v) for dec in desc]
File "wrapper_rdf.pyx", line 73, in   sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters
/wrapper_rdf.c:1289) ValueError /wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func func

Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func func

return [dec(*v) for dec in desc]
File "wrapper_rdf.pyx", line 73, in   sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func func

Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func func

return [dec(*v) for dec in desc]
File "wrapper_rdf.pyx", line 73, in   sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func func

Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func func

return [dec(*v) for dec in desc]
File "wrapper_rdf.pyx", line 73, in   sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func func

Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func func

return [dec(*v) for dec in desc]
File "wrapper_rdf.pyx", line 73, in   sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func func

Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func func

return [dec(*v) for dec in desc]
File "wrapper_rdf.pyx", line 73, in   sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func func

Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func func

return [dec(*v) for dec in desc]
File "wrapper_rdf.pyx", line 73, in   sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func func

Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus last):

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1529, in func func

return [dec(*v) for dec in desc]
File "wrapper_rdf.pyx", line 73, in   sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError (sage/ext/interpreters

/wrapper_rdf.c:1289)

ValueError

odepack.error: Error occured while calling the Python function named func func

[[  0.00000000e+000   1.00000000e-001   5.00000000e-001   0.00000000e+000 0.00000000e+000]
0.00000000e+000

0.00000000e+000]

[  1.91816300e-273   1.00000000e-001   5.00000000e-001  -3.33812103e-313 0.00000000e+000]
-3.33812103e-313

0.00000000e+000]

[  4.77937088e-268   1.00000000e-001   5.00000000e-001   5.69304317e-311 0.00000000e+000]
5.69304317e-311

0.00000000e+000]

[  2.00438470e-267   1.00000000e-001   5.00000000e-001   2.35773229e-310 0.00000000e+000]
2.35773229e-310

0.00000000e+000]

[  2.36867914e-267   1.00000000e-001   5.00000000e-001   2.78367228e-310 0.00000000e+000]
2.78367228e-310

0.00000000e+000]

[  2.38572583e-267   1.00000000e-001   5.00000000e-001   2.80306160e-310 0.00000000e+000]
2.80306160e-310

0.00000000e+000]

[  2.39510579e-267   1.00000000e-001   5.00000000e-001   2.81360368e-310 0.00000000e+000]
2.81360368e-310

0.00000000e+000]

[  2.39681901e-267   1.00000000e-001   5.00000000e-001   2.81529855e-310 0.00000000e+000]
2.81529855e-310

0.00000000e+000]

[  2.39086550e-267   1.00000000e-001   5.00000000e-001   2.80814619e-310 0.00000000e+000]
2.80814619e-310

0.00000000e+000]

[  2.37724526e-267   1.00000000e-001   5.00000000e-001   2.79214662e-310 0.00000000e+000]
2.79214662e-310

0.00000000e+000]

[  2.35595828e-267   1.00000000e-001   5.00000000e-001   2.76729981e-310 0.00000000e+000]
2.76729981e-310

0.00000000e+000]

[  2.32700457e-267   1.00000000e-001   5.00000000e-001   2.73360579e-310 0.00000000e+000]
2.73360579e-310

0.00000000e+000]

[  2.29038413e-267   1.00000000e-001   5.00000000e-001   2.69106454e-310 0.00000000e+000]
2.69106454e-310

0.00000000e+000]

[  2.24609696e-267   1.00000000e-001   5.00000000e-001   2.63967607e-310 0.00000000e+000]
2.63967607e-310

0.00000000e+000]

[  2.19414306e-267   1.00000000e-001   5.00000000e-001   2.57944037e-310 0.00000000e+000]
2.57944037e-310

0.00000000e+000]

[  2.13452242e-267   1.00000000e-001   5.00000000e-001   2.51035746e-310 0.00000000e+000]
2.51035746e-310

0.00000000e+000]

[  2.06896087e-267   1.00000000e-001   5.00000000e-001   2.43444676e-310 0.00000000e+000]
2.43444676e-310

0.00000000e+000]

[  2.12162851e-267   1.00000000e-001   5.00000000e-001   2.49700403e-310 0.00000000e+000]
2.49700403e-310

0.00000000e+000]

[  2.36901260e-267   1.00000000e-001   5.00000000e-001   2.78752969e-310 0.00000000e+000]
2.78752969e-310

0.00000000e+000]

[  2.81111315e-267   1.00000000e-001   5.00000000e-001   3.30602374e-310 0.00000000e+000]
3.30602374e-310

0.00000000e+000]

[  3.44793016e-267   1.00000000e-001   5.00000000e-001   4.05248617e-310 0.00000000e+000]
4.05248617e-310

0.00000000e+000]

[  4.27946362e-267   1.00000000e-001   5.00000000e-001   5.02691698e-310 0.00000000e+000]
5.02691698e-310

0.00000000e+000]

[  5.30571354e-267   1.00000000e-001   5.00000000e-001   6.22931619e-310 0.00000000e+000]
6.22931619e-310

0.00000000e+000]

[  6.52667991e-267   1.00000000e-001   5.00000000e-001   7.65968378e-310 0.00000000e+000]
7.65968378e-310

0.00000000e+000]

[  7.94236274e-267   1.00000000e-001   5.00000000e-001   9.31801975e-310 0.00000000e+000]
9.31801975e-310

0.00000000e+000]

[  9.55276203e-267   1.00000000e-001   5.00000000e-001   1.12043241e-309 0.00000000e+000]
1.12043241e-309

0.00000000e+000]

[  1.13578778e-266   1.00000000e-001   5.00000000e-001   1.33185969e-309 0.00000000e+000]
1.33185969e-309

0.00000000e+000]

[  1.33577100e-266   1.00000000e-001   5.00000000e-001   1.56608380e-309 1.56608380e-309

0.00000000e+000]]
------Cell 3------ P=desolve_system_rk4(rhs,[x,y,z,u],[0,.1,.5,0,0],t,.28) P=desolve_system_rk4(rhs,[x,y,z,u],[0,.1,.5,0,0],t,.28)

print PP
------Cell 3 Error----- Traceback (most recent call last): last):

File "<stdin>", line 1, in <module> <module>

File "_sage_input_31.py", line 10, in <module> <module>

exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" +
_support_.preparse_worksheet_cell(base64.b64decode("UD1kZXNvbHZlX3N5c3RlbV9yazQocmhzL Ft4LHkseix1XSxbMCwuMSwuNSwwLDBdLHQsLjI4KQpwcmludCBQ"),globals())+"\n");  execfile(os.path.abspath("___code___.py")) +

_support_.preparse_worksheet_cell(base64.b64decode("UD1kZXNvbHZlX3N5c3RlbV9yazQocmhzL

Ft4LHkseix1XSxbMCwuMSwuNSwwLDBdLHQsLjI4KQpwcmludCBQ"),globals())+"\\n");

execfile(os.path.abspath("___code___.py"))

File "", line 1, in <module> <module>

File "/tmp/tmpBY363j/___code___.py", line 3, in <module> <module>

P=desolve_system_rk4(rhs,[x,y,z,u],[_sage_const_0 ,_sage_const_p1
,_sage_const_p1

,_sage_const_p5 ,_sage_const_0 ,_sage_const_0 ],t,_sage_const_p28 ) File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus )

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/desolvers.py", line 1342, in desolve_system_rk4 desolve_system_rk4

sol_2=maxima(cmd).sage()
File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces
File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/interface.py", line 868, in sage sage

return self._sage_()
File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces
File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima_abstract.py", line 1224, in _sage_ _sage_

maxima=self.parent())
File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus
File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus

/calculus.py", line 1634, in symbolic_expression_from_maxima_string symbolic_expression_from_maxima_string

s = maxima._eval_line('_tmp_;')
File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima.py", line 787, in _eval_line _eval_line

self._error_check(line, out)
File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima.py", line 924, in _error_check _error_check

self._error_msg(cmd, out)
File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces

/maxima.py", line 941, in _error_msg _error_msg

raise TypeError, "Error executing code in Maxima\nCODE:\n\t%s\nMaxima ERROR:\n
\t%s"%(cmd, out.replace('-- an error.  To debug this try debugmode(true);','')) debugmode(true);',''))

TypeError: Error executing code in Maxima CODE: Maxima

CODE:

_tmp_;
Maxima ERROR: ERROR:

(%o52)   Maxima encountered a Lisp error: # error:

#<a ARITHMETIC-ERROR>

Automatically continuing. continuing.

To enable the Lisp debugger set debugger-hook *debugger-hook* to nil. nil.



 3 No.3 Revision updated 2016-01-07 01:05:38 +0200 vdelecroix 7585 ●20 ●83 ●167 http://www.labri.fr/pe... Numerical Integration Causes Errors I have a 4 ODE model of a chemical oscillator. desolve_system_rk4 and desolve_odeint give different, equally strange errors. My source and the errors are pasted below. Any ideas what could be causing this? ------Cell 1------- var('x y z u t') m=.4 a=.3 h=.16 k1=(2e6)*h k2=2*(h^2)*a k3=3000 k4=42*h*a k7=29*m m = .4; a = .3; h = .16 k1 = (2e6)*h k2 = 2*(h^2)*a k3 = 3000 k4 = 42*h*a k7 = 29*m k9 = .1*m if m>=.1: k9=.1*m else: k9=.07*m k10=0.05*m kr=2e8 kred=5e6 d=1e-5 c0=3e-3 cmin=sqrt((2*kr*(k9+k10)*c0)/(kred^2)) rhs=[] m>=.1 else .07*m k10 = 0.05*m kr = 2e8 kred = 5e6 d = 1e-5 c0 = 3e-3 cmin = sqrt((2*kr*(k9+k10)*c0)/(kred^2)) rhs = [] rhs.append(-k1*x*y+k2*y-2*k3*(x^2)+k4*x*((c0-z)/(c0-z+cmin))) rhs.append(-3*k1*x*y-2*k2*y*-k3*(x^2)+k7*u+k9*z) rhs.append(2*k4*x*((c0-z)/(c0-z+cmin))-k9*z-k10*z) rhs.append(2*k1*x*y+k2*y+k3*(x^2)-k7*u) -------Cell 2------- P=desolve_odeint(rhs,[0,.1,.5,0,0],srange(0,.28,.01),[x,y,z,u],t) print P desolve_odeint(rhs,[0,.1,.5,0,0],srange(0,.28,.01),[x,y,z,u],t) ---------Cell 2 Error----- Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func return [dec(*v) for dec in desc] File "wrapper_rdf.pyx", line 73, in sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func return [dec(*v) for dec in desc] File "wrapper_rdf.pyx", line 73, in sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func return [dec(*v) for dec in desc] File "wrapper_rdf.pyx", line 73, in sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func return [dec(*v) for dec in desc] File "wrapper_rdf.pyx", line 73, in sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func return [dec(*v) for dec in desc] File "wrapper_rdf.pyx", line 73, in sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func return [dec(*v) for dec in desc] File "wrapper_rdf.pyx", line 73, in sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func return [dec(*v) for dec in desc] File "wrapper_rdf.pyx", line 73, in sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func Traceback (most recent call last): File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1529, in func return [dec(*v) for dec in desc] File "wrapper_rdf.pyx", line 73, in sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (sage/ext/interpreters /wrapper_rdf.c:1289) ValueError odepack.error: Error occured while calling the Python function named func [[ 0.00000000e+000 1.00000000e-001 5.00000000e-001 0.00000000e+000 0.00000000e+000] [ 1.91816300e-273 1.00000000e-001 5.00000000e-001 -3.33812103e-313 0.00000000e+000] [ 4.77937088e-268 1.00000000e-001 5.00000000e-001 5.69304317e-311 0.00000000e+000] [ 2.00438470e-267 1.00000000e-001 5.00000000e-001 2.35773229e-310 0.00000000e+000] [ 2.36867914e-267 1.00000000e-001 5.00000000e-001 2.78367228e-310 0.00000000e+000] [ 2.38572583e-267 1.00000000e-001 5.00000000e-001 2.80306160e-310 0.00000000e+000] [ 2.39510579e-267 1.00000000e-001 5.00000000e-001 2.81360368e-310 0.00000000e+000] [ 2.39681901e-267 1.00000000e-001 5.00000000e-001 2.81529855e-310 0.00000000e+000] [ 2.39086550e-267 1.00000000e-001 5.00000000e-001 2.80814619e-310 0.00000000e+000] [ 2.37724526e-267 1.00000000e-001 5.00000000e-001 2.79214662e-310 0.00000000e+000] [ 2.35595828e-267 1.00000000e-001 5.00000000e-001 2.76729981e-310 0.00000000e+000] [ 2.32700457e-267 1.00000000e-001 5.00000000e-001 2.73360579e-310 0.00000000e+000] [ 2.29038413e-267 1.00000000e-001 5.00000000e-001 2.69106454e-310 0.00000000e+000] [ 2.24609696e-267 1.00000000e-001 5.00000000e-001 2.63967607e-310 0.00000000e+000] [ 2.19414306e-267 1.00000000e-001 5.00000000e-001 2.57944037e-310 0.00000000e+000] [ 2.13452242e-267 1.00000000e-001 5.00000000e-001 2.51035746e-310 0.00000000e+000] [ 2.06896087e-267 1.00000000e-001 5.00000000e-001 2.43444676e-310 0.00000000e+000] [ 2.12162851e-267 1.00000000e-001 5.00000000e-001 2.49700403e-310 0.00000000e+000] [ 2.36901260e-267 1.00000000e-001 5.00000000e-001 2.78752969e-310 0.00000000e+000] [ 2.81111315e-267 1.00000000e-001 5.00000000e-001 3.30602374e-310 0.00000000e+000] [ 3.44793016e-267 1.00000000e-001 5.00000000e-001 4.05248617e-310 0.00000000e+000] [ 4.27946362e-267 1.00000000e-001 5.00000000e-001 5.02691698e-310 0.00000000e+000] [ 5.30571354e-267 1.00000000e-001 5.00000000e-001 6.22931619e-310 0.00000000e+000] [ 6.52667991e-267 1.00000000e-001 5.00000000e-001 7.65968378e-310 0.00000000e+000] [ 7.94236274e-267 1.00000000e-001 5.00000000e-001 9.31801975e-310 0.00000000e+000] [ 9.55276203e-267 1.00000000e-001 5.00000000e-001 1.12043241e-309 0.00000000e+000] [ 1.13578778e-266 1.00000000e-001 5.00000000e-001 1.33185969e-309 0.00000000e+000] [ 1.33577100e-266 1.00000000e-001 5.00000000e-001 1.56608380e-309 0.00000000e+000]] ------Cell 3------ P=desolve_system_rk4(rhs,[x,y,z,u],[0,.1,.5,0,0],t,.28) print P ------Cell 3 Error----- Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_31.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("UD1kZXNvbHZlX3N5c3RlbV9yazQocmhzL Ft4LHkseix1XSxbMCwuMSwuNSwwLDBdLHQsLjI4KQpwcmludCBQ"),globals())+"\\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module> File "/tmp/tmpBY363j/___code___.py", line 3, in <module> P=desolve_system_rk4(rhs,[x,y,z,u],[_sage_const_0 ,_sage_const_p1 ,_sage_const_p5 ,_sage_const_0 ,_sage_const_0 ],t,_sage_const_p28 ) File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /desolvers.py", line 1342, in desolve_system_rk4 sol_2=maxima(cmd).sage() File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces /interface.py", line 868, in sage return self._sage_() File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces /maxima_abstract.py", line 1224, in _sage_ maxima=self.parent()) File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/calculus /calculus.py", line 1634, in symbolic_expression_from_maxima_string s = maxima._eval_line('_tmp_;') File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces /maxima.py", line 787, in _eval_line self._error_check(line, out) File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces /maxima.py", line 924, in _error_check self._error_msg(cmd, out) File "/home/sage/sage-4.8/local/lib/python2.6/site-packages/sage/interfaces /maxima.py", line 941, in _error_msg raise TypeError, "Error executing code in Maxima\nCODE:\n\t%s\nMaxima ERROR:\n \t%s"%(cmd, out.replace('-- an error. To debug this try debugmode(true);','')) TypeError: Error executing code in Maxima CODE: _tmp_; Maxima ERROR: (%o52) Maxima encountered a Lisp error: #<a ARITHMETIC-ERROR> Automatically continuing. To enable the Lisp debugger set *debugger-hook* to nil. 


 Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license. about | faq | help | privacy policy | terms of service Powered by Askbot version 0.7.59 Please note: Askbot requires javascript to work properly, please enable javascript in your browser, here is how //IE fix to hide the red margin var noscript = document.getElementsByTagName('noscript')[0]; noscript.style.padding = '0px'; noscript.style.backgroundColor = 'transparent'; askbot['urls']['mark_read_message'] = '/s/messages/markread/'; askbot['urls']['get_tags_by_wildcard'] = '/s/get-tags-by-wildcard/'; askbot['urls']['get_tag_list'] = '/s/get-tag-list/'; askbot['urls']['follow_user'] = '/followit/follow/user/{{userId}}/'; askbot['urls']['unfollow_user'] = '/followit/unfollow/user/{{userId}}/'; askbot['urls']['user_signin'] = '/account/signin/'; askbot['urls']['getEditor'] = '/s/get-editor/'; askbot['urls']['apiGetQuestions'] = '/s/api/get_questions/'; askbot['urls']['ask'] = '/questions/ask/'; askbot['urls']['questions'] = '/questions/'; askbot['settings']['groupsEnabled'] = false; askbot['settings']['static_url'] = '/m/'; askbot['settings']['minSearchWordLength'] = 4; askbot['settings']['mathjaxEnabled'] = true; askbot['settings']['sharingSuffixText'] = ''; askbot['settings']['errorPlacement'] = 'after-label'; askbot['data']['maxCommentLength'] = 800; askbot['settings']['editorType'] = 'markdown'; askbot['settings']['commentsEditorType'] = 'rich\u002Dtext'; askbot['messages']['askYourQuestion'] = 'Ask Your Question'; askbot['messages']['acceptOwnAnswer'] = 'accept or unaccept your own answer'; askbot['messages']['followQuestions'] = 'follow questions'; askbot['settings']['allowedUploadFileTypes'] = [ "jpg", "jpeg", "gif", "bmp", "png", "tiff" ]; askbot['data']['haveFlashNotifications'] = true; askbot['data']['activeTab'] = 'questions'; askbot['settings']['csrfCookieName'] = 'asksage_csrf'; askbot['data']['searchUrl'] = ''; /*<![CDATA[*/ $('.mceStatusbar').remove();//a hack to remove the tinyMCE status bar$(document).ready(function(){ // focus input on the search bar endcomment var activeTab = askbot['data']['activeTab']; if (inArray(activeTab, ['users', 'questions', 'tags', 'badges'])) { var searchInput = $('#keywords'); } else if (activeTab === 'ask') { var searchInput =$('#id_title'); } else { var searchInput = undefined; animateHashes(); } var wasScrolled = $('#scroll-mem').val(); if (searchInput && !wasScrolled) { searchInput.focus(); putCursorAtEnd(searchInput); } var haveFullTextSearchTab = inArray(activeTab, ['questions', 'badges', 'ask']); var haveUserProfilePage =$('body').hasClass('user-profile-page'); if ((haveUserProfilePage || haveFullTextSearchTab) && searchInput && searchInput.length) { var search = new FullTextSearch(); askbot['controllers'] = askbot['controllers'] || {}; askbot['controllers']['fullTextSearch'] = search; search.setSearchUrl(askbot['data']['searchUrl']); if (activeTab === 'ask') { search.setAskButtonEnabled(false); } search.decorate(searchInput); } else if (activeTab === 'tags') { var search = new TagSearch(); search.decorate(searchInput); } if (askbot['data']['userIsAdminOrMod']) { $('body').addClass('admin'); } if (askbot['settings']['groupsEnabled']) { askbot['urls']['add_group'] = "/s/add-group/"; var group_dropdown = new GroupDropdown();$('.groups-dropdown').append(group_dropdown.getElement()); } var userRep = $('#userToolsNav .reputation'); if (userRep.length) { var showPermsTrigger = new ShowPermsTrigger(); showPermsTrigger.decorate(userRep); } }); if (askbot['data']['haveFlashNotifications']) {$('#validate_email_alert').click(function(){notify.close(true)}) notify.show(); } var langNav = $('.lang-nav'); if (langNav.length) { var nav = new LangNav(); nav.decorate(langNav); } /*]]>*/ if (typeof MathJax != 'undefined') { MathJax.Hub.Config({ extensions: ["tex2jax.js"], jax: ["input/TeX","output/HTML-CSS"], tex2jax: {inlineMath: [["$","$"],["\$","\$"]]} }); } else { console.log('Could not load MathJax'); } //todo - take this out into .js file$(document).ready(function(){ $('div.revision div[id^=rev-header-]').bind('click', function(){ var revId = this.id.substr(11); toggleRev(revId); }); lanai.highlightSyntax(); }); function toggleRev(id) { var arrow =$("#rev-arrow-" + id); var visible = arrow.attr("src").indexOf("hide") > -1; if (visible) { var image_path = '/m/default/media/images/expander-arrow-show.gif?v=19'; } else { var image_path = '/m/default/media/images/expander-arrow-hide.gif?v=19'; } image_path = image_path + "?v=19"; arrow.attr("src", image_path); \$("#rev-body-" + id).slideToggle("fast"); } for (url_name in askbot['urls']){ askbot['urls'][url_name] = cleanUrl(askbot['urls'][url_name]); }