Title: Ber
1Numeriska beräkningar i Naturvetenskap och Teknik
- Numerical differentiation and quadrature
- Discrete differentiation and integration
-
- --------------------------------------------------
---------- - 2. Ordinary differential equations
- Eulers method, Runge-Kutta methods
- --------------------------------------------------
---------- - 3. Systems of differential equations
- --------------------------------------------------
---------- - 4. Initial value and boundary value problem
- Shooting method
2Numeriska beräkningar i Naturvetenskap och Teknik
Derivative ---------------------------------------
-------------------
Taylor expansion around x00 gives
Maclaurin
-------------------------------------------------
---------- f in the points x0h
3Numeriska beräkningar i Naturvetenskap och Teknik
Derivative with Taylor expansion -----------------
--------------------------------------------
Difference
Derivative in point form
Local error
4Numeriska beräkningar i Naturvetenskap och Teknik
Forward difference -------------------
------------------------------------------
Local error
Compare to the definition of the derivative
In the same way
5Numeriska beräkningar i Naturvetenskap och Teknik
Ordinary differential equations
An ordinary differential equation is defined
as
First order
Second order
6Numeriska beräkningar i Naturvetenskap och Teknik
Eulers method, discrete solution of first order
ordinary diff. equations
Based on the forward difference given above
which gives
7Numeriska beräkningar i Naturvetenskap och Teknik
Runge-Kutta methods
Start by integrating between step n and n1
Taylor approx of f around the central point n1/2
Integrate
8Numeriska beräkningar i Naturvetenskap och Teknik
i.e.
9Numeriska beräkningar i Naturvetenskap och Teknik
Now one needs an estimate of fn1/2 in the
expression
Use Euler!
At half way between points
i.e. with
Runge-Kutta of order 2 is given by
10Numeriska beräkningar i Naturvetenskap och Teknik
Runge-Kutta of order 2
yn1 to order h3 at the cost of calculating
f(x,y) in two points.
Geometrical picture
y
x
11Numeriska beräkningar i Naturvetenskap och Teknik
Runge-Kutta error of order 4 gt rk3
12Numeriska beräkningar i Naturvetenskap och Teknik
Runge-Kutta error of order 5 gt rk4
13Numeriska beräkningar i Naturvetenskap och Teknik
Exemple solve with Eulers method and RK4 and
study precision
Note that the solution is
possibly another function
14Numeriska beräkningar i Naturvetenskap och Teknik
Higher order ordinary differential equations
Can be solved as a system of first order
equations by substitution
So, an ordinary differential equation of order n
can be solved numerically by e.g. RK4 as defined
for a first order ordinary differential equation.
15Numeriska beräkningar i Naturvetenskap och Teknik
Conditions
A differential equation of order n is completely
determined only if n conditions are are given
for the solution. Compare to the simple
differential equation
condition on y
condition on y
Initial value problems
Conditions given for the same value of the
independent variable. An example for the case
above is y(0)2, y(0)0. In classical
mechanics this could e.g. correspond to knowing
the position and velocity at a given time.
16Numeriska beräkningar i Naturvetenskap och Teknik
On the board
Second example on the board Second order
equation transferred to system.
17Numeriska beräkningar i Naturvetenskap och Teknik
Boundary value problems
In this case one knows the value of the function
(and/or its derivatives) for different values of
the independent variable. An exemple from physics
is the case of a second order differential
equation
There are several ways of solving this problem
numerically. A simple method is to transfer the
problem to become an initial value problem
and find values for ? that gives solutions that
shoot over or under the boundary value in
point b. The value for? which gives a value for
y(b) within a given accuracy from ßis then
solved for. This method is called the shooting
method. See page 329
18Numeriska beräkningar i Naturvetenskap och Teknik
Boundary value problem
19Numeriska beräkningar i Naturvetenskap och Teknik
Boundary value problem
dvs
20Numeriska beräkningar i Naturvetenskap och Teknik
Boundary value problem
21Numeriska beräkningar i Naturvetenskap och Teknik
Example, boundary value problem
22Numeriska beräkningar i Naturvetenskap och Teknik
Quadrature Trapetzoidal rule
Linear interpolation
23Numeriska beräkningar i Naturvetenskap och Teknik
f1
f0
Trapetzoidal rule
f-1
h
h
Area between x-h and xh
24Numeriska beräkningar i Naturvetenskap och Teknik
Trapetzoidal rule with error estimate
f1
f0
f-1
h
h
25Numeriska beräkningar i Naturvetenskap och Teknik
Simpsons rule Approximate by Taylor expansion
f1
f0
Integrated over x gives 0
f-1
h
h