sabkebir

5 Reputation

One Badge

0 years, 193 days

MaplePrimes Activity


These are questions asked by sabkebir

    

please where is the problem 

with(DEtools);

eq1 := (D(x))(t) = -y(t);

eq2 := (D(y))(t) = x(t)+2*x(t)^3-signum(z(t));

eq3 := (D(z))(t) = w(t);

eq4 := (D(w))(t) = -z(t)*(1+6*x(t)^2);

sys := eq1, eq2, eq3, eq4;

ic1 := [x(0) = 0, y(0) = 0, z(0) = cos(1), w(0) = sin(1)];

ic2 := [x(0) = 0, y(0) = 0, z(0) = cos(2.5), w(0) = sin(2.5)];

ic := ic1, ic2;

DEplot([sys], [x(t), y(t), z(t), w(t)], t = 0 .. 10, [ic], stepsize = 0.5e-1, scene = [x(t), y(t)], linecolor = [blue, red]);

sol1:=dsolve({sys,x(0)=0,y(0)=0,z(0)=cos(1),w(0)=sin(1)},{x(t),y(t),z(t),w(t)},type=numeric);

T := 10.0 ; N := 100 ; h := T/N;

xk := 0;

for k from 1 to N do

 solk := sol1(k*h);

  xknew := subs(solk,x(t));

 yknew := subs(solk,y(t));

 if xk*xknew<=0 and abs(yknew-6)<0.5 then break fi;

 xk := xknew;

od; sol1(k*h);

temps := proc(alpha,eps)

local sol,solk,T,N,h,k,xk,xknew,yknew,t0,t1,tm,x0,x1,xm;

sol := dsolve({sys,x(0)=0,y(0)=0,z(0)=cos(alpha),w(0)=sin(alpha)},{x(t),y(t),z(t),w(t)},type=numeric);

T := 10.0 ; N := 100 ; h := T/N;

xk := 0;

for k from 1 to N do

 solk := sol(k*h);

  xknew := subs(solk,x(t));

 yknew := subs(solk,y(t));

 if xk*xknew<=0 and abs(yknew-6)<0.5 then break fi;

 xk := xknew;

od; 

t0 := (k-1)*h ; t1 := k*h ;

x0 := subs(sol(t0),x(t)) ; x1 := subs(sol(t1),x(t)) ;

while abs(x0-x1)>eps do

 tm := (t0+t1)/2;

 xm := subs(sol(tm),x(t));

 if xm*x0<0 then x1 := xm; t1:=tm;

            else x0 := xm; t0:=tm;

 fi;

od;

RETURN(t0);

end;

 

dicho := proc(eps)

local a,b,m,sola,solb,solm,ta,tb,tm,ya,yb,ym;

a := 1 ; b := 2.5 ;

sola := dsolve({sys,x(0)=0,y(0)=0,z(0)=cos(a),w(0)=sin(a)},{x(t),y(t),z(t),w(t)},type=numeric);

solb := dsolve({sys,x(0)=0,y(0)=0,z(0)=cos(b),w(0)=sin(b)},{x(t),y(t),z(t),w(t)},type=numeric);

ta := temps(a,eps) ; tb := temps(b,eps) ;

ya := subs(sola(ta),y(t)) ; yb := subs(solb(tb),y(t)) ;

while abs(yb-ya)>eps do

m := evalf((a+b)/2);

solm := dsolve({sys,x(0)=0,y(0)=0,z(0)=cos(m),w(0)=sin(m)},{x(t),y(t),z(t),w(t)},type=numeric);

tm := temps(m,eps) ;

yb := subs(sol(tm),y(t));

 if (ym-6)*(ya-6)<0 then b := m; yb := ym;

            else a := m; ya := ym;

 fi;

od;

RETURN(a);

end;

dicho(0.01);

2.136718750

temps(2.136718750,0.01);

8.737500000

DEplot([sys], [x(t), y(t), z(t), w(t)], t = 0 .. 8.7375, [[x(0)=0,y(0)=0,z(0)=cos(2.136718750),w(0)=sin(2.136718750)]], stepsize = 0.5e-1, scene = [x(t), y(t)], linecolor = [blue]);

 

 

Error, (in dsolve/numeric/process_input) system must be entered as a set/list of expressions/equations

Page 1 of 1