Items tagged with differential-equations

Feed

Pls what is the maple code for the fourth order Runge-kutta method for five systems of ODE of several variables?

i am interested to numerically solve the 3 non-linear coupled ODE's in the 3 different intervals of rho(define in attached file) for the different corresponding parameters alpha and beta at i=0..2.

density_interval_solution.mw 

How to convert a system of differential equations to a matrix?

can infolevel show this matrix during the process?


To summarize,

dsolve numeric parametric form gives wrong answers when fdiff is used to calculate the Hessian. Doing dsolve twice gives the correct answer. Hope I am not making syntax or programming errors.

Also, fdiff is not compatible with vector form.

restart;

Digits:=15;

Digits := 15

(1)

sys:=diff(y1(t),t)=-(u+u^2/2)*y1(t),diff(y2(t),t)=u*y1(t);

sys := diff(y1(t), t) = -(u+(1/2)*(u^2))*y1(t), diff(y2(t), t) = u*y1(t)

(2)

 The system is solved with initial conditions 1,0 and value of u being equal to u1 for t<=0.5, and u2 for t>0.5. The objective is y2 at t =1. There are errors when Hessian is calculated using parametric dsolve and fdiff

sol1 := dsolve({sys, y1(0) = alpha, y2(0) = beta}, type = numeric, 'parameters' = [alpha, beta, u],maxfun=0,range=0..0.5):

obj1:=proc(u1,u2)
local z1,s1,s2,z2;
global sol1;
sol1('parameters'=[1,0,u1]);
z1 := sol1(.5);
s1:=subs(z1,y1(t));
s2:=subs(z1,y2(t));
sol1('parameters'=[s1,s2,u2]):
z2:=sol1(0.5);
-subs(z2,y2(t));
end proc;

obj1 := proc (u1, u2) local z1, s1, s2, z2; global sol1; sol1('parameters' = [1, 0, u1]); z1 := sol1(.5); s1 := subs(z1, y1(t)); s2 := subs(z1, y2(t)); sol1('parameters' = [s1, s2, u2]); z2 := sol1(.5); -subs(z2, y2(t)) end proc

(3)

u0:=[0.8,1.8];

u0 := [.8, 1.8]

(4)

obj1(op(u0));

-.552540796143903

(5)

Hess1:=Matrix(2,2):for i from 1 to 2 do for j from 1 to 2 do Hess1[i,j]:=fdiff(obj1,[i,j],u0,workprec=1.0);od;od;Hess1;

Matrix(2, 2, {(1, 1) = 115.470000000000, (1, 2) = -1.11000000000000, (2, 1) = -1.11000000000000, (2, 2) = 2.22000000000000})

(6)

 Hessian is wrong. It should be noted that when dsolve is called twice inside the objective function there is no error in Hessian calculation with fdiff. The parametric dsolve is efficient, how to get correct answers with that? Another question is how to use fdiff with vector form instead u1,u2 etc to make it generic for any number of variables?

obj2:=proc(u1,u2)
local z1,s1,s2,z2,sol2;
sol2:=dsolve({op(subs(u=u1,[sys])), y1(0) = 1, y2(0) = 0}, type = numeric,maxfun=0,range=0..0.5);
z1 := sol2(.5);
s1:=subs(z1,y1(t));
s2:=subs(z1,y2(t));
sol2:=dsolve({op(subs(u=u2,[sys])), y1(0) = s1, y2(0) = s2}, type = numeric,maxfun=0,range=0..0.5):
z2:=sol2(0.5);
-subs(z2,y2(t));
end proc;

obj2 := proc (u1, u2) local z1, s1, s2, z2, sol2; sol2 := dsolve({op(subs(u = u1, [sys])), y1(0) = 1, y2(0) = 0}, type = numeric, maxfun = 0, range = 0 .. .5); z1 := sol2(.5); s1 := subs(z1, y1(t)); s2 := subs(z1, y2(t)); sol2 := dsolve({op(subs(u = u2, [sys])), y1(0) = s1, y2(0) = s2}, type = numeric, maxfun = 0, range = 0 .. .5); z2 := sol2(.5); -subs(z2, y2(t)) end proc

(7)

obj2(op(u0));

-.552540796143903

(8)

Hess2:=Matrix(2,2):for i from 1 to 2 do for j from 1 to 2 do Hess2[i,j]:=fdiff(obj2,[i,j],u0,workprec=1.0);od;od;Hess2;

Matrix(2, 2, {(1, 1) = .234295697631809, (1, 2) = 0.101868715004724e-1, (2, 1) = 0.101868715004724e-1, (2, 2) = 0.853480932660994e-1})

(9)

 Doing dsolve twice gives correct answer compared to one parametric dsolve even though objective returns the same number (even gradient returns the expected answers).


 

Download Bugindsolveorfdiff.mws

hi .may every one help me for pdsolve this differential equations?

all initial boundary condition are zero

thanks...

pdeSol_(1).mw

 

#
# Define some parameters
#
  sigma := 10; N := 0; beta := 1; alpha := 1; PDE1 := diff(w(X, theta, t), X, X, X, X)+2*alpha^2*(diff(w(X, theta, t), theta, theta, X, X))+alpha^4*(diff(w(X, theta, t), theta, theta, theta, theta))-N*(diff(w(X, theta, t), X, X))+diff(w(X, theta, t), t, t)-beta*w(X, theta, t)-sigma = 0

10

 

0

 

1

 

1

 

diff(diff(diff(diff(w(X, theta, t), X), X), X), X)+2*(diff(diff(diff(diff(w(X, theta, t), X), X), theta), theta))+diff(diff(diff(diff(w(X, theta, t), theta), theta), theta), theta)-10+diff(diff(w(X, theta, t), t), t)-w(X, theta, t) = 0

(1)

#
# Define the PDES
#
  PDEs:= { diff(w(X, theta, t), X, X, X, X)+2*alpha^2*(diff(w(X, theta, t), theta, theta, X, X))+alpha^4*(diff(w(X, theta, t), theta, theta, theta, theta))-N*(diff(w(X, theta, t), X, X))+diff(w(X, theta, t), t, t)-beta*w(X, theta, t)-sigma = 0
   };

{diff(diff(diff(diff(w(X, theta, t), X), X), X), X)+2*(diff(diff(diff(diff(w(X, theta, t), X), X), theta), theta))+diff(diff(diff(diff(w(X, theta, t), theta), theta), theta), theta)-10+diff(diff(w(X, theta, t), t), t)-w(X, theta, t) = 0}

(2)

#
# Set of boundary conditions at x=1.
#
   bcs1:= { D[1](w)(1,theta, t) = 0,
              w(1,theta, t) = 0
         };

{w(1, theta, t) = 0, (D[1](w))(1, theta, t) = 0}

(3)

#
# Set of boundary conditions at x=0
#
  bcs2:= {    w(0,theta, t)=0,
           D[1](w)(0,theta, t)=0
         };

{w(0, theta, t) = 0, (D[1](w))(0, theta, t) = 0}

(4)

#
# Set of boundary conditions at t=0
#
  bcs3:= { w(x,theta,0)=0,
          
           D[2](w)(x,theta,0)=0 };
           

{w(x, theta, 0) = 0, (D[2](w))(x, theta, 0) = 0}

(5)

 


  pdsolve( PDEs, `union`(bcs1, bcs2, bcs3), numeric);

Error, (in pdsolve/numeric/process_PDEs) can only numerically solve PDE with two independent variables, got {X, t, theta}

 

 

 

Download pdeSol_(1).mw

Hello

I was looking for information on how to solve a differential equation in Maple, but I do not know how to start.

I have yet equations in symbolic form and I want to apply for the calculation of such a procedure ODE4 (Runge Kutta 4) with fixed step integration Tc and time calculations ongoing T.

Where to start?
1. This should be done in another sheet, or I could write command in next line under the symbolic transformations?
2. To enter numeric parameters that certain symbols were they equal?
3. How to perform iterative calculations?

Thank you in advance for your help

Hi everyone, I'm working a problem

Given a dog and a man. At t=0, the position of the man and his dog is (0,0) and (0,h), respectively. Then, the man start moving along Ox with constant speed vm. The dog keep running toward its master with constant speed vd. Describe the movement of the dog?

Therefore, let say the position of the dog is (f1(x),f2(x)), I wrote these:

restart;

with(plots);

MD := proc (h, vm, vd) local x, y, ode, ics, sol;

ode := {(diff(f2(t), t))*(vm*t-f1(t))+(diff(f1(t), t))*f2(t), diff(f2(t), t) = -sqrt(vd^2-(diff(f1(t), t))^2)};

ics := {f1(0) = h, f2(0) = 0};

sol := dsolve(ode union ics);

x := unapply(eval(f1(t), sol), t);

y := unapply(eval(f2(t), sol), t);

plot([x(t), y(t), t = 0 .. 10], scaling = constrained) end proc;

MD(10, 1, 5);

However, "sol" is returned NULL, which means the equation has no solution. I supposed I completed the motion part of the problem correctly. Please help me or point out an another method

 

i have this problem -> f'^2 -ff''=f'''-k1(2f'f'''-ff''''-f''^2)+Ha^2(E1-f') with boundary conditions f(0)=0, f'(0)=1, f'(∞)=0.

since it is a fourth order equation, but only three bcs, it does not produce unique solution. so the solution of the equation may be seek in form of f=f0(eta)+k1f1(eta).

thus the equation will become 

f0'^2-f0f0''=f0'''+Ha^2(E1-f0')

and

f1'''-Ha^2f1'-2f0'f1'+f0f1''+f1f0''=2f0'f0'''-f0f0''''-f0''^2.

boundary conditions are 

f0(0)=0,f0'(0)=1,f0'(∞)=0

f1(0)=0,f1'(0)=0,f1'(∞)=0.

i had been clueless in solving this problem. please somebody help me with this problem.

Hi everyone

I'm trying to solve the following system of ODE equations for my end paper and since I'm new with maple I couldn't find a way to do it. Can anyone Plz help me? I need to fit a curve to the result and gain a symbolic equation.

Here are the equations I need to solve

d^2*Y(x)/dt^2 = 500000*Y(x)*exp(-10/T(x))+d*Y(x)/dt

d^2*T(x)/dt^2 = 10*(-100000*Y(x)*exp(-10/T(x)))+d*T(x)/dt

with the follwoing boundary conditions:

Y(0)=1 , Y'(0)=0, T(0)=0 , T'(0)=0

I need to plot Y and T and then find then do the curve fitting thing.

I really appreciate your help.

 

Sorry for making such a rude, big question. I have to solve these equations, but it's impossible ofcourse with my bad mathematics and even maple skills. Somebody help me pleaseㅠ_ㅠ

 

Differential equations

Hello!

So as the title says i have a problem with solution of second order differential equation system.

The problem is that after i set some initial conditions and check the solution when the time equals zero, the solution graph is completely different from my initial conditions which is obviously incorrect. I know that i can change "spacestep" parameter, but i am not sure if it is the only way to fix the problem. Are there any other ways to fix this?

Here is a part of my code if it helps

r0=1.570796327
theta0=6.000000000


 A'(t)=20+0.03*A(t)-0.00005*A(t)*Q(t)-0.0002*A(t)*Q(t)-0.0743*A(t)-12,

B'(t)=0.03*B(t)+0.00005*A(t)*Q(t)+0.0002*A(t)*Q(t)-0.0743*B(t)-0.01072*B(t),

C'(t)=0.01072*B(t)-(0.0743+0.0123)*C(t),

P'(t)=15+0.03*P(t)-0.0001*P(t)*B(t)-0.0743*A(t)-10,

Q'(t)=0.03*Q(t)+0.0001*P(t)*B(t)-0.0743*Q(t)-0.25*Q(t),

R'(t)=0.25*Q(t)-(0.0743+0.0123)*R(t),

X'(t)=25-0.0003*X(t)*B(t)-0.0743*X(t)-10,

Y'(t)=0.0003*X(t)*B(t)-0.0743*Y(t)-0.3*Y(t),

Z'(t)=0.3*Y(t)-(0.0743+0.0123)*Z(t).

Initial conditions

A(0)=150,B(0)=30, C(0)=10,P(0)=130,Q(0)=45,R(0)=10,X(0)=85,Y(0)=30, Z(0)=20.

Can I plot the graph between {A(t),B(t),C(t),P(t),Q(t),R(t),X(t),Y(t),Z(t)}and time t{0,100}.

Hi,
The FunctionAdvisor project is currently developing at full speed. During the last two months, a significant amount of new conversion routines and mathematical information for Jacobi elliptic and Jacobi Theta functions, on identities, periodicity, transformations, etc. got added to the conversion network for mathematical functions and to the FunctionAdvisor. The previous months was the turn of the set of complex components, added to the network. Developments regarding the simplification and integration of special functions (e.g SphericalY for computing spherical harmonics or Dirac), as well as fixes to the numerical evaluation of JacobiAM, `assuming` and to differential equation subroutines are also part of the update.

These developments are available to everybody as usual in the Maplesoft R&D Differential Equations and Mathematical Functions webpage. Below there is a list of the latest developments as seen in the worksheet that comes in the zip with the DEsAndMathematicalFunctions update.

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

I am having trouble printing out a limit cylce on maple 16.  I have the attached file and if anybody could look at it and perhaps help me out it would be greatly appreciated.  The first limit cycle is supposed to look somewhat like the second one.  I'v tried many different things but nothing seems to be working.  an explenation would also be nice too.  if the file does not open correctly also let me know. thank you very much.  

 Math_4710_Hilbert_16.mw

Hi! I was wondering if anyone knows of a way to taylor expand an expression around a function. For example, let's say I have an expression like

expression := diff(f(r), r$2) + exp(-f(r))*(1 - g(r))^2

and I want this expression to be linear order in f and g. If I try

mtaylor(expression, [f(r), g(r)], 2)

I get an error. I don't want to replace f(r) with just f (for example) because then all of the derivative terms vanish, and I want this to also be of linear order. 

1 2 3 Page 1 of 3