Rouben Rostamian

MaplePrimes Activity


These are answers submitted by Rouben Rostamian

@dharr has shown how to implement your textbook's approach to solving the PDE.  I just want to remark that a solution may be obtained directy in Maple through the traditional apprach.  Maple's solution appears to be computationally more efficient since it involves an integration over the interval [0,t] as opposed to the textbook's solution which integrates over [0,infinity].

Plotting the result at the default 25x25 grid size takes about 10 minutes on my computer.  On a 10x10 grid it takes about 20 seconds.

restart;

pde := diff(u(x,t),t) = diff(u(x,t),x,x);

diff(u(x, t), t) = diff(diff(u(x, t), x), x)

 

ic := u(x,0) = exp(-x);

u(x, 0) = exp(-x)

 

bc := u(0,t) = cos(t);

u(0, t) = cos(t)

 

pdsol := pdsolve({pde,ic,bc}) assuming x > 0, t > 0;

u(x, t) = (1/2)*((1/4)*x*(Int(-sin(-t+zeta)*exp(-(1/4)*x^2/zeta)*(x^2-6*zeta)/zeta^(7/2), zeta = 0 .. t))+Pi^(1/2)*(erf((1/2)*(2*t+x)/t^(1/2))*exp(x+t)-erf((1/2)*(2*t-x)/t^(1/2))*exp(-x+t)-exp(x+t)+exp(-x+t)))/Pi^(1/2)

 

plot3d(rhs(pdsol), x=1e-3..3, t=0..2*Pi, color="Orange");

 
 

 

Download heat-eq2.mw

 

Here is a general proc for plotting arrowheads. 

restart;

with(plots):


Proc arrowhead()
        Draws an arrowhead at the point p in Cartesian coordinates.
        The arrowhead's reference point is its reentrant vertex.
Arguments:
        p: is the arrowhead's location specified as a list [a, b]  or a vector `<,>`(a, b) .
        angle: is the angle of the arrowhead (rotation) relative to the horizontal axis
        mag: (optional, default=1) is the magnification factor.  With the default mag = 1,
        the distant between the reentrant corner and the arrow tip is 1/10.

        Any additional arguments are assumed to be plotting options and are passed
        to plots:-display.

>

 arrowhead := proc(p::{[realcons,realcons],'Vector'(2,realcons)}, angle, {mag:=1})
        uses plots, plottools;
        polygon([[0,0], [-1/2,-sqrt(3)/2], [2,0], [-1/2,sqrt(3)/2]],
                style=polygon);

        rotate(%, angle);
        scale(%, mag/20, mag/20);
        translate(%, p[1], p[2]);
        display(%, _rest);
end proc:

   

 

Example

arrowhead(<3,4>, Pi/3, mag=10, color=red, scaling=constrained);

 

Example

A, B, C := <-1,0>, <0,0>, <1,0>;

Vector[column](%id = 36893614961805893492), Vector[column](%id = 36893614961805893628), Vector[column](%id = 36893614961805893748)

(1)

display(
        pointplot([A, B, C], symbol=solidcircle, symbolsize=25),
        plottools:-line([-2,0],[2,0]),
        arrowhead((A+B)/2,   Pi, mag=1.2),
        arrowhead((B+C)/2,   0,  mag=1.2),
        arrowhead(A-<1/2,0>, 0,  mag=1.2),
        arrowhead(C+<1/2,0>, Pi, mag=1.2),
scaling=constrained, tickmarks=[0,0], size=[800,100]);
 

   

 

Download arrowhead.mw

The terms "chaos" and "chaotic" have precise technical meanings.  The equations in your textbook may have nonperiodic solutions, but they are not chaotic.  Furthermore, the textbook refers to the u--v diagrams as "phase portraits".  But they are not phase portraits.  There is no meaning to a "phase portrait" for nonautonomous systems.  [Nonautonomous means that the independent variable (eta in your case) appears explicitly on the right-hand sides of the equations.]  With that in mind, here are a few things that you can do with that system.

restart;

with(plots):

de1 := diff(u(t),t) = v(t);
de2 := diff(v(t),t) = - 1/2*u(t) - u(t)^2 + 1/100*cos(t);

diff(u(t), t) = v(t)

diff(v(t), t) = -(1/2)*u(t)-u(t)^2+(1/100)*cos(t)

ic := u(0)=0, v(0)=0;

u(0) = 0, v(0) = 0

dsol := dsolve({de1,de2,ic}, numeric);

proc (x_rkf45) local _res, _dat, _vars, _solnproc, _xout, _ndsol, _pars, _n, _i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; if 1 < nargs then error "invalid input: too many arguments" end if; _EnvDSNumericSaveDigits := Digits; Digits := 15; if _EnvInFsolve = true then _xout := evalf[_EnvDSNumericSaveDigits](x_rkf45) else _xout := evalf(x_rkf45) end if; _dat := Array(1..4, {(1) = proc (_xin) local _xout, _dtbl, _dat, _vmap, _x0, _y0, _val, _dig, _n, _ne, _nd, _nv, _pars, _ini, _par, _i, _j, _k, _src; option `Copyright (c) 2002 by Waterloo Maple Inc. All rights reserved.`; table( [( "complex" ) = false ] ) _xout := _xin; _pars := []; _dtbl := array( 1 .. 4, [( 1 ) = (array( 1 .. 28, [( 1 ) = (datatype = float[8], order = C_order, storage = rectangular), ( 2 ) = (datatype = float[8], order = C_order, storage = rectangular), ( 3 ) = ([0, 0, 0, Array(1..0, 1..2, {}, datatype = float[8], order = C_order)]), ( 4 ) = (Array(1..65, {(1) = 2, (2) = 2, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 1, (8) = 0, (9) = 0, (10) = 0, (11) = 0, (12) = 0, (13) = 0, (14) = 0, (15) = 0, (16) = 0, (17) = 0, (18) = 1, (19) = 30000, (20) = 0, (21) = 0, (22) = 1, (23) = 4, (24) = 0, (25) = 1, (26) = 15, (27) = 1, (28) = 0, (29) = 1, (30) = 3, (31) = 3, (32) = 0, (33) = 1, (34) = 0, (35) = 0, (36) = 0, (37) = 0, (38) = 0, (39) = 0, (40) = 0, (41) = 0, (42) = 0, (43) = 1, (44) = 0, (45) = 0, (46) = 0, (47) = 0, (48) = 0, (49) = 0, (50) = 50, (51) = 1, (52) = 0, (53) = 0, (54) = 0, (55) = 0, (56) = 0, (57) = 0, (58) = 0, (59) = 10000, (60) = 0, (61) = 1000, (62) = 0, (63) = 0, (64) = -1, (65) = 0}, datatype = integer[8])), ( 5 ) = (Array(1..28, {(1) = .0, (2) = 0.10e-5, (3) = .0, (4) = 0.500001e-14, (5) = .0, (6) = .5047658755841546, (7) = .0, (8) = 0.10e-5, (9) = .0, (10) = .0, (11) = .0, (12) = .0, (13) = 1.0, (14) = .0, (15) = .49999999999999, (16) = .0, (17) = 1.0, (18) = 1.0, (19) = .0, (20) = .0, (21) = 1.0, (22) = 1.0, (23) = .0, (24) = .0, (25) = 0.10e-14, (26) = .0, (27) = .0, (28) = .0}, datatype = float[8], order = C_order)), ( 6 ) = (Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order)), ( 7 ) = ([Array(1..4, 1..7, {(1, 1) = .0, (1, 2) = .203125, (1, 3) = .3046875, (1, 4) = .75, (1, 5) = .8125, (1, 6) = .40625, (1, 7) = .8125, (2, 1) = 0.6378173828125e-1, (2, 2) = .0, (2, 3) = .279296875, (2, 4) = .27237892150878906, (2, 5) = -0.9686851501464844e-1, (2, 6) = 0.1956939697265625e-1, (2, 7) = .5381584167480469, (3, 1) = 0.31890869140625e-1, (3, 2) = .0, (3, 3) = -.34375, (3, 4) = -.335235595703125, (3, 5) = .2296142578125, (3, 6) = .41748046875, (3, 7) = 11.480712890625, (4, 1) = 0.9710520505905151e-1, (4, 2) = .0, (4, 3) = .40350341796875, (4, 4) = 0.20297467708587646e-1, (4, 5) = -0.6054282188415527e-2, (4, 6) = -0.4770040512084961e-1, (4, 7) = .77858567237854}, datatype = float[8], order = C_order), Array(1..6, 1..6, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (1, 6) = 1.0, (2, 1) = .25, (2, 2) = .0, (2, 3) = .0, (2, 4) = .0, (2, 5) = .0, (2, 6) = 1.0, (3, 1) = .1875, (3, 2) = .5625, (3, 3) = .0, (3, 4) = .0, (3, 5) = .0, (3, 6) = 2.0, (4, 1) = .23583984375, (4, 2) = -.87890625, (4, 3) = .890625, (4, 4) = .0, (4, 5) = .0, (4, 6) = .2681884765625, (5, 1) = .1272735595703125, (5, 2) = -.5009765625, (5, 3) = .44921875, (5, 4) = -0.128936767578125e-1, (5, 5) = .0, (5, 6) = 0.626220703125e-1, (6, 1) = -0.927734375e-1, (6, 2) = .626220703125, (6, 3) = -.4326171875, (6, 4) = .1418304443359375, (6, 5) = -0.861053466796875e-1, (6, 6) = .3131103515625}, datatype = float[8], order = C_order), Array(1..6, {(1) = .0, (2) = .386, (3) = .21, (4) = .63, (5) = 1.0, (6) = 1.0}, datatype = float[8], order = C_order), Array(1..6, {(1) = .25, (2) = -.1043, (3) = .1035, (4) = -0.362e-1, (5) = .0, (6) = .0}, datatype = float[8], order = C_order), Array(1..6, 1..5, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (2, 1) = 1.544, (2, 2) = .0, (2, 3) = .0, (2, 4) = .0, (2, 5) = .0, (3, 1) = .9466785280815533, (3, 2) = .25570116989825814, (3, 3) = .0, (3, 4) = .0, (3, 5) = .0, (4, 1) = 3.3148251870684886, (4, 2) = 2.896124015972123, (4, 3) = .9986419139977808, (4, 4) = .0, (4, 5) = .0, (5, 1) = 1.2212245092262748, (5, 2) = 6.019134481287752, (5, 3) = 12.537083329320874, (5, 4) = -.687886036105895, (5, 5) = .0, (6, 1) = 1.2212245092262748, (6, 2) = 6.019134481287752, (6, 3) = 12.537083329320874, (6, 4) = -.687886036105895, (6, 5) = 1.0}, datatype = float[8], order = C_order), Array(1..6, 1..5, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (2, 1) = -5.6688, (2, 2) = .0, (2, 3) = .0, (2, 4) = .0, (2, 5) = .0, (3, 1) = -2.4300933568337584, (3, 2) = -.20635991570891224, (3, 3) = .0, (3, 4) = .0, (3, 5) = .0, (4, 1) = -.10735290581452621, (4, 2) = -9.594562251021896, (4, 3) = -20.470286148096154, (4, 4) = .0, (4, 5) = .0, (5, 1) = 7.496443313968615, (5, 2) = -10.246804314641219, (5, 3) = -33.99990352819906, (5, 4) = 11.708908932061595, (5, 5) = .0, (6, 1) = 8.083246795922411, (6, 2) = -7.981132988062785, (6, 3) = -31.52159432874373, (6, 4) = 16.319305431231363, (6, 5) = -6.0588182388340535}, datatype = float[8], order = C_order), Array(1..3, 1..5, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (2, 1) = 10.126235083446911, (2, 2) = -7.487995877607633, (2, 3) = -34.800918615557414, (2, 4) = -7.9927717075687275, (2, 5) = 1.0251377232956207, (3, 1) = -.6762803392806898, (3, 2) = 6.087714651678606, (3, 3) = 16.43084320892463, (3, 4) = 24.767225114183653, (3, 5) = -6.5943891257167815}, datatype = float[8], order = C_order)]), ( 9 ) = ([Array(1..2, {(1) = .1, (2) = .1}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, 1..2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0}, datatype = float[8], order = C_order), Array(1..2, 1..2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, 1..2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0}, datatype = float[8], order = C_order), Array(1..2, 1..6, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (1, 6) = .0, (2, 1) = .0, (2, 2) = .0, (2, 3) = .0, (2, 4) = .0, (2, 5) = .0, (2, 6) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0, (2) = 0}, datatype = integer[8]), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..4, {(1) = .0, (2) = .0, (3) = .0, (4) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = 0, (2) = 0}, datatype = integer[8])]), ( 8 ) = ([Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = 0.1e-1}, datatype = float[8], order = C_order), 0, 0]), ( 11 ) = (Array(1..6, 0..2, {(1, 1) = .0, (1, 2) = .0, (2, 0) = .0, (2, 1) = .0, (2, 2) = .0, (3, 0) = .0, (3, 1) = .0, (3, 2) = .0, (4, 0) = .0, (4, 1) = .0, (4, 2) = .0, (5, 0) = .0, (5, 1) = .0, (5, 2) = .0, (6, 0) = .0, (6, 1) = .0, (6, 2) = .0}, datatype = float[8], order = C_order)), ( 10 ) = ([proc (N, X, Y, YP) option `[Y[1] = u(t), Y[2] = v(t)]`; YP[2] := -(1/2)*Y[1]-Y[1]^2+(1/100)*cos(X); YP[1] := Y[2]; 0 end proc, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), ( 13 ) = (), ( 12 ) = (), ( 15 ) = ("rkf45"), ( 14 ) = ([0, 0]), ( 18 ) = ([]), ( 19 ) = (0), ( 16 ) = ([0, 0, 0, 0, 0, 0, []]), ( 17 ) = ([proc (N, X, Y, YP) option `[Y[1] = u(t), Y[2] = v(t)]`; YP[2] := -(1/2)*Y[1]-Y[1]^2+(1/100)*cos(X); YP[1] := Y[2]; 0 end proc, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), ( 22 ) = (0), ( 23 ) = (0), ( 20 ) = ([]), ( 21 ) = (0), ( 27 ) = (""), ( 26 ) = (Array(1..0, {})), ( 25 ) = (Array(1..0, {})), ( 24 ) = (0), ( 28 ) = (0)  ] ))  ] ); _y0 := Array(0..2, {(1) = 0., (2) = 0.}); _vmap := array( 1 .. 2, [( 1 ) = (1), ( 2 ) = (2)  ] ); _x0 := _dtbl[1][5][5]; _n := _dtbl[1][4][1]; _ne := _dtbl[1][4][3]; _nd := _dtbl[1][4][4]; _nv := _dtbl[1][4][16]; if not type(_xout, 'numeric') then if member(_xout, ["start", "left", "right"]) then if _Env_smart_dsolve_numeric = true or _dtbl[1][4][10] = 1 then if _xout = "left" then if type(_dtbl[2], 'table') then return _dtbl[2][5][1] end if elif _xout = "right" then if type(_dtbl[3], 'table') then return _dtbl[3][5][1] end if end if end if; return _dtbl[1][5][5] elif _xout = "method" then return _dtbl[1][15] elif _xout = "storage" then return evalb(_dtbl[1][4][10] = 1) elif _xout = "leftdata" then if not type(_dtbl[2], 'array') then return NULL else return eval(_dtbl[2]) end if elif _xout = "rightdata" then if not type(_dtbl[3], 'array') then return NULL else return eval(_dtbl[3]) end if elif _xout = "enginedata" then return eval(_dtbl[1]) elif _xout = "enginereset" then _dtbl[2] := evaln(_dtbl[2]); _dtbl[3] := evaln(_dtbl[3]); return NULL elif _xout = "initial" then return procname(_y0[0]) elif _xout = "laxtol" then return _dtbl[`if`(member(_dtbl[4], {2, 3}), _dtbl[4], 1)][5][18] elif _xout = "numfun" then return `if`(member(_dtbl[4], {2, 3}), _dtbl[_dtbl[4]][4][18], 0) elif _xout = "parameters" then return [seq(_y0[_n+_i], _i = 1 .. nops(_pars))] elif _xout = "initial_and_parameters" then return procname(_y0[0]), [seq(_y0[_n+_i], _i = 1 .. nops(_pars))] elif _xout = "last" then if _dtbl[4] <> 2 and _dtbl[4] <> 3 or _x0-_dtbl[_dtbl[4]][5][1] = 0. then error "no information is available on last computed point" else _xout := _dtbl[_dtbl[4]][5][1] end if elif _xout = "function" then if _dtbl[1][4][33]-2. = 0 then return eval(_dtbl[1][10], 1) else return eval(_dtbl[1][10][1], 1) end if elif _xout = "map" then return copy(_vmap) elif type(_xin, `=`) and type(rhs(_xin), 'list') and member(lhs(_xin), {"initial", "parameters", "initial_and_parameters"}) then _ini, _par := [], []; if lhs(_xin) = "initial" then _ini := rhs(_xin) elif lhs(_xin) = "parameters" then _par := rhs(_xin) elif select(type, rhs(_xin), `=`) <> [] then _par, _ini := selectremove(type, rhs(_xin), `=`) elif nops(rhs(_xin)) < nops(_pars)+1 then error "insufficient data for specification of initial and parameters" else _par := rhs(_xin)[-nops(_pars) .. -1]; _ini := rhs(_xin)[1 .. -nops(_pars)-1] end if; _xout := lhs(_xout); _i := false; if _par <> [] then _i := `dsolve/numeric/process_parameters`(_n, _pars, _par, _y0) end if; if _ini <> [] then _i := `dsolve/numeric/process_initial`(_n-_ne, _ini, _y0, _pars, _vmap) or _i end if; if _i then `dsolve/numeric/SC/reinitialize`(_dtbl, _y0, _n, procname, _pars); if _Env_smart_dsolve_numeric = true and type(_y0[0], 'numeric') and _dtbl[1][4][10] <> 1 then procname("right") := _y0[0]; procname("left") := _y0[0] end if end if; if _xout = "initial" then return [_y0[0], seq(_y0[_vmap[_i]], _i = 1 .. _n-_ne)] elif _xout = "parameters" then return [seq(_y0[_n+_i], _i = 1 .. nops(_pars))] else return [_y0[0], seq(_y0[_vmap[_i]], _i = 1 .. _n-_ne)], [seq(_y0[_n+_i], _i = 1 .. nops(_pars))] end if elif _xin = "eventstop" then if _nv = 0 then error "this solution has no events" end if; _i := _dtbl[4]; if _i <> 2 and _i <> 3 then return 0 end if; if _dtbl[_i][4][10] = 1 and assigned(_dtbl[5-_i]) and _dtbl[_i][4][9] < 100 and 100 <= _dtbl[5-_i][4][9] then _i := 5-_i; _dtbl[4] := _i; _j := round(_dtbl[_i][4][17]); return round(_dtbl[_i][3][1][_j, 1]) elif 100 <= _dtbl[_i][4][9] then _j := round(_dtbl[_i][4][17]); return round(_dtbl[_i][3][1][_j, 1]) else return 0 end if elif _xin = "eventstatus" then if _nv = 0 then error "this solution has no events" end if; _i := [selectremove(proc (a) options operator, arrow; _dtbl[1][3][1][a, 7] = 1 end proc, {seq(_j, _j = 1 .. round(_dtbl[1][3][1][_nv+1, 1]))})]; return ':-enabled' = _i[1], ':-disabled' = _i[2] elif _xin = "eventclear" then if _nv = 0 then error "this solution has no events" end if; _i := _dtbl[4]; if _i <> 2 and _i <> 3 then error "no events to clear" end if; if _dtbl[_i][4][10] = 1 and assigned(_dtbl[5-_i]) and _dtbl[_i][4][9] < 100 and 100 < _dtbl[5-_i][4][9] then _dtbl[4] := 5-_i; _i := 5-_i end if; if _dtbl[_i][4][9] < 100 then error "no events to clear" elif _nv < _dtbl[_i][4][9]-100 then error "event error condition cannot be cleared" else _j := _dtbl[_i][4][9]-100; if irem(round(_dtbl[_i][3][1][_j, 4]), 2) = 1 then error "retriggerable events cannot be cleared" end if; _j := round(_dtbl[_i][3][1][_j, 1]); for _k to _nv do if _dtbl[_i][3][1][_k, 1] = _j then if _dtbl[_i][3][1][_k, 2] = 3 then error "range events cannot be cleared" end if; _dtbl[_i][3][1][_k, 8] := _dtbl[_i][3][1][_nv+1, 8] end if end do; _dtbl[_i][4][17] := 0; _dtbl[_i][4][9] := 0; if _dtbl[1][4][10] = 1 then if _i = 2 then try procname(procname("left")) catch:  end try else try procname(procname("right")) catch:  end try end if end if end if; return  elif type(_xin, `=`) and member(lhs(_xin), {"eventdisable", "eventenable"}) then if _nv = 0 then error "this solution has no events" end if; if type(rhs(_xin), {('list')('posint'), ('set')('posint')}) then _i := {op(rhs(_xin))} elif type(rhs(_xin), 'posint') then _i := {rhs(_xin)} else error "event identifiers must be integers in the range 1..%1", round(_dtbl[1][3][1][_nv+1, 1]) end if; if select(proc (a) options operator, arrow; _nv < a end proc, _i) <> {} then error "event identifiers must be integers in the range 1..%1", round(_dtbl[1][3][1][_nv+1, 1]) end if; _k := {}; for _j to _nv do if member(round(_dtbl[1][3][1][_j, 1]), _i) then _k := `union`(_k, {_j}) end if end do; _i := _k; if lhs(_xin) = "eventdisable" then _dtbl[4] := 0; _j := [evalb(assigned(_dtbl[2]) and member(_dtbl[2][4][17], _i)), evalb(assigned(_dtbl[3]) and member(_dtbl[3][4][17], _i))]; for _k in _i do _dtbl[1][3][1][_k, 7] := 0; if assigned(_dtbl[2]) then _dtbl[2][3][1][_k, 7] := 0 end if; if assigned(_dtbl[3]) then _dtbl[3][3][1][_k, 7] := 0 end if end do; if _j[1] then for _k to _nv+1 do if _k <= _nv and not type(_dtbl[2][3][4][_k, 1], 'undefined') then userinfo(3, {'events', 'eventreset'}, `reinit #2, event code `, _k, ` to defined init `, _dtbl[2][3][4][_k, 1]); _dtbl[2][3][1][_k, 8] := _dtbl[2][3][4][_k, 1] elif _dtbl[2][3][1][_k, 2] = 0 and irem(iquo(round(_dtbl[2][3][1][_k, 4]), 32), 2) = 1 then userinfo(3, {'events', 'eventreset'}, `reinit #2, event code `, _k, ` to rate hysteresis init `, _dtbl[2][5][24]); _dtbl[2][3][1][_k, 8] := _dtbl[2][5][24] elif _dtbl[2][3][1][_k, 2] = 0 and irem(iquo(round(_dtbl[2][3][1][_k, 4]), 2), 2) = 0 then userinfo(3, {'events', 'eventreset'}, `reinit #2, event code `, _k, ` to initial init `, _x0); _dtbl[2][3][1][_k, 8] := _x0 else userinfo(3, {'events', 'eventreset'}, `reinit #2, event code `, _k, ` to fireinitial init `, _x0-1); _dtbl[2][3][1][_k, 8] := _x0-1 end if end do; _dtbl[2][4][17] := 0; _dtbl[2][4][9] := 0; if _dtbl[1][4][10] = 1 then procname(procname("left")) end if end if; if _j[2] then for _k to _nv+1 do if _k <= _nv and not type(_dtbl[3][3][4][_k, 2], 'undefined') then userinfo(3, {'events', 'eventreset'}, `reinit #3, event code `, _k, ` to defined init `, _dtbl[3][3][4][_k, 2]); _dtbl[3][3][1][_k, 8] := _dtbl[3][3][4][_k, 2] elif _dtbl[3][3][1][_k, 2] = 0 and irem(iquo(round(_dtbl[3][3][1][_k, 4]), 32), 2) = 1 then userinfo(3, {'events', 'eventreset'}, `reinit #3, event code `, _k, ` to rate hysteresis init `, _dtbl[3][5][24]); _dtbl[3][3][1][_k, 8] := _dtbl[3][5][24] elif _dtbl[3][3][1][_k, 2] = 0 and irem(iquo(round(_dtbl[3][3][1][_k, 4]), 2), 2) = 0 then userinfo(3, {'events', 'eventreset'}, `reinit #3, event code `, _k, ` to initial init `, _x0); _dtbl[3][3][1][_k, 8] := _x0 else userinfo(3, {'events', 'eventreset'}, `reinit #3, event code `, _k, ` to fireinitial init `, _x0+1); _dtbl[3][3][1][_k, 8] := _x0+1 end if end do; _dtbl[3][4][17] := 0; _dtbl[3][4][9] := 0; if _dtbl[1][4][10] = 1 then procname(procname("right")) end if end if else for _k in _i do _dtbl[1][3][1][_k, 7] := 1 end do; _dtbl[2] := evaln(_dtbl[2]); _dtbl[3] := evaln(_dtbl[3]); _dtbl[4] := 0; if _dtbl[1][4][10] = 1 then if _x0 <= procname("right") then try procname(procname("right")) catch:  end try end if; if procname("left") <= _x0 then try procname(procname("left")) catch:  end try end if end if end if; return  elif type(_xin, `=`) and lhs(_xin) = "eventfired" then if not type(rhs(_xin), 'list') then error "'eventfired' must be specified as a list" end if; if _nv = 0 then error "this solution has no events" end if; if _dtbl[4] <> 2 and _dtbl[4] <> 3 then error "'direction' must be set prior to calling/setting 'eventfired'" end if; _i := _dtbl[4]; _val := NULL; if not assigned(_EnvEventRetriggerWarned) then _EnvEventRetriggerWarned := false end if; for _k in rhs(_xin) do if type(_k, 'integer') then _src := _k elif type(_k, 'integer' = 'anything') and type(evalf(rhs(_k)), 'numeric') then _k := lhs(_k) = evalf[max(Digits, 18)](rhs(_k)); _src := lhs(_k) else error "'eventfired' entry is not valid: %1", _k end if; if _src < 1 or round(_dtbl[1][3][1][_nv+1, 1]) < _src then error "event identifiers must be integers in the range 1..%1", round(_dtbl[1][3][1][_nv+1, 1]) end if; _src := {seq(`if`(_dtbl[1][3][1][_j, 1]-_src = 0., _j, NULL), _j = 1 .. _nv)}; if nops(_src) <> 1 then error "'eventfired' can only be set/queried for root-finding events and time/interval events" end if; _src := _src[1]; if _dtbl[1][3][1][_src, 2] <> 0. and _dtbl[1][3][1][_src, 2]-2. <> 0. then error "'eventfired' can only be set/queried for root-finding events and time/interval events" elif irem(round(_dtbl[1][3][1][_src, 4]), 2) = 1 then if _EnvEventRetriggerWarned = false then WARNING(`'eventfired' has no effect on events that retrigger`) end if; _EnvEventRetriggerWarned := true end if; if _dtbl[_i][3][1][_src, 2] = 0 and irem(iquo(round(_dtbl[_i][3][1][_src, 4]), 32), 2) = 1 then _val := _val, undefined elif type(_dtbl[_i][3][4][_src, _i-1], 'undefined') or _i = 2 and _dtbl[2][3][1][_src, 8] < _dtbl[2][3][4][_src, 1] or _i = 3 and _dtbl[3][3][4][_src, 2] < _dtbl[3][3][1][_src, 8] then _val := _val, _dtbl[_i][3][1][_src, 8] else _val := _val, _dtbl[_i][3][4][_src, _i-1] end if; if type(_k, `=`) then if _dtbl[_i][3][1][_src, 2] = 0 and irem(iquo(round(_dtbl[_i][3][1][_src, 4]), 32), 2) = 1 then error "cannot set event code for a rate hysteresis event" end if; userinfo(3, {'events', 'eventreset'}, `manual set event code `, _src, ` to value `, rhs(_k)); _dtbl[_i][3][1][_src, 8] := rhs(_k); _dtbl[_i][3][4][_src, _i-1] := rhs(_k) end if end do; return [_val] elif type(_xin, `=`) and lhs(_xin) = "direction" then if not member(rhs(_xin), {-1, 1, ':-left', ':-right'}) then error "'direction' must be specified as either '1' or 'right' (positive) or '-1' or 'left' (negative)" end if; _src := `if`(_dtbl[4] = 2, -1, `if`(_dtbl[4] = 3, 1, undefined)); _i := `if`(member(rhs(_xin), {1, ':-right'}), 3, 2); _dtbl[4] := _i; _dtbl[_i] := `dsolve/numeric/SC/IVPdcopy`(_dtbl[1], `if`(assigned(_dtbl[_i]), _dtbl[_i], NULL)); if 0 < _nv then for _j to _nv+1 do if _j <= _nv and not type(_dtbl[_i][3][4][_j, _i-1], 'undefined') then userinfo(3, {'events', 'eventreset'}, `reinit #4, event code `, _j, ` to defined init `, _dtbl[_i][3][4][_j, _i-1]); _dtbl[_i][3][1][_j, 8] := _dtbl[_i][3][4][_j, _i-1] elif _dtbl[_i][3][1][_j, 2] = 0 and irem(iquo(round(_dtbl[_i][3][1][_j, 4]), 32), 2) = 1 then userinfo(3, {'events', 'eventreset'}, `reinit #4, event code `, _j, ` to rate hysteresis init `, _dtbl[_i][5][24]); _dtbl[_i][3][1][_j, 8] := _dtbl[_i][5][24] elif _dtbl[_i][3][1][_j, 2] = 0 and irem(iquo(round(_dtbl[_i][3][1][_j, 4]), 2), 2) = 0 then userinfo(3, {'events', 'eventreset'}, `reinit #4, event code `, _j, ` to initial init `, _x0); _dtbl[_i][3][1][_j, 8] := _x0 else userinfo(3, {'events', 'eventreset'}, `reinit #4, event code `, _j, ` to fireinitial init `, _x0-2*_i+5.0); _dtbl[_i][3][1][_j, 8] := _x0-2*_i+5.0 end if end do end if; return _src elif _xin = "eventcount" then if _dtbl[1][3][1] = 0 or _dtbl[4] <> 2 and _dtbl[4] <> 3 then return 0 else return round(_dtbl[_dtbl[4]][3][1][_nv+1, 12]) end if elif type(_xin, `=`) and lhs(_xin) = "setdatacallback" then if not type(rhs(_xin), 'nonegint') then error "data callback must be a nonnegative integer (address)" end if; _dtbl[1][28] := rhs(_xin) else return "procname" end if end if; if _xout = _x0 then return [_x0, seq(evalf(_dtbl[1][6][_vmap[_i]]), _i = 1 .. _n-_ne)] end if; _i := `if`(_x0 <= _xout, 3, 2); if _xin = "last" and 0 < _dtbl[_i][4][9] and _dtbl[_i][4][9] < 100 then _dat := eval(_dtbl[_i], 2); _j := _dat[4][20]; return [_dat[11][_j, 0], seq(_dat[11][_j, _vmap[_i]], _i = 1 .. _n-_ne-_nd), seq(_dat[8][1][_vmap[_i]], _i = _n-_ne-_nd+1 .. _n-_ne)] end if; if not type(_dtbl[_i], 'array') then _dtbl[_i] := `dsolve/numeric/SC/IVPdcopy`(_dtbl[1], `if`(assigned(_dtbl[_i]), _dtbl[_i], NULL)); if 0 < _nv then for _j to _nv+1 do if _j <= _nv and not type(_dtbl[_i][3][4][_j, _i-1], 'undefined') then userinfo(3, {'events', 'eventreset'}, `reinit #5, event code `, _j, ` to defined init `, _dtbl[_i][3][4][_j, _i-1]); _dtbl[_i][3][1][_j, 8] := _dtbl[_i][3][4][_j, _i-1] elif _dtbl[_i][3][1][_j, 2] = 0 and irem(iquo(round(_dtbl[_i][3][1][_j, 4]), 32), 2) = 1 then userinfo(3, {'events', 'eventreset'}, `reinit #5, event code `, _j, ` to rate hysteresis init `, _dtbl[_i][5][24]); _dtbl[_i][3][1][_j, 8] := _dtbl[_i][5][24] elif _dtbl[_i][3][1][_j, 2] = 0 and irem(iquo(round(_dtbl[_i][3][1][_j, 4]), 2), 2) = 0 then userinfo(3, {'events', 'eventreset'}, `reinit #5, event code `, _j, ` to initial init `, _x0); _dtbl[_i][3][1][_j, 8] := _x0 else userinfo(3, {'events', 'eventreset'}, `reinit #5, event code `, _j, ` to fireinitial init `, _x0-2*_i+5.0); _dtbl[_i][3][1][_j, 8] := _x0-2*_i+5.0 end if end do end if end if; if _xin <> "last" then if 0 < 0 then if `dsolve/numeric/checkglobals`(op(_dtbl[1][14]), _pars, _n, _y0) then `dsolve/numeric/SC/reinitialize`(_dtbl, _y0, _n, procname, _pars, _i) end if end if; if _dtbl[1][4][7] = 0 then error "parameters must be initialized before solution can be computed" end if end if; _dat := eval(_dtbl[_i], 2); _dtbl[4] := _i; try _src := `dsolve/numeric/SC/IVPrun`(_dat, _xout) catch: userinfo(2, `dsolve/debug`, print(`Exception in solnproc:`, [lastexception][2 .. -1])); error  end try; if _dat[17] <> _dtbl[1][17] then _dtbl[1][17] := _dat[17]; _dtbl[1][10] := _dat[10] end if; if _src = 0 and 100 < _dat[4][9] then _val := _dat[3][1][_nv+1, 8] else _val := _dat[11][_dat[4][20], 0] end if; if _src <> 0 or _dat[4][9] <= 0 then _dtbl[1][5][1] := _xout else _dtbl[1][5][1] := _val end if; if _i = 3 and _val < _xout then Rounding := -infinity; if _dat[4][9] = 1 then error "cannot evaluate the solution further right of %1, probably a singularity", evalf[8](_val) elif _dat[4][9] = 2 then error "cannot evaluate the solution further right of %1, maxfun limit exceeded (see ?dsolve,maxfun for details)", evalf[8](_val) elif _dat[4][9] = 3 then if _dat[4][25] = 3 then error "cannot evaluate the solution past the initial point, problem may be initially singular or improperly set up" else error "cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up" end if elif _dat[4][9] = 4 then error "cannot evaluate the solution further right of %1, accuracy goal cannot be achieved with specified 'minstep'", evalf[8](_val) elif _dat[4][9] = 5 then error "cannot evaluate the solution further right of %1, too many step failures, tolerances may be too loose for problem", evalf[8](_val) elif _dat[4][9] = 6 then error "cannot evaluate the solution further right of %1, cannot downgrade delay storage for problems with delay derivative order > 1, try increasing delaypts", evalf[8](_val) elif _dat[4][9] = 10 then error "cannot evaluate the solution further right of %1, interrupt requested", evalf[8](_val) elif 100 < _dat[4][9] then if _dat[4][9]-100 = _nv+1 then error "constraint projection failure on event at t=%1", evalf[8](_val) elif _dat[4][9]-100 = _nv+2 then error "index-1 and derivative evaluation failure on event at t=%1", evalf[8](_val) elif _dat[4][9]-100 = _nv+3 then error "maximum number of event iterations reached (%1) at t=%2", round(_dat[3][1][_nv+1, 3]), evalf[8](_val) else if _Env_dsolve_nowarnstop <> true then `dsolve/numeric/warning`(StringTools:-FormatMessage("cannot evaluate the solution further right of %1, event #%2 triggered a halt", evalf[8](_val), round(_dat[3][1][_dat[4][9]-100, 1]))) end if; Rounding := 'nearest'; _xout := _val end if else error "cannot evaluate the solution further right of %1", evalf[8](_val) end if elif _i = 2 and _xout < _val then Rounding := infinity; if _dat[4][9] = 1 then error "cannot evaluate the solution further left of %1, probably a singularity", evalf[8](_val) elif _dat[4][9] = 2 then error "cannot evaluate the solution further left of %1, maxfun limit exceeded (see ?dsolve,maxfun for details)", evalf[8](_val) elif _dat[4][9] = 3 then if _dat[4][25] = 3 then error "cannot evaluate the solution past the initial point, problem may be initially singular or improperly set up" else error "cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up" end if elif _dat[4][9] = 4 then error "cannot evaluate the solution further left of %1, accuracy goal cannot be achieved with specified 'minstep'", evalf[8](_val) elif _dat[4][9] = 5 then error "cannot evaluate the solution further left of %1, too many step failures, tolerances may be too loose for problem", evalf[8](_val) elif _dat[4][9] = 6 then error "cannot evaluate the solution further left of %1, cannot downgrade delay storage for problems with delay derivative order > 1, try increasing delaypts", evalf[8](_val) elif _dat[4][9] = 10 then error "cannot evaluate the solution further right of %1, interrupt requested", evalf[8](_val) elif 100 < _dat[4][9] then if _dat[4][9]-100 = _nv+1 then error "constraint projection failure on event at t=%1", evalf[8](_val) elif _dat[4][9]-100 = _nv+2 then error "index-1 and derivative evaluation failure on event at t=%1", evalf[8](_val) elif _dat[4][9]-100 = _nv+3 then error "maximum number of event iterations reached (%1) at t=%2", round(_dat[3][1][_nv+1, 3]), evalf[8](_val) else if _Env_dsolve_nowarnstop <> true then `dsolve/numeric/warning`(StringTools:-FormatMessage("cannot evaluate the solution further left of %1, event #%2 triggered a halt", evalf[8](_val), round(_dat[3][1][_dat[4][9]-100, 1]))) end if; Rounding := 'nearest'; _xout := _val end if else error "cannot evaluate the solution further left of %1", evalf[8](_val) end if end if; if _EnvInFsolve = true then _dig := _dat[4][26]; if type(_EnvDSNumericSaveDigits, 'posint') then _dat[4][26] := _EnvDSNumericSaveDigits else _dat[4][26] := Digits end if; _Env_dsolve_SC_native := true; if _dat[4][25] = 1 then _i := 1; _dat[4][25] := 2 else _i := _dat[4][25] end if; _val := `dsolve/numeric/SC/IVPval`(_dat, _xout, _src); _dat[4][25] := _i; _dat[4][26] := _dig; [_xout, seq(_val[_vmap[_i]], _i = 1 .. _n-_ne)] else Digits := _dat[4][26]; _val := `dsolve/numeric/SC/IVPval`(eval(_dat, 2), _xout, _src); [_xout, seq(_val[_vmap[_i]], _i = 1 .. _n-_ne)] end if end proc, (2) = Array(0..0, {}), (3) = [t, u(t), v(t)], (4) = []}); _vars := _dat[3]; _pars := map(lhs, _dat[4]); _n := nops(_vars)-1; _solnproc := _dat[1]; if not type(_xout, 'numeric') then if member(x_rkf45, ["start", 'start', "method", 'method', "left", 'left', "right", 'right', "leftdata", "rightdata", "enginedata", "eventstop", 'eventstop', "eventclear", 'eventclear', "eventstatus", 'eventstatus', "eventcount", 'eventcount', "laxtol", 'laxtol', "numfun", 'numfun', NULL]) then _res := _solnproc(convert(x_rkf45, 'string')); if 1 < nops([_res]) then return _res elif type(_res, 'array') then return eval(_res, 1) elif _res <> "procname" then return _res end if elif member(x_rkf45, ["last", 'last', "initial", 'initial', "parameters", 'parameters', "initial_and_parameters", 'initial_and_parameters', NULL]) then _xout := convert(x_rkf45, 'string'); _res := _solnproc(_xout); if _xout = "parameters" then return [seq(_pars[_i] = _res[_i], _i = 1 .. nops(_pars))] elif _xout = "initial_and_parameters" then return [seq(_vars[_i+1] = [_res][1][_i+1], _i = 0 .. _n), seq(_pars[_i] = [_res][2][_i], _i = 1 .. nops(_pars))] else return [seq(_vars[_i+1] = _res[_i+1], _i = 0 .. _n)] end if elif type(_xout, `=`) and member(lhs(_xout), ["initial", 'initial', "parameters", 'parameters', "initial_and_parameters", 'initial_and_parameters', NULL]) then _xout := convert(lhs(x_rkf45), 'string') = rhs(x_rkf45); if type(rhs(_xout), 'list') then _res := _solnproc(_xout) else error "initial and/or parameter values must be specified in a list" end if; if lhs(_xout) = "initial" then return [seq(_vars[_i+1] = _res[_i+1], _i = 0 .. _n)] elif lhs(_xout) = "parameters" then return [seq(_pars[_i] = _res[_i], _i = 1 .. nops(_pars))] else return [seq(_vars[_i+1] = [_res][1][_i+1], _i = 0 .. _n), seq(_pars[_i] = [_res][2][_i], _i = 1 .. nops(_pars))] end if elif type(_xout, `=`) and member(lhs(_xout), ["eventdisable", 'eventdisable', "eventenable", 'eventenable', "eventfired", 'eventfired', "direction", 'direction', NULL]) then return _solnproc(convert(lhs(x_rkf45), 'string') = rhs(x_rkf45)) elif _xout = "solnprocedure" then return eval(_solnproc) elif _xout = "sysvars" then return _vars end if; if procname <> unknown then return ('procname')(x_rkf45) else _ndsol := 1; _ndsol := _ndsol; _ndsol := pointto(_dat[2][0]); return ('_ndsol')(x_rkf45) end if end if; try _res := _solnproc(_xout); [seq(_vars[_i+1] = _res[_i+1], _i = 0 .. _n)] catch: error  end try end proc

odeplot(dsol, [[t, u(t)], [t,v(t)]], t=0..12*Pi,
        color=["Red", "Green"], size=[600,300], thickness=2);

odeplot(dsol, [u(t),v(t)], t=0..12*Pi, color="Blue");

odeplot(dsol, [t, u(t), v(t)], t=0..12*Pi, color="Blue", axes=framed);

odeplot(dsol, [u(t),v(t)], t=0..12*Pi, color="Blue", frames=100);

 

Download mw.mw

 

Why Mathematica or Matlab?  This is a Maple forum, so you will get a Maple answer.

The easiest way to plot the system's phase portrait—essentially just two lines of Maple code—is to observe that your system of differential equations is conservative and its potential is

P := 1/2*F1*u^2 + 1/3*F2*u^3 - 1/2*v^2;

The system's orbits are the level curves of P, so here is what we get:

subs(F1=1, F2=-1, P):
plots:-contourplot(%, u=-1.5..2, v=-1.5..1.5, scaling=constrained,
    colorscheme="DivergeRainbow", contours=[seq](x, x=-0.4..0.4,0.1));

In a reply to your previous question, I explained how to upload your worksheet.  Don't be shy.  Uploading your worksheet will help others to help you.  Anyway, here is a solution, shot in the dark.  

Give a name to your animation, as in 

QQ := animate(...);

Then do:

with(DocumentTools): with(DocumentTools:-Layout):
InsertContent(Worksheet(Group(Textfield(InlinePlot(QQ, scale=2.5)))));

Change the 2.5 to an appropirate scale factor.

Here I do Exercise #7.  You do the rest.

restart;

with(LinearAlgebra):

with(DEtools):

A := < -1, 1; 0, -1>;

Matrix(2, 2, {(1, 1) = -1, (1, 2) = 1, (2, 1) = 0, (2, 2) = -1})

det := Determinant(A);    # the determinant
tra := Trace(A);          # the trace
dsc := tra^2 - 4*det;     # the discriminant (Delta)
Eigenvalues(A);           # the eigenvalues

det := 1

tra := -2

dsc := 0

Vector[column](%id = 36893613368677088300)

We see that the discriminant is zero, A is not diagonal, eigenvalues are negative.

Referring to the table shown in your question, we see that the equilibrium at (0,0)

is a Stable Improper Node.  Here is how we sketch it.

diff(<x(t),y(t)>, t) =~ A . <x(t),y(t)>;
sys := {seq}(%);

Vector(2, {(1) = diff(x(t), t) = -x(t)+y(t), (2) = diff(y(t), t) = -y(t)})

{diff(x(t), t) = -x(t)+y(t), diff(y(t), t) = -y(t)}

ic := [x(0)=1,y(0)=1], [x(0)=-1,y(0)=1], [x(0)=1,y(0)=-1], [x(0)=-1,y(0)=-1];

[x(0) = 1, y(0) = 1], [x(0) = -1, y(0) = 1], [x(0) = 1, y(0) = -1], [x(0) = -1, y(0) = -1]

DEplot(sys, [x(t),y(t)], t=0..8, [ic], axes=normal, tickmarks=[0,0], labels=["",""], dirfield=[10,10], arrows=comet, color="DarkCyan");

Download mw.mw

 

 

 

This is a linear system, therefore (0,0) is an equilibrium point.

To plot a phase portrait, do:

DEplot(sys, [x(t),y(t)], t=0..1, x=-4..4, y=-4..4, arrows=comet, color="DarkCyan",
    dirfield=[15,15], size=[800,600], axes=boxed);

I much prefer quaternions over Euler angles for expressing rotation of rigid bodies.  Euler angles work well when the rigid body's orientation is limited to rather narrow range (think of a spinning top).  Quaternions work well when a rigid body has the possibility of turning in every which way (think of a satellite in space).

Stylistically, each of the three Euler angles  serves a different purpose.  In contrast, the components of a quaternion participate symmetrically in the equations of dynamics, resulting in a more pleasant treatment.

That said, Euler angles tend to result in a more compact form of the differential equations of motion.  These are preferable for "calculations by hand".  The differential equations of motion obtained via quaternions are generally more complex, and are better suited for numerical calculations on a computer.

Here is a mini-lession on quaternion algebra

A quaternion is a pair [a, u], where a is a scalar and u is a 3D vector.  The algebra of quaternions prescribes the algebraic properties of such a pair.  Thus, the sum of the quaternions [a,u] and [b,v] is defined in the expected way as [a+b, u+v].  The scalar product  of a number c and a quaternion [a,u] is [ca, cu].

The interesting new concepts are those of the conjugate [a,u]* of a quaternion and the product [a,u] o [b,v] of two quaternions, defined as

[a, u]* = [a, -u]
[a, u] o [b,v] = [ab - u.v, av + bu + uxv]

where u.v and uxv are the dot product and the cross product of the vectors u and v.  Note that the quaternion product is not commutative because uxv = - vxu.

That's pretty much all of the quaternion algebra needed for expressing rotations in 3D.

To see that, let n be an arbitrary unit vector in 3D and phi an arbitrary angle.  Define the rotation quaternion

q = [ cos(phi/2), n sin(phi/2)]

Let P be an arbitrary point P in space and let r be its position vector, that is, the vector that stretches from the origin to P.  Then form the quaternion product

[a,v] = q o [0,r] o q*

Expanding the product according to the quaternion rules laid out above, we find that a = 0, that is

[0,v] = q o [0,r] o q*

Furthermore, an elementary geometric analysis shows that  the vector v is the result of rotating the vector r about the vector n by the angle phi.

Thus, to rotate a rigid body about a vector n by angle phi, apply the formula obtained above to all of its points. That expresses the rigid body's rotation in a natural way; there are no Euler angles!

End of the lesson

To connect this to what you have shown in your post, MapleSim expresses the rotation quaternion q as a list of four numbers, q0 for the scalar part, and q1, q2, q3 for the components of the vector part.  Since n is a unit vector in the rotation quaternion, we have q0^2 + q1^2 + q2^2 + q3^2 = 1.  That's the "algebraic constraint" seen in MapleSim's message.  There is some confusion there about the rest of the message.  There are 7 (not 8) generalized coordinates, x, y, z, q0, q1, q2, q3.  The duplicate q0 at the end of the vector vQ should not be there, unless MapleSim has some good reason for expressing vQ that way.

 

I can only guess what you are asking.  Consider formulating the question in your native language and having Google Translate change it to English.

Here is my best attempt to make something meaningful from what you have written.

The function f given in your post has infinitely many roots.  The roots are grouped in clusters.  You wish to find the first cluster which contains 50 or more roots.

It turns out that the first cluster contains 122 roots, so it meets your requirement.

To see that, we change the variable from x to s by setting x^3 = s that is, x = s^(1/3).  Then the roots (in s) within each cluster will be more or less uniformly distributed, making it easier for fsolve() to find them.  Here are the details.

restart;

f := x -> 0.995-cos(0.25*x)*sin(x^3);

proc (x) options operator, arrow; .995-cos(.25*x)*sin(x^3) end proc

Change from x to s through x^3 = s:

g := 0.995-cos(0.25*surd(s,3))*sin(s);

.995-cos(.25*surd(s, 3))*sin(s)

Here is what the graph of g looks like:

plot(g(s), s=0..2.4e3);

The envelope visible in the diagram is the graph of the function cos(0.25*surd(s,3)):

plot(cos(0.25*surd(s,3)), s=0..2.6e3);

The roots of g occur where the latter graph drops below the -0.995 level.  Let's see where that happens:

fsolve(cos(0.25*surd(s,3)) = -0.995, s=1000..2500, maxsols=4);

1800.799068, 2180.078129

This says that the first root cluster occurs in the interval 1800 < s < 2181.
Since the sin(s) factor oscillates with a period of 2*Pi, we can expect approximately
( 2181 - 1800)/Pi roots in that interval.  That value is

( 2181 - 1800) / (1.0*Pi);

121.2760666

Let's check:

s_roots := [fsolve(g(s), s=1800..2181, maxsols=130)];

[1801.693347, 1801.713539, 1807.958436, 1808.014816, 1814.231592, 1814.308027, 1820.507168, 1820.598817, 1826.784092, 1826.888260, 1833.061919, 1833.176800, 1839.340413, 1839.464672, 1845.619431, 1845.752020, 1851.898879, 1852.038939, 1858.178689, 1858.325496, 1864.458811, 1864.611739, 1870.739210, 1870.897708, 1877.019854, 1877.183430, 1883.300722, 1883.468929, 1889.581793, 1889.754224, 1895.863053, 1896.039332, 1902.144487, 1902.324264, 1908.426086, 1908.609032, 1914.707840, 1914.893645, 1920.989740, 1921.178111, 1927.271781, 1927.462438, 1933.553956, 1933.746630, 1939.836260, 1940.030693, 1946.118689, 1946.314631, 1952.401239, 1952.598447, 1958.683908, 1958.882146, 1964.966692, 1965.165729, 1971.249590, 1971.449198, 1977.532599, 1977.732555, 1983.815720, 1984.015802, 1990.098949, 1990.298940, 1996.382288, 1996.581968, 2002.665736, 2002.864887, 2008.949293, 2009.147698, 2015.232959, 2015.430398, 2021.516737, 2021.712988, 2027.800626, 2027.995466, 2034.084629, 2034.277830, 2040.368748, 2040.560079, 2046.652986, 2046.842208, 2052.937347, 2053.124215, 2059.221833, 2059.406096, 2065.506451, 2065.687845, 2071.791206, 2071.969458, 2078.076104, 2078.250927, 2084.361154, 2084.532244, 2090.646365, 2090.813401, 2096.931748, 2097.094385, 2103.217318, 2103.375183, 2109.503091, 2109.655778, 2115.789087, 2115.936149, 2122.075333, 2122.216270, 2128.361863, 2128.496108, 2134.648720, 2134.775619, 2140.935964, 2141.054742, 2147.223680, 2147.333393, 2153.511997, 2153.611444, 2159.801124, 2159.888685, 2166.091451, 2166.164725, 2172.383903, 2172.438641, 2178.682741, 2178.706170]

nops(s_roots);

122

That agrees with our estimate.  The roots of f(x) are the cube roots of these roots:

x_roots := surd~(s_roots, 3);

[12.16821734, 12.16826280, 12.18230534, 12.18243197, 12.19637891, 12.19655019, 12.21042549, 12.21063039, 12.22444283, 12.22467518, 12.23843010, 12.23868576, 12.25238696, 12.25266286, 12.26631325, 12.26660698, 12.28020894, 12.28051852, 12.29407406, 12.29439782, 12.30790866, 12.30824516, 12.32171283, 12.32206081, 12.33548668, 12.33584501, 12.34923033, 12.34959798, 12.36294390, 12.36331994, 12.37662752, 12.37701111, 12.39028134, 12.39067167, 12.40390548, 12.40430182, 12.41750009, 12.41790175, 12.43106532, 12.43147163, 12.44460131, 12.44501166, 12.45810820, 12.45852200, 12.47158615, 12.47200282, 12.48503530, 12.48545429, 12.49845579, 12.49887659, 12.51184777, 12.51226986, 12.52521139, 12.52563428, 12.53854680, 12.53897000, 12.55185414, 12.55227718, 12.56513356, 12.56555597, 12.57838519, 12.57880652, 12.59160919, 12.59202899, 12.60480571, 12.60522351, 12.61797488, 12.61839025, 12.63111684, 12.63152933, 12.64423175, 12.64464091, 12.65731974, 12.65772511, 12.67038095, 12.67078209, 12.68341553, 12.68381197, 12.69642362, 12.69681489, 12.70940537, 12.70979098, 12.72236091, 12.72274037, 12.73529038, 12.73566318, 12.74819394, 12.74855954, 12.76107172, 12.76142956, 12.77392387, 12.77427337, 12.78675054, 12.78709107, 12.79955188, 12.79988278, 12.81232804, 12.81264860, 12.82507919, 12.82538861, 12.83780548, 12.83810291, 12.85050709, 12.85079158, 12.86318422, 12.86345466, 12.87583707, 12.87609221, 12.88846587, 12.88870422, 12.90107092, 12.90129064, 12.91365259, 12.91385136, 12.92621140, 12.92638608, 12.93874825, 12.93889414, 12.95126507, 12.95137385, 12.96377041, 12.96381688]

Here are the residuals.  For greater accuracy, set Digits to something greater than 10.

f~(x_roots);

[0.87e-8, -0.20e-8, 0.546e-7, -0.688e-7, 0.212e-7, -0.456e-7, -0.418e-7, 0.884e-7, -0.1183e-6, 0.594e-7, -0.274e-7, -0.294e-7, -0.752e-7, 0.158e-7, 0.130e-7, 0.94e-8, 0.1221e-6, -0.600e-7, -0.325e-7, 0.263e-7, -0.464e-7, 0.439e-7, 0.613e-7, 0.1038e-6, 0.1970e-6, 0.1855e-6, 0.764e-7, 0.893e-7, 0.216e-7, -0.2005e-6, 0.1556e-6, 0.372e-7, -0.1430e-6, 0.241e-7, -0.754e-7, 0.199e-7, 0.703e-7, 0.1814e-6, -0.733e-7, -0.1366e-6, -0.1173e-6, 0.1139e-6, 0.551e-7, 0.1999e-6, -0.349e-7, 0.1162e-6, -0.2262e-6, -0.713e-7, -0.1909e-6, 0.1621e-6, -0.324e-7, -0.1744e-6, 0.930e-7, -0.1534e-6, 0.724e-7, -0.1816e-6, -0.651e-7, -0.291e-7, -0.2492e-6, -0.249e-7, 0.1284e-6, -0.1600e-6, 0.2146e-6, 0.1103e-6, -0.1058e-6, -0.2276e-6, -0.2148e-6, 0.401e-7, 0.405e-7, -0.232e-7, -0.1335e-6, 0.1712e-6, -0.2065e-6, -0.2210e-6, -0.58e-8, -0.474e-7, 0.1054e-6, -0.599e-7, 0.2052e-6, -0.828e-7, -0.1365e-6, 0.137e-7, -0.1618e-6, 0.1374e-6, 0.989e-7, 0.880e-7, -0.1078e-6, 0.2022e-6, -0.815e-7, 0.123e-7, -0.75e-8, 0.477e-7, 0.701e-7, -0.796e-7, 0.197e-7, -0.14e-8, 0.1472e-6, 0.1679e-6, -0.1135e-6, 0.209e-7, -0.69e-8, -0.615e-7, 0.1503e-6, 0.1314e-6, 0.450e-7, -0.762e-7, -0.924e-7, 0.1371e-6, 0.381e-7, 0.1007e-6, 0.29e-8, -0.1353e-6, -0.573e-7, -0.1134e-6, -0.158e-7, -0.46e-8, -0.242e-7, -0.379e-7, 0.38e-8, 0.576e-7, 0.51e-8, -0.28e-8]


Download mw.mw

I can't tell why Maple does what it does.  But a close look at the Maple's result makes it possible to find the correct solution as follows.

restart;

ode:=diff(y(x),x)=1+y(x)+y(x)^2*cos(x);

diff(y(x), x) = 1+y(x)+y(x)^2*cos(x)

dsolve({ode, y(0)=0}):
dsol :=simplify(%) assuming x > 0, x < 2*Pi;

y(x) = (2*c__1*MathieuS(-1, -2, (1/2)*x)+2*MathieuC(-1, -2, (1/2)*x))/(-c__1*MathieuS(-1, -2, (1/2)*x)+c__1*MathieuSPrime(-1, -2, (1/2)*x)-MathieuC(-1, -2, (1/2)*x)+MathieuCPrime(-1, -2, (1/2)*x))

indets(dsol, name);

{c__1, x}

That c__1 should not be there.  Let's see how dsol's initial value depends on c__1NULL

eval(dsol, x=0);

y(0) = 2/(-1+c__1)

Okay, so if we want y(0) = 0, then c__1 should be infinity.

limit(dsol, c__1=infinity):
mysol := unapply(rhs(%), x);

proc (x) options operator, arrow; 2*MathieuS(-1, -2, (1/2)*x)/(-MathieuS(-1, -2, (1/2)*x)+MathieuSPrime(-1, -2, (1/2)*x)) end proc

Here what the solution looks like:

plot(mysol(x), x=0..5);

 

Download mw.mw

Maple's mod, modp, and mods are intended for use in polynomial algebras.  For modular arithmetic with integers use irem instead.  Thus,

FB := sum(irem(5, product(2, t = 0 .. irem(q - 1, 3))), q = 1 .. 2);

evaluates to 2 as you would expect.

 

restart;

with(plots):

HarmonicEnergies := proc(N::posint)
    local n;
    return Vector([seq(n + 1/2, n = 0..N-1)]);
end proc:

BuildM := proc(N::posint, mx::positive)
    local m, n, Mentry, M;
    Mentry := (m,n) -> exp(1/(4*mx)) *
        sqrt(min(m,n)!/max(m,n)!) *
        (1/sqrt(2*mx))^abs(m-n) *
        LaguerreL(min(m,n), abs(m-n), -1/(2*mx));
    M := Matrix(N, N, (m,n) -> evalf(Mentry(m-1, n-1)));
    return M;
end proc:

GaussianStateCoeffs := proc(N::posint, mx::positive,
                             x0::realcons := 0.0, vx0::realcons := 0.0,
                             omega::realcons := 1.0,
                             sigmax::realcons := 1/sqrt(2*mx*omega))
    local px0, alpha, pref, C, n;

    px0 := mx * vx0;
    alpha := x0 / (sqrt(2) * sigmax) + I * px0 * sigmax;
    pref := exp(-abs(alpha)^2 / 2);

    # Proper n from 0 to N-1
    C := Vector(N, n -> evalf(pref * alpha^(n-1) / sqrt((n-1)!)), datatype = complex[8]):
    return C;
end proc:

N := 3:
mx := 2:
my := 1:
lambda := 1:
y0 := 0:
p0 := -5:
t_final := 1:   # was 30(!)

E := HarmonicEnergies(N);

Vector(3, {(1) = 1/2, (2) = 3/2, (3) = 5/2})

M := BuildM(N, mx);

Matrix(3, 3, {(1, 1) = 1.133148453, (1, 2) = .5665742265, (1, 3) = .2003142388, (2, 1) = .5665742265, (2, 2) = 1.416435566, (2, 3) = .9014140745, (3, 1) = .2003142388, (3, 2) = .9014140745, (3, 3) = 1.735133569})

B := Matrix(N,N, (m,n) -> exp(I*(E[m]-E[n])*tau) * M[m,n]);

Matrix(3, 3, {(1, 1) = 1.133148453, (1, 2) = .5665742265*exp(-I*tau), (1, 3) = .2003142388*exp(-(2*I)*tau), (2, 1) = .5665742265*exp(I*tau), (2, 2) = 1.416435566, (2, 3) = .9014140745*exp(-I*tau), (3, 1) = .2003142388*exp((2*I)*tau), (3, 2) = .9014140745*exp(I*tau), (3, 3) = 1.735133569})

Cvec := Vector(N, i -> C[i](tau));

Vector(3, {(1) = C[1](tau), (2) = C[2](tau), (3) = C[3](tau)})

de_C := seq(diff(Cvec,tau) =~ lambda*exp(-y(tau)) * B . Cvec);

diff(C[1](tau), tau) = 1.133148453*exp(-y(tau))*C[1](tau)+.5665742265*exp(-I*tau)*exp(-y(tau))*C[2](tau)+.2003142388*exp(-(2*I)*tau)*exp(-y(tau))*C[3](tau), diff(C[2](tau), tau) = .5665742265*exp(I*tau)*exp(-y(tau))*C[1](tau)+1.416435566*exp(-y(tau))*C[2](tau)+.9014140745*exp(-I*tau)*exp(-y(tau))*C[3](tau), diff(C[3](tau), tau) = .2003142388*exp((2*I)*tau)*exp(-y(tau))*C[1](tau)+.9014140745*exp(I*tau)*exp(-y(tau))*C[2](tau)+1.735133569*exp(-y(tau))*C[3](tau)

de_y := diff(y(tau),tau) = p(tau) / my;

diff(y(tau), tau) = p(tau)

de_p := diff(p(tau),tau) = lambda * exp(-y(tau)) * Cvec^+ . B . Cvec;

diff(p(tau), tau) = (1.133148453*exp(-y(tau))*C[1](tau)+.5665742265*exp(I*tau)*exp(-y(tau))*C[2](tau)+.2003142388*exp(-y(tau))*C[3](tau)*exp((2*I)*tau))*C[1](tau)+(.5665742265*exp(-y(tau))*C[1](tau)*exp(-I*tau)+1.416435566*exp(-y(tau))*C[2](tau)+.9014140745*exp(-y(tau))*C[3](tau)*exp(I*tau))*C[2](tau)+(.2003142388*exp(-y(tau))*C[1](tau)*exp(-(2*I)*tau)+.9014140745*exp(-I*tau)*exp(-y(tau))*C[2](tau)+1.735133569*exp(-y(tau))*C[3](tau))*C[3](tau)

ic := seq(subs(tau=0, Cvec) =~ GaussianStateCoeffs(N, mx)),
        y(0)=y0, p(0)=p0;

C[1](0) = HFloat(1.0)+HFloat(0.0)*I, C[2](0) = HFloat(0.0)+HFloat(0.0)*I, C[3](0) = HFloat(0.0)+HFloat(0.0)*I, y(0) = 0, p(0) = -5

dsol := dsolve({de_C, de_y, de_p, ic}, numeric);

`Non-fatal error while reading data from kernel.`

Plot the real and imaginary parts of y(tau)

display(
    < odeplot(dsol, [tau, Re(y(tau))], tau=0..t_final) |
      odeplot(dsol, [tau, Im(y(tau))], tau=0..t_final) > );

 

 

 

 

 

 

display(
    < odeplot(dsol, [tau, Re(p(tau))], tau=0..t_final) |
      odeplot(dsol, [tau, Im(p(tau))], tau=0..t_final) > );

 

 

 

 

 

 

display(
    < odeplot(dsol, [tau, Re(C[1](tau))], tau=0..t_final) |
      odeplot(dsol, [tau, Im(C[1](tau))], tau=0..t_final) > );

 

 

 

 

 

 

display(
    < odeplot(dsol, [tau, Re(C[2](tau))], tau=0..t_final) |
      odeplot(dsol, [tau, Im(C[2](tau))], tau=0..t_final) > );

 

 

 

 

 

 

display(
    < odeplot(dsol, [tau, Re(C[3](tau))], tau=0..t_final) |
      odeplot(dsol, [tau, Im(C[3](tau))], tau=0..t_final) > );

 

 

 

 

 

 

 

Download mw2.mw

I assume that you are writing your notes in LaTeX.  If not, then you should.

You may do the drawings in Maple, but that will be a struggle.  Things will go much smoother if you learn how to use the TikZ package and do the drawings in LaTeX.  That will require some investment of time and effort, but it would be a worthwhile investment.

Here is a sample.  Took me less than 10 minutes to do it.

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[>=latex]
    \pgfmathsetmacro{\R}{2.5}
    \pgfmathsetmacro{\h}{0.05*\R}

    % the coordinate axes
    \draw[->] (-1.2*\R,0) -- (1.2*\R,0) node[below] {$x$};
    \draw[->] (0,-0.1*\R) -- (0,1.2*\R) node[right] {$y$};

    % the contour
    \draw[red, thick]
        (-\R,0) 
        -- (-1/\R,0)
        arc [start angle = 180, delta angle = -180, radius = 1/\R]
        -- (\R,0)
        arc [start angle = 0, delta angle = 180, radius = \R]
        -- cycle;

    % arrowheads
    \draw[->, >=stealth, red, very thick] (-0.5*\R,0) -- +(0.01,0);
    \draw[->, >=stealth, red, very thick] ( 0.5*\R,0) -- +(0.01,0);
    \draw[->, >=stealth, red, very thick] ( 0, \R)    -- +(-0.01,0);

    % labels
    \node at (45:1.15*\R) {$\mu_R$};
    \draw
        (-\R,0) -- +(0,-\h) node [below] {$-R$}
        (-1/\R,0) -- +(0,-\h) node [below] {$-\frac{1}{R}$}
        ( 1/\R,0) -- +(0,-\h) node [below] {$ \frac{1}{R}$}
        ( \R,0) -- +(0,-\h) node [below] {$ R$}
    ;
        
\end{tikzpicture}
\end{document}

 

 

restart;

with(plots):

The vertices:

A, B, C := <0,0>, <3,0>, <3*cos(Pi/3), 3*sin(Pi/3) >;

Vector[column](%id = 36893622867421332772), Vector[column](%id = 36893622867421332892), Vector[column](%id = 36893622867421333012)

The points P, Q, R:

Q := 1/3*A + 2/3*C;
P := 1/3*C + 2/3*B;
R := <4,0>;

Vector(2, {(1) = 1, (2) = sqrt(3)})

Vector(2, {(1) = 5/2, (2) = (1/2)*sqrt(3)})

Vector[column](%id = 36893622867421339764)

If P lies on QR, them this equation will have a solution, otherwise there won't be a solution:

P = (1-t)*Q + t*R;
solve(%, t);

(Vector(2, {(1) = 5/2, (2) = (1/2)*sqrt(3)})) = (Vector(2, {(1) = 1+3*t, (2) = (1-t)*sqrt(3)}))

{t = 1/2}

display(
        pointplot([A,B,C,A], connect, color="Green"),
        pointplot([B,R], connect, color="Green", linestyle=dash),
        pointplot([P,Q,R], symbol=solidcircle, symbolsize=20, color="Red"),
        pointplot([Q, R], connect, color="Blue"),
        textplot([
                [seq(A), 'A', align={below,left}],
                [seq(B), 'B', align={below}],
                [seq(C), 'C', align={above}],
                [seq(Q), 'Q', align={above,left}],
                [seq(P), 'P', align={above,right}],
                [seq(R), 'R', align={below}],
        NULL]),
scaling=constrained, axes=none);

Download mw.mw

 

restart;

with(plots):

with(plottools):

The integers m and n specify a hexagon's column and row indices, and col is the color.

p := proc(m, n, col)
        local p, x, y;
        p := polygonbyname("hexagon", color=col, radius=sqrt(3)/2);
        x := 3/2*m;
        y := sqrt(3)* `if`(type(m, even), n, n+1/2);
        translate(p, x, y);
end proc:

P :=
        p(0,0,red),
        p(1,0,green),
        p(2,0,blue),
        p(0,1,yellow),
        p(1,1,cyan),
        p(2,1,magenta):

display(P, scaling=constrained, size=[600,600], axes=none);

 

 

Download mw.mw

Added later:

With the proc(m,n,col) on hand, we can generate tilings of desired size:

M, N := 10, 7:
seq(seq(p(m,n,red),   n=irem(m,2)..N, 3), m=0..M),
seq(seq(p(m,n,green), n=irem(m,2)+1..N, 3), m=0..M),
seq(seq(p(m,n,blue),  n=2*irem(m+1,2)..N, 3), m=0..M):
display(%, scaling=constrained, axes=none);

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