Approximate solution of the system v’=f(t,v) : odesolve

### 8.3.5 Approximate solution of the system v’=f(t,v) : odesolve

- If v is a vector of variables [x1,..,xn] and if f is given by a vector of expressions [e1,...,en] depending on t and of [x1,..,xn], if the initial value of v at t0 is the vector [x10,...,xn0] then the instruction
  odesolve([e1,..,en],t=t0..t1,[x1,...,xn], [x10,...,xn0])
  returns an approximated value of v at t=t1. With the optional argument curve, odesolve returns the list of the intermediate values of [t,v(t)] computed by the solver.

  Example, to solve the system

  x′(t) | = | −y(t)
  y′(t) | = | x(t)

  Input :

  odesolve([-y,x],t=0..pi,[x,y],[0,1])

  Output :

  [-1.79045146764e-15,-1]
- If f is a function from ℝ × ℝn to ℝn.
  odesolve(t0..t1,(t,v)->f(t,v),v0) or
  odesolve(t0..t1,f,v0)
  computes an approximate value of v(t1) where the vector v(t) in ℝn is the solution of

  v′(t)=f(t,v(t)), v(t0)=v0

  With the optional argument curve, odesolve returns the list of the intermediate value [t,v(t)] computed by the solver.

  Example, to solve the system :

  x′(t) | = | −y(t)
  y′(t) | = | x(t)

  Input :

  odesolve(0..pi,(t,v)->[-v[1],v[0]],[0,1])

  Or define the function:

  f(t,v):=[-v[1],v[0]]

  then input :

  odesolve(0..pi,f,[0,1])

  Output :

  [-1.79045146764e-15,-1]

  Alternative input :

  odesolve(0..pi/4,f,[0,1],curve)

  Output :

  [[0.1781,[-0.177159948386,0.984182072936]], [0.3781,[-0.369155338156,0.929367707805]], [0.5781,[-0.54643366953,0.837502384954]], [0.7781,[-0.701927414872,0.712248484906]]]