dharr

Dr. David Harrington

8522 Reputation

22 Badges

21 years, 48 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a retired professor of chemistry at the University of Victoria, BC, Canada. My research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are answers submitted by dharr

I did this before your latest comments, so you may need to alter to suit.

restart;

with(PDEtools, dchange):with(plots):

with(Units):

Automatically loading the Units[Simple] subpackage
 

params:={k= 1.3806490000*10^(-23)*Unit(J/K),rb=5.293*10^(-11)*Unit(m),
ec= 1.602176634*10^(-19)*Unit(C),Tq=1.765*10^(-19)*Unit(s),
c= 299792458*Unit(m/s),T=297*Unit(K),a=1,nu1=7.880979442*10^14*Unit(s^(-1)),E__nu1=8.941594733*10^(-20)*Unit(J)};

{E__nu1 = 0.8941594733e-19*Units:-Unit(J), T = 297*Units:-Unit(K), Tq = 0.1765000000e-18*Units:-Unit(s), a = 1, c = 299792458*Units:-Unit(m/s), ec = 0.1602176634e-18*Units:-Unit(C), k = 0.1380649000e-22*Units:-Unit(J/K), nu1 = 0.7880979442e15*Units:-Unit(1/s), rb = 0.5293000000e-10*Units:-Unit(m)}

N:=8*Pi*Tq^2*nu^2*E(nu)/(c^3*(exp(E(nu)/(k*T)) - 1));V:=Pi*rb^3;

8*Pi*Tq^2*nu^2*E(nu)/(c^3*(exp(E(nu)/(k*T))-1))

Pi*rb^3

Find value and units of NV at nu1 and E__nu1.

NV:=N*V;
eval(eval(NV,{E(nu)=E__nu1,nu=nu1}),params);

8*Pi^2*Tq^2*nu^2*E(nu)*rb^3/(c^3*(exp(E(nu)/(k*T))-1))

0.2546180250e-90*Units:-Unit(s*kg*m^2)

Expected units ??????????? I'll assume NV really has units J*s^3 = s kg m^2. NV has the same units as C

convert(1*Unit(J*s^3/m^3),system,base);

Units:-Unit(kg*s/m)

Non dim energy e=E/kT; non-dim time tau = t/Tg; non dim frequency f=nu*Tq,

So tau*f = t*nu =1

NV2:=eval(NV,{E(nu)=e(f)*k*T, nu=f/Tq});
const:=8*Pi^2*k*T*rb^3/c^3;
NV3:=algsubs(const=C,NV2);

8*Pi^2*f^2*e(f)*k*T*rb^3/(c^3*(exp(e(f))-1))

8*Pi^2*k*T*rb^3/c^3

f^2*e(f)*C/(exp(e(f))-1)

Still rather small

eval(const,params);

0.1781857781e-74*Units:-Unit(s*kg*m^2)

Now we change from frequency to time by a substitution.

NV_tau:=dchange(f=1/tau,NV3);

e(tau)*C/(tau^2*(exp(e(tau))-1))

Difference over 1 period

sol_tau:=NV_tau - eval(NV_tau, tau=tau+1);

e(tau)*C/(tau^2*(exp(e(tau))-1))-e(tau+1)*C/((tau+1)^2*(exp(e(tau+1))-1))

sol_f:=simplify(dchange(tau=1/f,sol_tau));

f^3*e(f)*C*(f+2)/((1+f)^2*(exp(e(f))-1))

Next we differentiation sol_nu wrt nu. dsdnu has units of C*Tq

Diff(sol(nu),nu);
dchange({nu=f/Tq},%,[f],'params'=Tq); # chain rule
dsdnu:=simplify(eval(%,sol(f)=sol_f));

Diff(sol(nu), nu)

(diff(sol(f), f))*Tq

-((1+(e(f)-1)*exp(e(f)))*(1+f)*(f+2)*f*(diff(e(f), f))-2*e(f)*(f^2+3*f+3)*(exp(e(f))-1))*f^2*Tq*C/((1+f)^3*(exp(e(f))-1)^2)

Now we integrate from t = t0 to t0+Tq.
But dsdnu is not a finction of t (?), so this just amounts to multiplying by Tq.
B has same units as C*Tq^2

B:=dsdnu*Tq;

-((1+(e(f)-1)*exp(e(f)))*(1+f)*(f+2)*f*(diff(e(f), f))-2*e(f)*(f^2+3*f+3)*(exp(e(f))-1))*f^2*Tq^2*C/((1+f)^3*(exp(e(f))-1)^2)

The differential equation is sol = B*A or sol-B*A (=0 is assumed by Maple). From a unit point of view A must have same units as 1/Tq^2 = s^(-2). So write A = a/Tq^2, where a is dimensionless.

Just set the numerator zero to simplify the problem. C cancels out, and there is a single dimensionless parameter a

de:=simplify(numer(normal(sol_f - B*a/Tq^2)))/C/f^2;

(1+(e(f)-1)*exp(e(f)))*a*(f+2)*f*(1+f)*(diff(e(f), f))-2*(exp(e(f))-1)*e(f)*(-(1/2)*f^3+(a-3/2)*f^2+(3*a-1)*f+3*a)

No analytical solution

dsolve({de,e(f0)=e0},e(f));

e(f) = RootOf(f-a*ln(f+2)-3*a*ln(f)+2*a*ln(1+f)+a*ln(exp(_Z)-1)-a*ln(_Z)-f0+a*ln(f0+2)+3*a*ln(f0)-2*a*ln(1+f0)-a*ln(exp(e0)-1)+a*ln(e0))

Initial condition and end of frequency range - now numbers seem more reasonable but note exp(e1) is still large.

invals:=eval({f1=nu1*Tq,e1=E__nu1/(k*T),f2=1e18*Unit(s^(-1))*Tq},params);

{e1 = 21.80596196, f1 = 0.1390992872e-3, f2 = .1765000000}

Numerical solution for a=1

sol:=dsolve(eval({de,e(f1)=e1},{a=1} union invals),e(f),numeric,stiff=true);

proc (x_rosenbrock) 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_rosenbrock) else _xout := evalf(x_rosenbrock) end if; _dat := Array(1..4, {(1) = proc (_x_in) local _x_out, _dtbl, _dat, _vmap, _x0, _y0, _val, _digits, _neq, _nevar, _ndisc, _nevt, _pars, _ini, _par, _i, _j, _k, _src, _t1; option `Copyright (c) 2002 by Waterloo Maple Inc. All rights reserved.`; table( [( "complex" ) = false ] ) _x_out := _x_in; _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) = 1, (2) = 1, (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) = 2, (23) = 3, (24) = 0, (25) = 1, (26) = 15, (27) = 1, (28) = 0, (29) = 1, (30) = 3, (31) = 3, (32) = 0, (33) = 2, (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.1390992872e-3, (2) = 0.10e-5, (3) = .0, (4) = 0.500001e-14, (5) = 0.1390992872e-3, (6) = 0.13356737814211669e-4, (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..1, {(1) = 21.80596196}, 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..1, {(1) = 1.0}, datatype = float[8], order = C_order), Array(1..1, {(1) = .0}, datatype = float[8], order = C_order), Array(1..1, {(1) = .0}, datatype = float[8], order = C_order), Array(1..1, {(1) = .0}, datatype = float[8], order = C_order), Array(1..1, {(1) = -162502067.43793884}, datatype = float[8], order = C_order), Array(1..1, 1..1, {(1, 1) = -49.81617060028293}, datatype = float[8], order = C_order), Array(1..1, 1..1, {(1, 1) = .0}, datatype = float[8], order = C_order), Array(1..1, {(1) = .0}, datatype = float[8], order = C_order), Array(1..1, 1..1, {(1, 1) = .0}, datatype = float[8], order = C_order), Array(1..1, 1..6, {(1, 1) = .0, (1, 2) = .0, (1, 3) = .0, (1, 4) = .0, (1, 5) = .0, (1, 6) = .0}, datatype = float[8], order = C_order), Array(1..1, {(1) = 0}, datatype = integer[8]), Array(1..1, {(1) = .0}, datatype = float[8], order = C_order), Array(1..1, {(1) = .0}, datatype = float[8], order = C_order), Array(1..1, {(1) = .0}, datatype = float[8], order = C_order), Array(1..1, {(1) = .0}, datatype = float[8], order = C_order), Array(1..1, {(1) = .0}, datatype = float[8], order = C_order), Array(1..2, {(1) = .0, (2) = .0}, datatype = float[8], order = C_order), Array(1..1, {(1) = 0}, datatype = integer[8])]), ( 8 ) = ([Array(1..1, {(1) = 21.80596196}, datatype = float[8], order = C_order), Array(1..1, {(1) = .0}, datatype = float[8], order = C_order), Array(1..1, {(1) = -163627977.75921127}, datatype = float[8], order = C_order), 0, 0]), ( 11 ) = (Array(1..6, 0..1, {(1, 1) = .0, (2, 0) = .0, (2, 1) = .0, (3, 0) = .0, (3, 1) = .0, (4, 0) = .0, (4, 1) = .0, (5, 0) = .0, (5, 1) = .0, (6, 0) = .0, (6, 1) = .0}, datatype = float[8], order = C_order)), ( 10 ) = ([proc (N, X, Y, YP) option `[Y[1] = e(f)]`; YP[1] := 2*(exp(Y[1])-1)*Y[1]*(-(1/2)*X^3-(1/2)*X^2+2*X+3)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)*(X+2)*X); 0 end proc, proc (X, Y, FX, FY) FX[1 .. 1] := 0; FY[1 .. 1, 1 .. 1] := 0; FY[1, 1] := 2*exp(Y[1])*Y[1]*(-(1/2)*X^3-(1/2)*X^2+2*X+3)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)*(X+2)*X)+2*(exp(Y[1])-1)*(-(1/2)*X^3-(1/2)*X^2+2*X+3)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)*(X+2)*X)-2*(exp(Y[1])-1)*Y[1]*(-(1/2)*X^3-(1/2)*X^2+2*X+3)*(exp(Y[1])+(Y[1]-1)*exp(Y[1]))/((1+(Y[1]-1)*exp(Y[1]))^2*(X+1)*(X+2)*X); FX[1] := 2*(exp(Y[1])-1)*Y[1]*(-(3/2)*X^2-X+2)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)*(X+2)*X)-2*(exp(Y[1])-1)*Y[1]*(-(1/2)*X^3-(1/2)*X^2+2*X+3)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)^2*(X+2)*X)-2*(exp(Y[1])-1)*Y[1]*(-(1/2)*X^3-(1/2)*X^2+2*X+3)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)*(X+2)^2*X)-2*(exp(Y[1])-1)*Y[1]*(-(1/2)*X^3-(1/2)*X^2+2*X+3)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)*(X+2)*X^2); 0 end proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), ( 13 ) = (), ( 12 ) = (), ( 15 ) = ("rosenbrock"), ( 14 ) = ([0, 0]), ( 18 ) = ([]), ( 19 ) = (0), ( 16 ) = ([0, 0, 0, 0, 0, 0, []]), ( 17 ) = ([proc (N, X, Y, YP) option `[Y[1] = e(f)]`; YP[1] := 2*(exp(Y[1])-1)*Y[1]*(-(1/2)*X^3-(1/2)*X^2+2*X+3)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)*(X+2)*X); 0 end proc, proc (X, Y, FX, FY) FX[1 .. 1] := 0; FY[1 .. 1, 1 .. 1] := 0; FY[1, 1] := 2*exp(Y[1])*Y[1]*(-(1/2)*X^3-(1/2)*X^2+2*X+3)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)*(X+2)*X)+2*(exp(Y[1])-1)*(-(1/2)*X^3-(1/2)*X^2+2*X+3)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)*(X+2)*X)-2*(exp(Y[1])-1)*Y[1]*(-(1/2)*X^3-(1/2)*X^2+2*X+3)*(exp(Y[1])+(Y[1]-1)*exp(Y[1]))/((1+(Y[1]-1)*exp(Y[1]))^2*(X+1)*(X+2)*X); FX[1] := 2*(exp(Y[1])-1)*Y[1]*(-(3/2)*X^2-X+2)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)*(X+2)*X)-2*(exp(Y[1])-1)*Y[1]*(-(1/2)*X^3-(1/2)*X^2+2*X+3)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)^2*(X+2)*X)-2*(exp(Y[1])-1)*Y[1]*(-(1/2)*X^3-(1/2)*X^2+2*X+3)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)*(X+2)^2*X)-2*(exp(Y[1])-1)*Y[1]*(-(1/2)*X^3-(1/2)*X^2+2*X+3)/((1+(Y[1]-1)*exp(Y[1]))*(X+1)*(X+2)*X^2); 0 end proc, 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..1, {(1) = 0.1390992872e-3}); _vmap := array( 1 .. 1, [( 1 ) = (1)  ] ); _x0 := _dtbl[1][5][5]; _neq := _dtbl[1][4][1]; _nevar := _dtbl[1][4][3]; _ndisc := _dtbl[1][4][4]; _nevt := _dtbl[1][4][16]; if not type(_x_out, 'numeric') then if member(_x_out, ["start", "left", "right"]) then if _Env_smart_dsolve_numeric = true or _dtbl[1][4][10] = 1 then if _x_out = "left" then if type(_dtbl[2], 'array') then return _dtbl[2][5][1] end if elif _x_out = "right" then if type(_dtbl[3], 'array') then return _dtbl[3][5][1] end if end if end if; return _dtbl[1][5][5] elif _x_out = "method" then return _dtbl[1][15] elif _x_out = "storage" then return evalb(_dtbl[1][4][10] = 1) elif _x_out = "leftdata" then if not type(_dtbl[2], 'array') then return NULL else return eval(_dtbl[2]) end if elif _x_out = "rightdata" then if not type(_dtbl[3], 'array') then return NULL else return eval(_dtbl[3]) end if elif _x_out = "enginedata" then return _dtbl[1] elif _x_out = "enginereset" then _dtbl[2] := evaln(_dtbl[2]); _dtbl[3] := evaln(_dtbl[3]); return NULL elif _x_out = "initial" then return procname(_y0[0]) elif _x_out = "laxtol" then return _dtbl[`if`(member(_dtbl[4], {2, 3}), _dtbl[4], 1)][5][18] elif _x_out = "numfun" then return `if`(member(_dtbl[4], {2, 3}), _dtbl[_dtbl[4]][4][18], 0) elif _x_out = "parameters" then return [seq(_y0[_neq+_i], _i = 1 .. nops(_pars))] elif _x_out = "initial_and_parameters" then return procname(_y0[0]), [seq(_y0[_neq+_i], _i = 1 .. nops(_pars))] elif _x_out = "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 _x_out := _dtbl[_dtbl[4]][5][1] end if elif _x_out = "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 _x_out = "map" then return copy(_vmap) elif type(_x_in, `=`) and type(rhs(_x_in), 'list') and member(lhs(_x_in), {"initial", "parameters", "initial_and_parameters"}) then _ini, _par := [], []; if lhs(_x_in) = "initial" then _ini := rhs(_x_in) elif lhs(_x_in) = "parameters" then _par := rhs(_x_in) elif select(type, rhs(_x_in), `=`) <> [] then _par, _ini := selectremove(type, rhs(_x_in), `=`) elif nops(rhs(_x_in)) < nops(_pars)+1 then error "insufficient data for specification of initial and parameters" else _par := rhs(_x_in)[-nops(_pars) .. -1]; _ini := rhs(_x_in)[1 .. -nops(_pars)-1] end if; _x_out := lhs(_x_out); _i := false; if _par <> [] then _i := `dsolve/numeric/process_parameters`(_neq, _pars, _par, _y0) end if; if _ini <> [] then _i := `dsolve/numeric/process_initial`(_neq-_nevar, _ini, _y0, _pars, _vmap) or _i end if; if _i then `dsolve/numeric/SC/reinitialize`(_dtbl, _y0, _neq, 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 _x_out = "initial" then return [_y0[0], seq(_y0[_vmap[_i]], _i = 1 .. _neq-_nevar)] elif _x_out = "parameters" then return [seq(_y0[_neq+_i], _i = 1 .. nops(_pars))] else return [_y0[0], seq(_y0[_vmap[_i]], _i = 1 .. _neq-_nevar)], [seq(_y0[_neq+_i], _i = 1 .. nops(_pars))] end if elif _x_in = "eventstop" then if _nevt = 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 _x_in = "eventstatus" then if _nevt = 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][_nevt+1, 1]))})]; return ':-enabled' = _i[1], ':-disabled' = _i[2] elif _x_in = "eventclear" then if _nevt = 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 _nevt < _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 _nevt 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][_nevt+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(_x_in, `=`) and member(lhs(_x_in), {"eventdisable", "eventenable"}) then if _nevt = 0 then error "this solution has no events" end if; if type(rhs(_x_in), {('list')('posint'), ('set')('posint')}) then _i := {op(rhs(_x_in))} elif type(rhs(_x_in), 'posint') then _i := {rhs(_x_in)} else error "event identifiers must be integers in the range 1..%1", round(_dtbl[1][3][1][_nevt+1, 1]) end if; if select(proc (a) options operator, arrow; _nevt < a end proc, _i) <> {} then error "event identifiers must be integers in the range 1..%1", round(_dtbl[1][3][1][_nevt+1, 1]) end if; _k := {}; for _j to _nevt do if member(round(_dtbl[1][3][1][_j, 1]), _i) then _k := `union`(_k, {_j}) end if end do; _i := _k; if lhs(_x_in) = "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 _nevt+1 do if _k <= _nevt 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 _nevt+1 do if _k <= _nevt 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(_x_in, `=`) and lhs(_x_in) = "eventfired" then if not type(rhs(_x_in), 'list') then error "'eventfired' must be specified as a list" end if; if _nevt = 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(_x_in) 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][_nevt+1, 1]) < _src then error "event identifiers must be integers in the range 1..%1", round(_dtbl[1][3][1][_nevt+1, 1]) end if; _src := {seq(`if`(_dtbl[1][3][1][_j, 1]-_src = 0., _j, NULL), _j = 1 .. _nevt)}; 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(_x_in, `=`) and lhs(_x_in) = "direction" then if not member(rhs(_x_in), {-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(_x_in), {1, ':-right'}), 3, 2); _dtbl[4] := _i; _dtbl[_i] := `dsolve/numeric/SC/IVPdcopy`(_dtbl[1], `if`(assigned(_dtbl[_i]), _dtbl[_i], NULL)); if 0 < _nevt then for _j to _nevt+1 do if _j <= _nevt 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 _x_in = "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][_nevt+1, 12]) end if elif type(_x_in, `=`) and lhs(_x_in) = "setdatacallback" then if not type(rhs(_x_in), 'nonegint') then error "data callback must be a nonnegative integer (address)" end if; _dtbl[1][28] := rhs(_x_in) elif type(_x_in, `=`) and lhs(_x_in) = "Array" then _i := rhs(_x_in); if not type(_i, 'list') or nops(_i) <> 2 or not type(_i[1], 'numeric') or not type(_i[2], 'posint') or _i[2] < 2 then error "Array output must be specified as [end time, min number of points]" end if; _src := array(1 .. 1, [`dsolve/numeric/SC/IVPdcopy`(_dtbl[1])]); if 0 < 0 then if `dsolve/numeric/checkglobals`(op(_src[1][14]), _pars, _neq, _y0) then `dsolve/numeric/SC/reinitialize`(_src, _y0, _neq, procname, _pars, 1) end if end if; if _src[1][4][7] = 0 then error "parameters must be initialized before solution can be computed" end if; _val := `dsolve/numeric/SC/IVPvalues`(_src[1], _x0 .. _i[1], _i[2], _i[2], []); if _val[3] <> "" then `dsolve/numeric/warning`(cat(`requested integration incomplete, received error:`, convert(_val[3], 'symbol'))) end if; _t1 := Array(1 .. _val[2], 0 .. _neq-_nevar+nops(_pars)); _t1[() .. (), 0] := _val[1][1 .. _val[2], 0]; for _i to _neq-_nevar do _t1[() .. (), _i] := _val[1][1 .. _val[2], _vmap[_i]] end do; for _i to nops(_pars) do _t1[() .. (), _neq-_nevar+_i] := _val[1][1 .. _val[2], _neq+_i] end do; return _t1 else return "procname" end if end if; if _x_out = _x0 then return [_x0, seq(evalf(_dtbl[1][6][_vmap[_i]]), _i = 1 .. _neq-_nevar)] end if; _i := `if`(_x0 <= _x_out, 3, 2); if _x_in = "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 .. _neq-_nevar-_ndisc), seq(_dat[8][1][_vmap[_i]], _i = _neq-_nevar-_ndisc+1 .. _neq-_nevar)] 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 < _nevt then for _j to _nevt+1 do if _j <= _nevt 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 _x_in <> "last" then if 0 < 0 then if `dsolve/numeric/checkglobals`(op(_dtbl[1][14]), _pars, _neq, _y0) then `dsolve/numeric/SC/reinitialize`(_dtbl, _y0, _neq, 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, _x_out) 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][_nevt+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] := _x_out else _dtbl[1][5][1] := _val end if; if _i = 3 and _val < _x_out 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 = _nevt+1 then error "constraint projection failure on event at t=%1", evalf[8](_val) elif _dat[4][9]-100 = _nevt+2 then error "index-1 and derivative evaluation failure on event at t=%1", evalf[8](_val) elif _dat[4][9]-100 = _nevt+3 then error "maximum number of event iterations reached (%1) at t=%2", round(_dat[3][1][_nevt+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'; _x_out := _val end if else error "cannot evaluate the solution further right of %1", evalf[8](_val) end if elif _i = 2 and _x_out < _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 = _nevt+1 then error "constraint projection failure on event at t=%1", evalf[8](_val) elif _dat[4][9]-100 = _nevt+2 then error "index-1 and derivative evaluation failure on event at t=%1", evalf[8](_val) elif _dat[4][9]-100 = _nevt+3 then error "maximum number of event iterations reached (%1) at t=%2", round(_dat[3][1][_nevt+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'; _x_out := _val end if else error "cannot evaluate the solution further left of %1", evalf[8](_val) end if end if; if _EnvInFsolve = true then _digits := _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, _x_out, _src); _dat[4][25] := _i; _dat[4][26] := _digits; [_x_out, seq(_val[_vmap[_i]], _i = 1 .. _neq-_nevar)] else Digits := _dat[4][26]; _val := `dsolve/numeric/SC/IVPval`(eval(_dat, 2), _x_out, _src); [_x_out, seq(_val[_vmap[_i]], _i = 1 .. _neq-_nevar)] end if end proc, (2) = Array(0..0, {}), (3) = [f, e(f)], (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_rosenbrock, ["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_rosenbrock, '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_rosenbrock, ["last", 'last', "initial", 'initial', "parameters", 'parameters', "initial_and_parameters", 'initial_and_parameters', NULL]) then _xout := convert(x_rosenbrock, '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_rosenbrock), 'string') = rhs(x_rosenbrock); 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', "Array", 'Array', NULL]) then return _solnproc(convert(lhs(x_rosenbrock), 'string') = rhs(x_rosenbrock)) elif _xout = "solnprocedure" then return eval(_solnproc) elif _xout = "sysvars" then return _vars elif _xout = "Array" then return [op(_vars), op(_pars)] end if; if procname <> unknown then return ('procname')(x_rosenbrock) else _ndsol := 1; _ndsol := _ndsol; _ndsol := pointto(_dat[2][0]); return ('_ndsol')(x_rosenbrock) 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(sol,[f,e(f)],f=eval(f1..f2,invals),labels=[nu/Tq,E/k/T]);

NULL

Download plm3.mw

It's not entirely clear what you want. This can be modified if it is not what you want.

restart

List of characters to choose from

L := [seq("@#$SDFA35")]; n := nops(L)

["@", "#", "$", "S", "D", "F", "A", "3", "5"]

9

Random number generator to pick a number between 1 and n

r := rand(1 .. n)

Choose three characters

q := 3

3

cat(op(L[[seq(r(), 1 .. q)]]))

"AF#"

So to do it k times

k := 4; [seq(cat(op(L[[seq(r(), 1 .. q)]])), 1 .. k)]

4

["SFD", "@3D", "##S", "3$5"]

As a procedure

rands := proc(s::string, k::posint, q::posint)
  local L, r, n;
  L := [seq(s)];
  n := nops(L);
  r := rand(1 .. n);
  [seq(cat(op(L[[seq(r(), 1 .. q)]])), 1 .. k)]
end proc:
  
  

rands("qs4K*N$", 4, 3)

["s*K", "*Ns", "4$s", "NKq"]

NULL

Download rands.mw

According to the text, Eq (1) has nonlinear terms. But the linear/non-linear test in pde-condition.mw says all terms are linear. That test finds it linear because if you double the function you are solving for, you double the pde. That would be consistent with the usual practice in say, second order ODEs like the Bessel equation, where multiplying y(x) by a function of x does not make it a nonlinear equation, but multiplying by a function of y(x) would.

This is the source of your problem finding R. When you choose a form u = R*ln(f)_x and substitute it into the pde, you get R*(something)=0; since the PDE is linear, multiplying it by R leads to R*pde=0 and solving for R gives zero (the pde part is zero but Maple doesn't know that).

So what is the definition of linear/non-linear that you want?

[Edit @acer had some better code for linear/nonlinear parts - maybe that already works for what you want? [moderator: example] ]

Unless I've mistyped something, it looks like the paper is wrong. It is possible the complicated lambda[0] that Maple gives can be simplified to something similar to the lambda[0] in the paper (different sign perhaps), but I don't see it immediately.

restart

with(PDEtools)

with(LinearAlgebra)

with(Physics)

with(SolveTools)

undeclare(prime)

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

ode := (diff(G(xi), xi))^2 = lambda[0]+lambda[1]*G(xi)+lambda[2]*G(xi)^2+lambda[3]*G(xi)^3+lambda[4]*G(xi)^4

(diff(G(xi), xi))^2 = lambda[0]+lambda[1]*G(xi)+lambda[2]*G(xi)^2+lambda[3]*G(xi)^3+lambda[4]*G(xi)^4

ode1 := subs({lambda[1] = 0, lambda[3] = 0}, ode)

(diff(G(xi), xi))^2 = lambda[0]+lambda[2]*G(xi)^2+lambda[4]*G(xi)^4

S2 := G(xi) = sqrt(-aleph^2/((-aleph^2+2)*lambda[4]))*JacobiDN(sqrt(lambda[2]/(-aleph^2+2))*xi, aleph)

G(xi) = (-aleph^2/((-aleph^2+2)*lambda[4]))^(1/2)*JacobiDN((lambda[2]/(-aleph^2+2))^(1/2)*xi, aleph)

res2 := `assuming`([odetest(S2, ode1)], [lambda[2] > 0, lambda[4] < 0]); eq2 := `assuming`([lambda[0] = simplify(solve(res2, lambda[0]))], [lambda[2] > 0, lambda[4] < 0])

-JacobiSN((-lambda[2]/(aleph^2-2))^(1/2)*xi, aleph)^4*aleph^8/(lambda[4]*(aleph^4-4*aleph^2+4))+JacobiSN((-lambda[2]/(aleph^2-2))^(1/2)*xi, aleph)^4*aleph^6*lambda[2]/(lambda[4]*(aleph^4-4*aleph^2+4))+2*JacobiSN((-lambda[2]/(aleph^2-2))^(1/2)*xi, aleph)^2*aleph^6/(lambda[4]*(aleph^4-4*aleph^2+4))-2*JacobiSN((-lambda[2]/(aleph^2-2))^(1/2)*xi, aleph)^2*aleph^4*lambda[2]/(lambda[4]*(aleph^4-4*aleph^2+4))-aleph^4*lambda[0]/(aleph^4-4*aleph^2+4)-aleph^4*lambda[2]/(lambda[4]*(aleph^4-4*aleph^2+4))-aleph^4/(lambda[4]*(aleph^4-4*aleph^2+4))+4*aleph^2*lambda[0]/(aleph^4-4*aleph^2+4)+2*lambda[2]*aleph^2/(lambda[4]*(aleph^4-4*aleph^2+4))-4*lambda[0]/(aleph^4-4*aleph^2+4)

lambda[0] = -(aleph^4*(aleph^2-lambda[2])*JacobiSN(lambda[2]^(1/2)*(-1/(aleph^2-2))^(1/2)*xi, aleph)^4+(-2*aleph^4+2*aleph^2*lambda[2])*JacobiSN(lambda[2]^(1/2)*(-1/(aleph^2-2))^(1/2)*xi, aleph)^2+(lambda[2]+1)*aleph^2-2*lambda[2])*aleph^2/(lambda[4]*(aleph^2-2)^2)

`assuming`([odetest(S2, eval(ode1, eq2))], [lambda[2] > 0, lambda[4] < 0])

0

Paper has lambda[0] as

eq3 := lambda[0] = lambda[2]^2*(-aleph^2+1)/(lambda[4]*(-aleph^2+2)^2)

lambda[0] = lambda[2]^2*(-aleph^2+1)/(lambda[4]*(-aleph^2+2)^2)

Check paper version

`assuming`([simplify(odetest(S2, eval(ode1, eq3)))], [lambda[2] > 0, lambda[4] < 0])

-(aleph^2-lambda[2])*(JacobiSN(lambda[2]^(1/2)*(-1/(aleph^2-2))^(1/2)*xi, aleph)^4*aleph^6-2*JacobiSN(lambda[2]^(1/2)*(-1/(aleph^2-2))^(1/2)*xi, aleph)^2*aleph^4+(lambda[2]+1)*aleph^2-lambda[2])/(lambda[4]*(aleph^2-2)^2)

The two lambda[0]'s are not the same;

`assuming`([simplify(eval(lambda[0], eq2)-(eval(lambda[0], eq3)))], [lambda[2] > 0, lambda[4] < 0]); evalf(eval(%, {aleph = 2, xi = 2.4, lambda[2] = -7, lambda[4] = -2}))

-(aleph^2-lambda[2])*(JacobiSN(lambda[2]^(1/2)*(-1/(aleph^2-2))^(1/2)*xi, aleph)^4*aleph^6-2*JacobiSN(lambda[2]^(1/2)*(-1/(aleph^2-2))^(1/2)*xi, aleph)^2*aleph^4+(lambda[2]+1)*aleph^2-lambda[2])/(lambda[4]*(aleph^2-2)^2)

-28.61877034

NULL

Download compare.mw

The following works except for the indexed names where the index is a constant, such as m[e]. Probably I would consider assigning these to variables m__e rather than m['e'] and always needing the uneval quotes.

Using the constants

restart

with(ScientificConstants)

GetConstants()

`A[r](alpha)`, `A[r](d)`, `A[r](e)`, `A[r](h)`, `A[r](n)`, `A[r](p)`, E[h], F, G, G[0], K[J], M[Earth], M[Moon], M[Sun], M[u], N[A], Phi[0], R, R[Earth], R[K], R[Moon], R[infinity], V[m], Z[0], a[0], a[e], a[mu], alpha, b, c, c[1, L], c[1], c[2], e, epsilon[0], g, g[e], g[mu], g[n], g[p], gamma[e], gamma[n], gamma[p], gamma_prime[h], gamma_prime[p], h, hbar, k, l[P], lambda[C, mu], lambda[C, n], lambda[C, p], lambda[C, tau], lambda[C], m[P], m[alpha], m[d], m[e], `m[e]/m[mu]`, m[h], m[mu], m[n], m[p], m[tau], `m[tau]c^2`, m[u], mu[0], mu[B], mu[N], mu[d], `mu[d]/mu[e]`, mu[e], `mu[e]/mu[p]`, `mu[e]/mu_prime[p]`, mu[mu], mu[n], `mu[n]/mu_prime[p]`, mu[p], mu_prime[h], `mu_prime[h]/mu_prime[p]`, mu_prime[p], n[0], r[e], sigma, sigma[e], sigma_prime[p], t[P]

L := [c, e, hbar, epsilon[0], alpha, m['e']]

[c, e, hbar, epsilon[0], alpha, m[e]]

nops(L)

6

for j to nops(L) do assign(L[j] = GetValue(Constant(L[j]))*GetUnit(Constant(L[j]))) end do

Error, (in ScientificConstants:-Constant) Constant `m[.1602176620e-18*Units:-Unit(C)]` is not known

NULL

L

[299792458*Units:-Unit(m/s), 0.1602176620e-18*Units:-Unit(C), 0.1054571800e-33*Units:-Unit(m^2*kg/s), (625000/22468879468420441)*Units:-Unit(A^2*s^4/(m^3*kg))/Pi, 0.7297352566e-2, m[0.1602176620e-18*Units:-Unit(C)]]

c

299792458*Units:-Unit(m/s)

NULL

epsilon[0]

(625000/22468879468420441)*Units:-Unit(A^2*s^4/(m^3*kg))/Pi

``

m[e]

m[0.1602176620e-18*Units:-Unit(C)]

m['e']

m[e]

m['e'] := GetValue(Constant(m['e']))*GetUnit(Constant(m['e']))

0.9109383560e-30*Units:-Unit(kg)

m['e']

0.9109383560e-30*Units:-Unit(kg)

NULL

Download Using_the_constants_.mw

indets(..., name(assignable)) is very useful for finding the "real" variables in an expression, i.e., those to which you could assign a value, without also capturing other unwanted symbols such as Pi, infinity, undefined.

restart;

K:=2*x+I*y/Pi+Catalan*5-g(infinity)+f(undefined);

2*x+I*y/Pi+5*Catalan-g(infinity)+f(undefined)

indets(K,name(assignable));

{x, y}

Download indets.mw

If you make a larger size plot using size=[1000,1000] then you can get minimal overlap. The orientation of the plot differs each time you hit enter on the DrawGraph command, and that influences the amount of overlap, so you want to repeat until you get a nice result. Then exporting with the right-click menu to prn gives you a 1000x1000 pixel image.

Download DrawGraph.mw

This is the  output prn file:

Here I removed the singularity by multiplying by the denominator and so derived Eq. 9. Is that what you wanted or were you looking for something more? Maybe the ConservedCurrents would work after a while. But the condition in the paper does not seem to be satisfied by alpha[5]=0, n=2/3.

For the equilibria, if you don't like the complicated solutions, I think you will just have to give the parameters some numerical values and use fsolve.

restart

with(PDEtools)

with(plots)

with(plots):

with(DEtools):

undeclare(prime, quiet)

with(LinearAlgebra)

NULL

ode := n*Omega(xi)*(2*alpha[6]*n*Omega(xi)^2+alpha[5]*n*Omega(xi)+beta)*(diff(diff(Omega(xi), xi), xi))+(2*alpha[6]*n^2*Omega(xi)^2-beta*(n-1))*(diff(Omega(xi), xi))^2-n^2*Omega(xi)^2*(-alpha[4]*Omega(xi)^4-alpha[3]*Omega(xi)^3+beta*k^2-Omega(xi)^2*alpha[2]-Omega(xi)*alpha[1]+w) = 0

n*Omega(xi)*(2*alpha[6]*n*Omega(xi)^2+alpha[5]*n*Omega(xi)+beta)*(diff(diff(Omega(xi), xi), xi))+(2*alpha[6]*n^2*Omega(xi)^2-beta*(n-1))*(diff(Omega(xi), xi))^2-n^2*Omega(xi)^2*(-alpha[4]*Omega(xi)^4-alpha[3]*Omega(xi)^3+beta*k^2-Omega(xi)^2*alpha[2]-Omega(xi)*alpha[1]+w) = 0

#Typesetting:-Settings(prime=xi):
#Typesetting:-Settings(typesetprime=true):

I don't know why Q, QP doesn't work here, but you need to specify otherwise it is hard to work with the escaped locals Y and YP chosen by default.

raw := DEtools[convertsys]({ode}, {}, Omega(xi), xi, s, QP, QP)[1..2];

[[QP[1] = s[2], QP[2] = (-(2*alpha[6]*n^2*s[1]^2-beta*(n-1))*s[2]^2+n^2*s[1]^2*(-alpha[4]*s[1]^4-alpha[3]*s[1]^3+beta*k^2-alpha[2]*s[1]^2-alpha[1]*s[1]+w))/(n*s[1]*(2*n*alpha[6]*s[1]^2+n*alpha[5]*s[1]+beta))], [s[1] = Omega(xi), s[2] = diff(Omega(xi), xi)]]

Extract the denominator and scale the right hand sides by it

den:=denom(eval(QP[2],raw[1]));
raw_eta:=map(q->rhs(q)*den,raw[1]);

n*s[1]*(2*n*alpha[6]*s[1]^2+n*alpha[5]*s[1]+beta)

[s[2]*n*s[1]*(2*n*alpha[6]*s[1]^2+n*alpha[5]*s[1]+beta), -(2*alpha[6]*n^2*s[1]^2-beta*(n-1))*s[2]^2+n^2*s[1]^2*(-alpha[4]*s[1]^4-alpha[3]*s[1]^3+beta*k^2-alpha[2]*s[1]^2-alpha[1]*s[1]+w)]

Back to the real transformed variables, which are now in terms of eta.

rhs_eta := eval(raw_eta, {s[1] = Omega(eta), s[2] = y(eta)})

[y(eta)*n*Omega(eta)*(2*alpha[6]*n*Omega(eta)^2+alpha[5]*n*Omega(eta)+beta), -(2*alpha[6]*n^2*Omega(eta)^2-beta*(n-1))*y(eta)^2+n^2*Omega(eta)^2*(-alpha[4]*Omega(eta)^4-alpha[3]*Omega(eta)^3+beta*k^2-Omega(eta)^2*alpha[2]-Omega(eta)*alpha[1]+w)]

Find equilibrium points - one is at the origin; the others are a complicated mess.

equilibria := [solve(rhs_eta, {Omega(eta), y(eta)}, explicit)]; nops(%)

9

Eq 9.

de1 := diff(Omega(eta), eta) = rhs_eta[1]; de2 := diff(y(eta), eta) = rhs_eta[2]

diff(Omega(eta), eta) = y(eta)*n*Omega(eta)*(2*alpha[6]*n*Omega(eta)^2+alpha[5]*n*Omega(eta)+beta)

diff(y(eta), eta) = -(2*alpha[6]*n^2*Omega(eta)^2-beta*(n-1))*y(eta)^2+n^2*Omega(eta)^2*(-alpha[4]*Omega(eta)^4-alpha[3]*Omega(eta)^3+beta*k^2-Omega(eta)^2*alpha[2]-Omega(eta)*alpha[1]+w)

#now we need to construct conservative quantity

Following is too slow, but might work.

We want the condition diff(P,Omega) = -diff(Q,y), so we want the following to be zero

cons_eq := Physics:-diff(rhs_eta[1], Omega(eta))+Physics:-diff(rhs_eta[2], y(eta))

y(eta)*n*(2*alpha[6]*n*Omega(eta)^2+alpha[5]*n*Omega(eta)+beta)+y(eta)*n*Omega(eta)*(4*n*Omega(eta)*alpha[6]+n*alpha[5])-2*(2*alpha[6]*n^2*Omega(eta)^2-beta*(n-1))*y(eta)

According to the paper this is satisfied for alpha[5]=0,n=2/3 but this seems not to be the case.

factor(cons_eq); eval(%, {n = 2/3, alpha[5] = 0})

y(eta)*(2*alpha[6]*n^2*Omega(eta)^2+2*Omega(eta)*alpha[5]*n^2+3*beta*n-2*beta)

(8/9)*y(eta)*alpha[6]*Omega(eta)^2

``

Download bi-1.mw

Following @rcorless's suggestion, a "dimensional" analysis allows us to eliminate two variables, but we still cannot solve it in any reasonable time; the same conclusion that @sand15 came to.

restart

with(LinearAlgebra); with(SolveTools)

K2 := -(Pn-Pr)/(1-delta)+(-beta*((-2*delta+2)*tau^2+((-Pn+Pr-delta+1)*Cr+(-2+2*delta)*(w+i2))*tau+Cr*i2*(-1+delta+Pn-Pr))*upsilon/((4*delta-4)*tau+Cr*(-1+delta+Pn-Pr))+Pr)/delta+(Pr-w-Cr)*beta*(-2+2*delta)*tau*upsilon/(((4*delta-4)*tau+Cr*(-1+delta+Pn-Pr))*delta) = 0

K3 := 1-(Pn-Pr)/(1-delta)-(Pn-Cn)/(1-delta)+(Pr-w-Cr)*(1/(1-delta)-(-beta*(Cr*i2-Cr*tau)*upsilon/((4*delta-4)*tau+Cr*(-1+delta+Pn-Pr))+beta*((-2*delta+2)*tau^2+((-Pn+Pr-delta+1)*Cr+(-2+2*delta)*(w+i2))*tau+Cr*i2*(-1+delta+Pn-Pr))*upsilon*Cr/((4*delta-4)*tau+Cr*(-1+delta+Pn-Pr))^2)/delta)+Ce*rho0/(1-delta) = 0

K4 := (Pn-Cn)/(1-delta)+(Pn-Pr)/(1-delta)-(-beta*((-2*delta+2)*tau^2+((-Pn+Pr-delta+1)*Cr+(-2+2*delta)*(w+i2))*tau+Cr*i2*(-1+delta+Pn-Pr))*upsilon/((4*delta-4)*tau+Cr*(-1+delta+Pn-Pr))+Pr)/delta+(Pr-w-Cr)*(-1/(1-delta)-(-beta*(-Cr*i2+Cr*tau)*upsilon/((4*delta-4)*tau+Cr*(-1+delta+Pn-Pr))-beta*((-2*delta+2)*tau^2+((-Pn+Pr-delta+1)*Cr+(-2+2*delta)*(w+i2))*tau+Cr*i2*(-1+delta+Pn-Pr))*upsilon*Cr/((4*delta-4)*tau+Cr*(-1+delta+Pn-Pr))^2+1)/delta)-Ce*rho0/(1-delta) = 0

vars := {Pn, Pr, w}

{Pn, Pr, w}

Write as numerator over denominator then just take the numerators, which we want equal to zero.

Q2 := numer(normal(lhs(K2))); Q3 := numer(normal(lhs(K3))); Q4 := numer(normal(lhs(K4)))

Let's try @rcorless's suggestion to reduce the number of variables.
All the terms in Q2 have the same dimensions. If we divide all terms by the first term, then each of the new terms is dimensionless.

Q2nondims := op(2 .. (), expand(Q2/op(1, Q2)))

Pr*tau/(Pn*i2), -2*delta*Pr*tau/(Cr*Pn*i2), 4*delta*tau*w/(Cr*Pn*i2), -Pr*tau/(Pn*delta*i2), 4*Pr*tau/(Cr*Pn*i2), -8*tau*w/(Cr*Pn*i2), -2*Pr*tau/(Cr*Pn*delta*i2), 4*tau*w/(Cr*Pn*delta*i2), 4*Pr*tau/(Cr*Pn*beta*i2*upsilon), -4*Pr*tau/(Cr*Pn*beta*delta*i2*upsilon), -1/delta, -tau/i2, -Pr/Pn, delta*tau/(Pn*i2), 2*delta*tau/(Cr*Pn), -2*delta*tau^2/(Cr*Pn*i2), tau/(delta*i2), Pr/(Pn*delta), -2*tau/(Pn*i2), -4*tau/(Cr*Pn), 4*tau^2/(Cr*Pn*i2), Pr/(beta*i2*upsilon), tau/(Pn*delta*i2), -4*delta*tau/(Cr*beta*i2*upsilon), 2*tau/(Cr*Pn*delta), -2*tau^2/(Cr*Pn*delta*i2), Pr/(beta*delta*i2*upsilon), -Pr^2/(Pn*beta*delta*i2*upsilon), Pr/(Pn*beta*i2*upsilon), 4*tau/(Cr*beta*i2*upsilon), -Pr/(Pn*beta*delta*i2*upsilon), 1/(beta*i2*upsilon), -2/Pn, -Pn/(beta*i2*upsilon), -delta/(beta*i2*upsilon), 1/(Pn*delta), delta/Pn

Combine with the ones from Q3 and Q4 and remove duplicates. We want the "real" variables Pr, Pn and w last.

terms := [{Q2nondims, op(2 .. (), expand(Q3/op(1, Q3))), op(2 .. (), expand(Q4/op(1, Q4)))}[]]; nterms := nops(terms); allvars := [(`minus`(indets(terms), vars))[], vars[]]; nvars := nops(allvars)

386

[Ce, Cn, Cr, beta, delta, i2, rho0, tau, upsilon, Pn, Pr, w]

12

We construct a matrix K that contains the powers of allvars (rows) in each of the terms (columns)
Matrix K has 12 rows but rank 10, so we can eliminate 12-10=2 variables. The code below shows we can, for example eliminate beta and Ce (these are the ones = 1 in "rewrites").

K := Matrix(nvars, nterms, (i, j) -> diff(terms[j], allvars[i])*allvars[i]/terms[j]):
DataFrame(K,rows=allvars,columns=[$nops(terms)]);
r1:=Rank(K);

DataFrame(_rtable[36893490580276833924], rows = [Ce, Cn, Cr, beta, delta, i2, rho0, tau, upsilon, Pn, Pr, w], columns = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386])

10

Some technical stuff. See E. Hubert, G, Labahn, Found Comput Math 13 (2013) 479–516, doi:10.1007/s10208-013-9165-9.

or https://youtu.be/Nl2FBAbU1pE

H, U := HermiteForm(K, output = ['H', 'U'], method = 'integer'):
Determinant(U):
A := U[-nvars + r1 .. -1, ..]:
rA := Rank(A):
V:=ColumnHermiteFormSpecial(A): #ColumnHermiteFormSpecial is in startup region
# Find the non-dim variables
nondims := table():
for i to nvars-rA do
        nondimvars[i]:=cat(allvars[i+rA], "__new");
        nondims[i] := nondimvars[i] = mul(allvars^~V[.., i+rA]);
end do:
nondimvars:=convert(nondimvars,list):
nondims:=convert(nondims, list);
W:=V^(-1):
Wd:=W[-(nvars-rA)..-1,..]:
rewrites := table():
for i to nvars do
        rewrites[i] := allvars[i] = mul(nondimvars^~Wd[.., i])
end do:
rewrites := convert(rewrites, list);

[Cr__new = Cn, beta__new = Cr, delta__new = delta, i2__new = i2, rho0__new = Ce*rho0, tau__new = tau, upsilon__new = beta*upsilon, Pn__new = Pn, Pr__new = Pr, w__new = w]

[Ce = 1, Cn = Cr__new, Cr = beta__new, beta = 1, delta = delta__new, i2 = i2__new, rho0 = rho0__new, tau = tau__new, upsilon = upsilon__new, Pn = Pn__new, Pr = Pr__new, w = w__new]

The naming isn't optimal here so we'll ignore it and make up our own. Basically (see nondims), we can leave all variables the same except introduce R=Ce*rho0, B=beta*upsilon. (I used R instead of rho0__new, B instead of upsilon_new.) So we need to do the following substitutions to get rid of Ce and beta.

eqBR := {B = beta*upsilon, R = Ce*rho0}; eqCebeta := solve(eqBR, {Ce, beta}); eqs := eval({Q2, Q3, Q4}, eqCebeta); newvars := indets(eqs)

{B = beta*upsilon, R = Ce*rho0}

{Ce = R/rho0, beta = B/upsilon}

{B, Cn, Cr, Pn, Pr, R, delta, i2, tau, w}

We are down to 3 unknowns and 7 parameters, but this is still too hard for solve. Trying a polynomial solve specifying that we want vars in terms of the others is still too slow. We can get solutions without backsubstitution if we let it choose the solver choose the variable order by specifying newvars as a set.

sols := [PolynomialSystem(eqs, newvars, engine = triade, backsubstitute = false)]; nops(%)

8

We have 8 solutions. Some are simple, e.g. tau=Cr=0.  We should check that even if they solve {Q2,Q3,Q4}, they also don't give a division by zero error for {K2,K3,K4}

sols[2]; eval({Q2, Q3, Q4}, {Cr = 0, tau = 0}); eval({K2, K3, K4}, {Cr = 0, tau = 0})

[[tau, Cr], {}]

{0}

Error, numeric exception: division by zero

For solution 1 we have B=0 (so either beta=0 or upsilon=0), and a range of solutions only for particular relationships involving Pn-Pr, not Pn and Pr separately. The solution is only valid when delta is not 1.

sols[1]; eqPn := isolate(%[1][2], Pn); simplify(eval(eval({Q2, Q3, Q4}, eqBR), {eqPn, beta = 0})); simplify(eval(eval({K2, K3, K4}, eqBR), {eqPn, beta = 0}))

[[B, (4*delta-4)*tau+Cr*(-Pr+Pn+delta-1)], {4*delta-4 <> 0}]

Pn = -(4*delta-4)*tau/Cr+Pr-delta+1

{0}

Error, numeric exception: division by zero

This one also depends on Pn-Pr

sols[3]; simplify(eval(eval({Q2, Q3, Q4}, eqBR), {Pn = Pr-delta+1, tau = 0})); simplify(eval(eval({K2, K3, K4}, eqBR), {Pn = Pr-delta+1, tau = 0}))

[[tau, Pr-Pn-delta+1], {}]

{0}

Error, numeric exception: division by zero

Cr = 0 and delta=1 is a solution but not to the originals

sols[4]; eval({Q2, Q3, Q4}, {Cr = 0, delta = 1}); eval({K2, K3, K4}, {Cr = 0, delta = 1})

[[Cr, delta-1], {}]

{0}

Error, numeric exception: division by zero

The next one has only the combination Pr-Pn=0 i.e. Pr=Pn

sols[5]; eval({Q2, Q3, Q4}, {Pr = Pn, delta = 1}); eval({K2, K3, K4}, {Pr = Pn, delta = 1})

[[Pr-Pn, delta-1], {}]

{0}

Error, numeric exception: division by zero

Similar to above but a more complicated relationship. For a given Pr we can get w and Pn. delta=0

sols[8]; eqwPn := eval(solve(%[1][1 .. 2], {Pn, w}), eqBR); simplify(eval(eval({Q2, Q3, Q4}, eqBR), {eqwPn[], delta = 0})); simplify(eval(eval({K2, K3, K4}, eqBR), {eqwPn[], delta = 0}))

[[((-Pn+Pr+1)*Cr+2*tau)*B*i2+(-2*tau^2+((Pn-Pr-3)*Cr+2*Pr)*tau)*B-4*tau*Pr+((Pn-1)*Pr-Pr^2)*Cr, w+Cr-Pr, delta], {((-Pn+Pr+1)*Cr+2*tau)*B <> 0}]

{Pn = (Cr*Pr*beta*i2*upsilon-Cr*Pr*beta*tau*upsilon+Cr*beta*i2*upsilon-3*Cr*beta*tau*upsilon+2*Pr*beta*tau*upsilon+2*beta*i2*tau*upsilon-2*beta*tau^2*upsilon-Cr*Pr^2-Cr*Pr-4*Pr*tau)/(Cr*(beta*i2*upsilon-beta*tau*upsilon-Pr)), w = -Cr+Pr}

{0}

Error, numeric exception: division by zero

In this case we get a solution for all of Pr,Pn,w for {Q2,Q3,Q4} but not for the original system. Close!

sols[7]; eqwPn := eval(solve(%[1], {Pn, Pr, w}), eqBR); simplify(eval(eval({Q2, Q3, Q4}, eqBR), eqwPn)); simplify(eval(eval({K2, K3, K4}, eqBR), eqwPn))

[[(Pr-Pn-delta+1)*Cr*i2+(4*delta-4)*tau^2+((2*Pn-2*Pr+6*delta-6)*Cr+(-4*delta+4)*Pr)*tau, w+Cr-Pr, (4*delta-4)*tau+Cr*(-Pr+Pn+delta-1)], {(Pr-Pn-delta+1)*Cr <> 0, 4*delta-4 <> 0}]

{Pn = (Cr^2-Cr*delta+Cr*i2-Cr*tau-4*delta*tau+Cr+4*tau)/Cr, Pr = i2-tau+Cr, w = i2-tau}

{0}

Error, (in simplify/normal) numeric exception: division by zero

And now the hard one, which is probably not so different from the original

sol6 := sols[6][1]; nops(%); map(indets, sol6)

3

[{B, Cn, Cr, Pn, Pr, R, delta, i2, tau, w}, {B, Cr, Pn, Pr, delta, i2, tau, w}, {B, Cr, Pn, Pr, delta, tau, w}]

And we still cannot solve this in any reasonable time.

sol6b := PolynomialSystem(sol6, vars, engine = triade)

NULL

 

Download Q_solve2.mw

Corrected. I entered psi(y) directly instead of using psi:=psi(y). You can use diff_table to shorten how the odes are entered, but then you also shorten how the derivatives are entered.

The first and second derivatives of a function of 1 variable are D(psi)(1) and (D@@2)(psi)(1); the D[1] and D[2] notation means derivative wrt 1st or 2nd variable if you have a function of two variables.

OdeSys and Cond should have been sequences not lists; you then can combine them into the single list [OdeSys,Cond].

I changed the y range from -1.5..1.5 to -1..1 to agree with the bcs otherwise odeplot gives a warning and changes them anyway.

All your plots are on top of each other; I guess the value of Rd doesn't make much difference.

restart; with(DEtools); with(plots); Mn := .1; We := .1; Omega := .1; Grt := .1; Grc := .1; Grf := .1; Pr := .1; Nb := .1; Nt := .1; Ntc := .1; Nct := .1; beta := .1; alpha := .1; f := .1; eq1 := diff(psi(y), `$`(y, 4))-Mn^2*(diff(psi(y), `$`(y, 2)))/(Omega^2+1)+Grt*theta(y)+Grc*phi(y)-Grf*gamma(y)-2*We^2*(Mn^2*(diff(psi(y), `$`(y, 2)))/(Omega^2+1)-Grt*theta(y)-Grc*phi(y)+Grf*gamma(y))^3 = 0; eq2 := (Pr*Rd+1)*(diff(theta(y), `$`(y, 2)))+Nb*Pr*(diff(theta(y), y))*(diff(gamma(y), y))+Nt*Pr*(diff(theta(y), y))^2+Ntc*Pr*(diff(phi(y), `$`(y, 2)))+beta = 0; eq3 := diff(phi(y), `$`(y, 2))+Nct*(diff(theta(y), `$`(y, 2))) = 0; eq4 := diff(gamma(y), `$`(y, 2))+Nt*(diff(theta(y), `$`(y, 2)))/Nb = 0; bc1 := psi(1) = (1/2)*f, (D(psi))(1)-alpha*((D@@2)(psi))(1) = -1, theta(1) = 0, phi(1) = 0, gamma(1) = 0; bc2 := psi(-1) = -(1/2)*f, (D(psi))(-1)+alpha*((D@@2)(psi))(-1) = -1, theta(-1) = 1, phi(-1) = 1, gamma(-1) = 1; OdeSys := eq1, eq2, eq3, eq4; Cond := bc1, bc2; RdVals := [.1, .8, 1.6, 2.4]; for j to numelems(RdVals) do Ans[j] := dsolve(eval([OdeSys, Cond], Rd = RdVals[j]), numeric, output = listprocedure) end do; cols := [red, blue, black, green]; plotA := display([seq(odeplot(Ans[k], [y, psi(y)], y = -1 .. 1, color = cols[k], thickness = 2), k = 1 .. numelems(RdVals))], axes = boxed, labels = ["y", "&psi;(y)"], title = Typesetting:-mtext("Steady Velocity distribution", color = red), size = [600, 600]); display(plotA)

NULL

Download pulatile_flow_error.mw

Your description is not very clear, but I think the following does what you want.

restart

with(combstruct)

n := 4; k := 2

4

2

Define trees with k branches from each node. Z here is a leaf on the tree.

sys := {Tree = Union(Z, Prod(`$`(Tree, k)))}

{Tree = Union(Z, Prod(Tree, Tree))}

Find all possibilities

all := allstructs([Tree, sys], size = n)

[Prod(Z, Prod(Z, Prod(Z, Z))), Prod(Z, Prod(Prod(Z, Z), Z)), Prod(Prod(Z, Z), Prod(Z, Z)), Prod(Prod(Z, Prod(Z, Z)), Z), Prod(Prod(Prod(Z, Z), Z), Z)]

Convert the Prod(...) to [...]

lists := eval(all, Prod = (proc () options operator, arrow; [args] end proc))

[[Z, [Z, [Z, Z]]], [Z, [[Z, Z], Z]], [[Z, Z], [Z, Z]], [[Z, [Z, Z]], Z], [[[Z, Z], Z], Z]]

The LeafToSymbol routine below then substitutes the a,b,c,d for the Z's

Here is a procedure to carry out the whole thing

Groupings := proc(L::list(symbol), k::posint)
local Tree, Leaf, sys, n, lists, LeafToSymbol;
LeafToSymbol := proc(lst) local S, x;
  S:=String(lst);
  for x in L do
    S := StringTools:-Substitute(S, "Leaf", String(x));
  end do;
  parse(S)
end proc;
if k = 1 then error "k must be greater than 1" end if;
n := nops(L);
sys := {Tree = 'Union'(Leaf, 'Prod'(Tree $ k)), Leaf = 'Atom'};
lists := eval(combstruct['allstructs']([Tree, sys], 'size' = n), 'Prod' = (()->[args]));
map(LeafToSymbol, lists);
end proc:

Groupings([a, b, c, d], 2)

[[a, [b, [c, d]]], [a, [[b, c], d]], [[a, b], [c, d]], [[a, [b, c]], d], [[[a, b], c], d]]

NULL

Download Groupings.mw

On a technical note, there has to be a more elegant way to implement LeafToSymbol that doesn't involve conversion to a string, string proccessing and parse, but I'm out of ideas today. 

Here's one way to look at the matrix (in Maple 2025 there is also a colorbar that doesn't display here).

restart

with(ImageTools); with(LinearAlgebra)

M := (1/255)*RandomMatrix(8, generator = 0 .. 255); G := convert(M, Image); Embed(G)

plots:-matrixplot(M, dimension = 2)

NULL

Download image.mw

For your new question, I believe this is what you want?

Simultaneously_solve.mw

You had an extra 0=0 equation. Not sure that made much difference, but more importantly if you leave out the explicit option, you get back 66 solutions in a quite short time. If they have RootOfs, you can use allvalues on them. If you want to keep option explicit and wait longer, you could try maxsols=200 (or perhaps infinity)

 f-p-.mw

[Edited] The immediate error is just because solve returned NULL. You can find a parametric solution (at least in Maple 2025).

There are very many parameters here. What sort of answer do you want here - many specifications of say 10 different conditiions between parameters that leads to the relation being true? If so you could look more into the parametric solution that Maple provides. Note that many of the cases are for negative parameters and so not of interest. Making assumptions might narrow down the possibilities but the time will likely be too long. A full analysis might also be possible with the tools in the regular chains package.

Otherwise a more manual solution might make some progress, but would need more input about feasible parameter ranges, e.g., you may know that delta<1 or eta>1.

restart

kernelopts(version)

`Maple 2025.1, X86 64 WINDOWS, Jun 12 2025, Build ID 1932578`

ineq := rho*(1-(Pn-Pr)/(1-delta)+eta*(Pn-Pr)/(1-delta)) <= (1/2+(i1-i2)/(2*tau))*(1-(-beta*i1*upsilon+Pr)/delta)-eta*(-beta*i1*upsilon+Pr)/delta

rho*(1-(Pn-Pr)/(1-delta)+eta*(Pn-Pr)/(1-delta)) <= (1/2+(1/2)*(i1-i2)/tau)*(1-(-beta*i1*upsilon+Pr)/delta)-eta*(-beta*i1*upsilon+Pr)/delta

temp := collect(ineq,i1);

rho*(1-(Pn-Pr)/(1-delta)+eta*(Pn-Pr)/(1-delta)) <= (1/2)*beta*upsilon*i1^2/(tau*delta)+((1/2-(1/2)*i2/tau)*beta*upsilon/delta+(1/2)*(1-Pr/delta)/tau+eta*beta*upsilon/delta)*i1+(1/2-(1/2)*i2/tau)*(1-Pr/delta)-eta*Pr/delta

Move the lhs over to the rhs

temp2 := temp-lhs(temp)

0 <= (1/2)*beta*upsilon*i1^2/(tau*delta)+((1/2-(1/2)*i2/tau)*beta*upsilon/delta+(1/2)*(1-Pr/delta)/tau+eta*beta*upsilon/delta)*i1+(1/2-(1/2)*i2/tau)*(1-Pr/delta)-eta*Pr/delta-rho*(1-(Pn-Pr)/(1-delta)+eta*(Pn-Pr)/(1-delta))

It looks as thogh Maple can solve the whole problem, but it will be a nightmare sorting through the various 1368 cases (and the "otherwise" case).

sol := solve(temp2, i1, parametric); length(%); (nops(`%%`)-1)*(1/2)

1586597

1368

A typical condition and result.

case := 520; op(2*case-1, sol); op(2*case, sol)

520

And(delta < 0, 0 < tau, upsilon < 0, 1 < eta, 0 < beta, rho = 0)

[[i1 <= (1/2)*(-2*beta*eta*upsilon*tau+i2*beta*upsilon-beta*upsilon*tau+(4*beta^2*eta^2*upsilon^2*tau^2-4*i2*beta^2*eta*upsilon^2*tau+4*beta^2*eta*upsilon^2*tau^2+i2^2*beta^2*upsilon^2-2*i2*beta^2*upsilon^2*tau+beta^2*upsilon^2*tau^2+4*Pr*beta*eta*upsilon*tau+4*beta*eta*upsilon*tau*delta-2*Pr*i2*beta*upsilon+2*Pr*beta*upsilon*tau+2*i2*beta*upsilon*delta-2*beta*upsilon*tau*delta+Pr^2-2*Pr*delta+delta^2)^(1/2)+Pr-delta)/(beta*upsilon)], [-(1/2)*(2*beta*eta*upsilon*tau-i2*beta*upsilon+beta*upsilon*tau-Pr+delta+(4*beta^2*eta^2*upsilon^2*tau^2-4*i2*beta^2*eta*upsilon^2*tau+4*beta^2*eta*upsilon^2*tau^2+i2^2*beta^2*upsilon^2-2*i2*beta^2*upsilon^2*tau+beta^2*upsilon^2*tau^2+4*Pr*beta*eta*upsilon*tau+4*beta*eta*upsilon*tau*delta-2*Pr*i2*beta*upsilon+2*Pr*beta*upsilon*tau+2*i2*beta*upsilon*delta-2*beta*upsilon*tau*delta+Pr^2-2*Pr*delta+delta^2)^(1/2))/(beta*upsilon) <= i1]]

Let's simplify by collecting the complicated combinations of parameters into simpler parameters

params:={(a,b,c)=~(seq(coeff(rhs(temp2),i1,k),k=2..0,-1))};

{a = (1/2)*beta*upsilon/(tau*delta), b = (1/2-(1/2)*i2/tau)*beta*upsilon/delta+(1/2)*(1-Pr/delta)/tau+eta*beta*upsilon/delta, c = (1/2-(1/2)*i2/tau)*(1-Pr/delta)-eta*Pr/delta-rho*(1-(Pn-Pr)/(1-delta)+eta*(Pn-Pr)/(1-delta))}

So in simpler form we have

temp3 := 0 <= a*i1^2 + b*i1 + c;

0 <= a*i1^2+b*i1+c

solve(temp3, i1, parametric)

piecewise(And(a = 0, b = 0, 0 <= c), [[i1 = i1]], And(a = 0, 0 < b), [[-c/b <= i1]], And(a = 0, b < 0), [[i1 <= -c/b]], And(0 < a, (1/4)*b^2/a <= c), [[i1 = i1]], And(0 < a, c < (1/4)*b^2/a), [[i1 <= -(1/2)*(b+(-4*a*c+b^2)^(1/2))/a], [(1/2)*(-b+(-4*a*c+b^2)^(1/2))/a <= i1]], And(a < 0, (1/4)*b^2/a <= c), [[(1/2)*(-b+(-4*a*c+b^2)^(1/2))/a <= i1, i1 <= -(1/2)*(b+(-4*a*c+b^2)^(1/2))/a]], [])

Aside from the cases with b=0, there are three different cases, depending on the value of d = -4*a*c+b^2, which is just the discriminant of the quadratic a*i1^2+b*i1+c. We want to know the values of i1 for which the parabola is above the i1 axis. Since a is positive, the parabola is not inverted. If d < 0 the roots are complex, and the whole parabola is above the axis. This is case 4. If  d >= 0 the roots are real (part of the parabola is below/on the axis) and for the relation to hold i1 must be greater than the more positive root or less than the more negative root (outside the interval between the roots) - this is case 5. Case 6 is for a<0, which is not of interest.

So we want to find when the discriminant is positive or negative

d := simplify(eval(-4*a*c+b^2, params))

-2*((1/2-(1/2)*i2/tau)*(1-Pr/delta)-eta*Pr/delta-rho*(1-(Pn-Pr)/(1-delta)+eta*(Pn-Pr)/(1-delta)))*beta*upsilon/(tau*delta)+(1/4)*(upsilon*((-2*eta-1)*tau+i2)*beta-delta+Pr)^2/(tau^2*delta^2)

This is going to depend on the exact values of the parameters and is still a complicated problem. But if you know some extra conditions you might be able to narrow it down. For example it seems important to know if delta<1

`assuming`([coulditbe(d >= 0)], [eta > 1, delta < 1, Pn > Pr, delta > 0])

true

So this is progress, but not enough to narrow it down

`assuming`([is(d >= 0)], [eta > 1, delta < 1, Pn > Pr, delta > 0])

false

solve(d = 0)

{Pn = (1/8)*(4*beta^2*delta*eta^2*tau^2*upsilon^2-4*beta^2*delta*eta*i2*tau*upsilon^2+4*beta^2*delta*eta*tau^2*upsilon^2-4*beta^2*eta^2*tau^2*upsilon^2+8*Pr*beta*delta*eta*rho*tau*upsilon+beta^2*delta*i2^2*upsilon^2-2*beta^2*delta*i2*tau*upsilon^2+beta^2*delta*tau^2*upsilon^2+4*beta^2*eta*i2*tau*upsilon^2-4*beta^2*eta*tau^2*upsilon^2+4*Pr*beta*delta*eta*tau*upsilon-8*Pr*beta*delta*rho*tau*upsilon-beta^2*i2^2*upsilon^2+2*beta^2*i2*tau*upsilon^2-beta^2*tau^2*upsilon^2+4*beta*delta^2*eta*tau*upsilon+8*beta*delta^2*rho*tau*upsilon-2*Pr*beta*delta*i2*upsilon+2*Pr*beta*delta*tau*upsilon-4*Pr*beta*eta*tau*upsilon+2*beta*delta^2*i2*upsilon-2*beta*delta^2*tau*upsilon-4*beta*delta*eta*tau*upsilon-8*beta*delta*rho*tau*upsilon+2*Pr*beta*i2*upsilon-2*Pr*beta*tau*upsilon-2*beta*delta*i2*upsilon+2*beta*delta*tau*upsilon+Pr^2*delta-2*Pr*delta^2+delta^3-Pr^2+2*Pr*delta-delta^2)/(rho*beta*upsilon*tau*delta*(eta-1)), Pr = Pr, beta = beta, delta = delta, eta = eta, i2 = i2, rho = rho, tau = tau, upsilon = upsilon}

NULL

Download Question_Isolate_i1.mw

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