Question: Combinations of numerical solutions from dsolve

Hi! I am trying to plot and store in memory some specific combinations of the solutions of the systems of ODEs that I get numerically from dsolve for a particular range of the independent variable. 

A particular case for my problem is the following system of stiff ODEs for two unknown functions f[0,0](x) and f[1,0](x) beween xini (where the Initial conditions are defined) and xfin, an arbitrary value of x. Note that rosebrock method does not work, and I can only solve it with lsode[adamsfull] or lsode[backfull]. I am attaching a maple file that shows what I have done.


``

############## System of ODEs that needs to be solved ####################################

xini := .1

.1

(1)

xfin := 2

2

(2)

SystemToSolve := diff(f[0, 0](x), x)+(2./x^5+.5000000000/x)*f[0, 0](x) = -15.58845727*sin(.5773502693*x)/x^2+(46.76537182*(3.*sin(.5773502693*x)-1.732050808*x*cos(.5773502693*x)))/x^4, diff(f[1, 0](x), x)+(6./x^5+1.500000000/x)*f[1, 0](x)-1.*f[0, 0](x)/x = (-15.58845727*sin(.5773502693*x)/x^2+(46.76537182*(3.*sin(.5773502693*x)-1.732050808*x*cos(.5773502693*x)))/x^4)*(1.-1.*(1/x^4)^(1/4)*exp(1/x^4)*GAMMA(.7500000000, 1/x^4))-(1.*(-10.39230485*sin(.5773502693*x)/x^2+(31.17691454*(3.*sin(.5773502693*x)-1.732050808*x*cos(.5773502693*x)))/x^4+(4.*((.8660254040*(3.*sin(.5773502693*x)-1.732050808*x*cos(.5773502693*x)))/x+(.8660254040*((3.*(1.-6./x^2))*sin(.5773502693*x)+10.39230485*cos(.5773502693*x)/x))/x))/((1/x^4)^(1/4)*exp(1/x^4)*GAMMA(.7500000000, 1/x^4)*x^5)))*(1/x^4)^(1/4)*exp(1/x^4)*GAMMA(.7500000000, 1/x^4), f[0, 0](xini) = 1.503498546, f[1, 0](xini) = -.5011661819:

 

###################################################################################

 

``

ListProcs := dsolve({SystemToSolve}, numeric, method = lsode[backfull], output = listprocedure):

f00 := eval(f[0, 0](x), ListProcs);

proc (x) local _res, _dat, _solnproc, _xout, _ndsol, _pars, _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) else _xout := evalf(x) end if; _dat := Array(1..4, {(1) = proc (_xin) local _xout, _n, _y0, _ctl, _octl, _reinit, _errcd, _fcn, _i, _yini, _pars, _ini, _par; option `Copyright (c) 2002 by the University of Waterloo. All rights reserved.`; table( [( "complex" ) = false ] ) _xout := _xin; _ctl := array( 1 .. 34, [( 1 ) = (2), ( 2 ) = (.1), ( 3 ) = (.1), ( 4 ) = (1), ( 5 ) = (1), ( 6 ) = (22), ( 7 ) = (0), ( 9 ) = (-.5011661819), ( 8 ) = (1.503498546), ( 11 ) = (0.1e-6), ( 10 ) = (0.1e-6), ( 13 ) = (0), ( 12 ) = (0), ( 15 ) = (0), ( 14 ) = (0), ( 18 ) = (0), ( 19 ) = (0), ( 16 ) = (0), ( 17 ) = (0), ( 22 ) = (0), ( 23 ) = (0), ( 20 ) = (0), ( 21 ) = (0), ( 27 ) = (0), ( 26 ) = (0), ( 25 ) = (0), ( 24 ) = (0), ( 31 ) = (0), ( 30 ) = (0), ( 29 ) = (0), ( 28 ) = (0), ( 32 ) = (0), ( 33 ) = (-1), ( 34 ) = (0)  ] ); _octl := array( 1 .. 34, [( 1 ) = (2), ( 2 ) = (.1), ( 3 ) = (.1), ( 4 ) = (1), ( 5 ) = (1), ( 6 ) = (22), ( 7 ) = (0), ( 9 ) = (-.5011661819), ( 8 ) = (1.503498546), ( 11 ) = (0.1e-6), ( 10 ) = (0.1e-6), ( 13 ) = (0), ( 12 ) = (0), ( 15 ) = (0), ( 14 ) = (0), ( 18 ) = (0), ( 19 ) = (0), ( 16 ) = (0), ( 17 ) = (0), ( 22 ) = (0), ( 23 ) = (0), ( 20 ) = (0), ( 21 ) = (0), ( 27 ) = (0), ( 26 ) = (0), ( 25 ) = (0), ( 24 ) = (0), ( 31 ) = (0), ( 30 ) = (0), ( 29 ) = (0), ( 28 ) = (0), ( 32 ) = (0), ( 33 ) = (-1), ( 34 ) = (0)  ] ); _n := trunc(_ctl[1]); _yini := Array(0..2, {(1) = .1, (2) = 1.503498546}); _y0 := Array(0..2, {(1) = .1, (2) = 1.503498546}); _fcn := proc (N, X, Y, YP) option `[Y[1] = f[0,0](x), Y[2] = f[1,0](x)]`; YP[1] := -15.58845727*sin(.5773502693*X)/X^2+46.76537182*(3.*sin(.5773502693*X)-1.732050808*X*cos(.5773502693*X))/X^4-(2./X^5+.5000000000/X)*Y[1]; if 1/X^4 < 0 then YP[1] := undefined; return 0 end if; if 1/X^4 < 0 then YP[1] := undefined; return 0 end if; YP[2] := (-15.58845727*sin(.5773502693*X)/X^2+46.76537182*(3.*sin(.5773502693*X)-1.732050808*X*cos(.5773502693*X))/X^4)*(1.-1.*evalf((1/X^4)^(1/4))*exp(1/X^4)*GAMMA(.7500000000, 1/X^4))-1.*(-10.39230485*sin(.5773502693*X)/X^2+31.17691454*(3.*sin(.5773502693*X)-1.732050808*X*cos(.5773502693*X))/X^4+4.*(.8660254040*(3.*sin(.5773502693*X)-1.732050808*X*cos(.5773502693*X))/X+.8660254040*(3.*(1.-6./X^2)*sin(.5773502693*X)+10.39230485*cos(.5773502693*X)/X)/X)*evalf(1/(1/X^4)^(1/4))/(exp(1/X^4)*GAMMA(.7500000000, 1/X^4)*X^5))*evalf((1/X^4)^(1/4))*exp(1/X^4)*GAMMA(.7500000000, 1/X^4)-(6./X^5+1.500000000/X)*Y[2]+1.*Y[1]/X; 0 end proc; _pars := []; if not type(_xout, 'numeric') then if member(_xout, ["start", "left", "right"]) then return _y0[0] elif _xout = "method" then return "lsode" elif _xout = "numfun" then return trunc(_ctl[24+trunc(_ctl[1])]) elif _xout = "initial" then return [seq(_yini[_i], _i = 0 .. _n)] elif _xout = "parameters" then return [seq(_yini[_n+_i], _i = 1 .. nops(_pars))] elif _xout = "initial_and_parameters" then return [seq(_yini[_i], _i = 0 .. _n)], [seq(_yini[_n+_i], _i = 1 .. nops(_pars))] elif _xout = "last" then if _ctl[2]-_y0[0] = 0. then error "no information is available on last computed point" else _xout := _ctl[2] end if elif _xout = "enginedata" then return eval(_octl, 1) elif _xout = "function" then return eval(_fcn, 1) 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); if _par <> [] then `dsolve/numeric/process_parameters`(_n, _pars, _par, _yini) end if; if _ini <> [] then `dsolve/numeric/process_initial`(_n, _ini, _yini, _pars) end if; if _pars <> [] then _par := {seq(rhs(_pars[_i]) = _yini[_n+_i], _i = 1 .. nops(_pars))}; for _i from 0 to _n do _y0[_i] := subs(_par, _yini[_i]) end do; for _i from _n+1 to _n+nops(_pars) do _y0[_i] := _yini[_i] end do else for _i from 0 to _n do _y0[_i] := _yini[_i] end do end if; _octl[2] := _y0[0]; _octl[3] := _y0[0]; for _i to _n do _octl[_i+7] := _y0[_i] end do; for _i to nops(_pars) do _octl[2*_n+30+_i] := _y0[_n+_i] end do; for _i to 34 do _ctl[_i] := _octl[_i] end do; if _Env_smart_dsolve_numeric = true and type(_y0[0], 'numeric') then procname("right") := _y0[0]; procname("left") := _y0[0] end if; if _xout = "initial" then return [seq(_yini[_i], _i = 0 .. _n)] elif _xout = "parameters" then return [seq(_yini[_n+_i], _i = 1 .. nops(_pars))] else return [seq(_yini[_i], _i = 0 .. _n)], [seq(_yini[_n+_i], _i = 1 .. nops(_pars))] end if else return "procname" end if end if; if _xout-_y0[0] = 0. then return [seq(_y0[_i], _i = 0 .. _n)] end if; _reinit := false; if _xin <> "last" then if 0 < 0 and `dsolve/numeric/checkglobals`(0, table( [ ] ), _pars, _n, _yini) then _reinit := true; if _pars <> [] then _par := {seq(rhs(_pars[_i]) = _yini[_n+_i], _i = 1 .. nops(_pars))}; for _i from 0 to _n do _y0[_i] := subs(_par, _yini[_i]) end do; for _i from _n+1 to _n+nops(_pars) do _y0[_i] := _yini[_i] end do else for _i from 0 to _n do _y0[_i] := _yini[_i] end do end if; for _i to _n do _octl[_i+7] := _y0[_i] end do; for _i to nops(_pars) do _octl[2*_n+30+_i] := _y0[_n+_i] end do end if; if _pars <> [] and select(type, {seq(_yini[_n+_i], _i = 1 .. nops(_pars))}, 'undefined') <> {} then error "parameters must be initialized before solution can be computed" end if end if; if not _reinit and _xout-_ctl[2] = 0 then [_ctl[2], seq(_ctl[_i], _i = 8 .. 7+_n)] else if sign(_xout-_ctl[2]) <> sign(_ctl[2]-_y0[0]) or abs(_xout-_y0[0]) < abs(_xout-_ctl[2]) or _reinit then for _i to 34 do _ctl[_i] := _octl[_i] end do end if; _ctl[3] := _xout; if Digits <= evalhf(Digits) then try _errcd := evalhf(`dsolve/numeric/lsode`(_fcn, var(_ctl))) catch: userinfo(2, `dsolve/debug`, print(`Exception in lsode:`, [lastexception])); if searchtext('evalhf', lastexception[2]) <> 0 or searchtext('real', lastexception[2]) <> 0 or searchtext('hardware', lastexception[2]) <> 0 then _errcd := `dsolve/numeric/lsode`(_fcn, _ctl) else error  end if end try else _errcd := `dsolve/numeric/lsode`(_fcn, _ctl) end if; if _errcd < 0 then userinfo(2, {dsolve, `dsolve/lsode`}, `Last values returned:`); userinfo(2, {dsolve, `dsolve/lsode`}, ` t =`, _ctl[2]); _i := 8; userinfo(2, {dsolve, `dsolve/lsode`}, ` y =`, _ctl[_i]); for _i from _i+1 to 7+_n do userinfo(2, {dsolve, `dsolve/lsode`}, `	 `, _ctl[_i]) end do; if _errcd+1. = 0. then if _ctl[14+trunc(_ctl[1])] <> 0 then error "an excessive amount of work was done, maxstep may be too small" else error "an excessive amount of work (greater than mxstep) was done" end if elif _errcd+2. = 0. then error "too much accuracy was requested for the machine being used" elif _errcd+3. = 0. then error "illegal input was detected" elif _errcd+4. = 0. then error "repeated error test failures on the attempted step" elif _errcd+5. = 0. then error "repeated convergence test failures on the attempted step" elif _errcd+6. = 0. then error "pure relative error control requested for a variable that has vanished" elif _errcd+7. = 0. then error "cannot evaluate the solution past %1, maxfun limit exceeded (see ?dsolve,maxfun for details)", evalf[8](_ctl[2]) else error "unknown error code returned from lsode %1", trunc(_errcd) end if end if; if _Env_smart_dsolve_numeric = true then if _y0[0] < _xout and procname("right") < _xout then procname("right") := _xout elif _xout < _y0[0] and _xout < procname("left") then procname("left") := _xout end if end if; [_xout, seq(_ctl[_i], _i = 8 .. 7+_n)] end if end proc, (2) = Array(1..3, {(1) = 18446744078356217278, (2) = 18446744078356217454, (3) = 18446744078356217630}), (3) = [x, f[0, 0](x), f[1, 0](x)], (4) = []}); _solnproc := _dat[1]; _pars := map(rhs, _dat[4]); if not type(_xout, 'numeric') then if member(x, ["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, '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, ["last", 'last', "initial", 'initial', NULL]) then _res := _solnproc(convert(x, 'string')); if type(_res, 'list') then return _res[2] else return NULL end if elif member(x, ["parameters", 'parameters', "initial_and_parameters", 'initial_and_parameters', NULL]) then _xout := convert(x, 'string'); _res := _solnproc(_xout); if _xout = "parameters" then return [seq(_pars[_i] = _res[_i], _i = 1 .. nops(_pars))] else return [_res[2], seq(_pars[_i] = [_res][2][_i], _i = 1 .. nops(_pars))] 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), 'string') = rhs(x); if lhs(_xout) = "initial" then if type(rhs(_xout), 'list') then _res := _solnproc(_xout) else _res := _solnproc("initial" = ["single", 2, rhs(_xout)]) end if elif not type(rhs(_xout), 'list') then error "initial and/or parameter values must be specified in a list" elif lhs(_xout) = "initial_and_parameters" and nops(rhs(_xout)) = nops(_pars)+1 then _res := _solnproc(lhs(_xout) = ["single", 2, op(rhs(_xout))]) else _res := _solnproc(_xout) end if; if lhs(_xout) = "initial" then return _res[2] elif lhs(_xout) = "parameters" then return [seq(_pars[_i] = _res[_i], _i = 1 .. nops(_pars))] else return [_res[2], 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), 'string') = rhs(x)) elif _xout = "solnprocedure" then return eval(_solnproc) elif _xout = "sysvars" then return _dat[3] end if; if procname <> unknown then return ('procname')(x) else _ndsol := `tools/gensym`("f[0,0](x)"); eval(FromInert(_Inert_FUNCTION(_Inert_NAME("assign"), _Inert_EXPSEQ(ToInert(_ndsol), _Inert_VERBATIM(pointto(_dat[2][2])))))); return FromInert(_Inert_FUNCTION(ToInert(_ndsol), _Inert_EXPSEQ(ToInert(x)))) end if end if; try _res := _solnproc(_xout); _res[2] catch: error  end try end proc

(3)

f10 := eval(f[1, 0](x), ListProcs);

proc (x) local _res, _dat, _solnproc, _xout, _ndsol, _pars, _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) else _xout := evalf(x) end if; _dat := Array(1..4, {(1) = proc (_xin) local _xout, _n, _y0, _ctl, _octl, _reinit, _errcd, _fcn, _i, _yini, _pars, _ini, _par; option `Copyright (c) 2002 by the University of Waterloo. All rights reserved.`; table( [( "complex" ) = false ] ) _xout := _xin; _ctl := array( 1 .. 34, [( 1 ) = (2), ( 2 ) = (.1), ( 3 ) = (.1), ( 4 ) = (1), ( 5 ) = (1), ( 6 ) = (22), ( 7 ) = (0), ( 9 ) = (-.5011661819), ( 8 ) = (1.503498546), ( 11 ) = (0.1e-6), ( 10 ) = (0.1e-6), ( 13 ) = (0), ( 12 ) = (0), ( 15 ) = (0), ( 14 ) = (0), ( 18 ) = (0), ( 19 ) = (0), ( 16 ) = (0), ( 17 ) = (0), ( 22 ) = (0), ( 23 ) = (0), ( 20 ) = (0), ( 21 ) = (0), ( 27 ) = (0), ( 26 ) = (0), ( 25 ) = (0), ( 24 ) = (0), ( 31 ) = (0), ( 30 ) = (0), ( 29 ) = (0), ( 28 ) = (0), ( 32 ) = (0), ( 33 ) = (-1), ( 34 ) = (0)  ] ); _octl := array( 1 .. 34, [( 1 ) = (2), ( 2 ) = (.1), ( 3 ) = (.1), ( 4 ) = (1), ( 5 ) = (1), ( 6 ) = (22), ( 7 ) = (0), ( 9 ) = (-.5011661819), ( 8 ) = (1.503498546), ( 11 ) = (0.1e-6), ( 10 ) = (0.1e-6), ( 13 ) = (0), ( 12 ) = (0), ( 15 ) = (0), ( 14 ) = (0), ( 18 ) = (0), ( 19 ) = (0), ( 16 ) = (0), ( 17 ) = (0), ( 22 ) = (0), ( 23 ) = (0), ( 20 ) = (0), ( 21 ) = (0), ( 27 ) = (0), ( 26 ) = (0), ( 25 ) = (0), ( 24 ) = (0), ( 31 ) = (0), ( 30 ) = (0), ( 29 ) = (0), ( 28 ) = (0), ( 32 ) = (0), ( 33 ) = (-1), ( 34 ) = (0)  ] ); _n := trunc(_ctl[1]); _yini := Array(0..2, {(1) = .1, (2) = 1.503498546}); _y0 := Array(0..2, {(1) = .1, (2) = 1.503498546}); _fcn := proc (N, X, Y, YP) option `[Y[1] = f[0,0](x), Y[2] = f[1,0](x)]`; YP[1] := -15.58845727*sin(.5773502693*X)/X^2+46.76537182*(3.*sin(.5773502693*X)-1.732050808*X*cos(.5773502693*X))/X^4-(2./X^5+.5000000000/X)*Y[1]; if 1/X^4 < 0 then YP[1] := undefined; return 0 end if; if 1/X^4 < 0 then YP[1] := undefined; return 0 end if; YP[2] := (-15.58845727*sin(.5773502693*X)/X^2+46.76537182*(3.*sin(.5773502693*X)-1.732050808*X*cos(.5773502693*X))/X^4)*(1.-1.*evalf((1/X^4)^(1/4))*exp(1/X^4)*GAMMA(.7500000000, 1/X^4))-1.*(-10.39230485*sin(.5773502693*X)/X^2+31.17691454*(3.*sin(.5773502693*X)-1.732050808*X*cos(.5773502693*X))/X^4+4.*(.8660254040*(3.*sin(.5773502693*X)-1.732050808*X*cos(.5773502693*X))/X+.8660254040*(3.*(1.-6./X^2)*sin(.5773502693*X)+10.39230485*cos(.5773502693*X)/X)/X)*evalf(1/(1/X^4)^(1/4))/(exp(1/X^4)*GAMMA(.7500000000, 1/X^4)*X^5))*evalf((1/X^4)^(1/4))*exp(1/X^4)*GAMMA(.7500000000, 1/X^4)-(6./X^5+1.500000000/X)*Y[2]+1.*Y[1]/X; 0 end proc; _pars := []; if not type(_xout, 'numeric') then if member(_xout, ["start", "left", "right"]) then return _y0[0] elif _xout = "method" then return "lsode" elif _xout = "numfun" then return trunc(_ctl[24+trunc(_ctl[1])]) elif _xout = "initial" then return [seq(_yini[_i], _i = 0 .. _n)] elif _xout = "parameters" then return [seq(_yini[_n+_i], _i = 1 .. nops(_pars))] elif _xout = "initial_and_parameters" then return [seq(_yini[_i], _i = 0 .. _n)], [seq(_yini[_n+_i], _i = 1 .. nops(_pars))] elif _xout = "last" then if _ctl[2]-_y0[0] = 0. then error "no information is available on last computed point" else _xout := _ctl[2] end if elif _xout = "enginedata" then return eval(_octl, 1) elif _xout = "function" then return eval(_fcn, 1) 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); if _par <> [] then `dsolve/numeric/process_parameters`(_n, _pars, _par, _yini) end if; if _ini <> [] then `dsolve/numeric/process_initial`(_n, _ini, _yini, _pars) end if; if _pars <> [] then _par := {seq(rhs(_pars[_i]) = _yini[_n+_i], _i = 1 .. nops(_pars))}; for _i from 0 to _n do _y0[_i] := subs(_par, _yini[_i]) end do; for _i from _n+1 to _n+nops(_pars) do _y0[_i] := _yini[_i] end do else for _i from 0 to _n do _y0[_i] := _yini[_i] end do end if; _octl[2] := _y0[0]; _octl[3] := _y0[0]; for _i to _n do _octl[_i+7] := _y0[_i] end do; for _i to nops(_pars) do _octl[2*_n+30+_i] := _y0[_n+_i] end do; for _i to 34 do _ctl[_i] := _octl[_i] end do; if _Env_smart_dsolve_numeric = true and type(_y0[0], 'numeric') then procname("right") := _y0[0]; procname("left") := _y0[0] end if; if _xout = "initial" then return [seq(_yini[_i], _i = 0 .. _n)] elif _xout = "parameters" then return [seq(_yini[_n+_i], _i = 1 .. nops(_pars))] else return [seq(_yini[_i], _i = 0 .. _n)], [seq(_yini[_n+_i], _i = 1 .. nops(_pars))] end if else return "procname" end if end if; if _xout-_y0[0] = 0. then return [seq(_y0[_i], _i = 0 .. _n)] end if; _reinit := false; if _xin <> "last" then if 0 < 0 and `dsolve/numeric/checkglobals`(0, table( [ ] ), _pars, _n, _yini) then _reinit := true; if _pars <> [] then _par := {seq(rhs(_pars[_i]) = _yini[_n+_i], _i = 1 .. nops(_pars))}; for _i from 0 to _n do _y0[_i] := subs(_par, _yini[_i]) end do; for _i from _n+1 to _n+nops(_pars) do _y0[_i] := _yini[_i] end do else for _i from 0 to _n do _y0[_i] := _yini[_i] end do end if; for _i to _n do _octl[_i+7] := _y0[_i] end do; for _i to nops(_pars) do _octl[2*_n+30+_i] := _y0[_n+_i] end do end if; if _pars <> [] and select(type, {seq(_yini[_n+_i], _i = 1 .. nops(_pars))}, 'undefined') <> {} then error "parameters must be initialized before solution can be computed" end if end if; if not _reinit and _xout-_ctl[2] = 0 then [_ctl[2], seq(_ctl[_i], _i = 8 .. 7+_n)] else if sign(_xout-_ctl[2]) <> sign(_ctl[2]-_y0[0]) or abs(_xout-_y0[0]) < abs(_xout-_ctl[2]) or _reinit then for _i to 34 do _ctl[_i] := _octl[_i] end do end if; _ctl[3] := _xout; if Digits <= evalhf(Digits) then try _errcd := evalhf(`dsolve/numeric/lsode`(_fcn, var(_ctl))) catch: userinfo(2, `dsolve/debug`, print(`Exception in lsode:`, [lastexception])); if searchtext('evalhf', lastexception[2]) <> 0 or searchtext('real', lastexception[2]) <> 0 or searchtext('hardware', lastexception[2]) <> 0 then _errcd := `dsolve/numeric/lsode`(_fcn, _ctl) else error  end if end try else _errcd := `dsolve/numeric/lsode`(_fcn, _ctl) end if; if _errcd < 0 then userinfo(2, {dsolve, `dsolve/lsode`}, `Last values returned:`); userinfo(2, {dsolve, `dsolve/lsode`}, ` t =`, _ctl[2]); _i := 8; userinfo(2, {dsolve, `dsolve/lsode`}, ` y =`, _ctl[_i]); for _i from _i+1 to 7+_n do userinfo(2, {dsolve, `dsolve/lsode`}, `	 `, _ctl[_i]) end do; if _errcd+1. = 0. then if _ctl[14+trunc(_ctl[1])] <> 0 then error "an excessive amount of work was done, maxstep may be too small" else error "an excessive amount of work (greater than mxstep) was done" end if elif _errcd+2. = 0. then error "too much accuracy was requested for the machine being used" elif _errcd+3. = 0. then error "illegal input was detected" elif _errcd+4. = 0. then error "repeated error test failures on the attempted step" elif _errcd+5. = 0. then error "repeated convergence test failures on the attempted step" elif _errcd+6. = 0. then error "pure relative error control requested for a variable that has vanished" elif _errcd+7. = 0. then error "cannot evaluate the solution past %1, maxfun limit exceeded (see ?dsolve,maxfun for details)", evalf[8](_ctl[2]) else error "unknown error code returned from lsode %1", trunc(_errcd) end if end if; if _Env_smart_dsolve_numeric = true then if _y0[0] < _xout and procname("right") < _xout then procname("right") := _xout elif _xout < _y0[0] and _xout < procname("left") then procname("left") := _xout end if end if; [_xout, seq(_ctl[_i], _i = 8 .. 7+_n)] end if end proc, (2) = Array(1..3, {(1) = 18446744078356217278, (2) = 18446744078356217454, (3) = 18446744078356217630}), (3) = [x, f[0, 0](x), f[1, 0](x)], (4) = []}); _solnproc := _dat[1]; _pars := map(rhs, _dat[4]); if not type(_xout, 'numeric') then if member(x, ["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, '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, ["last", 'last', "initial", 'initial', NULL]) then _res := _solnproc(convert(x, 'string')); if type(_res, 'list') then return _res[3] else return NULL end if elif member(x, ["parameters", 'parameters', "initial_and_parameters", 'initial_and_parameters', NULL]) then _xout := convert(x, 'string'); _res := _solnproc(_xout); if _xout = "parameters" then return [seq(_pars[_i] = _res[_i], _i = 1 .. nops(_pars))] else return [_res[3], seq(_pars[_i] = [_res][2][_i], _i = 1 .. nops(_pars))] 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), 'string') = rhs(x); if lhs(_xout) = "initial" then if type(rhs(_xout), 'list') then _res := _solnproc(_xout) else _res := _solnproc("initial" = ["single", 3, rhs(_xout)]) end if elif not type(rhs(_xout), 'list') then error "initial and/or parameter values must be specified in a list" elif lhs(_xout) = "initial_and_parameters" and nops(rhs(_xout)) = nops(_pars)+1 then _res := _solnproc(lhs(_xout) = ["single", 3, op(rhs(_xout))]) else _res := _solnproc(_xout) end if; if lhs(_xout) = "initial" then return _res[3] elif lhs(_xout) = "parameters" then return [seq(_pars[_i] = _res[_i], _i = 1 .. nops(_pars))] else return [_res[3], 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), 'string') = rhs(x)) elif _xout = "solnprocedure" then return eval(_solnproc) elif _xout = "sysvars" then return _dat[3] end if; if procname <> unknown then return ('procname')(x) else _ndsol := `tools/gensym`("f[1,0](x)"); eval(FromInert(_Inert_FUNCTION(_Inert_NAME("assign"), _Inert_EXPSEQ(ToInert(_ndsol), _Inert_VERBATIM(pointto(_dat[2][3])))))); return FromInert(_Inert_FUNCTION(ToInert(_ndsol), _Inert_EXPSEQ(ToInert(x)))) end if end if; try _res := _solnproc(_xout); _res[3] catch: error  end try end proc

(4)

ftoplot := unapply(f00(x)+0.45e-1*f10(x)/x^(3/2), x)

proc (x) options operator, arrow; f00(x)+0.45e-1*f10(x)/x^(3/2) end proc

(5)

``

plot(ftoplot(x), x = xini .. xfin)

 

``


Download Test2ODEs.mw

The approach in that file works, however I have a question regarding the efficiency of my method, since I plan to extend the system to many more ODEs besides just 2 and also extend the range to a larger xfin. In this method, since I define the function to plot in terms of f01 and f02, wich are procedures, does this mean that for each x on the grid for the plot(ftoplot,x=xini..xfin) maple actually computes the solutions f00(x) and f01(x) and then forms the ftoplot combination and plots that specific point? If the default sampling of my interval is, say 1000 points, does it mean that the way I wrote it I will have 1000 invocations of the dsolve procedure, for each x in the sample? I am not sure, it seems to me that is the case. This would imply that instead of advancing the solution at each step maple starts over again from xini. How could I just avoid this behavior and instead have access to the values of ftoplot(x) in the range xini to xfin stored from one invocation of dsolve? 

 

The ideal scenario for me would be to have f[0,0](x) and f[0,1](x) stored as an interpolated function between xini and xfin from the solutions of one invocation of dsolve prior to defining ftoplot. Can this be achieved in principle? How? Remember, i have to use method=lsode and range is not accepted.  

 

Please Wait...