Numerical Analysis/ODE in vector form Exercises

< Numerical Analysis

All of the standard methods for solving ordinary differential equations are intended for first order equations. When you need to solve a higher order differential equation, you first convert it to a system of first order of equations. Then you rewrite as a vector form and solve this ODE using a standard method. On this page we demonstrate how to convert to a system of equations and then apply standard methods in vector form.

Reduction to a first order system

(Based on Reduction of Order and Converting a general higher order equation.)

I want to show how to convert higher order differential equation to a system of the first order differential equation. Any differential equation of order n of the form

f\left(t, u, u', u'',\ \cdots,\ u^{(n-1)}\right) = u^{(n)}

can be written as a system of n first-order differential equations by defining a new family of unknown functions

y_i = u^{(i-1)}\quad\text{for}\quad i = 1, 2,... n\,.

The n-dimensional system of first-order coupled differential equations is then

\begin{array}{rclcl}
  y_1&=&u\\
  y_2&=&u'\\
  y_3&=&u''\\
  &\vdots&\\
  y_n&=&u^{(n-1)}.\\
\end{array}

Differentiating both sides yields

\begin{array}{rclclcl}
  y_1'&=&u' &=&y_2\\
  y_2'&=&u''&=&y_3\\
  y_3'&=&u'''&=&y_4\\
  &\vdots&\\
  y_{n}'&=&u^{(n)}&=&f(t,y_1,\cdots,y_n).\\
\end{array}

We can express this more compactly in vector form

\mathbf{y}'=\mathbf{f}(t,\mathbf{y})

where \ y_{i+1} = f_i\left(t, \mathbf{y} \right) for i < n and \ f_n\left(t, \mathbf{y} \right) = \  f\left(t, y_1, y_2, \cdots,y_n \right)\,.

Exercise

Consider the second order differential equation \ u''+u =0 with initial conditions \ u{(0)}=1 and \ u'{(0)}=0 . We will use two steps with step size \ h = \frac{\pi}{8} and approximate the values of \ u{(\frac{\pi}{4})} and \ u'{(\frac{\pi}{4})}.

Since the exact solution is u(t)=\cos(t) we have \ u{(\frac{\pi}{4})}=0.707106781 and u'{(\frac{\pi}{4})}=-0.707106781.

Exercise 1: Convert this second order differential equation to a system of first order equations.

Exercise 2: Apply the Euler method twice.

Exercise 3: Apply the Backward Euler method twice.

Exercise 4: Apply the Midpoint method twice.

Exercise 5: Using the values from the Midpoint method at \ t=h in exercise3, apply the Two-step Adams-Bashforth method once.

Reference

http://en.wikipedia.org/wiki/Ordinary_differential_equation

http://www.math.ohiou.edu/courses/math3600/lecture29.pdf

http://www.ohio.edu/people/mohlenka/20131/4600-5600/hw7.pdf

This article is issued from Wikiversity - version of the Saturday, April 02, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.