how to solve an ode numerically?

mittina22's picture

hey guys.. i have put input this in maple.. but it doesn't seem to solve it..

 

ode:= D(D(y(t)))- u*(1-(y(t)^2))*D(y(t)) + y(t)=0;
ics:=y(0)=0.2, D(y)(0)=0;
                           y(0) = 0.2, D(y)(0) = 0
dsolve({ode,ics},numeric);

Error, (in unknown) invalid input: op expects 1 or 2 arguments, but received 0

 

Different format

Try the following format.  Notice that I have given "u" a value.

ode1:= diff(y(t),t$2)- 5*(1-(y(t)^2))*diff(y(t),t) + y(t)=0;
ics1:=y(0)=0.2, D(y)(0)=0;
dsolve({ode1,ics1},y(t),numeric);
 

Doug Meade's picture

correct usage of D, dsolve, ...

The first problem with the initial poster's attempt is the incorrect usage of D. It is possible to use diff, as suggested in the previous post, but here is how this equation should be entered with D:

ode:= D(D(y))(t)- u*(1-(y(t)^2))*D(y)(t) + y(t)=0;
ics:= y(0)=0.2, D(y)(0)=0;

Next, the second argument to dsolve needs to be the unknown function, in this case y(t):

dsolve({ode,ics},y(t));

Maple is unable to solve this equation exactly. But, it appears you are looking for a numeric solution. So, we use:

Y := dsolve({ode,ics},y(t),numeric);

This returns a Maple procedure that will return an approximate solution to the initial value problem. For example,

Y(0);
              [                                  d           ]
              [t = 0., y(t) = 0.20000000000000, --- y(t) = 0.]
              [                                  dt          ]

For any non-zero value of t, Maple needs a value for u to obtain the solution.

Y(1);
Error, (in Y) global 'u' must be assigned to a numeric value before obtaining a solution

Following this advise, you can assign a value to u (u := 3;). Or, you can avoid a global assignment by using subs:

subs(u=3,Y)(1);
   [                                       d                             ]
   [t = 1., y(t) = -0.114091806521692929, --- y(t) = -1.05459156309341574]
   [                                       dt                            ]

You will need to see the online help for numerical solutions to ODEs (?dsolve,numeric) for additional information on the different output you can obtain from dsolve and the ways to use this output.

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu       
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu/~meade/
</
mittina22's picture

thanks.. i knew there was

thanks.. i knew there was smoething wrong with my assignment of function.. i tried everything.. but strangely.. wen i used another ode it worked.. thanks a lot :D

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}