Sie sind auf Seite 1von 8

ACTIVITY: Numerical Differentiation

1. Use forward and backward difference approximations of O(h2 ) to estimate the first derivative of the function
f ( x) 25 x ^3 6 x ^ 2 7 x 88

Evaluate the derivative at x = 2 using step size of h = 0.25. Compare your results with the true value of the derivative. Interpret your results on the basis of the remainder term of the Taylor Series expansion.

1
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

ACTIVITY: Numerical Differentiation

2. Use a centered difference approximation of O(h2) to estimate the second derivative of the function examined in Problem 1. Perform the evaluation at x = 2 using step sizes of h= 0.2 and 0.1. Compare your estimates with the true value of the second derivative. Interpret your results on the basis of the remainder term of the Taylor series expansion

2
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Activity 3 (Solution to Differential equation)

Solve the following initial-value theorem problem analytically over the interval from x = 0 to 2: dy/dx = (yx2 1.2y)

where y(0) = 1. Use Eulers method with h = 0.5 and 0.25


x Ytrue yeuler Global

3
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Numerical Solution of Ordinary Differential Equations


Chapter 25

4
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Differential Equations

Differential equations play a fundamental role in engineering. Many physical phenomena are best formulated in terms of their rate of change:

dv c g v dt m

v- dependent variable t- independent variable

Equations which are composed of an unknown function and its derivatives are called differential equations. One independent variable ordinary differential equation (or ODE) Two or more independent variables partial diff. equation (or PDE) A first order equation includes a first derivative as its highest derivative Second order equation includes second derivative Higher order equations can be reduced to a system of first order equations, by redefining the variables.

Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

ODEs and Engineering Practice

Swinging pendulum

d 2 g sin 0 2 dt l
A second-order nonlinear ODE. Falling parachutist problem
6
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Solving Ordinary Differential Equations (ODEs)

This chapter is devoted to solving ordinary differential equations (ODEs) of the form

dy f ( x, y ) dx
New value old value slope * (step_size) yi 1 yi * h

Eulers Method
First derivative provides a direct estimate of the slope at xi:

f ( x i , yi )

(diff.equ. evaluated at x i and y i )

then, y i 1 y i f ( x i , y i ) h
7
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Example: Eulers Method


Solve numerically :
dy 2 x 3 12 x 2 20 x 8.5 dx
X

Percent Relative ERROR


yeuler ytrue 1 3.218 3.000 Error
Global

Error
Local

From x=0 to x=4 with step size h=0.5 initial condition: (x=0 ; y=1) Exact Solution: y = -0.5x4 + 4x3 - 10x2 + 8.5x + 1
Numerical Solution:

0 0.5 1.0

1 5.250 5.875

% 63.1 95.8

% 63.1 28

yi 1 yi f ( xi , yi )h

1.5
2.0

5.125
4.500

2.218
2.000

131.0
125.0

1.41
20.5

y(0.5) = y(0)+f(0, 1)0.5 = 1+8.5*0.5 = 5.25


(true solution at x=0.5 is y(0.5) = 3.22 and et = 63%)

y(1) = y(0.5)+f(0.5, 5.25)0.5 = 5.25+[-2(0.5)3+12(0.5)2-20(0.5)+8.5]*0.5 = 5.25+0.625 = 5.875


(true solution at x=1 is y(1) = 3 and et = 96%)

y(1.5) = y(1)+f(1, 5.875)0.5 = 5.125 .


8
Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Das könnte Ihnen auch gefallen