Komputasi numerik integrasi dan differensiasi numerik
This presentation is the property of its rightful owner.
Sponsored Links
1 / 53

Komputasi Numerik : Integrasi dan Differensiasi Numerik PowerPoint PPT Presentation


  • 158 Views
  • Uploaded on
  • Presentation posted in: General

Komputasi Numerik : Integrasi dan Differensiasi Numerik. Agus Naba Physics Dept., FMIPA-UB. Ordinary Differential Equation. Ordinary Differential Equation (ODE) is a differential equation in which all dependent variables are functions of a single independent variable. ODE’s Problem.

Download Presentation

Komputasi Numerik : Integrasi dan Differensiasi Numerik

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Komputasi numerik integrasi dan differensiasi numerik

Komputasi Numerik:Integrasi dan Differensiasi Numerik

Agus Naba

Physics Dept., FMIPA-UB


Ordinary differential equation

Ordinary Differential Equation

Ordinary Differential Equation (ODE) is a differential equation in which all dependent variables are functions of a single independent variable.


Ode s problem

ODE’s Problem

First-order Ordinary Differential Equation (ODE):


Euler s method

Euler’s Method


Komputasi numerik integrasi dan differensiasi numerik

y(t)

Slope:

yn

tn

tn+1

It enables us to calculate all of yn = y (tn), given y(t0).


Numerical errors

Numerical Errors

  • Truncation Errors, depending on numerical methods

  • Round-off Errors, depending on capability of computer in storing floating-point number


Truncation errors

Truncation Errors

The curve y(t) is not generally a straight-line between the neighbouring grid-times tn and tn+1as assumed.

According to Taylor Series:

O(t2)

Truncation Error

Each step incurs truncation error ~ t2

Net truncation errors of Euler’s Method ~ t


Round off errors

Round-off Errors

For every type of computer, there is a charasteristic number, , which defined as the smallest number which when added to a number of order unity gives rise to a new number.

For example:

 = 2.2 x 10-16 (for double precision number in IBM-PC )

 = 1.19 x 10-7 (for single precision number in IBM-PC )

The net round-off errors of Euler’s Method  /t.


Net numerical errors of euler s method

Net Numerical Errors of Euler’s Method

At large t, the error is dominated by the truncation errors, whereas the round-off errors dominates at small t.

Minimum net numerical errors are achieved when


Komputasi numerik integrasi dan differensiasi numerik

~1/2

t

t~1/2


Numerical instalibilities

Numerical Instalibilities

y(0)=1

t


Solusi numerik

Solusi Numerik

y(0)

y(0)

Numerical Instabilities

t

t


Defect of euler s method

Defect of Euler’s Method

Not generally used in scientific computing:

  • Truncation errors is far larger than other, more advanced, methods.

  • Too prone to numerical instabilities


Komputasi numerik integrasi dan differensiasi numerik

Main reason of large truncation errors:

Euler’s method only evaluates derivative at the beginning of the interval [tn,tn+1], i.e., at tn.

(Very asymetric with respect to the beginning and the end of the interval)


Runge kutta rk methods

k1

k2

k1 /2

yn

Runge-Kutta (RK) Methods

Euler’s Method

y(t)

f2

y(t)

The 2nd order RK Method

f1

tn

tn+ h/2

tn+1

h


Modified euler s method

(k1+k2)/2

k2

k1

yn

Modified Euler’s Method

y(t)

yn+1 =yn+(k1+k2)/2

Modified Euler’s Method

f1

f2

tn

tn+ h

h


The 4 th order rk method

The 4th order RK method

f2

f4

f3

f1

tn

tn + h/2

tn + h


The 4 th order rk method1

The 4th order RK method


Net numerical errors of rk methods

Net Numerical Errors of RK Methods


Rk methods performance on ibm pc for double precision

RK Methods Performanceon IBM-PC for double precision

hmin increases and min decreases as order gets larger, but needs more computational effort.


Example

Example


Komputasi numerik integrasi dan differensiasi numerik

err = yanalitic-ynumeric

Global integration errors associated with Euler's method (solid curve) and the4th order Runge-Kutta method (dotted curve) plotted against the step-length h. Single precision calculation.


Komputasi numerik integrasi dan differensiasi numerik

Global integration errors associated with Euler's method (solid curve) and the 4th order Runge-Kutta method (dotted curve) plotted against the step-length h. Double precision calculation.


Adaptive integration method

Adaptive Integration Method

Consider the following ODE:

Analitic solution:


Komputasi numerik integrasi dan differensiasi numerik

err = xanalitic-xnumeric

Global integration error associated with a xed step-length (h = 0:01), 4th order RK method, plotted against the independent variable, t, for a system of o.d.e.s in which the variation scale-length decreases rapidly with increasing t. Double precision calculation.


Komputasi numerik integrasi dan differensiasi numerik

It can be seen that, although the error starts off small, it rises rapidly as the variation scale-length of the solution decreases (i.e., as t increases), and quickly becomes unacceptably large. Of course, we could reduce the error by simply reducing the step-length, h. However, this is a very inefficient solution. The step-length only needs to be reduced at large t. There is no need to reduce it, at all, at small t.

Solution: h should be large at small t but needs to be reduced at large t


Komputasi numerik integrasi dan differensiasi numerik

The step-length h should be increased if the truncation error per step is too small, and vice versa, in such a manner that the error per step remains relatively constant at 0.


Komputasi numerik integrasi dan differensiasi numerik

Global integration errors associated with fixed step-length (h = 0.01), 4th order RK method (solid curve) and a corresponding adaptive method (0 = 10-8) (dotted curve), plotted against the independent variable, t, for a system of o.d.e.s in which the variation scale-length decreases rapidly with increasing t. Double precision calculation.


Differentiation

Differentiation

An object is moving through space, its position as a function of time x(t) is recorded in a table.

Problem:

Determine the object’s velocity v(t)=dx/dt and acceleration a(t)=d2x/dt2


Method numeric

Method: Numeric

Even a computer runs into errors with such a method because of its subtraction operations: the numerator tends to fluctuate between 0 and the machine precision  as the denominator approaches zero.


Method forward difference fd

Method: Forward Difference (FD)

c denotes a computed expression.


Komputasi numerik integrasi dan differensiasi numerik

f(x)

x

x+h

h

FD: using two points to represent the 1st derivative function by a straight line in the interval from x to x+h


Komputasi numerik integrasi dan differensiasi numerik

Error


Example of fd

Example of FD


Fd solution

FD solution

This clearly becomes a good approximation only for small h, i.e., h << 2x


Method central difference cd

Method: Central Difference (CD)


Komputasi numerik integrasi dan differensiasi numerik

f(x)

x

x+h/2

x-h/2

h

CD: using two points to represent the function by a straight line in the interval from x-h/2 to x+h/2


Komputasi numerik integrasi dan differensiasi numerik

Error


Example of cd

Example of CD


Cd solution

CD solution

CD Method gives the exact answer regardless of the size of h !


Method extrapolated difference ed

Method:Extrapolated Difference (ED)

  • The error in FD ~ h

  • The error in CD ~ h2

  • The error in ED ~ h4


Komputasi numerik integrasi dan differensiasi numerik

f(x)

x+h/2

x+h/4

x

x-h/2

x-h/4

h/2

h


Extrapolated difference

Extrapolated Difference


Komputasi numerik integrasi dan differensiasi numerik

f(x)

x+h/2

x+h/4

x

x-h/2

x-h/4

h/2

h


Komputasi numerik integrasi dan differensiasi numerik

Error


A good way of computing for ed

A Good Way of Computing for ED

It reduces the loss of precision that occurs when large and small numbers are added together, only to be subtracted from other large numbers.

Subtract the large number from each other and then add the difference to the small numbers !


Attention

Attention !

Regardless of the algorithm, evaluating the derivative of f(x) at x requires us to know the values of f surrounding x !

HOW ?

Once we have the derivative of f(x) at x, USE the integration methods, ex., RK Method, to approximate the values of f surrounding x !


Error analysis

Error Analysis

The approximation/truncation errors in numerical differentiation decrease with decreasing step size h while roundoff errors increase with a smaller step size. Total error is minimum if

minimum. This occurs when


Roundoff error

Roundoff Error

The limit of roundoff error is essentially machine precision:


Truncation errors1

Truncation Errors

  • Truncation Error of FD:

  • Truncation Error of CD:


Best h

Best h

The h value for which roundoff and truncation errors are equal is

Ex., for single precision 10-7 for f(x)=ex or cos(x)

hfd  0.0005 and hcd  0.01


  • Login