Problem solving system of ODEs

22 views
Skip to first unread message

Richard

unread,
Jul 22, 2010, 7:29:19 PM7/22/10
to sage-s...@googlegroups.com
Hello,

I am trying to solve a small system of ODEs, following the tutorial on
the SAGE homepage; however, I only receive an error message. What am I
doing wrong?

Here is my code:

====================
t = var ('t')

S_0 = 1.5
X_0 = 0.05
Y_XS = 0.5
K_S = 0.007
mu_max = 0.8

X = function ('X', t)
S = function ('S', X)
mu = function ('mu', S)

dXdt = diff (X, t) == mu * X
dSdt = diff (S, t) == -mu * X / Y_XS
mu = (mu_max * S) / (K_S + S)

desolve_system ([dXdt, dSdt], [X, S], ics = [0, X_0, S_0])
====================


(Part of) the error message is:

====================
TypeError: Error executing code in Maxima
CODE:
sage7 : atvalue(sage1,sage5,sage6)$
Maxima ERROR:

Improper argument to atvalue:
['X(t)]
====================


Thanks,

Richard

Richard

unread,
Jul 22, 2010, 7:46:16 PM7/22/10
to sage-s...@googlegroups.com
Forgot to mention: This is SAGE 4.5.1.

Richard

Richard

unread,
Jul 22, 2010, 8:25:03 PM7/22/10
to sage-s...@googlegroups.com
Sorry for spamming,

but I figured my initial code didn't make sense in the way mu was
computed; so I changed it to the following. The error message stays
the same, though.

====================
t = var ('t')

S_0 = 1.5
X_0 = 0.05
Y_XS = 0.5
K_S = 0.007
mu_max = 0.8

X = function ('X', t)
S = function ('S', X)

def mu (S):
return (mu_max * S) / (K_S + S)

dXdt = diff (X, t) == mu(S) * X
dSdt = diff (S, t) == -mu(S) * X / Y_XS

desolve_system ([dXdt, dSdt], [X, S], ics = [0, X_0, S_0])
====================

Richard

kcrisman

unread,
Jul 22, 2010, 10:41:57 PM7/22/10
to sage-support
Thanks for this explicit example. I think that what is happening is
that we are providing a list to the Maxima function "atvalue" (the
'X(t) is just an unevaluated function X(t)), which Maxima wouldn't
like, perhaps.


626 ivar_ic = ics[0]
627 for dvar, ic in zip(dvars, ics[1:]):
--> 628 dvar.atvalue(ivar==ivar_ic, ic)
629 soln = dvars[0].parent().desolve(des, dvars)
630 if str(soln).strip() == 'false':

But I'm not sure why this is happening; doing the atvalue 'by hand'
seems to give the right thing. Anyone else have ideas why this
happens?

- kcrisman

Richard

unread,
Jul 25, 2010, 2:10:42 PM7/25/10
to sage-s...@googlegroups.com
Hello,

On 07/23/2010 04:41 AM, kcrisman wrote:

> Thanks for this explicit example. I think that what is happening is
> that we are providing a list to the Maxima function "atvalue" (the
> 'X(t) is just an unevaluated function X(t)), which Maxima wouldn't
> like, perhaps.

[...]


> But I'm not sure why this is happening; doing the atvalue 'by hand'
> seems to give the right thing. Anyone else have ideas why this
> happens?

Apparently no, at least there hasn't been any further reply so far :)
Should I file a bug?

Is there any other way to solve my system of ODEs using SAGE? I need
to work with those equations in systems biology class.

Thanks,

Richard


Reply all
Reply to author
Forward
0 new messages