MATLAB: Can I use numeric::odesolve as a replacement to ode45

advanced symbolic toolboxadvanced symbolicscash karp methodck45dormand-prince methodode45runge kuttasecond order differential equation integrationsolving non-smooth solution

I am using ode45 to solve nonlinear differential equations. Can I use numeric::odesolve with CK45 as a substitute to ode45?. I did not find any material on using odesolve with Cash Karp as a replacement to ode45. Is there any differences in the inputs that has to be given to ode45 and CK45 in numeric odesolve?. Is there any thing which has to be kept in mind while converting the ode45 statement to CK45 numeric odesolve? Any inputs on this will be highly appreciated.

Best Answer

It is possible, by using some magic. See for example,
syms y(t)
%Boundary conditions are required
eqns = {diff(y(t),t) == t*sin(y(t)), y(0) == 2}; %use a cell array!
numdig = 16; %number of decimal places to use
digits(numdig);
symLIST = @(varargin)feval(symengine,'DOM_LIST',varargin{:});
symRANGE = @(a,b) feval(symengine, '_range', a, b);
IVP = symLIST(eqns{:});
fields = symLIST(y(t));
IVP = feval(symengine,'numeric::ode2vectorfield', IVP, fields);
syms CK45
method = CK45;
feval(symengine, 'numeric::odesolve', IVP(1), symRANGE(IVP(2),10), IVP(3), method)
You can omit the method parameter from the call.
Related Question