tomleslie

6247 Reputation

17 Badges

10 years, 107 days

MaplePrimes Activity


These are answers submitted by tomleslie

to select those sublists from main list which fulfil certain criteria, as in the "toy" example in the attached?

The fact that some sublist strings contain '\', which may/may not be interpreted as an 'escape' character might make the file import process a bit "fiddly" - but since you do not provide the original csv file, I can't tell just how much of an issue this might be.

  restart:
  testList:= [
               ["MsMpEng.exe",         14480, "N/A",              "Unknown"],
               ["NisSrv.exe",          16092, "N/A",              "Unknown"],
               ["MicrosoftEdgeCP.exe", 4280,  "VAGRANTASP\\Adam", "Running"],
               ["MicrosoftEdgeCP.exe", 22488, "VAGRANTASP\\Adam", "Running"]
             ];
  testString:="VAGRANTASP\\Adam";

[["MsMpEng.exe", 14480, "N/A", "Unknown"], ["NisSrv.exe", 16092, "N/A", "Unknown"], ["MicrosoftEdgeCP.exe", 4280, "VAGRANTASP\Adam", "Running"], ["MicrosoftEdgeCP.exe", 22488, "VAGRANTASP\Adam", "Running"]]

 

"VAGRANTASP\Adam"

(1)

#
# Select only those sublists from testList which have
# the string 'testString' as the third entry
#
  select( j->evalb(j[3]=testString), testList);

[["MicrosoftEdgeCP.exe", 4280, "VAGRANTASP\Adam", "Running"], ["MicrosoftEdgeCP.exe", 22488, "VAGRANTASP\Adam", "Running"]]

(2)

  

 

Download selStr.mw

to start with a "simpler" solution, before figuring out how Carl's "sophisticcated version does what it does

As in the attached

  restart:
  with(plots):
  ode:= diff(theta(t),t) = 1+A+(A-1)*cos(theta(t));
  Q:= dsolve({ode, theta(0)= -Pi/2}, numeric, parameters= [A]);

diff(theta(t), t) = 1+A+(A-1)*cos(theta(t))

 

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 := [A = A]; _dtbl := array( 1 .. 4, [( 1 ) = (array( 1 .. 26, [( 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..63, {(1) = 1, (2) = 1, (3) = 0, (4) = 0, (5) = 1, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 0, (11) = 0, (12) = 0, (13) = 0, (14) = 0, (15) = 0, (16) = 0, (17) = 0, (18) = 0, (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}, datatype = integer[8])), ( 5 ) = (Array(1..28, {(1) = .0, (2) = 0.10e-5, (3) = .0, (4) = 0.500001e-14, (5) = .0, (6) = .0, (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) = -1.57079632679490, (2) = Float(undefined)})), ( 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}, 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..1, 1..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) = .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..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..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..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..1, {(1) = .0}, 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] = theta(t)]`; YP[1] := 1+Y[2]+(Y[2]-1)*cos(Y[1]); 0 end proc, -1, 0, 0, 0, 0, 0, 0, 0, 0]), ( 13 ) = (), ( 12 ) = (), ( 15 ) = ("rkf45"), ( 14 ) = ([0, 0]), ( 18 ) = ([]), ( 19 ) = (0), ( 16 ) = ([0, 0, 0, 0, 0, []]), ( 17 ) = ([proc (N, X, Y, YP) option `[Y[1] = theta(t)]`; YP[1] := 1+Y[2]+(Y[2]-1)*cos(Y[1]); 0 end proc, -1, 0, 0, 0, 0, 0, 0, 0, 0]), ( 22 ) = (0), ( 23 ) = (0), ( 20 ) = ([]), ( 21 ) = (0), ( 26 ) = (Array(1..0, {})), ( 25 ) = (Array(1..0, {})), ( 24 ) = (0)  ] ))  ] ); _y0 := Array(0..2, {(1) = 0., (2) = -1.57079632679490}); _vmap := array( 1 .. 1, [( 1 ) = (1)  ] ); _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 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, theta(t)], (4) = [A = A]}); _vars := _dat[3]; _pars := map(rhs, _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

(1)

#
# Procedure which returns a solution plot for any
# supplied value of the parameter A
#
  getPlot:= proc( Aval )
                  Q(parameters=[Aval]);
                  odeplot( Q,
                           [t, theta(t)],
                           t=-2..2,
                           color= COLOR(HUE, .85*(Aval+1))
                         )
            end proc:

#
# Generate a plot for (say) A=0.25, just as an example
#
  getPlot(0.5);

 

#
# Generate plots for all values of the parameter 'A' from
# -1 to 1 in steps of 0.2
#
  display( [ seq
             ( getPlot(j),
               j=-1..1, 0.2
             )
           ]
         );

 

 

Download odeplts.mw

the value of 'B' is complex.

'B' is only real when either a=0, or a>=44460.18115.

See the attached

  restart;
  expr:=(7.72-7.72*B)*(-7.717267500*a) = 662204.4444*B^2:
#
# Isolate 'B'
#
  sol:=unapply( isolate( expr, B),a);
#
# Compte B for any value of 'a' from 0 to 100000
# in steps of 1000. For any value of 'a' less
# than 45000 (approximately), the value of B will
# be complex
#
  seq( [a, evalc(sol(a))], a=0..100000, 1000);

proc (a) options operator, arrow; B = 0.4498407222e-4*a-0.2265161481e-12*(0.3943839203e17*a^2-0.1753438054e22*a)^(1/2) end proc

 

[0, B = 0.], [1000, B = 0.4498407222e-1-.2965545105*I], [2000, B = 0.8996814444e-1-.4145383237*I], [3000, B = .1349522167-.5016894782*I], [4000, B = .1799362889-.5722722338*I], [5000, B = .2249203611-.6318635559*I], [6000, B = .2699044333-.6833450543*I], [7000, B = .3148885055-.7284382198*I], [8000, B = .3598725778-.7682687570*I], [9000, B = .4048566500-.8036195575*I], [10000, B = .4498407222-.8350597397*I], [11000, B = .4948247944-.8630168081*I], [12000, B = .5398088666-.8878198696*I], [13000, B = .5847929389-.9097269349*I], [14000, B = .6297770111-.9289429145*I], [15000, B = .6747610833-.9456318768*I], [16000, B = .7197451555-.9599256334*I], [17000, B = .7647292277-.9719298655*I], [18000, B = .8097133000-.9817285628*I], [19000, B = .8546973722-.9893872580*I], [20000, B = .8996814444-.9949553694*I], [21000, B = .9446655166-.9984678733*I], [22000, B = .9896495888-.9999464330*I], [23000, B = 1.034633661-.9994000747*I], [24000, B = 1.079617733-.9968254693*I], [25000, B = 1.124601806-.9922068281*I], [26000, B = 1.169585878-.9855154131*I], [27000, B = 1.214569950-.9767086241*I], [28000, B = 1.259554022-.9657285897*I], [29000, B = 1.304538094-.9525001568*I], [30000, B = 1.349522167-.9369280946*I], [31000, B = 1.394506239-.9188932620*I], [32000, B = 1.439490311-.8982473303*I], [33000, B = 1.484474383-.8748054478*I], [34000, B = 1.529458455-.8483358673*I], [35000, B = 1.574442528-.8185449174*I], [36000, B = 1.619426600-.7850545756*I], [37000, B = 1.664410672-.7473676862*I], [38000, B = 1.709394744-.7048113905*I], [39000, B = 1.754378817-.6564393353*I], [40000, B = 1.799362889-.6008485429*I], [41000, B = 1.844346961-.5357967983*I], [42000, B = 1.889331033-.4572639427*I], [43000, B = 1.934315105-.3564481499*I], [44000, B = 1.979299178-.2024181823*I], [45000, B = 1.802571328], [46000, B = 1.690674392], [47000, B = 1.622767753], [48000, B = 1.572867948], [49000, B = 1.533291303], [50000, B = 1.500531679], [51000, B = 1.472651463], [52000, B = 1.448452389], [53000, B = 1.427135789], [54000, B = 1.408139971], [55000, B = 1.391053575], [56000, B = 1.375565631], [57000, B = 1.361434997], [58000, B = 1.348470706], [59000, B = 1.336518858], [60000, B = 1.325453547], [61000, B = 1.315170443], [62000, B = 1.305582112], [63000, B = 1.296614572], [64000, B = 1.288204655], [65000, B = 1.280298017], [66000, B = 1.272847578], [67000, B = 1.265812283], [68000, B = 1.259156137], [69000, B = 1.252847404], [70000, B = 1.246857984], [71000, B = 1.241162865], [72000, B = 1.235739711], [73000, B = 1.230568491], [74000, B = 1.225631182], [75000, B = 1.220911513], [76000, B = 1.216394749], [77000, B = 1.212067507], [78000, B = 1.207917598], [79000, B = 1.203933905], [80000, B = 1.200106245], [81000, B = 1.196425279], [82000, B = 1.192882430], [83000, B = 1.189469791], [84000, B = 1.186180073], [85000, B = 1.183006535], [86000, B = 1.179942930], [87000, B = 1.176983473], [88000, B = 1.174122779], [89000, B = 1.171355848], [90000, B = 1.168678012], [91000, B = 1.166084920], [92000, B = 1.163572509], [93000, B = 1.161136970], [94000, B = 1.158774746], [95000, B = 1.156482493], [96000, B = 1.154257077], [97000, B = 1.152095546], [98000, B = 1.149995132], [99000, B = 1.147953221], [100000, B = 1.145967351]

(1)

#
# Actual value of 'a' at which 'B' stops being complex
# appears to be 44460.18115
#
  isolate( expr, B);
  fsolve(op([2,2,2,1],%));

B = 0.4498407222e-4*a-0.2265161481e-12*(0.3943839203e17*a^2-0.1753438054e22*a)^(1/2)

 

0., 44460.18115

(2)

 


 

Download complexB.mw

Using the VectorCalculus:-Laplacian() function just to get the second (spatial) derivative seems a bit "overkill" - not wrong, just a bit unnecessary.

What is wrong with the attached?

  restart;
  PDE := diff(u(x, t), t) - diff(u(x, t), x$2) - u(x, t) + x - 2*sin(2*x)*cos(x) = 0;
  IBC := D[1](u)(Pi/2, t) = 1, u(0, t) = 0, u(x, 0) = x;
  pds := pdsolve(eval(PDE), {IBC}, type = numeric);
  pds:-plot3d( u(x,t), x=0..Pi/2, t=0..10);

diff(u(x, t), t)-(diff(diff(u(x, t), x), x))-u(x, t)+x-2*sin(2*x)*cos(x) = 0

 

(D[1](u))((1/2)*Pi, t) = 1, u(0, t) = 0, u(x, 0) = x

 

_m708065760

 

 

 

 

Download pdeIss.mw

see the attached


 

NULL

restart:

Eq1 := (2.394038482*10^(-25)*A[1]*B[1]*b[1]*ln(4624/3969)*a[1]^2 + 6.231123984*10^(-25)*a[1]^2*b[1]*ln(4624/3969)^2*A[1]*B[1] + 8.857755670*10^(-26)*a[1]^3*ln(4624/3969)^3*B[1]^2 + 1.856626218*10^(-33)*a[1]*ln(4624/3969)^2*A[1]^2 + 3.115561992*10^(-25)*a[1]*b[1]^2*ln(4624/3969)^2*A[1]^2 + 2.657326700*10^(-25)*a[1]*b[1]^2*ln(4624/3969)^3*A[1]^2 + 2.657326700*10^(-25)*a[1]*b[1]^2*ln(4624/3969)^3*B[1]^2 + 4.995877205*10^(-27)*a[1]^3*B[1]^2 + 4.023466006*10^(-35)*a[1]*B[1]^2 + 2.497938606*10^(-26)*a[1]^3*A[1]^2 + 5.314653400*10^(-25)*a[1]^2*b[1]*ln(4624/3969)^3*A[1]*B[1] + 1.995032068*10^(-25)*A[1]^2*ln(4624/3969)*a[1]^3 + 4.428877833*10^(-25)*a[1]^3*ln(4624/3969)^3*A[1]^2 + 5.192603320*10^(-25)*a[1]^3*ln(4624/3969)^2*A[1]^2 + 1.038520664*10^(-25)*a[1]^3*ln(4624/3969)^2*B[1]^2 + 1.498763163*10^(-26)*a[1]*b[1]^2*A[1]^2 + 1.498763163*10^(-26)*a[1]*b[1]^2*B[1]^2 + 8.199429997*10^(-34)*a[1]*ln(4624/3969)*A[1]^2 + 4.671138947*10^(-34)*a[1]*ln(4624/3969)^3*B[1]^2 + 1.401341684*10^(-33)*a[1]*ln(4624/3969)^3*A[1]^2 + 3.990064137*10^(-26)*B[1]^2*ln(4624/3969)*a[1]^3 + 9.991754410*10^(-27)*A[1]*B[1]*b[1]^3 + 8.046932010*10^(-35)*A[1]*B[1]*b[1] + 3.115561992*10^(-25)*a[1]*b[1]^2*ln(4624/3969)^2*B[1]^2 + 2.997526324*10^(-26)*a[1]^2*b[1]*A[1]*B[1] + 1.237750812*10^(-33)*A[1]*B[1]*b[1]*ln(4624/3969)^2 + 6.188754060*10^(-34)*a[1]*ln(4624/3969)^2*B[1]^2 + 2.077041328*10^(-25)*b[1]^3*ln(4624/3969)^2*A[1]*B[1] + 1.771551133*10^(-25)*b[1]^3*ln(4624/3969)^3*A[1]*B[1] + 7.980128275*10^(-26)*A[1]*B[1]*b[1]^3*ln(4624/3969) + 5.466286665*10^(-34)*A[1]*B[1]*b[1]*ln(4624/3969) + 9.342277895*10^(-34)*A[1]*B[1]*b[1]*ln(4624/3969)^3 - 8.980366659*10^(-50)*b[1]*ln(4624/3969)^5 + 8.628745640*10^(-49)*a[1]*ln(4624/3969)^4 - 1.983002476*10^(-49)*b[1]*ln(4624/3969)^4 + 3.907675385*10^(-49)*a[1]*ln(4624/3969)^5 + 1.207039802*10^(-34)*a[1]*A[1]^2 + 1.197019241*10^(-25)*A[1]^2*b[1]^2*ln(4624/3969)*a[1] + 1.197019241*10^(-25)*B[1]^2*b[1]^2*ln(4624/3969)*a[1] + 2.733143333*10^(-34)*a[1]*ln(4624/3969)*B[1]^2 - 1.751509252*10^(-49)*b[1]*ln(4624/3969)^3 + 3.365859858*10^(-49)*a[1]*ln(4624/3969)^2 + 7.621436685*10^(-49)*a[1]*ln(4624/3969)^3 - 1.708050894*10^(-50)*b[1]*ln(4624/3969) - 7.735201281*10^(-50)*b[1]*ln(4624/3969)^2 + 7.432333988*10^(-50)*ln(4624/3969)*a[1] - 1.508655173*10^(-51)*b[1] + 6.564692631*10^(-51)*a[1])/(4.097832766*10^(-51)*ln(4624/3969)^5 + 9.048642256*10^(-51)*ln(4624/3969)^4 + 7.992315096*10^(-51)*ln(4624/3969)^3 + 3.529651123*10^(-51)*ln(4624/3969)^2 + 7.794010183*10^(-52)*ln(4624/3969) + 6.884147200*10^(-53)):

Eq2 := (6.188754060*10^(-34)*b[1]*A[1]^2*ln(4624/3969)^2 + 9.991754410*10^(-27)*a[1]^3*A[1]*B[1] + 8.199429997*10^(-34)*b[1]*B[1]^2*ln(4624/3969) + 1.498763163*10^(-26)*a[1]^2*b[1]*A[1]^2 + 1.401341684*10^(-33)*b[1]*B[1]^2*ln(4624/3969)^3 + 1.197019241*10^(-25)*b[1]*B[1]^2*ln(4624/3969)*a[1]^2 + 1.197019241*10^(-25)*b[1]*A[1]^2*ln(4624/3969)*a[1]^2 + 2.497938606*10^(-26)*B[1]^2*b[1]^3 - 1.594466862*10^(-55)*ln(4624/3969)^3 - 7.041653990*10^(-56)*ln(4624/3969)^2 + 2.394038482*10^(-25)*A[1]*B[1]*b[1]^2*ln(4624/3969)*a[1] + 1.038520664*10^(-25)*b[1]^3*ln(4624/3969)^2*A[1]^2 + 5.192603320*10^(-25)*b[1]^3*ln(4624/3969)^2*B[1]^2 + 8.980366659*10^(-50)*a[1]*ln(4624/3969)^5 + 2.657326700*10^(-25)*a[1]^2*b[1]*ln(4624/3969)^3*B[1]^2 + 4.023466006*10^(-35)*b[1]*A[1]^2 + 1.207039802*10^(-34)*b[1]*B[1]^2 + 4.671138947*10^(-34)*b[1]*A[1]^2*ln(4624/3969)^3 + 1.856626218*10^(-33)*b[1]*B[1]^2*ln(4624/3969)^2 - 8.175176368*10^(-56)*ln(4624/3969)^5 - 1.805204130*10^(-55)*ln(4624/3969)^4 + 3.115561992*10^(-25)*a[1]^2*b[1]*ln(4624/3969)^2*A[1]^2 + 3.115561992*10^(-25)*a[1]^2*b[1]*ln(4624/3969)^2*B[1]^2 + 2.657326700*10^(-25)*a[1]^2*b[1]*ln(4624/3969)^3*A[1]^2 + 5.314653400*10^(-25)*a[1]*b[1]^2*ln(4624/3969)^3*A[1]*B[1] + 6.231123984*10^(-25)*a[1]*b[1]^2*ln(4624/3969)^2*A[1]*B[1] - 1.373387366*10^(-57) + 3.990064137*10^(-26)*b[1]^3*A[1]^2*ln(4624/3969) + 3.365859858*10^(-49)*b[1]*ln(4624/3969)^2 + 7.735201281*10^(-50)*a[1]*ln(4624/3969)^2 + 1.498763163*10^(-26)*a[1]^2*b[1]*B[1]^2 + 2.733143333*10^(-34)*b[1]*A[1]^2*ln(4624/3969) + 1.237750812*10^(-33)*a[1]*ln(4624/3969)^2*A[1]*B[1] + 5.466286665*10^(-34)*A[1]*B[1]*ln(4624/3969)*a[1] + 9.342277895*10^(-34)*a[1]*ln(4624/3969)^3*A[1]*B[1] - 1.554905032*10^(-56)*ln(4624/3969) + 8.857755670*10^(-26)*b[1]^3*ln(4624/3969)^3*A[1]^2 + 1.995032068*10^(-25)*B[1]^2*b[1]^3*ln(4624/3969) + 8.046932010*10^(-35)*A[1]*B[1]*a[1] + 4.428877833*10^(-25)*b[1]^3*ln(4624/3969)^3*B[1]^2 + 2.077041328*10^(-25)*a[1]^3*ln(4624/3969)^2*A[1]*B[1] + 2.997526324*10^(-26)*a[1]*b[1]^2*A[1]*B[1] + 7.980128275*10^(-26)*A[1]*B[1]*ln(4624/3969)*a[1]^3 + 1.771551133*10^(-25)*a[1]^3*ln(4624/3969)^3*A[1]*B[1] + 1.983002476*10^(-49)*a[1]*ln(4624/3969)^4 + 8.628745640*10^(-49)*b[1]*ln(4624/3969)^4 + 3.907675385*10^(-49)*b[1]*ln(4624/3969)^5 + 4.995877205*10^(-27)*b[1]^3*A[1]^2 + 7.621436685*10^(-49)*b[1]*ln(4624/3969)^3 + 1.751509252*10^(-49)*a[1]*ln(4624/3969)^3 + 7.432333988*10^(-50)*b[1]*ln(4624/3969) + 1.708050894*10^(-50)*ln(4624/3969)*a[1] + 6.564692631*10^(-51)*b[1] + 1.508655173*10^(-51)*a[1])/(4.097832766*10^(-51)*ln(4624/3969)^5 + 9.048642256*10^(-51)*ln(4624/3969)^4 + 7.992315096*10^(-51)*ln(4624/3969)^3 + 3.529651123*10^(-51)*ln(4624/3969)^2 + 7.794010183*10^(-52)*ln(4624/3969) + 6.884147200*10^(-53)):

Eq3 := (6.795005989*10^(-42)*a[1]^4*ln(4624/3969)^3*A[1] + 4.209850900*10^(-42)*a[1]^4*ln(4624/3969)^4*A[1] + 1.359001197*10^(-42)*b[1]^4*ln(4624/3969)^3*A[1] + 8.419701800*10^(-43)*b[1]^4*ln(4624/3969)^4*A[1] + 8.388879275*10^(-44)*a[1]*b[1]^3*B[1] - 1.228735462*10^(-57)*A[1]*ln(4624/3969)^5 + 1.074935208*10^(-42)*A[1]*ln(4624/3969)*a[1]^4 - 3.754479537*10^(-60)*B[1] - 2.064212054*10^(-59)*A[1] - 1.340926813*10^(-57)*B[1]*ln(4624/3969)^5 - 5.060514119*10^(-58)*B[1]*ln(4624/3969)^6 + 8.388879275*10^(-44)*a[1]^3*b[1]*B[1] + 6.756044870*10^(-52)*a[1]*b[1]*B[1] + 1.776052466*10^(-50)*a[1]*b[1]*ln(4624/3969)^4*B[1] + 3.367880720*10^(-42)*a[1]*b[1]^3*ln(4624/3969)^4*B[1] + 5.436004790*10^(-42)*a[1]*b[1]^3*ln(4624/3969)^3*B[1] + 2.097219818*10^(-44)*b[1]^4*A[1] + 3.367880720*10^(-42)*a[1]^3*b[1]*ln(4624/3969)^4*B[1] + 5.436004790*10^(-42)*a[1]^3*b[1]*ln(4624/3969)^3*B[1] + 5.051821080*10^(-42)*a[1]^2*b[1]^2*ln(4624/3969)^4*A[1] + 8.154007187*10^(-42)*a[1]^2*b[1]^2*ln(4624/3969)^3*A[1] + 1.289922249*10^(-42)*b[1]^2*A[1]*ln(4624/3969)*a[1]^2 + 8.599481665*10^(-43)*b[1]*B[1]*ln(4624/3969)*a[1]^3 + 8.599481665*10^(-43)*b[1]^3*B[1]*ln(4624/3969)*a[1] + 3.260938160*10^(-42)*a[1]^3*b[1]*ln(4624/3969)^2*B[1] + 4.891407240*10^(-42)*a[1]^2*b[1]^2*ln(4624/3969)^2*A[1] - 1.058366154*10^(-57)*ln(4624/3969)^2*A[1] - 2.887504260*10^(-58)*ln(4624/3969)^2*B[1] - 2.396496281*10^(-57)*A[1]*ln(4624/3969)^3 - 2.337034537*10^(-58)*A[1]*ln(4624/3969) + 3.378022435*10^(-52)*b[1]^2*A[1] + 1.048609909*10^(-43)*a[1]^4*A[1] + 1.013406730*10^(-51)*a[1]^2*A[1] - 2.713236060*10^(-57)*A[1]*ln(4624/3969)^4 - 8.717705361*10^(-58)*B[1]*ln(4624/3969)^3 - 5.100841261*10^(-59)*B[1]*ln(4624/3969) - 1.480485871*10^(-57)*B[1]*ln(4624/3969)^4 + 6.119181470*10^(-51)*b[1]*B[1]*ln(4624/3969)*a[1] + 3.137436654*10^(-50)*a[1]*b[1]*ln(4624/3969)^3*B[1] + 2.078382172*10^(-50)*a[1]*b[1]*ln(4624/3969)^2*B[1] + 3.260938160*10^(-42)*a[1]*b[1]^3*ln(4624/3969)^2*B[1] + 2.664078699*10^(-50)*a[1]^2*ln(4624/3969)^4*A[1] + 2.149870415*10^(-43)*b[1]^4*A[1]*ln(4624/3969) + 4.706154981*10^(-50)*a[1]^2*ln(4624/3969)^3*A[1] + 9.178772213*10^(-51)*A[1]*ln(4624/3969)*a[1]^2 + 3.117573259*10^(-50)*a[1]^2*ln(4624/3969)^2*A[1] + 8.880262330*10^(-51)*b[1]^2*A[1]*ln(4624/3969)^4 + 3.059590737*10^(-51)*b[1]^2*A[1]*ln(4624/3969) + 8.152345410*10^(-43)*b[1]^4*ln(4624/3969)^2*A[1] + 4.076172701*10^(-42)*a[1]^4*ln(4624/3969)^2*A[1] + 1.039191087*10^(-50)*b[1]^2*ln(4624/3969)^2*A[1] + 1.568718327*10^(-50)*b[1]^2*A[1]*ln(4624/3969)^3 + 1.258331891*10^(-43)*a[1]^2*b[1]^2*A[1])/(5.196166686*10^(-61)*ln(4624/3969)^6 + 1.376871810*10^(-60)*ln(4624/3969)^5 + 1.520171900*10^(-60)*ln(4624/3969)^4 + 8.951392907*10^(-61)*ln(4624/3969)^3 + 2.964906943*10^(-61)*ln(4624/3969)^2 + 5.237574842*10^(-62)*ln(4624/3969) + 3.855122432*10^(-63)):

Eq4 := (1.340926813*10^(-57)*A[1]*ln(4624/3969)^5 + 3.754479537*10^(-60)*A[1] + 8.717705361*10^(-58)*A[1]*ln(4624/3969)^3 - 1.228735462*10^(-57)*B[1]*ln(4624/3969)^5 + 4.891407240*10^(-42)*a[1]^2*b[1]^2*ln(4624/3969)^2*B[1] + 5.051821080*10^(-42)*a[1]^2*b[1]^2*ln(4624/3969)^4*B[1] + 8.388879275*10^(-44)*a[1]*b[1]^3*A[1] + 6.756044870*10^(-52)*a[1]*b[1]*A[1] + 8.388879275*10^(-44)*a[1]^3*b[1]*A[1] + 3.117573259*10^(-50)*b[1]^2*ln(4624/3969)^2*B[1] + 4.706154981*10^(-50)*b[1]^2*ln(4624/3969)^3*B[1] + 1.568718327*10^(-50)*a[1]^2*ln(4624/3969)^3*B[1] + 1.039191087*10^(-50)*a[1]^2*ln(4624/3969)^2*B[1] + 2.664078699*10^(-50)*b[1]^2*ln(4624/3969)^4*B[1] + 9.178772213*10^(-51)*b[1]^2*ln(4624/3969)*B[1] + 8.880262330*10^(-51)*a[1]^2*ln(4624/3969)^4*B[1] + 4.209850900*10^(-42)*b[1]^4*ln(4624/3969)^4*B[1] + 6.795005989*10^(-42)*b[1]^4*ln(4624/3969)^3*B[1] + 3.059590737*10^(-51)*a[1]^2*ln(4624/3969)*B[1] + 2.149870415*10^(-43)*ln(4624/3969)*a[1]^4*B[1] + 1.359001197*10^(-42)*ln(4624/3969)^3*a[1]^4*B[1] + 8.419701800*10^(-43)*ln(4624/3969)^4*a[1]^4*B[1] + 8.152345410*10^(-43)*ln(4624/3969)^2*a[1]^4*B[1] + 4.076172701*10^(-42)*b[1]^4*ln(4624/3969)^2*B[1] + 1.074935208*10^(-42)*b[1]^4*ln(4624/3969)*B[1] + 1.258331891*10^(-43)*a[1]^2*b[1]^2*B[1] + 3.378022435*10^(-52)*a[1]^2*B[1] + 1.013406730*10^(-51)*b[1]^2*B[1] + 5.060514119*10^(-58)*A[1]*ln(4624/3969)^6 + 2.097219818*10^(-44)*a[1]^4*B[1] + 1.048609909*10^(-43)*b[1]^4*B[1] + 1.480485871*10^(-57)*A[1]*ln(4624/3969)^4 - 2.713236060*10^(-57)*B[1]*ln(4624/3969)^4 + 2.887504260*10^(-58)*ln(4624/3969)^2*A[1] - 1.058366154*10^(-57)*ln(4624/3969)^2*B[1] - 2.396496281*10^(-57)*B[1]*ln(4624/3969)^3 + 5.100841261*10^(-59)*A[1]*ln(4624/3969) - 2.337034537*10^(-58)*B[1]*ln(4624/3969) + 1.289922249*10^(-42)*a[1]^2*b[1]^2*ln(4624/3969)*B[1] + 8.154007187*10^(-42)*a[1]^2*b[1]^2*ln(4624/3969)^3*B[1] + 3.260938160*10^(-42)*a[1]*b[1]^3*ln(4624/3969)^2*A[1] + 2.078382172*10^(-50)*a[1]*b[1]*ln(4624/3969)^2*A[1] + 3.260938160*10^(-42)*a[1]^3*b[1]*ln(4624/3969)^2*A[1] + 8.599481665*10^(-43)*a[1]^3*b[1]*ln(4624/3969)*A[1] + 8.599481665*10^(-43)*a[1]*b[1]^3*ln(4624/3969)*A[1] + 5.436004790*10^(-42)*a[1]^3*b[1]*ln(4624/3969)^3*A[1] + 1.776052466*10^(-50)*a[1]*b[1]*ln(4624/3969)^4*A[1] + 3.367880720*10^(-42)*a[1]^3*b[1]*ln(4624/3969)^4*A[1] + 5.436004790*10^(-42)*a[1]*b[1]^3*ln(4624/3969)^3*A[1] + 6.119181470*10^(-51)*a[1]*b[1]*ln(4624/3969)*A[1] + 3.137436654*10^(-50)*a[1]*b[1]*ln(4624/3969)^3*A[1] + 3.367880720*10^(-42)*a[1]*b[1]^3*ln(4624/3969)^4*A[1] - 2.064212054*10^(-59)*B[1])/(5.196166686*10^(-61)*ln(4624/3969)^6 + 1.376871810*10^(-60)*ln(4624/3969)^5 + 1.520171900*10^(-60)*ln(4624/3969)^4 + 8.951392907*10^(-61)*ln(4624/3969)^3 + 2.964906943*10^(-61)*ln(4624/3969)^2 + 5.237574842*10^(-62)*ln(4624/3969) + 3.855122432*10^(-63)):

sys := { Eq1 , Eq2, Eq3, Eq4 }:

#
# Attempt a numerical solution.
#
# fsolve() returns unevaluated, suggesting that
# no solution exists
#
  fsolve( evalf~(sys), indets~(sys)[]);

fsolve({0.4837481725e11*a[1]^2*B[1]+0.1451244518e12*b[1]^2*B[1]+0.3410193433e19*a[1]^4*B[1]+0.1705096716e20*b[1]^4*B[1]+973.8937223*A[1]-3978.447451*B[1]+0.1364077373e20*a[1]*b[1]^3*A[1]+0.9674963450e11*a[1]*b[1]*A[1]+0.1364077373e20*a[1]^3*b[1]*A[1]+0.2046116060e20*a[1]^2*b[1]^2*B[1], 0.3410193433e19*b[1]^4*A[1]+0.4837481725e11*b[1]^2*A[1]+0.1705096716e20*a[1]^4*A[1]+0.1451244518e12*a[1]^2*A[1]-3978.447451*A[1]-973.8937223*B[1]+0.1364077373e20*a[1]*b[1]^3*B[1]+0.1364077373e20*a[1]^3*b[1]*B[1]+0.9674963446e11*a[1]*b[1]*B[1]+0.2046116060e20*a[1]^2*b[1]^2*A[1], 0.4549198038e26*a[1]^3*B[1]^2+0.3226600311e18*a[1]*B[1]^2+0.2274599020e27*a[1]^3*A[1]^2+0.9679800931e18*a[1]*A[1]^2-21.91491740*b[1]+95.35956218*a[1]+0.2729518823e27*a[1]^2*b[1]*A[1]*B[1]+0.1364759412e27*a[1]*b[1]^2*A[1]^2+0.1364759412e27*a[1]*b[1]^2*B[1]^2+0.9098396076e26*A[1]*B[1]*b[1]^3+0.6453200619e18*A[1]*B[1]*b[1], 0.2274599020e27*B[1]^2*b[1]^3+0.3226600311e18*b[1]*A[1]^2+0.9679800931e18*b[1]*B[1]^2+0.4549198038e26*b[1]^3*A[1]^2+95.35956218*b[1]+21.91491740*a[1]+0.2729518823e27*a[1]*b[1]^2*A[1]*B[1]+0.9098396076e26*a[1]^3*A[1]*B[1]+0.1364759412e27*a[1]^2*b[1]*A[1]^2+0.1364759412e27*a[1]^2*b[1]*B[1]^2+0.6453200619e18*A[1]*B[1]*a[1]-0.1995000000e-4}, {A[1], B[1], a[1], b[1]})

(1)

#
# DirectSearch return a "solution", but the residuals
# are "huge", again suggesting that no solution exists
#
  DirectSearch:-SolveEquations(convert(evalf~(sys), list));

[1.1782090079949228*10^14, Vector(4, {(1) = -7660.19490245949, (2) = -4146.042186128595, (3) = -10825910.08, (4) = -787715.5405}), [A[1] = .5385264020439374, B[1] = 2.057250343383483, a[1] = -7.013902666610012*10^(-12), b[1] = 1.0087019453655173*10^(-12)], 1305]

(2)

``


 

Download simEq.mw

Before attempting to "solve" the PDE, you should ensure that your "piecewise function" is correctly defined.

The attached contains four possibilities, with associated PDE solutions

restart

f := proc (x, y) options operator, arrow; piecewise((x, y) = (.8, .5) or (x, y) = (1.6, 1.5), -250, 0) end proc

proc (x, y) options operator, arrow; piecewise((x, y) = (.8, .5) or (x, y) = (1.6, 1.5), -250, 0) end proc

(1)

pde1 := -(diff(u(x, y), `$`(x, 2)))-(diff(u(x, y), `$`(y, 2))) = f; pde2 := -(diff(u(x, y), `$`(x, 2)))-(diff(u(x, y), `$`(y, 2))) = f(x, y); f := proc (x, y) options operator, arrow; piecewise(Or(And(x = .9, y = .5), And(x = .8, y = .5)), -250, 0) end proc; pde3 := -(diff(u(x, y), `$`(x, 2)))-(diff(u(x, y), `$`(y, 2))) = f(x, y); f := proc (x, y) options operator, arrow; -250*Dirac(x-4/5)*Dirac(y-1/2)-250*Dirac(x-9/10)*Dirac(y-1/2) end proc; pde4 := -(diff(u(x, y), `$`(x, 2)))-(diff(u(x, y), `$`(y, 2))) = f(x, y)

pde1 := -(diff(u(x, y), x, x))-(diff(u(x, y), y, y)) = f

 

pde2 := -(diff(u(x, y), x, x))-(diff(u(x, y), y, y)) = 0

 

f := proc (x, y) options operator, arrow; piecewise(x = .9 and y = .5 or x = .8 and y = .5, -250, 0) end proc

 

-(diff(diff(u(x, y), x), x))-(diff(diff(u(x, y), y), y)) = piecewise(Or(And(x = .8, y = .5), And(x = .9, y = .5)), -250, 0)

 

proc (x, y) options operator, arrow; -250*Dirac(x-4/5)*Dirac(y-1/2)-250*Dirac(x-9/10)*Dirac(y-1/2) end proc

 

-(diff(diff(u(x, y), x), x))-(diff(diff(u(x, y), y), y)) = -250*Dirac(-4/5+x)*Dirac(-1/2+y)-250*Dirac(-9/10+x)*Dirac(-1/2+y)

(2)

Bcs := u(0, y) = 100, u(2, y) = 100, (D[2](u))(x, 0) = 0, (D[2](u))(x, 2) = 0; sol1 := pdsolve([pde1, Bcs]); sol2 := pdsolve([pde2, Bcs]); sol3 := pdsolve([pde3, Bcs]); sol4 := pdsolve([pde4, Bcs])

Bcs := u(0, y) = 100, u(2, y) = 100, (D[2](u))(x, 0) = 0, (D[2](u))(x, 2) = 0

 

sol1 := u(x, y) = 100+(1/2)*(-x^2+2*x)*f

 

sol2 := u(x, y) = 100

 

u(x, y) = Int(Sum(.6366197722*sin(1.570796327*n*x)*(Int(sin(1.570796327*n*x)*piecewise(Or(And(x = 4/5, tau = 1/2), And(x = 9/10, tau = 1/2)), -250., 0.), x = 0. .. 2.))*(exp(-1.570796327*n*(y-1.*tau-4.))+exp(1.570796327*n*(y-1.*tau)))/(n*(exp(6.283185308*n)-1.)), n = 1 .. infinity), tau = 0. .. y)+100.

 

u(x, y) = -500*Heaviside(-1/2+y)*(Sum(sin((1/2)*n*Pi*x)*(exp(-(1/4)*Pi*n*(-9+2*y))+exp((1/4)*Pi*n*(-1+2*y)))*(sin((9/20)*Pi*n)+sin((2/5)*Pi*n))/(n*(exp(2*Pi*n)-1)), n = 1 .. infinity))/Pi+100

(3)

 

``

``

Download pdeSols.mw

 

The 'linalg' package was deprecated as of Maple 6, which was released in 1999.

Why are you using a package which was superseded more than 20 years ago?

If you hope to preserve the concept of "order" of equations, then do not define your equations as a set ( ie enclosed within '{}' braces). Sets have no concept of 'order', and anything you enter as a set will be reordered using a mixture of lexicography and complexity. So my first recommendation would be to change the definition of the quantity 'eqs' from a set to a list

If your 'unknowns' are u[1, 0], u[2, 0], u[3, 0], u[1, 1], u[2, 1], u[3, 1], u[1, 2], u[2, 2], u[3, 2], u[1, 3], u[2, 3], u[3, 3], then what are the quantities f[1, 0], f[1, 1], f[1, 2], f[1, 3], f[2, 0], f[2, 1], f[2, 2], f[2, 3], f[3, 0], f[3, 1], f[3, 2], f[3, 3]?

but (maybe) something like the attached is what you need

  restart;
  with(LinearAlgebra):
#
# Input matrix for test purposes
#
  m:= 10:
  n:= 10:
  M1:= RandomMatrix(m,n, generator=rand(-5..5));

Matrix(10, 10, {(1, 1) = 1, (1, 2) = 4, (1, 3) = 0, (1, 4) = -4, (1, 5) = 5, (1, 6) = -2, (1, 7) = 0, (1, 8) = -1, (1, 9) = 5, (1, 10) = -5, (2, 1) = 2, (2, 2) = -1, (2, 3) = 4, (2, 4) = 5, (2, 5) = -4, (2, 6) = -4, (2, 7) = -2, (2, 8) = 2, (2, 9) = 5, (2, 10) = -3, (3, 1) = 3, (3, 2) = 4, (3, 3) = -4, (3, 4) = 5, (3, 5) = 2, (3, 6) = 4, (3, 7) = 3, (3, 8) = 5, (3, 9) = -5, (3, 10) = 0, (4, 1) = 1, (4, 2) = 1, (4, 3) = -3, (4, 4) = -3, (4, 5) = -1, (4, 6) = -3, (4, 7) = 2, (4, 8) = 4, (4, 9) = -3, (4, 10) = -5, (5, 1) = -5, (5, 2) = -3, (5, 3) = -1, (5, 4) = -1, (5, 5) = 4, (5, 6) = 4, (5, 7) = 4, (5, 8) = 5, (5, 9) = -4, (5, 10) = 2, (6, 1) = -2, (6, 2) = -4, (6, 3) = 3, (6, 4) = -1, (6, 5) = 3, (6, 6) = 1, (6, 7) = -2, (6, 8) = -3, (6, 9) = 4, (6, 10) = 3, (7, 1) = 4, (7, 2) = 5, (7, 3) = -2, (7, 4) = 3, (7, 5) = 1, (7, 6) = 2, (7, 7) = 3, (7, 8) = -5, (7, 9) = 4, (7, 10) = -4, (8, 1) = 5, (8, 2) = -2, (8, 3) = 1, (8, 4) = 2, (8, 5) = -5, (8, 6) = 0, (8, 7) = -2, (8, 8) = -5, (8, 9) = 1, (8, 10) = -4, (9, 1) = 3, (9, 2) = -1, (9, 3) = 3, (9, 4) = 3, (9, 5) = -2, (9, 6) = -3, (9, 7) = -2, (9, 8) = 0, (9, 9) = -2, (9, 10) = -2, (10, 1) = 4, (10, 2) = 2, (10, 3) = -4, (10, 4) = 1, (10, 5) = -4, (10, 6) = 5, (10, 7) = -1, (10, 8) = 5, (10, 9) = -3, (10, 10) = -1})

(1)

#
# Create table (aka hash?) from matrix: table indices
# are matrix entries; table entries are lists of matrix
# (programmer) indices
#
  t:= table
      ( [ seq
          ( i=[ seq
                ( `if`( M1(j)=i , j, NULL ),
                  j = 1..m*n
                )
              ],
              i in { entries(M1,'nolist') }
          )
        ]
      );

table( [( -1 ) = [12, 19, 25, 35, 36, 44, 70, 71, 100], ( 0 ) = [21, 58, 61, 79, 93], ( -2 ) = [6, 18, 27, 49, 51, 62, 66, 68, 69, 89, 99], ( 1 ) = [1, 4, 14, 28, 40, 47, 56, 88], ( -3 ) = [15, 24, 34, 54, 59, 76, 84, 90, 92], ( 2 ) = [2, 20, 38, 43, 57, 64, 72, 95], ( -4 ) = [16, 23, 30, 31, 42, 50, 52, 85, 97, 98], ( 3 ) = [3, 9, 26, 29, 37, 39, 46, 63, 67, 96], ( 4 ) = [7, 10, 11, 13, 22, 45, 53, 55, 65, 74, 86, 87], ( -5 ) = [5, 48, 77, 78, 83, 91, 94], ( 5 ) = [8, 17, 32, 33, 41, 60, 73, 75, 80, 81, 82] ] )

(2)

#
# Reconstruct Matrix from table
#
  M2:=Matrix(m, n):
  seq
  ( seq
    ( (M2(j):=i),
      j in t[i]
    ),
    i in [ indices(t, 'nolist') ]
  ):
  M2;
  Equal(M1, M2);

Matrix(10, 10, {(1, 1) = 1, (1, 2) = 4, (1, 3) = 0, (1, 4) = -4, (1, 5) = 5, (1, 6) = -2, (1, 7) = 0, (1, 8) = -1, (1, 9) = 5, (1, 10) = -5, (2, 1) = 2, (2, 2) = -1, (2, 3) = 4, (2, 4) = 5, (2, 5) = -4, (2, 6) = -4, (2, 7) = -2, (2, 8) = 2, (2, 9) = 5, (2, 10) = -3, (3, 1) = 3, (3, 2) = 4, (3, 3) = -4, (3, 4) = 5, (3, 5) = 2, (3, 6) = 4, (3, 7) = 3, (3, 8) = 5, (3, 9) = -5, (3, 10) = 0, (4, 1) = 1, (4, 2) = 1, (4, 3) = -3, (4, 4) = -3, (4, 5) = -1, (4, 6) = -3, (4, 7) = 2, (4, 8) = 4, (4, 9) = -3, (4, 10) = -5, (5, 1) = -5, (5, 2) = -3, (5, 3) = -1, (5, 4) = -1, (5, 5) = 4, (5, 6) = 4, (5, 7) = 4, (5, 8) = 5, (5, 9) = -4, (5, 10) = 2, (6, 1) = -2, (6, 2) = -4, (6, 3) = 3, (6, 4) = -1, (6, 5) = 3, (6, 6) = 1, (6, 7) = -2, (6, 8) = -3, (6, 9) = 4, (6, 10) = 3, (7, 1) = 4, (7, 2) = 5, (7, 3) = -2, (7, 4) = 3, (7, 5) = 1, (7, 6) = 2, (7, 7) = 3, (7, 8) = -5, (7, 9) = 4, (7, 10) = -4, (8, 1) = 5, (8, 2) = -2, (8, 3) = 1, (8, 4) = 2, (8, 5) = -5, (8, 6) = 0, (8, 7) = -2, (8, 8) = -5, (8, 9) = 1, (8, 10) = -4, (9, 1) = 3, (9, 2) = -1, (9, 3) = 3, (9, 4) = 3, (9, 5) = -2, (9, 6) = -3, (9, 7) = -2, (9, 8) = 0, (9, 9) = -2, (9, 10) = -2, (10, 1) = 4, (10, 2) = 2, (10, 3) = -4, (10, 4) = 1, (10, 5) = -4, (10, 6) = 5, (10, 7) = -1, (10, 8) = 5, (10, 9) = -3, (10, 10) = -1})

 

true

(3)

 


 

Download tableMat.mw

see the attached

restart; PDEtools

pde := diff(u(x, t), `$`(t, 2)) = diff(u(x, t), `$`(x, 2))+1

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

(1)

ic := u(x, 0) = 4

u(x, 0) = 4

(2)

NULL

bc := u(0, t) = 0, (D[2, 2](u))(3, t) = -4*(D[1](u))(3, t)+4

u(0, t) = 0, (D[2, 2](u))(3, t) = -4*(D[1](u))(3, t)+4

(3)

sol := pdsolve([pde, bc])

u(x, t) = -(1/2)*x^2+4*x

(4)

plot3d(rhs(sol), x = 0 .. 3, t = 0 .. 1)

 

u

u

(5)

NULL

Download plotPDE.mw

Numerous syntax errors, some of which are 2D- Math-related, and some are misuse of the delimiters '()' , '[]' and even '{}'.

  1.  '()') is for groupting terms in an expression.
  2.  '[]' is used to obtain elements of indexable quantities, such as lists, vectors,matrices, etc and should not be used if you just want a subscripted variable name. n the latter case you should use a__D, rather than a[D].
  3.  '{}' is used to designate sets. You definitely do not have any mathematical sets in your worksheet, so don't use this at all

You have also used the construct e^(someArgument) when you probably(?) mean exp(someArgument)

So inn order to produce the attached I made a lot of guesses about your intention - and some of my guesswork may be wrong, so check this very carefully before using


 

  restart:
  with(RootFinding):

  r[eD] := 4.5:
  rootfunction:= beta -> BesselY(1, beta)*BesselJ(1, beta*r[eD]) - BesselJ(1, beta)*BesselY(1, beta*r[eD]):
  a := Vector(40, fill = 0):
  StartPoint:=0.001:
  for i from 1 by 1 to 40 do
      a[i]:= NextZero(rootfunction, StartPoint):
      StartPoint:=a[i]:
  od:
  a;

_rtable[18446744074329391222]

(1)

NULL

  p__D:= (r__D, t__D) ->(2*((r__D^2)/4+t__D))/(r[eD]^2-1)-(r[eD]^2*ln(r__D))/(r[eD]^2-1)-(3*r[eD]^4-4*r[eD]^4*ln(r[eD])-2*r[eD]^2-1)/(4*(r[eD]^2-1)^2)+Pi*add(BesselJ(1,a[i]*r[eD])^2*(BesselJ(1,a[i])*BesselY(0,a[i]*r__D)-BesselY(1,a[i])*BesselJ(0,a[i]*r__D))/(a[i]*BesselJ(1,a[i]*r[eD])^2-BesselJ(1,a[i])^2)*exp(-a[i]^2*t__D),  i = 1..40  );

proc (r__D, t__D) local i; options operator, arrow; 2*((1/4)*r__D^2+t__D)/(r[eD]^2-1)-r[eD]^2*ln(r__D)/(r[eD]^2-1)-(1/4)*(3*r[eD]^4-4*r[eD]^4*ln(r[eD])-2*r[eD]^2-1)/(r[eD]^2-1)^2+Pi*add(BesselJ(1, a[i]*r[eD])^2*(BesselJ(1, a[i])*BesselY(0, a[i]*r__D)-BesselY(1, a[i])*BesselJ(0, a[i]*r__D))*exp(-a[i]^2*t__D)/(a[i]*BesselJ(1, a[i]*r[eD])^2-BesselJ(1, a[i])^2), i = 1 .. 40) end proc

(2)

#
# Check a few values
#
  p__D(1,1);
  p__D(0.5,0.5);

.8036477586

 

1.378243473

(3)

``


 

Download diffFunc.mw

It is trivial to convert the original model I posted here

https://www.mapleprimes.com/posts/212100-Exploring-The-CoVid19-Outbreak

to use "difference" equations rather than odes, as in the attached - although TBH I have no idea why you would want to)

I think you should give some serious thought to your parameter choices
 

  restart;
  with(plots):
#
# Change the imaginary unit, just because
# most models use I() to designate the number
# of the population who are infected and I
# decided to stick with this convention
#
  interface(imaginaryunit=J):

####################################################
# S(t) represents the number of people who are
# susceptible to the disease
#
# I(t) represents the number of people who are
# infected
#
# R(t) represents the number of people who have
# reached a resolution - in other words they have
# either recovered or are dead!. With either of
# these resolutions, they are no longer infected or
# susceptible! If 'x' is the death rate, then
#
#      x*R(t) people are dead
#  (1-x)*R(t) people have recovered
#
# For Covid-19 the death rate is estimated anywhere
# between 1% and 5% - so 3% is probably about as good
# a guess as you are going to get
#
####################################################
#
# N represents the total population which is assumed
# constant - and hence neglects "normal" birth and
# death (unrelated to the epidemic) rates
#
# myBeta is the infection rate per unit time - in
# other words how many people per day will get
# the disease from a single infected person. Note that
# this can be reduced by "social isolation". If the
# infected person doesn't get to interact with the
# susceptible population, then the number of people
# who can be infected goes down
#
# myGamma is the "recovery" rate per unit time.
# Another way to look at this is that for 1/myGamma
# units of time an individual has the capability
# to infect others. After that time the infected
# individual has either recovered, or is dead. Either
# way they no longer infect anyone else.
#
# At time=0, there has to be (at least) one person
# infected (otherwise we can't start an epidemic),
# and hence N-1 people are susceptible
#

  N:= 100000000:
  myBeta:= 0.5:
  myGamma:= 0.25:
  t:= Vector(201, j->j-1):
  S:= Vector(201):
  I:= Vector(201):
  R:= Vector(201):  
  S[1]:= N-1: I[1]:= 1: R[1]:= 0:
  for j from 2 by 1 to 201 do
      S[j]:= S[j-1]-myBeta*I[j-1]*S[j-1]/N:
      I[j]:= I[j-1]+myBeta*I[j-1]*S[j-1]/N-myGamma*I[j-1]:
  od:

  display( [ pointplot( [t, S], color=blue),
             pointplot( [t, I], color=red),
             pointplot( [t, -(S+I-~N)], color=green)
           ]
         );

 

 

 


 

Download covid2.mw

'gamma' is an 'initially known name' in Maple  (Euler's constant).

You have two choices

  1. use a different name
  2. declare 'gamma' as local, as in the attached

diff( sin(gamma), gamma);

Error, invalid input: diff received gamma, which is not valid for its 2nd argument

 

local gamma;
diff( sin(gamma), gamma)

Warning, A new binding for the name `gamma` has been created. The global instance of this name is still accessible using the :- prefix, :-`gamma`.  See ?protect for details.

 

gamma

 

cos(gamma)

(1)

 


 

Download gamProb.mw

the attached


 

restart;
a:=[parse(readline( "C:/Users/TomLeslie/Desktop/bTest.csv"))];

[1, 2, 3, "x+y, algorithm=["123"]", "OK", 5]

(1)

 


Download icsv2.mw

produces the correct(?) output on the file containing

1,2,3,"x+y, algorithm=["123"]","OK",5

 

the attached


 

data:=Import("C:/Users/TomLeslie/Desktop/bTest.csv", format="CSV", output=Matrix, source=file);

Vector[row](6, {(1) = 1, (2) = 2, (3) = 3, (4) = "x+y, algorithm=["123"]", (5) = "OK", (6) = 5})

(1)

 

Download icsv.mw

Although you do have to change the input file to

1,2,3,"x+y, algorithm=[""123""]","OK",5

 

 

 

If I type your code into Maple 2020 under Windows 7, then the bracket matching seems to work, see the 'still' below. Because I obtained the attached with the simple 'Snipping Tool', the cursor at the end of the line is not visible, becuase the cursor was need to define the 'snip

Notice that the opening parenthesis in the "offending" line is surrounded by a 'square highlight'

 

You state that you are using Document Mode, which your  Options->Interface menu entry would *seem* to confirm. However if you look at the help page "Documents vs. Worksheets: Which Should You Choose?", you will note that in Document Mode the following apply by default

  • Quick problem-solving and free-form, rich content composition
  • No prompt (>) displayed
  • Math is entered and displayed in 2-D math
  • Solve math problems with right-click menu on input and output

Rather obviously, the worksheet in your original post has command prompts, and 1-D Maple input, which looks like you are actually using Worksheet Mode

NB, it is possible to use Document Mode with 1D input, but I don't think(?) it is possible to specify Document Mode and then turn on command prompts!

So are you using some weird sort of 'hybrid' setting - like 'Document Mode' with 1D input and command prompts??

If so, how??, why??

 

 

 

 

5 6 7 8 9 10 11 Last Page 7 of 132