Items tagged with dsolve dsolve Tagged Items Feed

Hello,

After solving ode I am looking only for the values >=1.5. For example at t=1, y(t)=3.8940.

How can I extract the values >= 1.5 from the solution to use it as data (t,y(t)) and save it ?

restart;
with(DEtools); with(plots);
eqn := diff(y(t), t) = -.25*y(t);

 init := y(0) = 5;

sol := dsolve({eqn, init}, {y(t)}, numeric, output = array([seq(i, i = 0 .. 50)]));
p[1] := plot(1.5, t = 0 .. 50, colour = black);

p[2] := odeplot(sol, [t, y(t)], t = 0 .. .50, colour = red);

display(p[1], p[2]);

 

Thanks

please help me a bout:


> u := am+bm*m0*x(t)+cm*n0*y(t);
> v := an+bn*m0*x(t)+cn*n0*y(t);
> eq1 := diff(x(t), t) = 2*A*(sinh(u)-x(t)*cosh(u));
> eq2 := diff(y(t), t) = 2*A*(sinh(v)-y(t)*cosh(v));
> init := x(0) = X, y(0) = Y;
> sol := dsolve({eq1, eq2, init}, {x(t), y(t)});
> param := A = 1/2, am = 0, bm = 1.2*exp(-4), cm = .5*exp(-5), m0 = 10000, an = 0, bn = -exp(-4), cn = 1.2*exp(-3), n0 = 1000;
> ;
> save u, v, param, " narm.sav";
Warning, unassigned variable `u` in save statement
Warning, unassigned variable `v` in save statement
Warning, unassigned variable `param` in save statement
> init := x(0) = 0, y(0) = 0.1e-1;
> eq1 := subs(param, eq1);
> eq2 := subs(param, eq2);
> sol := dsolve({eq1, eq2, init}, {x(t), y(t)}, numeric);
> with(plots);
> odeplot(sol, [x(t), y(t)], 0 .. 60, numpoints = 300, view = [-1 .. 1, -1 .. 1]);

Is it possible to use an option similar to range when using lsode method for dsolve? The ODEs I am trying to solve is stiff and will not work with the flag stiff=true or with method=rosenbrock unless i set Digits:=20. I want to avoid doing that as much as possible, since I believe wit will be very taxing, computationally. I have a very large systeom to solve. I found that method=lsode works with the default Digits=15. 

 

However I need to have the solutions in a given range stored for future access and manipulations. Using range gives me an error: 

Error, (in dsolve/numeric/an_args/lsode) lsode keyword was range, optional keyword must be one of 'ctrl', 'initial', 'itask', 'output', 'procedure', 'procvars', 'start', 'number', 'abserr', 'relerr', 'maxfun', 'minstep', 'maxstep', 'initstep', 'startinit', 'implicit', 'optimize', 'complex'

 

I cannot figure out how to use range or something similar with lsode. Anyone knows? 

Hi! I have to solve a very large system of ODEs for a set of functions that can be indexed with two integers, n and l, call them f[n,l](x), where n ranges from 1 to an order 1000 number and l ranges from 1 to an order 10 number. 

What is the best strategy in dsolve, keeping in mind I will only need to have quick access to the values of the first few such functions, say f[0,0](x) and f[0,1](x) for any given x in a given range. I dont need to store the rest, and trying to store all of them actually will give me a warning about length of output exceeds limit of 1000000. So, having maple output the result of dsolve in a procedural form seems to be what I want. However in doing so, for evey value of x i call the solving procedure maple will solve the system each time, thus taking a long time. 

 

My dilema is: to save storage space and memory I want to use dsolve output as procedures. To save time, when accessing the functions I need (only the first few in the large set of unknown functions that obey the ODE) for a given value of x, I would like maple to have those already stored instead of computing them with each invocation. So, what I need is a somehow split behavior of output. For some of my unknown functions to act as if i use range in dsolve, so that I have access at the values without further computation, and for the rest of the solutions (most of the unknown functions) just keep them in procedural form. How do I achieve this? 

 

Below is a schematic of my probem:

 

ODEs:={Set of about 10000 coupled ODEs for functions labeled f[n,l] n ranging from 1..1000 and l from 1..10}

 

dsolve(ODEs,numeric, output=???)#What options to put in dsolve such that I have quick access to f[0,0](x) and f[0,1](x) in a given range (say xmin=0.1 and xmax=10 for example) but not store the rest. 

 

 

Hello,

The idea: parameter "a" will have a new random value each 10 days.

The way I did it is working but it can get very long especially if I do it for a system of equations and for long time more than a year (365 days).

The code:

with(DEtools); with(plots);
n := 5;

for i to n do Ra[i] := RandomTools:-Generate(distribution(Uniform(0.1e-1, .5))); a[[i]] := Ra[i] end do;

b := 0.1e-2;

T := 10;

 eq := diff(L(t), t) = a*L(t)-b;

init[1] := L(0) = 100;
 sol[1] := dsolve({init[1], subs(a = a[[1]], eq)}, L(t), range = 0 .. T, numeric);


init[2] := L(T) = rhs(sol[1](T)[2]);

sol[2] := dsolve({init[2], subs(a = a[[2]], eq)}, L(t), range = T .. 2*T, numeric);

 

init[3] := L(2*T) = rhs(sol[2](2*T)[2]);
sol[3] := dsolve({init[3], subs(a = a[[3]], eq)}, L(t), range = 2*T .. 3*T, numeric);

p[1] := odeplot(sol[1], [t, L(t)], t = 0 .. T);

p[2] := odeplot(sol[2], [t, L(t)], t = T .. 2*T);

p[3] := odeplot(sol[3], [t, L(t)], t = 2*T .. 3*T);

p := display([p[1], p[2], p[3]]);
display(p);

 

Thank you

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 <a href='http://www.maplesoft.com/support/help/search.aspx?term=dsolve,maxfun' target='_new'>?dsolve,maxfun</a> 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 <a href='http://www.maplesoft.com/support/help/search.aspx?term=dsolve,maxfun' target='_new'>?dsolve,maxfun</a> 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.  

 

related topic is here

Suppose I have 2 differential equations in vector form, and I want to solve them using dsolve. I am not able to figure the syntax for what I would do for scalar ODE to initial its derivative at t=0, which is D(x)(0)=some_value, but do the same when x is a vector.

Here is an example:

restart;
x := t-> <x1(t),x2(t)>;
eq:=diff~(x(t),t$2) =~ <sin(t),t>;
ic1:=x(0)=~0;

So far so good. Now I wanted to also make initial conditions for derivative at zero to be some value. Only syntax I know is using D(x)(0)=some_value. But this works for scalar ODE. When I tried

ic2:=D(x)(0)=~0;

I got

This does not work:

ic2:=diff~(x)(0)=~0;

any help on the correct syntax to use? I am using Maple 2015

 

hi friends

i have a problem in maple with an error

dx := diff(x(t), t, t) = -G*Mz*x(t)/(x(t)^2+y(t)^2)^(3/2):

dy := diff(y(t), t, t) = -G*Mz*y(t)/(x(t)^2+y(t)^2)^(3/2):

 G := 6.67*10^(-11); Mz := 6*10^24:
 IniC := x(0) = 7*10^6, (D(x))(0) = 0, y(0) = 0, (D(y))(0) = 9*10^3:
 Digits := 15:
 Ns := dsolve({dx, dy, IniC}, {x(t), y(t)}, numeric):
 dsnumsort(Ns(0), [x, y]);

>for i from 0 to 400 do T := 40*i; NsT := Ns(T); X[i] := rhs(NsT[C1]); Vx[i] := rhs(NsT[V1]); Y[i] := rhs(NsT[C2]); Vy[i] := rhs(NsT[V2]); MofI[i] := X[i]*Vy[i]-Y[i]*Vx[i] end do:

> with(plots);
> p1 := polarplot(6378*10^3, phi = 0 .. 2*Pi);
> p2 := plot([seq([X[i], Y[i]], i = 0 .. 327)], thickness = 2);

display({p1, p2}, labels = ['x', 'y'], scaling = constrained);

but i see and I I can't draw PLOT:

Error, invalid input: rhs received [t = HFloat(0.0), x(t) = HFloat(1.0), diff(x(t), t) = HFloat(0.0), y(t) = HFloat(0.0), diff(y(t), t) = HFloat(1.0), z(t) = HFloat(0.75), diff(z(t), t) = HFloat(0.0)][C1], which is not valid for its 1st argument, expr

 

can you helpe me?

 

I am solving a system of ODEs with dsolve(ODES, numeric, method = lsode[adamsfull]) and I noticed that some of the solutions are really small numbers, of the order of 10^-{10} and smaller. Certainly for all intents and purposes I will treat those as zero, but my question is: what flag do I set in dsolve to force Maple stop seeking for a solution when it is so close to zero and set it to 0.0? It seems like a great waste of computational time to try and find the significant digits of the order one number in front of 10^{-10} for any particular solution, at least in my case. So, is there a way to add some option in dsolve such that maple sets that to zero before trying to fully calculate it fully (i.e. all the significant digits) ?? I have looked at abserr and relerr but that does not do the trick. 

 

IF the question was asked before, forgive me. I have tryed to find an answer within the search here and on the maple help page but was unsuccessful. 

Hi!

 

I am trying to solve a large nxl system of coupled differential equations. Maple seems to have trouble even for small n's so I wanted to know if anyone has any suggestions. Take the case of the following system of ODEs for my unknown functions f[0,0](x) and f[1,0](x). 

 

ODEs:= {diff(f[0, 0](x), x)+2.*f[0, 0](x)/x^5+.5000000000*f[0, 0](x)/x = -15.58845727*sin(.5773502693*x)/x^2+140.2961154*sin(.5773502693*x)/x^4-81.*cos(.5773502693*x)/x^3, diff(f[1, 0](x), x)+6.*f[1, 0](x)/x^5+1.500000000*f[1, 0](x)/x-1.*f[0, 0](x)/x = -15.58845727*sin(.5773502693*x)/x^2+25.98076212*sin(.5773502693*x)*(1/x^4)^(1/4)*exp(1/x^4)*GAMMA(.7500000000, 1/x^4)/x^2+140.2961154*sin(.5773502693*x)/x^4-233.8268591*sin(.5773502693*x)*(1/x^4)^(1/4)*exp(1/x^4)*GAMMA(.7500000000, 1/x^4)/x^4-81.*cos(.5773502693*x)/x^3+135.*cos(.5773502693*x)*(1/x^4)^(1/4)*exp(1/x^4)*GAMMA(.7500000000, 1/x^4)/x^3-20.78460970*sin(.5773502693*x)/x^6+6.000000004*cos(.5773502693*x)/x^5+62.35382908*sin(.5773502693*x)/x^8-36.00000002*cos(.5773502693*x)/x^7, f[0, 0](.1) = 1.503497680, f[1, 0](.1) = -.5011660086}

 

 

Following Preben Alsholm's suggestion from my previous thread I am using lsode[adamsfull], since no other method i have tried worked for this problem. I am currently using:

 

Sollsodefull:=dsolve({ODEs}, numeric, method = lsode[adamsfull])

 

and it seems to work. I am wondering if there is a way to optimize this, as I will be extending my problem to n and l much larger than order unity numbers, therefore my system will contain about 10^4-10^5 equations. Solving this symple system of 2 equations takes a bit less than a second, but still it takes some time for the processor on my MBP. I am affraid it will be a nightmare for the full problem. Whats the most optimal dsolve option for this kind of problem? Any ideas?

 

I have also attempted dverk78, rkf45,rosenbrock, lsode(without the adamsfull option), and all failed for this particular system. Errors were:

1. For rkf45: Error, (in f00) cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up

2. For dverk78: Error, (in Soldverk78) cannot evaluate the solution past .1, step size < hmin, problem may be singular or error tolerance may be too small

3. For rosenbrock: Error, (in dsolve/numeric/SC/firststep) unable to evaluate the partial derivatives of f(x,y) for stiff solution

4. For lsode without [adamsfull]: Error, (in Sollsode) an excessive amount of work (greater than mxstep) was done

5. For default method with stiff=true and inplicit=true options: Error, (in dsolve/numeric/SC/firststep) unable to evaluate the partial derivatives of f(x,y) for stiff solution

Hi! 

 

I have been trying to solve the following system of equations:

 

ODEs:=diff(f[0, 0](x), x)+2.*f[0, 0](x)/x^5+.5000000000*f[0, 0](x)/x+0.1500000000e-1*f[0, 1](x)/sqrt(x) = -15.58845727*sin(.5773502693*x)/x^2+140.2961154*sin(.5773502693*x)/x^4-81.*cos(.5773502693*x)/x^3, diff(f[0, 1](x), x)+2.*f[0, 1](x)/x^5+.5000000000*f[0, 1](x)/x-0.6666666667e-2*f[0, 0](x)/sqrt(x) = -1039.230485*sin(.5773502693*x)/x^(5/2)+600.0000000*cos(.5773502693*x)/x^(3/2)-346.4101616*sin(.5773502693*x)/x^(9/2)+2078.460970*sin(.5773502693*x)/x^(13/2)-1200.000000*cos(.5773502693*x)/x^(11/2), f[0, 0](.1) = 1.503498543, f[0, 1](.1) = -1.053038610

 

Using dsolve I cant get it to work. I have tried both dverk78 and lsode methods, with default options. For example:

 

Sollsode := dsolve({ODEs}, numeric, method = lsode) 

 

Gives me the follwing error, if I try to estimate the solution anywhere past the initial point of 0.1: Error, (in Sollsode) an excessive amount of work (greater than mxstep) was done

I have also attempted to solve it with dverk78, thinking perhaps the improved accuracy of the method will help.

Soldverk := dsolve({ODEs}, numeric, method = dverk78) 

 

However I will get the following error message then: Error, (in Soldverk) cannot evaluate the solution past .10000000, step size < hmin, problem may be singular or error tolerance may be too small

 

 

Any ideas on how to proceed? Thanks so much!

sample.mw

 

Hi, please help me,
Regards

dsolve.mw

Hi all, I want the bewst for you.

 

Could anyone help me with this bad equation, please?

 

Regards.

Hi,

I'm using maple to solve non linear DE system. The error below appeared. What to do?

eqd1:={diff(u(x),x)=U(x)}:

eqd2:={diff(v(x),x)=V(x)}:

eqd3:={0.004*x*diff(U(x),x)+(x-8*x*V(x)+0.006*U(x)+(3/2-12*V(x)-8*x*diff(V(x),x))*u(x)=0}:

eqd4:=(0.008*x*(V(x)^2)+2*(0.6+x)*v(x)*V(x)+v(x)*u(x)+(v(x)^2)=0}:

fonc:={U(x),u(x),V(x),v(x)}:

sol:=dsolve(eqd1,eqd2,eqd3,eqd4,fonc}:

Error, (in PDEtools/sdsolve) too many arguments; some or all of the following are wrong: [{U(x), u(x)}, {diff(v(x), x) = V(x)}, {1/250*x*(diff(U(x), x))+(x-8*x*V(x)+3/500)*U(x)+(3/2-12*V(x)-8*x*(diff(V(x), x)))*u(x) = 0}, {1/125*x*V(x)^2+2*(3/5+x)*v(x)*V(x)+v(x)*u(x)+v(x)^2 = 0}]

 

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