Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23.

Similar presentations


Presentation on theme: "Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23."— Presentation transcript:

1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23

2 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2 Part 6 Ordinary Differential Equations Equations which are composed of an unknown function and its derivatives are called differential equations. Differential equations play a fundamental role in engineering because many physical phenomena are best formulated mathematically in terms of their rate of change.

3 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Recall the parachutist problem from Chapter 1 3 v- dependent variable t- independent variable

4 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. ODE’s When a function involves one dependent variable, the equation is called an ordinary differential equation (or ODE). A partial differential equation (or PDE) involves two or more independent variables. 4 odepdeWave equation

5 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Order Differential equations are also classified as to their order. –A first order equation includes a first derivative as its highest derivative. –A second order equation includes a second derivative. 5

6 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Systems of equations Higher order equations can be reduced to a system of first order equations, by redefining a variable. 6

7 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. ODE’s and Engineering Practice 7

8 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 8 Initial Value Problems This chapter is devoted to solving ordinary differential equations of the form Euler’s Method was introduced in the first chapter Independent variable Dependent variable

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

10 10 The first derivative provides a direct estimate of the slope at x i where f(x i,y i ) is the differential equation evaluated at x i and y i. This estimate can be substituted into the equation: A new value of y is predicted using the slope to extrapolate linearly over the step size h.

11 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 11 Notice this function really only includes x, but we’ve included y to make the solution general

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

13 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Creating an Euler function 13

14 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Call the function from your main code 14

15 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 15 Error Analysis for Euler’s Method/ Numerical solutions of ODEs involves two types of error: –Truncation error Local truncation error Propagated truncation error –The sum of the two is the total or global truncation error –Round-off errors

16 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 16 The Taylor series provides a means of quantifying the error in Euler’s method. However; –The Taylor series provides only an estimate of the local truncation error-that is, the error created during a single step of the method. –In actual problems, the functions are more complicated than simple polynomials. Consequently, the derivatives needed to evaluate the Taylor series expansion would not always be easy to obtain. In conclusion, –the error can be reduced by reducing the step size –If the solution to the differential equation is linear, the method will provide error free predictions as for a straight line the 2 nd derivative would be zero.

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

18 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 18 Improvements of Euler’s method A fundamental source of error in Euler’s method is that the derivative at the beginning of the interval is assumed to apply across the entire interval. Two simple modifications are available to circumvent this shortcoming: –Heun’s Method –The Midpoint (or Improved Polygon) Method

19 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 19 Heun’s Method One method to improve the estimate of the slope involves the determination of two derivatives for the interval: –At the initial point –At the end point The two derivatives are then averaged to obtain an improved estimate of the slope for the entire interval.

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

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

22 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 22 Predictor Corrector

23 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 23 Heun’s Method Analytical Euler’s Method with h=1/2h Euler’s Method

24 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 24 MATLAB code to create the previous graph

25 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 25 The Midpoint (or Improved Polygon) Method/ Uses Euler’s method to predict a value of y at the midpoint of the interval:

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

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

28 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 28 Midpoint Method

29 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 29 This function includes both x and y

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

31 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 31 Runge-Kutta Methods (RK) Runge-Kutta methods achieve the accuracy of a Taylor series approach without requiring the calculation of higher derivatives. Increment function p’s and q’s are constants

32 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 32 k’s are recurrence functions. Because each k is a functional evaluation, this recurrence makes RK methods efficient for computer calculations. Various types of RK methods can be devised by employing different number of terms in the increment function as specified by n. First order RK method with n=1 is in fact Euler’s method. For n=1, eliminate all but the first term For Euler’s method, a 1 =1

33 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 33 Euler’s Method is a first order Runge-Kutta method

34 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. What about a second order? Once n is chosen, values of a’s, p’s, and q’s are evaluated by setting the general equation equal to terms in a Taylor series expansion. 34

35 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 35 Values of a 1, a 2, p 1, and q 11 are evaluated by setting the second order equation to Taylor series expansion to the second order term. Three equations to evaluate four unknowns constants are derived. A value is assumed for one of the unknowns to solve for the other three.

36 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 36 Because we can choose an infinite number of values for a 2, there are an infinite number of second-order RK methods. Every version would yield exactly the same results if the solution to ODE were quadratic, linear, or a constant. However, they yield different results if the solution is more complicated (typically the case). Three of the most commonly used methods are: –Heun Method with a Single Corrector (a 2 =1/2) –The Midpoint Method (a 2 =1) –Raltson’s Method (a 2 =2/3)

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

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

39 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Order Runge-Kutta The most popular RK methods are 4 th order There are an infinite number of versions We’ll look at the ‘Classical’ 4 th Order RK 39

40 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 40 Think of each of the k’s as a slope This is a weighted average of the slopes, similar in concept to Simpson’s 1/3 rule

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

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

43 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Built-in MATLAB Functions There is an entire series of ode solvers built into MATLAB They all have the same format, so that it is easy to switch between them The most popular are –ode23 –ode45 43

44 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 44 Function Handle Range of x values Initial y value Returns a graph Returns a set of ordered x and y values

45 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Built-In ODE Solvers This is actually an ‘adaptive’ RK method Notice that the spacing between points varies, depending on how much the slope changes 45

46 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 46 Adaptive Runge-Kutta Methods For an ODE with an abrupt changing solution, a constant step size can represent a serious limitation.

47 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 47 Step-Size Control The strategy is to increase the step size if the error is too small and decrease it if the error is too large. Press et al. (1992) have suggested the following criterion to accomplish this:  present = computed present accuracy  new = desired accuracy  = a constant power that is equal to 0.2 when step size increased and 0.25 when step size is decreased

48 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 48 Implementation of adaptive methods requires an estimate of the local truncation error at each step. The error estimate can then serve as a basis for either lengthening or decreasing step size.

49 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 49 Systems of Equations Many practical problems in engineering and science require the solution of a system of simultaneous ordinary differential equations rather than a single equation: Solution requires that n initial conditions be known at the starting value of x.

50 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. MATLAB’s ODE solvers can handle systems of 1 st order equations The system of equations must be stored in a single m-file, and is referenced with a function handle 50

51 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Example A linear model for a swinging pendulum 51 Dependant Variable Independant Variable

52 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. M-file Function to describe the system of equations 52 Notice that even though t is not used, it must still be included

53 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 53 Range of t values Initial conditions

54 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Solving Higher Order ODE’s Higher order ode’s can be reduced to a system of equations. Consider this second order differential equation 54

55 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Reformulate into a system of equations 55 The original second order equation is replaced by a system of two first order equations

56 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Rearrange to find the derivatives 56

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

58 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 58 Range of t valuesInitial conditions

59 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Summary There are many available techniques for solving differential equations We looked at –Euler’s Method –Heun’s Method –Midpoint Method –Runge Kutta Techniques 59 First order Runge Kutta Second order Runge Kutta The most popular are 4 th order

60 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. MATLAB Built-in Techniques There are a variety of built in ode solvers, all of which have the same format –Function handle –Range of values for the independent variable –Initial Conditions for the dependent variable(s) Next time we’ll look at some built-in techniques for ode’s where the boundary conditions are not the initial conditions 60

61 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. There is a streaming video presentation associated with the previous version of this PowerPoint file. You can find it in Blackboard/Vista 61


Download ppt "Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23."

Similar presentations


Ads by Google