Items tagged with ode ode Tagged Items Feed

I have solved ODE's with either i.c. or b.c. (mechanics stuff) where the results were in terms of expressions, not functions.  I could plot these expressions, substitute values in for parameters, etc. 

Then I thought that the real way to solve an ODE or system of ODE's was to define functions.  I wanted this to be in three levels: the solutions in generality, the solutions with i.c./m.c. applied, and then further with the parameter values defined. 

So far, no joy.  Lots of confusion--input eqns as sequence, list, set?  I looked on the Maple help page, thought I was doing things right. I even tried out "union" for the ode's and the ic's.

The code is below; statement (11) produces an error. Yes, I am using Maple 18, even though the file says Maple 15.  I'd like to solve the 4-ODE system at the three levels listed above, and then (if possible), plot the result! Am I asking too much?  Should I be using MapleSim or some other product instead?

 

Thanks for any and all help!

 

robert w.


NULL

restart

assume(m1 > 0);

eqn1 := diff(z1(t), t) = z2(t);

diff(z1(t), t) = z2(t)

(1)

eqn2 := diff(z2(t), t) = -(k1+k2)*z1(t)/m1-(c1+c2)*z2(t)/m1+k2*z3(t)/m1+c2*z4(t)/m1;

diff(z2(t), t) = -(k1+k2)*z1(t)/m1-(c1+c2)*z2(t)/m1+k2*z3(t)/m1+c2*z4(t)/m1

(2)

eqn3 := diff(z3(t), t) = z4(t);

diff(z3(t), t) = z4(t)

(3)

eqn4 := diff(z4(t), t) = k2*z1(t)/m2+c2*z2(t)/m2-k2*z3(t)/m2-c2*z4(t)/m2;

diff(z4(t), t) = k2*z1(t)/m2+c2*z2(t)/m2-k2*z3(t)/m2-c2*z4(t)/m2

(4)

eqns := eqn1, eqn2, eqn3, eqn4;

diff(z1(t), t) = z2(t), diff(z2(t), t) = -(k1+k2)*z1(t)/m1-(c1+c2)*z2(t)/m1+k2*z3(t)/m1+c2*z4(t)/m1, diff(z3(t), t) = z4(t), diff(z4(t), t) = k2*z1(t)/m2+c2*z2(t)/m2-k2*z3(t)/m2-c2*z4(t)/m2

(5)

var := z1(t), z2(t), z3(t), z4(t);

z1(t), z2(t), z3(t), z4(t)

(6)

ic1 := z1(0) = -2;

z1(0) = -2

(7)

ic2 := z2(0) = 0;

z2(0) = 0

(8)

ic3 := z3(0) = 1;

z3(0) = 1

(9)

ic4 := z4(0) = 0;

z4(0) = 0

(10)

ics := ic1, ic2, ic3, ic4;

z1(0) = -2, z2(0) = 0, z3(0) = 1, z4(0) = 0

(11)

dsolve(`union`(eqns, ics), var)

Error, invalid input: `union` received diff(z1(t), t) = z2(t), which is not valid for its 1st argument

 

var;

z1(t), z2(t), z3(t), z4(t)

(12)

data:=(m1=1,m2=2,m3=1,c1=0,c2=0,c3=0,k1=5,k2=2,k3=2);

m1 = 1, m2 = 2, m3 = 1, c1 = 0, c2 = 0, c3 = 0, k1 = 5, k2 = 2, k3 = 2

(13)

eqnsev := subs(data, eqns);

diff(z4(t), t) = z1(t)-z3(t)

(14)

NULL


Download mae340_state_space_4-ode_system.mw

Hi there,

I have an ODE system which apparently needs some initial conditions to have its vector field plotted.

I am giving Maple's dfieldplot function the following arguments:


dfieldplot([de1, de2], [A(t), G(t)], t = 0..1, [A(0) = 25, G(0) = 0], A = 0..900, G = 0..200)

But Maple yields an error that reads:

Error, (in DEtools%2Fdfieldplot) invalid use of initial points or option - see phaseportrait

 

I would say that the initial conditions are correctly stated, according to the documentation of the function.

This is the attempt: MaplePrimes_Malaria_infection_cont.mw

 

Any ideas on what's missing?

Thanks,

jon

 

Hi there,

I would like to have the Jacobian matrix of an ODE system evaluated, and their eigenvalues computed, at the steady states of the system.

I know how to get the Jacobian matrix evaluated and the eigenvalues computed on an individual basis, setting manually each steady state as the argument of the matrix.

However, I would like to have it in a loop, so that the loop manages all steady states, that is:

steadyStates:= solve(mySystem); # would yield a set of pairs/lists

for each steadyState

m:=Jacobian(steadyStateN); # evaluate the Jacobian matrix

ev:= eigenvals(m); # compute the eigenvalues and save them to another variable/array and print them

end for:

First, I am not to find a way to loop over my steadyStates.

Attached is an example where the Jacobian matrix and eigenvalues are computed individually, where the steady states have been hard-coded once they have been computed: MaplePrimes_Predator_prey_model_Jacobian.mw

 

Any ideas on how to do this?

Thanks,

jon

 

 

Hi there,

I would like to compute and display the nullclines of a set of ordinary differential equations.

AFAIK, I can compute the nullclines in Maple by defining the equations and solving the system

e.g.:

# Define the equations
eq1 := u(t)*(1-u(t)/kappa)-u(t)*v(t) = 0;
eq2 := g*(u(t)-1)*v(t) = 0;

# Solve the system (i.e. compute the nullclines)
sol := solve({eq1, eq2}, {u(t), v(t)});

However, I am not quite able to imagine how to display them over a dfieldplot or a phaseportrait.

Attached is an example with some differential equations, and their vector field and trajectories: MaplePrimes_Predator_prey_model_nullclines.mw.

It can be use to illustrate how to (compute and) display the nullclines.

 

Thank you,

jon

I am also not sure how to program a check in the code to determine that dsolve solved the differential equation.

For example

ode:=diff(y(x),x)-a*(x^n-x)*y(x)^3-y(x)^2=0;
sol:=dsolve(ode,y(x));

In this case, sol is () as it could not solve it. When I tried odetest, I get an error

odetest(sol,ode);

Error, invalid input: odetest uses a 2nd argument, ODE, which is missing

What is the correct way to check dsolve was successful that will work for all cases? I am looking for programmable method, no GUI use.

 

 

 

 

Hallo. I'm solving a initial value problem for system of 7 ODE:

dsn := dsolve({expand(maineq[1, 1]), expand(maineq[1, 2]), expand(maineq[1, 3]), expand(maineq[1, 4]), expand(maineq[1, 5]), expand(maineq[1, 6]), expand(maineq[1, 7]), T(0) = .5, u(0) = u0, Y[1](0) = .8, Y[2](0) = .2, Y[3](0) = 0, Y[4](0) = 0, Y[5](0) = 0}, numeric, method = lsode[backfull])

 

Is there easy way how to plot result?

 

 

 

Hi,

I'm trying to solve the following non-linear ODE numerically:

by ececuting

but maple gives me this error-message:

"Error, (in dsolve/numeric/make_proc) Could not convert to an explicit first order system due to 'RootOf'"

I couldnt find any useful information in the manual. What does this error mean? Is there something wrong with my maple code or is there just no solution for this particulare differential equation?

 

Thanks in advance

I got a problem with solving a second order ODE. 

The ODE is :

-V(xi)+(1/2)*xi*(diff(V(xi), xi))+(1/4)*(diff(V(xi), xi, xi))=-(1/2)*k2*(diff(H(xi), xi))-k1*n*X/E+1+k2

where k1,k2,n,X,E  all are constant.

the condition is :

V(xi) tends to 2*xi^2 as xi tends to infinity.

I used 'dsolve' to solve the equation firstly, and got a solution with two constant C1 and C2, I want to use the condition to elimilate C2, so I used limit(sol,xi=infinity)=2*xi^2. But when I used the command 'limit', I can't get the answer.

Could any one help me? 

Many thanks!!!

Hi,

 

I'm trying to solve the following differential equation numerically with dsolve:

but dsolve gives me this error:

> res := dsolve(DGL, numeric, parameters = [y0, A, B, C, E]);
Error, (in DEtools/convertsys) unable to convert to an explicit first-order system

I think the problem is that I use the wrong solver. Does Maple provide a solver which is capable of solving this kind of equations (nonlinear ODE)?

 

Thanks in advance!

 

Hello,

Im solving 4 ODE equations with BC. im trying to shoot the initial value but im having this error:

""Error, (in isolate) cannot isolate for a function when it appears with different arguments""

anyone could help me???

shooting92.mw

``

restart

Shootlib := "E:\\shooting/":

libname := Shootlib, libname:

with(Shoot):

with(plots):

n := 2:

FNS := {F(eta), H(eta), f(eta), g(eta), u(eta), v(eta)}:

ODE := {g(eta)*(diff(g(eta), eta))+B*(f(eta)+g(eta)) = 0, g(eta)*(diff(F(eta), eta))+F(eta)^2+B*(F(eta)-u(eta)) = 0, g(eta)*(diff(H(eta), eta))+H(eta)*(diff(g(eta), eta))+F(eta)*H(eta) = 0, diff(v(eta), eta)+f(eta)*v(eta)-u(eta)^2+B*H(eta)*(F(eta)-u(eta))-M*u(eta) = 0, diff(f(eta), eta) = u(eta), diff(u(eta), eta) = v(eta)};

{g(eta)*(diff(H(eta), eta))+H(eta)*(diff(g(eta), eta))+F(eta)*H(eta) = 0, g(eta)*(diff(g(eta), eta))+0.2e-1*f(eta)+0.2e-1*g(eta) = 0, g(eta)*(diff(F(eta), eta))+F(eta)^2+0.2e-1*F(eta)-0.2e-1*u(eta) = 0, diff(v(eta), eta)+f(eta)*v(eta)-u(eta)^2+0.2e-1*H(eta)*(F(eta)-u(eta))-3*u(eta) = 0, diff(f(eta), eta) = u(eta), diff(u(eta), eta) = v(eta)}

(1)

IC := {F(0) = gamma, H(0) = Q, f(0) = 0, g(0) = z, u(0) = 1, v(0) = alpha};

{F(0) = gamma, H(0) = Q, f(0) = 0, g(0) = z, u(0) = 1, v(0) = alpha}

(2)

BC := {F(L) = 0, H(L) = n, g(L) = -f(L), u(L) = 0};

{F(6) = 0, H(6) = 2, g(6) = -f(6), u(6) = 0}

(3)

infolevel[shoot] := 1:

S := shoot(ODE, IC, BC, FNS, [alpha = 0, gamma = 0, z = -.2, Q = 0])

Error, (in isolate) cannot isolate for a function when it appears with different arguments

 

``

``


Download shooting92.mw

Hi everyone, I have been trying to plot the Taylor Polynomial approximation with the following code. However, my maple crushes everytime I run it. I indexed some of the variables to get the plot. The code works fine without the index. What did I do wrong?

y := array(1 .. 2);

Digits := 10;

n := 30;

h := .1;

T := 0;

X := 1; 

f := (x, t) -> 1/(3*x(t)-t-2); 

one := 1/(3*x(t)-t-2);

two := diff(f(x, t), t);

first := diff(x(t), t)

 

for k to n do

y[1] := subs(t = T(k), x(T(k)) = X(k), one);

y[2] := subs(first = y[1], t = T, x(T(k)) = X(k), two);

X[k+1] := X+sum(y[i]*h^i/factorial(i), i = 1 .. 2);

T[k+1] := T+h

end do;

X[n];

data := [seq([T[n], X[n]], n = 0 .. 30)];

p[2] := plot(data, style = point, color = blue);

p[3] := plot(data, style = line, color = blue);
display(p[2],  p[3])


 

The code without Index (which works fine)

y := array(1 .. 2);

Digits := 10;

n := 30;

h := .1;

T := 1;

X := .1547196278;

f := (x, t) -> 1/(3*x(t)-t-2); 

one := x(t)^4*e^t-(1/3)*x(t);

two := diff(f(x, t), t);

first := diff(x(t), t);

for k to n do

y[1] := subs(t = T, x(T) = X, one);

y[2] := subs(first = y[1], t = T, x(T) = X, two);

X := X+sum(y[i]*h^i/factorial(i), i = 1 .. 2);

T := T+h

end do

Dear All,

I need your help to plot the phase portrait using DEtools[DEplot]  these are the lines of the code. But when I make RUN, there is an error. I need your help to fix the error. Many thinks.

 

r1:=1; r2:=1; q2:=2; q1=0.5;  a1:=1;

Sys1 := {diff(N(t),t) = r1*N*(1-N/q1)-P*N/(1+N), diff(P(t),t) = r2*P*(exp(-a1*P)-q2)+P*N/(1+N)};

DEtools[DEplot](Sys1,[N(t),P(t)],t=-10..10,N=0..2,P=0..2);

 

Many thinks

I have an ode in the form:

 

diff(u(x),x)-f(x)=u(x)^3+B(X)*u(x)+g(x)

how to extaract and name the different coefficients of the equation?

 

Thanks 

Hamada

So I am brand new to using Maple and am trying to solve a system of ODE's. When I try and use dsolve however I reciever the error "function expected" and I am not sure why. The code I have is as follows

 

sys_ode := diff(A(t), t) = a*(A(t)+B(t))-b1*A(t)*(C(t)+D(t))-g1*A(t)*B(t), diff(B(t), t) = -b2*B(t)*(C(t)+D(t))+g1*A(t)*B(t), diff(C(t), t) = e*(b1*A(t)+b2*B(t))*C(t)-g2*b2*C(t)*B(t)-g3*C(t)*D(t), diff(D(t), t) = g2*b2*C(t)*D(t)-m*D(t)

dsolve([sys_ode])

 

I'm sure it is something simple, but I just can't seem to figure out where the issue is. Any help is much appreciated.

1 2 3 4 5 6 7 Last Page 3 of 21