Re: [sage-support] desolve_system in sage

2012-10-11 Thread Doaa El-Sakout
Many thanks now I solved Lorentz equations and I plot in 2D.

But when I try to plot in 3D phase space I get result different about the
true "spirals "

This is what I did


from sage.calculus.desolvers import desolve_system_rk4
x,y,sigma,r,z,b,t=var('x,y,sigma,r,z,b,t')
sigma=10
b=8/3
r=10
P=desolve_system_rk4([sigma*(y-x),r*x-y-x*z,x*y-b*z],[x,y,z],ics=[0,0,1,0]
,ivar=t,end_points=20)

py=list_plot3d([[x,y,z] for t,x,y,z in P],plotjoined=True,axes_label=True)
show(py)

Please find the attached file to  see the plot
Thanks
Doaa

On 11 October 2012 12:55, David Joyner  wrote:

> On Thu, Oct 11, 2012 at 7:28 AM, Doaa El-Sakout  wrote:
> > Dear David,
> > I would like to plot x(t) against t similar for y and z
> > and after that plot [x,y,z] in phase space
> > So I want know the solution first for the system
> > before plot the result.
> > Thanks
> > Doaa
>
>
> Your system is similar to one used to model a Zombie attack (which is
> in turn borrowed from an infection model). The sage code is here:
> http://wdjoyner.org/zombies/love-war-zombies.sage
> The commands I think you want are towards the bottom.
> Slides going into more detail is here:
> http://wdjoyner.org/zombies/love-war-zombies_slides.pdf
> There is even a video:-)
>
> http://www.mosaic-web.org/go/MCAST/videos/MCAST-2011-04-22/lib/playback.html
>
>
> >
> >
> > On 11 October 2012 10:55, David Joyner  wrote:
> >>
> >> On Thu, Oct 11, 2012 at 3:20 AM, Doaa El-Sakout 
> wrote:
> >> > Hi everyone,
> >> > I try to solve a system of ODE by sage as follows
> >> >
> >> > x,y,sigma,r,z,b,t=var('x,y,sigma,r,z,b,t')
> >> > sigma=10
> >> > b=8/3
> >> > r=10
> >> > x= function('x',t)
> >> > y= function('y',t)
> >> > z= function('z',t)
> >> > d1=(diff(x,t)-sigma*(y-x)==0)
> >> > d2=(diff(y,t)-r*x+y+x*z==0)
> >> > d3=(diff(z,t)-x*y+b*z==0)
> >>
> >> This makes it non-linear. Did you intend to type that?
> >>
> >> > sol=desolve_system([d1,d2,d3],[x,y,z],ics=[0,1,0],ivar=t);show(sol)
> >> >
> >> > But I got the following error
> >> >
> >> > TypeError: unable to make sense of Maxima expression
> >> >
> >> >
> 'x(t)=ilt((?g3817-10*laplace(x(t)*z(t),t,?g3817)+1)/(?g3817^2+11*?g3817-90),?g3817,t)'
> >> > in Sage
> >> >
> >> >
> >> >
> >> > Any suggestion
> >> > Doaa
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "sage-support" group.
> >> > To post to this group, send email to sage-support@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> >> > sage-support+unsubscr...@googlegroups.com.
> >> > Visit this group at http://groups.google.com/group/sage-support?hl=en
> .
> >> >
> >> >
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "sage-support" group.
> >> To post to this group, send email to sage-support@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> sage-support+unsubscr...@googlegroups.com.
> >> Visit this group at http://groups.google.com/group/sage-support?hl=en.
> >>
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "sage-support" group.
> > To post to this group, send email to sage-support@googlegroups.com.
> > To unsubscribe from this group, send email to
> > sage-support+unsubscr...@googlegroups.com.
> > Visit this group at http://groups.google.com/group/sage-support?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To post to this group, send email to sage-support@googlegroups.com.
> To unsubscribe from this group, send email to
> sage-support+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support?hl=en.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.


<>

Re: [sage-support] desolve_system in sage

2012-10-11 Thread David Joyner
On Thu, Oct 11, 2012 at 7:28 AM, Doaa El-Sakout  wrote:
> Dear David,
> I would like to plot x(t) against t similar for y and z
> and after that plot [x,y,z] in phase space
> So I want know the solution first for the system
> before plot the result.
> Thanks
> Doaa


Your system is similar to one used to model a Zombie attack (which is
in turn borrowed from an infection model). The sage code is here:
http://wdjoyner.org/zombies/love-war-zombies.sage
The commands I think you want are towards the bottom.
Slides going into more detail is here:
http://wdjoyner.org/zombies/love-war-zombies_slides.pdf
There is even a video:-)
http://www.mosaic-web.org/go/MCAST/videos/MCAST-2011-04-22/lib/playback.html


>
>
> On 11 October 2012 10:55, David Joyner  wrote:
>>
>> On Thu, Oct 11, 2012 at 3:20 AM, Doaa El-Sakout  wrote:
>> > Hi everyone,
>> > I try to solve a system of ODE by sage as follows
>> >
>> > x,y,sigma,r,z,b,t=var('x,y,sigma,r,z,b,t')
>> > sigma=10
>> > b=8/3
>> > r=10
>> > x= function('x',t)
>> > y= function('y',t)
>> > z= function('z',t)
>> > d1=(diff(x,t)-sigma*(y-x)==0)
>> > d2=(diff(y,t)-r*x+y+x*z==0)
>> > d3=(diff(z,t)-x*y+b*z==0)
>>
>> This makes it non-linear. Did you intend to type that?
>>
>> > sol=desolve_system([d1,d2,d3],[x,y,z],ics=[0,1,0],ivar=t);show(sol)
>> >
>> > But I got the following error
>> >
>> > TypeError: unable to make sense of Maxima expression
>> >
>> > 'x(t)=ilt((?g3817-10*laplace(x(t)*z(t),t,?g3817)+1)/(?g3817^2+11*?g3817-90),?g3817,t)'
>> > in Sage
>> >
>> >
>> >
>> > Any suggestion
>> > Doaa
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "sage-support" group.
>> > To post to this group, send email to sage-support@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > sage-support+unsubscr...@googlegroups.com.
>> > Visit this group at http://groups.google.com/group/sage-support?hl=en.
>> >
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sage-support" group.
>> To post to this group, send email to sage-support@googlegroups.com.
>> To unsubscribe from this group, send email to
>> sage-support+unsubscr...@googlegroups.com.
>> Visit this group at http://groups.google.com/group/sage-support?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To post to this group, send email to sage-support@googlegroups.com.
> To unsubscribe from this group, send email to
> sage-support+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




Re: [sage-support] desolve_system in sage

2012-10-11 Thread Doaa El-Sakout
Dear David,
I would like to plot x(t) against t similar for y and z
and after that plot [x,y,z] in phase space
So I want know the solution first for the system
before plot the result.
Thanks
Doaa

On 11 October 2012 10:55, David Joyner  wrote:

> On Thu, Oct 11, 2012 at 3:20 AM, Doaa El-Sakout  wrote:
> > Hi everyone,
> > I try to solve a system of ODE by sage as follows
> >
> > x,y,sigma,r,z,b,t=var('x,y,sigma,r,z,b,t')
> > sigma=10
> > b=8/3
> > r=10
> > x= function('x',t)
> > y= function('y',t)
> > z= function('z',t)
> > d1=(diff(x,t)-sigma*(y-x)==0)
> > d2=(diff(y,t)-r*x+y+x*z==0)
> > d3=(diff(z,t)-x*y+b*z==0)
>
> This makes it non-linear. Did you intend to type that?
>
> > sol=desolve_system([d1,d2,d3],[x,y,z],ics=[0,1,0],ivar=t);show(sol)
> >
> > But I got the following error
> >
> > TypeError: unable to make sense of Maxima expression
> >
> 'x(t)=ilt((?g3817-10*laplace(x(t)*z(t),t,?g3817)+1)/(?g3817^2+11*?g3817-90),?g3817,t)'
> > in Sage
> >
> >
> >
> > Any suggestion
> > Doaa
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "sage-support" group.
> > To post to this group, send email to sage-support@googlegroups.com.
> > To unsubscribe from this group, send email to
> > sage-support+unsubscr...@googlegroups.com.
> > Visit this group at http://groups.google.com/group/sage-support?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To post to this group, send email to sage-support@googlegroups.com.
> To unsubscribe from this group, send email to
> sage-support+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support?hl=en.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




Re: [sage-support] desolve_system in sage

2012-10-11 Thread David Joyner
On Thu, Oct 11, 2012 at 3:20 AM, Doaa El-Sakout  wrote:
> Hi everyone,
> I try to solve a system of ODE by sage as follows
>
> x,y,sigma,r,z,b,t=var('x,y,sigma,r,z,b,t')
> sigma=10
> b=8/3
> r=10
> x= function('x',t)
> y= function('y',t)
> z= function('z',t)
> d1=(diff(x,t)-sigma*(y-x)==0)
> d2=(diff(y,t)-r*x+y+x*z==0)
> d3=(diff(z,t)-x*y+b*z==0)

This makes it non-linear. Did you intend to type that?

> sol=desolve_system([d1,d2,d3],[x,y,z],ics=[0,1,0],ivar=t);show(sol)
>
> But I got the following error
>
> TypeError: unable to make sense of Maxima expression
> 'x(t)=ilt((?g3817-10*laplace(x(t)*z(t),t,?g3817)+1)/(?g3817^2+11*?g3817-90),?g3817,t)'
> in Sage
>
>
>
> Any suggestion
> Doaa
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To post to this group, send email to sage-support@googlegroups.com.
> To unsubscribe from this group, send email to
> sage-support+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] desolve_system in sage

2012-10-11 Thread Doaa El-Sakout
Hi everyone,
I try to solve a system of ODE by sage as follows

x,y,sigma,r,z,b,t=var('x,y,sigma,r,z,b,t')
sigma=10
b=8/3
r=10
x= function('x',t)
y= function('y',t)
z= function('z',t)
d1=(diff(x,t)-sigma*(y-x)==0)
d2=(diff(y,t)-r*x+y+x*z==0)
d3=(diff(z,t)-x*y+b*z==0)
sol=desolve_system([d1,d2,d3],[x,y,z],ics=[0,1,0],ivar=t);show(sol)

But I got the following error

TypeError: unable to make sense of Maxima expression
'x(t)=ilt((?g3817-10*laplace(x(t)*z(t),t,?g3817)+1)/(?g3817^2+11*?g3817-90),?g3817,t)'
in Sage


Any suggestion
Doaa

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] desolve_system

2009-09-22 Thread AMSALEWORK EJIGU

Hi

I have previously solved this problem using odesolve from scipy.
I am now learning SAGE.

What is wrong here? I get zerodivision from SAGE but it had a solution
in odesolve.

t = var('t')
z = function('z',t)
y1= function('y1',t)
y2= function('y2',t)

b = 0.03; r1 = 6.0; r2 = 0.5; gamma = 0.01; ro = 6.0;

De1 = diff(z,t) - b + (r1*y1 + r2*y2 + b - (gamma*y2)*z) == 0
De2 = diff(y1,t)-(r1*y1+r2*y2)*z + (ro+b-gamma*y2)*y1 == 0
De3 = diff(y2,t)-ro*y1+gamma*y2*(1-y2)+y2*b == 0
desolve_system([De1, De2, De3], [z, y1, y2])


I get this result:



Traceback (click to the left for traceback)
...
ZeroDivisionError: Symbolic division by zero

Traceback (most recent call last):
  File "", line 1, in 
  File "/var/autofs/misc/home/amsalework/.sage/sage_notebook/
worksheets/admin/13/code/1.py", line 17, in 
desolve_system([De1, De2, De3], [z, y1, y2])
  File "", line 1, in 

  File "/usr/local/src/sage-4.1.1/local/lib/python2.6/site-packages/
sage/calculus/desolvers.py", line 259, in desolve_system
soln[i] = sol.sage()
  File "/usr/local/src/sage-4.1.1/local/lib/python2.6/site-packages/
sage/interfaces/expect.py", line 1578, in sage
return self._sage_()
  File "/usr/local/src/sage-4.1.1/local/lib/python2.6/site-packages/
sage/interfaces/maxima.py", line 1703, in _sage_
return symbolic_expression_from_maxima_string(repr(self))
  File "/usr/local/src/sage-4.1.1/local/lib/python2.6/site-packages/
sage/calculus/calculus.py", line 1677, in
symbolic_expression_from_maxima_string
return symbolic_expression_from_string(s, syms,
accept_sequence=True)
  File "/usr/local/src/sage-4.1.1/local/lib/python2.6/site-packages/
sage/calculus/calculus.py", line 1774, in
symbolic_expression_from_string
return parse_func(s)
  File "parser.pyx", line 516, in
sage.misc.parser.Parser.parse_sequence (sage/misc/parser.c:3803)
  File "parser.pyx", line 531, in
sage.misc.parser.Parser.parse_sequence (sage/misc/parser.c:3689)
  File "parser.pyx", line 602, in sage.misc.parser.Parser.p_sequence
(sage/misc/parser.c:4394)
  File "parser.pyx", line 692, in sage.misc.parser.Parser.p_eqn (sage/
misc/parser.c:5101)
  File "parser.pyx", line 728, in sage.misc.parser.Parser.p_expr (sage/
misc/parser.c:5382)
  File "parser.pyx", line 761, in sage.misc.parser.Parser.p_term (sage/
misc/parser.c:5605)
  File "parser.pyx", line 803, in sage.misc.parser.Parser.p_factor
(sage/misc/parser.c:5966)
  File "parser.pyx", line 830, in sage.misc.parser.Parser.p_power
(sage/misc/parser.c:6077)
  File "parser.pyx", line 884, in sage.misc.parser.Parser.p_atom (sage/
misc/parser.c:6525)
  File "parser.pyx", line 920, in sage.misc.parser.Parser.p_args (sage/
misc/parser.c:6924)
  File "parser.pyx", line 951, in sage.misc.parser.Parser.p_arg (sage/
misc/parser.c:7223)
  File "parser.pyx", line 728, in sage.misc.parser.Parser.p_expr (sage/
misc/parser.c:5382)
  File "parser.pyx", line 771, in sage.misc.parser.Parser.p_term (sage/
misc/parser.c:5721)
  File "element.pyx", line 1271, in
sage.structure.element.RingElement.__div__ (sage/structure/element.c:
10502)
  File "expression.pyx", line 1884, in
sage.symbolic.expression.Expression._div_ (sage/symbolic/
expression.cpp:10818)
ZeroDivisionError: Symbolic division by zero

regards,
Amsale

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---