Download presentation
Presentation is loading. Please wait.
Published byOsvaldo Cleavenger Modified over 9 years ago
1
Numeriska beräkningar i Naturvetenskap och Teknik 1. Numerical differentiation and quadrature Discrete differentiation and integration Trapezoidal and Simpson’s rules 2. Ordinary differential equations Euler’s method, Runge-Kutta methods 3. Systems of differential equations 4. Initial value and boundary problem Shooting method
2
Numerical differentiation och quadratur Numeriska beräkningar i Naturvetenskap och Teknik Function f(x) in three points:x 0 -h, x 0, x 0 +h
3
Numeriska beräkningar i Naturvetenskap och Teknik Derivative f in the points: x 0 ±h Taylor expansion around x 0 =0 gives Maclaurin:
4
Numeriska beräkningar i Naturvetenskap och Teknik Derivative with Taylor expansion Difference Derivative in three point form Local error
5
Numeriska beräkningar i Naturvetenskap och Teknik “Forward difference” Compare to the defintion of the derivative : Local error In the same way:
6
Numeriska beräkningar i Naturvetenskap och Teknik Quadrature: Trapetzoidal rule Linear interpolation
7
Numeriska beräkningar i Naturvetenskap och Teknik Trapetzoidal rule Area between x-h and x+h hh f -1 f1f1 f0f0
8
Numeriska beräkningar i Naturvetenskap och Teknik Trapetzoidal rule with error estimate: f -1 f0f0 f1f1 h h
9
Numeriska beräkningar i Naturvetenskap och Teknik f -1 f0f0 f1f1 h h Simpson’s rule: Approximate by Taylor expansion Integrated over x gives 0
10
Numeriska beräkningar i Naturvetenskap och Teknik Ordinary differential equations An ordinary differential equation is defined as: First order Second order
11
Numeriska beräkningar i Naturvetenskap och Teknik Euler’s method, discrete solution of first order ordinary diff. equations Based on the “forward difference” given above: which gives:
12
Numeriska beräkningar i Naturvetenskap och Teknik Runge-Kutta methods Start by integrating between step n and n+1 Taylor series for f(x,y) around the central point n+1/2 Integrate:
13
Numeriska beräkningar i Naturvetenskap och Teknik i.e.
14
Numeriska beräkningar i Naturvetenskap och Teknik Now one needs an estimate of f n+1/2 in the expression: Use Euler! At half way between points: i.e. with: Runge-Kutta of order 2 is given by:
15
Numeriska beräkningar i Naturvetenskap och Teknik Runge-Kutta of order 2 y n+1 to order h 3 at the cost of calculating f(x,y) in two points. Geometrical picture: x y
16
Numeriska beräkningar i Naturvetenskap och Teknik Runge-Kutta error of order 4 > rk3
17
Numeriska beräkningar i Naturvetenskap och Teknik Runge-Kutta error of order 5 > rk4
18
Numeriska 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.
19
Numeriska beräkningar i Naturvetenskap och Teknik condition on y’ 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: Initial value problems condition on y 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.
20
Numeriska 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…
21
Numeriska beräkningar i Naturvetenskap och Teknik Bounary value problem
22
Numeriska beräkningar i Naturvetenskap och Teknik Boundary value problem dvs
23
Numeriska beräkningar i Naturvetenskap och Teknik Boundary value problem
24
Numeriska beräkningar i Naturvetenskap och Teknik Exemple; solve with Euler’s method and RK4 and study precision Note that the solution is: …possibly another function
25
Numeriska beräkningar i Naturvetenskap och Teknik Example, second order equation transferred to system
26
Numeriska beräkningar i Naturvetenskap och Teknik Exemple, boundary value problem
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.