Approximate solution of y’=f(t,y) : odesolve

### 9.3.5 Approximate solution of y’=f(t,y) : odesolve

- Let f be a function from ℝ2 to ℝ.
  odesolve(f(t,y),[t,y],[t0,y0],t1) or
  odesolve(f(t,y),t=t0..t1,y,y0) or
  odesolve(t0..t1,f,y0) or
  odesolve(t0..t1,(t,y)->f(t,y),y0)
  returns an approximate value of y(t1) where y(t) is the solution of:

  y′(t)=f(t,y(t)), y(t0)=y0

- odesolve accepts an optional argument for the discretization of t (tstep=value). This value is passed as initial tstep value to the numeric solver from the GSL (Gnu Scientific Library), it may be modified by the solver. It is also used to control the number of iterations of the solver by 2*(t1-t0)/tstep (if the number of iterations exceeds this value, the solver will stops at a time t<t1).
- odesolve accepts curve as an optional argument. In that case, odesolve returns the list of all the [t,[y(t)]] values that were computed.

Input :

odesolve(sin(t*y),[t,y],[0,1],2)

or :

odesolve(sin(t*y),t=0..2,y,1)

or :

odesolve(0..2,(t,y)->sin(t*y),1)

or define the function :

f(t,y):=sin(t*y)

and input :

odesolve(0..2,f,1)

Output :

[1.82241255675]

Input :

odesolve(0..2,f,1,tstep=0.3)

Output :

[1.82241255675]

Input :

odesolve(sin(t*y),t=0..2,y,1,tstep=0.5)

Output :

[1.82241255675]

Input :

odesolve(sin(t*y),t=0..2,y,1,tstep=0.5,curve)

Output :

[[0.760963063136,[1.30972370515]],[1.39334557388,[1.86417104853]]]