MaplePrimes Questions

This Question involves using dsolve(..., numeric) for an IVP specifed by a procedure. This is based on a Question asked earlier today. In this Question, I have no interest in how to solve this IVP or in why this solution technique fails. In the worksheet below, the odeplot command seems to get stuck in an infinite loop (I am not interested in why that happens), and I press the stop button (in the Standard GUI). Then, instead of the usual Warning, computation interupted message followed by a return to the command prompt, I get an informative message and the plot that has been computed so far. This seems like a very useful feature: to return the results computed so far after an interuption. Furthermore, those results are programmatically accessible. My Question is How is this done? How do you trap the stop button and return the results?


restart:


Sys:= proc(N,t,Y,YP)

local eqs,yp2,yp4;

     YP[1]:= Y[2];

     YP[3]:= Y[4];

     eqs:= [
          yp2*Y[3]+yp4*Y[2]*sin(Y[1]^2)+cos(yp4*Y[3]) = sin(t),
          Y[2]*yp4*sin(Y[1]*Y[3])+5*yp2*Y[4]*cos(Y[1]^2)+t^2*Y[1]*Y[3]^2 = exp(-Y[3]^2)
     ];

     YP[2],YP[4]:= op(subs(fsolve(eqs,{yp2=1,yp4=2}),[yp2,yp4]))

end proc:

res:= dsolve(
     numeric, procedure= Sys, initial= Array([1,1,2,2]),
     number= 4, procvars= [x1(t),diff(x1(t),t),x2(t),diff(x2(t),t)],
     start= 0, maxfun= 0
):

 

plots:-odeplot(res, [t,x1(t)], 0..0.27);
#After 10 seconds or so, (I did)/(you should) hit the stop button.

Warning, cannot evaluate the solution further right of .25109286, cannot downgrade delay storage for problems with delay derivative order > 1, try increasing delaypts

#Note that the command's result is still programmatically accessible:

P:= %;

PLOT(CURVES(Array(1..201, 1..2, {(1, 1) = .0, (1, 2) = 1.0, (2, 1) = 0.135e-2, (2, 2) = 1.001349729199153, (3, 1) = 0.27e-2, (3, 2) = 1.0026989169868508, (4, 1) = 0.405e-2, (4, 2) = 1.004047563645964, (5, 1) = 0.54e-2, (5, 2) = 1.005395669456049, (6, 1) = 0.675e-2, (6, 2) = 1.0067432346933451, (7, 1) = 0.81e-2, (7, 2) = 1.0080902596307788, (8, 1) = 0.945e-2, (8, 2) = 1.0094367445379593, (9, 1) = 0.108e-1, (9, 2) = 1.0107826896811836, (10, 1) = 0.1215e-1, (10, 2) = 1.01212809532343, (11, 1) = 0.135e-1, (11, 2) = 1.0134729617243639, (12, 1) = 0.1485e-1, (12, 2) = 1.0148172891403349, (13, 1) = 0.162e-1, (13, 2) = 1.0161610778243784, (14, 1) = 0.1755e-1, (14, 2) = 1.0175043280262126, (15, 1) = 0.189e-1, (15, 2) = 1.0188470399922427, (16, 1) = 0.2025e-1, (16, 2) = 1.020189213965557, (17, 1) = 0.216e-1, (17, 2) = 1.0215308501859302, (18, 1) = 0.2295e-1, (18, 2) = 1.0228719488898206, (19, 1) = 0.243e-1, (19, 2) = 1.0242125103103719, (20, 1) = 0.2565e-1, (20, 2) = 1.0255525346774133, (21, 1) = 0.27e-1, (21, 2) = 1.0268920222174571, (22, 1) = 0.2835e-1, (22, 2) = 1.0282309731537027, (23, 1) = 0.297e-1, (23, 2) = 1.0295693877060321, (24, 1) = 0.3105e-1, (24, 2) = 1.0309072660910137, (25, 1) = 0.324e-1, (25, 2) = 1.0322446085219004, (26, 1) = 0.3375e-1, (26, 2) = 1.0335814152086296, (27, 1) = 0.351e-1, (27, 2) = 1.0349176863578238, (28, 1) = 0.3645e-1, (28, 2) = 1.0362534221727904, (29, 1) = 0.378e-1, (29, 2) = 1.037588622853522, (30, 1) = 0.3915e-1, (30, 2) = 1.0389232885966946, (31, 1) = 0.405e-1, (31, 2) = 1.0402574195956709, (32, 1) = 0.4185e-1, (32, 2) = 1.041591016040497, (33, 1) = 0.432e-1, (33, 2) = 1.0429240781179057, (34, 1) = 0.4455e-1, (34, 2) = 1.044256606011312, (35, 1) = 0.459e-1, (35, 2) = 1.0455885999008183, (36, 1) = 0.4725e-1, (36, 2) = 1.04692005996321, (37, 1) = 0.486e-1, (37, 2) = 1.0482509863719582, (38, 1) = 0.4995e-1, (38, 2) = 1.0495813792972193, (39, 1) = 0.513e-1, (39, 2) = 1.0509112389058335, (40, 1) = 0.5265e-1, (40, 2) = 1.0522405653613263, (41, 1) = 0.54e-1, (41, 2) = 1.0535693587831985, (42, 1) = 0.5535e-1, (42, 2) = 1.0548976192244952, (43, 1) = 0.567e-1, (43, 2) = 1.0562253468268996, (44, 1) = 0.5805e-1, (44, 2) = 1.0575525417260814, (45, 1) = 0.594e-1, (45, 2) = 1.058879204046671, (46, 1) = 0.6075e-1, (46, 2) = 1.0602053339022601, (47, 1) = 0.621e-1, (47, 2) = 1.0615309313954047, (48, 1) = 0.6345e-1, (48, 2) = 1.0628559966176196, (49, 1) = 0.648e-1, (49, 2) = 1.0641805296493847, (50, 1) = 0.6615e-1, (50, 2) = 1.0655045305601394, (51, 1) = 0.675e-1, (51, 2) = 1.0668279994082868, (52, 1) = 0.6885e-1, (52, 2) = 1.06815093624119, (53, 1) = 0.702e-1, (53, 2) = 1.0694733410951756, (54, 1) = 0.7155e-1, (54, 2) = 1.0707952139955317, (55, 1) = 0.729e-1, (55, 2) = 1.0721165549565084, (56, 1) = 0.7425e-1, (56, 2) = 1.0734373639813168, (57, 1) = 0.756e-1, (57, 2) = 1.074757641062132, (58, 1) = 0.7695e-1, (58, 2) = 1.0760773861800887, (59, 1) = 0.783e-1, (59, 2) = 1.0773965993052852, (60, 1) = 0.7965e-1, (60, 2) = 1.078715280396781, (61, 1) = 0.81e-1, (61, 2) = 1.0800334294025973, (62, 1) = 0.8235e-1, (62, 2) = 1.081351046259718, (63, 1) = 0.837e-1, (63, 2) = 1.082668130894088, (64, 1) = 0.8505e-1, (64, 2) = 1.0839846832206155, (65, 1) = 0.864e-1, (65, 2) = 1.0853007031431687, (66, 1) = 0.8775e-1, (66, 2) = 1.08661619055458, (67, 1) = 0.891e-1, (67, 2) = 1.0879311453366416, (68, 1) = 0.9045e-1, (68, 2) = 1.0892455673601087, (69, 1) = 0.918e-1, (69, 2) = 1.0905594564846983, (70, 1) = 0.9315e-1, (70, 2) = 1.0918728125590897, (71, 1) = 0.945e-1, (71, 2) = 1.0931856354209235, (72, 1) = 0.9585e-1, (72, 2) = 1.0944979248968028, (73, 1) = 0.972e-1, (73, 2) = 1.0958096808022917, (74, 1) = 0.9855e-1, (74, 2) = 1.097120902941917, (75, 1) = 0.999e-1, (75, 2) = 1.098431591109168, (76, 1) = .10125, (76, 2) = 1.0997417450864941, (77, 1) = .1026, (77, 2) = 1.1010513646453082, (78, 1) = .10395, (78, 2) = 1.1023604495459853, (79, 1) = .1053, (79, 2) = 1.1036689995378606, (80, 1) = .10665, (80, 2) = 1.1049770143592332, (81, 1) = .108, (81, 2) = 1.1062844937176912, (82, 1) = .10935, (82, 2) = 1.1075914369810387, (83, 1) = .1107, (83, 2) = 1.108897843678326, (84, 1) = .11205, (84, 2) = 1.1102037134210607, (85, 1) = .1134, (85, 2) = 1.1115090457860155, (86, 1) = .11475, (86, 2) = 1.1128138403152263, (87, 1) = .1161, (87, 2) = 1.1141180965159976, (88, 1) = .11745, (88, 2) = 1.1154218138608973, (89, 1) = .1188, (89, 2) = 1.1167249917877577, (90, 1) = .12015, (90, 2) = 1.118027629699678, (91, 1) = .1215, (91, 2) = 1.1193297269650222, (92, 1) = .12285, (92, 2) = 1.1206312829174188, (93, 1) = .1242, (93, 2) = 1.1219322968557623, (94, 1) = .12555, (94, 2) = 1.123232768044212, (95, 1) = .1269, (95, 2) = 1.1245326957121933, (96, 1) = .12825, (96, 2) = 1.1258320790543948, (97, 1) = .1296, (97, 2) = 1.1271309172307735, (98, 1) = .13095, (98, 2) = 1.1284292093665487, (99, 1) = .1323, (99, 2) = 1.1297269545522062, (100, 1) = .13365, (100, 2) = 1.131024151843497, (101, 1) = .135, (101, 2) = 1.1323208002614376, (102, 1) = .13635, (102, 2) = 1.133616898792309, (103, 1) = .1377, (103, 2) = 1.1349124463876585, (104, 1) = .13905, (104, 2) = 1.1362074419642976, (105, 1) = .1404, (105, 2) = 1.137501884404303, (106, 1) = .14175, (106, 2) = 1.1387957725550182, (107, 1) = .1431, (107, 2) = 1.1400891052290492, (108, 1) = .14445, (108, 2) = 1.1413818812042709, (109, 1) = .1458, (109, 2) = 1.1426740992238196, (110, 1) = .14715, (110, 2) = 1.1439657579960996, (111, 1) = .1485, (111, 2) = 1.1452568561947796, (112, 1) = .14985, (112, 2) = 1.1465473922561644, (113, 1) = .1512, (113, 2) = 1.1478373642224777, (114, 1) = .15255, (114, 2) = 1.14912677047606, (115, 1) = .1539, (115, 2) = 1.1504156093257876, (116, 1) = .15525, (116, 2) = 1.1517038789853584, (117, 1) = .1566, (117, 2) = 1.1529915775732906, (118, 1) = .15795, (118, 2) = 1.1542787031129238, (119, 1) = .1593, (119, 2) = 1.1555652535324183, (120, 1) = .16065, (120, 2) = 1.1568512266647548, (121, 1) = .162, (121, 2) = 1.1581366202477354, (122, 1) = .16335, (122, 2) = 1.1594214319239837, (123, 1) = .1647, (123, 2) = 1.1607056592409424, (124, 1) = .16605, (124, 2) = 1.1619892996508772, (125, 1) = .1674, (125, 2) = 1.1632723505108726, (126, 1) = .16875, (126, 2) = 1.1645548090828357, (127, 1) = .1701, (127, 2) = 1.165836672533493, (128, 1) = .17145, (128, 2) = 1.1671179379343934, (129, 1) = .1728, (129, 2) = 1.1683986022619053, (130, 1) = .17415, (130, 2) = 1.169678662397219, (131, 1) = .1755, (131, 2) = 1.1709581151263448, (132, 1) = .17685, (132, 2) = 1.172236957140115, (133, 1) = .1782, (133, 2) = 1.1735151850341814, (134, 1) = .17955, (134, 2) = 1.174792795282732, (135, 1) = .1809, (135, 2) = 1.1760697835893776, (136, 1) = .18225, (136, 2) = 1.1773461457270373, (137, 1) = .1836, (137, 2) = 1.1786218774884782, (138, 1) = .18495, (138, 2) = 1.179896974422449, (139, 1) = .1863, (139, 2) = 1.181171431833682, (140, 1) = .18765, (140, 2) = 1.182445244782893, (141, 1) = .189, (141, 2) = 1.1837184080867809, (142, 1) = .19035, (142, 2) = 1.1849909163180268, (143, 1) = .1917, (143, 2) = 1.1862627638052967, (144, 1) = .19305, (144, 2) = 1.1875339446332376, (145, 1) = .1944, (145, 2) = 1.1888044526424812, (146, 1) = .19575, (146, 2) = 1.1900742814296414, (147, 1) = .1971, (147, 2) = 1.1913434243473158, (148, 1) = .19845, (148, 2) = 1.1926118745040841, (149, 1) = .1998, (149, 2) = 1.193879624764512, (150, 1) = .20115, (150, 2) = 1.195146667749144, (151, 1) = .2025, (151, 2) = 1.1964129956664247, (152, 1) = .20385, (152, 2) = 1.1976785994686407, (153, 1) = .2052, (153, 2) = 1.1989434702227826, (154, 1) = .20655, (154, 2) = 1.2002075985381981, (155, 1) = .2079, (155, 2) = 1.2014709744148189, (156, 1) = .20925, (156, 2) = 1.2027335872431564, (157, 1) = .2106, (157, 2) = 1.2039954258043046, (158, 1) = .21195, (158, 2) = 1.2052564782699382, (159, 1) = .2133, (159, 2) = 1.2065167322023145, (160, 1) = .21465, (160, 2) = 1.2077761745542712, (161, 1) = .216, (161, 2) = 1.2090347916692288, (162, 1) = .21735, (162, 2) = 1.2102925692811892, (163, 1) = .2187, (163, 2) = 1.2115494925044938, (164, 1) = .22005, (164, 2) = 1.2128055446540236, (165, 1) = .2214, (165, 2) = 1.2140607079057624, (166, 1) = .22275, (166, 2) = 1.2153149635677838, (167, 1) = .2241, (167, 2) = 1.216568291442756, (168, 1) = .22545, (168, 2) = 1.2178206698279472, (169, 1) = .2268, (169, 2) = 1.2190720755152231, (170, 1) = .22815, (170, 2) = 1.2203224837910482, (171, 1) = .2295, (171, 2) = 1.221571868436484, (172, 1) = .23085, (172, 2) = 1.22282020172719, (173, 1) = .2322, (173, 2) = 1.224067453329788, (174, 1) = .23355, (174, 2) = 1.225313589366023, (175, 1) = .2349, (175, 2) = 1.226558573530251, (176, 1) = .23625, (176, 2) = 1.227802365810496, (177, 1) = .2376, (177, 2) = 1.229044922475539, (178, 1) = .23895, (178, 2) = 1.2302861960749185, (179, 1) = .2403, (179, 2) = 1.2315261354389295, (180, 1) = .24165, (180, 2) = 1.2327646837576534, (181, 1) = .243, (181, 2) = 1.2340017760538164, (182, 1) = .24435, (182, 2) = 1.2352373405616506, (183, 1) = .2457, (183, 2) = 1.2364712973589982, (184, 1) = .24705, (184, 2) = 1.2377035562942194, (185, 1) = .2484, (185, 2) = 1.2389340149185948, (186, 1) = .24975, (186, 2) = 1.2401625575137232, (187, 1) = .2511, (187, 2) = undefined, (188, 1) = .25245, (188, 2) = undefined, (189, 1) = .2538, (189, 2) = undefined, (190, 1) = .25515, (190, 2) = undefined, (191, 1) = .2565, (191, 2) = undefined, (192, 1) = .25785, (192, 2) = undefined, (193, 1) = .2592, (193, 2) = undefined, (194, 1) = .26055, (194, 2) = undefined, (195, 1) = .2619, (195, 2) = undefined, (196, 1) = .26325, (196, 2) = undefined, (197, 1) = .2646, (197, 2) = undefined, (198, 1) = .26595, (198, 2) = undefined, (199, 1) = .2673, (199, 2) = undefined, (200, 1) = .26865, (200, 2) = undefined, (201, 1) = .27, (201, 2) = undefined}, datatype = float[8], order = C_order), COLOUR(RGB, .47058824, 0., 0.54901961e-1)), AXESLABELS(t, x1))

``


Download trap_stop_button.mw

I need to graph multiple values of a function. i.e. equal number data sets graphed on the same graph. Can you please help me?

 

 

Hello there..I tried to plot this program n somehow it didnt work.. I dont know how to fix it (I'm a beginner user)..Can anyone help me?? Please..

Thanks a lot

--------------------------------------------------

hmin := .2;

tclose := 150;

topen := 120;

B0 := 0; B1 := 800; dB := (B1-B0)*(1/100);

B := dB*i+B0;

xcoor := [seq(B, i = 0 .. 99)];

ycoor := [seq(fsolve(tclose*ln((1-(1-hmin)*exp((-B+APD)/topen))/hmin) = APD), i = 0 .. 99)];

with(plots);

P := plot(xcoor, ycoor);

display(P)

restart;
odes:=diff(x1(t),t)*diff(x2(t),t$2)*sin(x1(t)*x2(t))+5*diff(x1(t),t$2)*diff(x2(t),t)*cos(x1(t)^2)+t^2*x1(t)*x2(t)^2=exp(-x2(t)^2),diff(x1(t),t$2)*x2(t)+diff(x2(t),t$2)*diff(x1(t),t)*sin(x1(t)^2)+cos(diff(x2(t),t$2)*x2(t))=sin(t);
ics:=x1(0)=1,D(x1)(0)=1,x2(0)=2,D(x2)(0)=2;
subs(diff(x1(t),t$2)=yp2,diff(x2(t),t$2)=yp4,diff(x1(t),t)=Y[2],diff(x2(t),t)=Y[4],x1(t)=Y[1],x2(t)=Y[3],{odes});
p:=proc(N,t,Y,YP)
local eqs,yp2,yp4;
YP[1]=Y[2];
YP[3]=Y[4];
eqs:=[yp2*Y[3]+yp4*Y[2]*sin(Y[1]^2)+cos(yp4*Y[3]) = sin(t), Y[2]*yp4*sin(Y[1]*Y[3])+5*yp2*Y[4]*cos(Y[1]^2)+t^2*Y[1]*Y[3]^2 = exp(-Y[3]^2)];
YP[2],YP[4]:=op(subs(fsolve(eqs,{yp2=1,yp4=2}),[yp2,yp4]));
end proc:
res:=dsolve(numeric,procedure=p,initial=array([1,1,2,2]),number=4,procvars=[x1(t),diff(x1(t),t),x2(t),diff(x2(t),t)],start=0,maxfun=0);
plots:-odeplot(res,[t,x1(t)],0..5,gridlines=true);

It's a long time to wait for the odeplot.

Any advice is appreciated.

How do I iterate starting from a given value. For example, I want to iterate a function F(x) evalf(solve(F(x)=-38)) so that the next value that F(x) uses is the solution to the previous?

Is there a way to convert this FDTD code into Maple

Hy(1 to M)=0;

Ex(1 to M+1)=0;

For t=1 to T,

Ex(1)=exp(-t);

For k=1 to M,

Hy(k)=Hy(k)-(Ex(k+1)-Ex(k));

end

For k=2 to M,

Ex(k)=Ex(k)-(Hy(k)-Hy(k-1));

end

end

Thanks in advance.

Hello, 

I want to solve and plot a multitime recurrence of the Samuelson Hicks Model (http://www.mathem.pub.ro/proc/bsgp-22/K22-gh-A84.pdf).

Feel free to share any tips that could help.

Thank you. 

hello every one

i need to solve this equation

> A1 := Matrix([[a11, a12, a13], [a12, a22, a23], [a13, a23, a33]]);
> A2 := Matrix([[A], [B], [C]]);
> A3 := Matrix([[15], [0], [0]]);
> eq := multiply(A1, A2)=A3;

> solve(eq, {A, B, C});

thank you :)

Hi, I'm tying to solve the ODE by variational iteration method, programme is running, but maple answer does'nt  match to origional answer, plz tell me the mistake?

ICs y(0)=y'(0)=y''(0)=1

VIM_2.mw

Hello everyone, 

In Maple8, I tried to plot this logistic map and an error occured (Error, (in Bifurcation) `plots` does not evaluate to a module).

What is wrong into this code?

Thank you

 

restart: with(plots):Warning, the name changecoords has been redefined

> Bifurcation := proc(initialpoint,xexpr,ra,rb,acc)
> local p1,hr,A,L1,i,j,phi:
> global r,L2:
> hr := unapply(xexpr,x);
> A := Vector(600):
> L1 := Vector(acc*500):
> for j from 1 to acc+1 do
> r := (ra + (j-1)*(rb-ra)/acc):
> A[1] := hr(initialpoint):
> for i from 2 to 500 do
> A[i] := evalf(hr(A[i-1])):
> end do:
> for i from 1 to 400 do
> L1[i+400*(j-1)] := [r,A[i+100]]:
> end do:
> end do:
> L2 := {seq(L1[i], i = 1..acc*400)}:
> p1 := plots:-pointplot(L2, 'symbol' = solidcircle, 'symbolsize' = 8, 'color' = blue):
> unassign('r'):
> return(p1):
> end proc:
> P1:= Bifurcation(1/2,r*x*(1-x),2.5,4,250):
>
Error, (in Bifurcation) `plots` does not evaluate to a module

 

Hello everyone!

 

Do you have any idea to solve and plot a 2-time logistic map:

x(t+ 1_\alpha)= r*x(t)*(1-x(t))  ,t=(t^1,t^2)  ?

 

Thank you

 

 

 

I want to reduce all solution of the equation sin(x)^2=1/4

restart:
sol:=solve(sin(x)^2=1/4, x, AllSolutions);

and

restart:
k:=combine((sin(x))^2);
sol:=solve(k=1/4, x, AllSolutions = true, explicit);
simplify(sol);

How can I reduce solution sol := -1/3*Pi*_B3+1/6*Pi+Pi*_Z3 ?

How can I get x= pi/6+k*pi and x= -pi/6+k*pi?

In Maple 11 we have:

> A := <a,b,c>:
> a := 1:  b := 2: c := 3:
> convert(A, list);
                                   [1, 2, 3]

In Maple 2015 we have:

> A := <a,b,c>:
> a := 1:  b := 2: c := 3:
> convert(A, list);
                                   [a, b, c]

Is that change really intended?

There are no examples for ModuleDeconstruct either on its help page or in the Programming Guide. Of course, I can figure out its basic and primarily intended purpose: to render the module/object in a one-dimensional plaintext printed form, which would be useful for debugging. But I am most interested in this use described in the second sentence of this, the second paragraph of Description at ?ModuleDeconstruct [italics added]:

When the value returned by ModuleDeconstruct is printed, the output could be capable of being parsed to the original module. When used with an object, ModuleDeconstruct can return an unevaluated call to a constructor to achieve this.

That seems very powerful. Is there any example of it being used in Maple library code? in user code? Can anyone here come up with a practical use for this? A Google search turns up nothing.

First 1249 1250 1251 1252 1253 1254 1255 Last Page 1251 of 2434