Approximating solutions of the system v’=f(t,v): odesolve

### 10.3.6 Approximating solutions of the system v’=f(t,v): odesolve

This section covers using odesolve to solve first order systems of differential equations; using it to solve a single first order differential equation was discussed last section.

The odesolve can be used to solve a system of the form

x′ = f(t,x)

where x=[x1,…,xn] is a list of unknown functions and f is a function of n+1 variables with an initial condition.

odesolve can takes its arguments in various ways. Letting t be the independent variable and x=[x1,…,xn] be a vector of dependent variables, t0 and x0 be the initial values, t1 the place where you want the value of x, f be the function in the differential equation, f(t,x) be a list of expressions which determines the function f (see Section 5.15.1 for the difference between a function and an expression):

- odesolve takes three or four mandatory arguments and two optional arguments:
  - mandatory, mandatory arguments given by one of the following sequences:
    - f(t,x),t=t0..t1,x,x0
    - t0..t1,(t,y)->f(t,y),x0
    - t0..t1,f,x0
  - Optionally, curve, the symbol.
- odesolve(mandatory ⟨,curve⟩) returns an approximate value of x(t1) where x(t) is the solution of:

  x′(t)=f(t,x(t)), x(t0)=x0

  With an optional argument of curve, the list of all the [t,[x(t)]] values that were computed by the solver are returned.

#### Examples.

- Solve the system:

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

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

  ⎡ ⎣ | −1.79045146764×10−15,−1 | ⎤ ⎦

- Solve the system:

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

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

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

  Output:

  ⎡ ⎣ | −1.79045146764×10−15,−1 | ⎤ ⎦

- Input:
  odesolve(0..pi/4,f,[0,1],curve)
  Output:

  ⎡ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ |
  0.0 |
  ⎡ ⎣ | 0.0,1.0 | ⎤ ⎦
  0.0165441856471 |
  ⎡ ⎣ | −0.0165434309391,0.999863148082 | ⎤ ⎦
  0.0325491321983 |
  ⎡ ⎣ | −0.0325433851614,0.999470323763 | ⎤ ⎦
  0.0486049854945 |
  ⎡ ⎣ | −0.0485858499906,0.998819010222 | ⎤ ⎦
  ⋮ | ⋮
  0.747336757246 |
  ⎡ ⎣ | −0.679687679865,0.733501641333 | ⎤ ⎦
  0.76509544295 |
  ⎡ ⎣ | −0.692605846268,0.721316256377 | ⎤ ⎦
  0.78286231703 |
  ⎡ ⎣ | −0.705311395415,0.708897619897 | ⎤ ⎦
  0.785398163397 |
  ⎡ ⎣ | −0.707106781186,0.707106781186 | ⎤ ⎦
  | ⎤ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦