Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 7 Differential Equation Problems

Similar presentations


Presentation on theme: "Chapter 7 Differential Equation Problems"— Presentation transcript:

1 Chapter 7 Differential Equation Problems
Solving Applied Mathematical Problems with MATLAB CRC/Taylor & Francis Press Chinese version by Tsinghua University Press PPT by Wenbin Dong and Jun Peng, Northeastern University, PRC Proofread by Dingyu Xue & YangQuan Chen 星期四, , 22:08:34 Slide 1 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

2 Chapter 7 MATLAB Solutions to Differential Equation Problems
Analytical Solutions of Differential Equations Numerical Solutions to Ordinary Differential Equations Numerical Solutions to Special Ordinary Differential Equations Solving Boundary Value Problems Introduction to Partial Differential Equations Solving Ordinary Differential Equations using Simulink Blocks 星期四, , 22:08:34 Slide 2 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

3 7.1 Analytical Solutions of Differential Equations
Mathematical descriptions Analytical solution methods Applications of Laplace transforms Analytical solutions to linear state-space equations Analytical solutions to special nonlinear differential equations 星期四, , 22:08:34 Slide 3 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

4 7.1.1 Mathematical descriptions
A general description of linear ordinary differential equations with constant coefficients: where are constants. 星期四, , 22:08:34 Slide 4 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

5 For zero initial value problems,
Correspondingly, the Laplace transform is: If the characteristic roots si are distinct roots, the analytical solutions become: where Ci are constants to be determined and g(t) is the special solution with respect to the input u(t) . 星期四, , 22:08:34 Slide 5 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

6 7.1.2 Analytical solution methods
Simple form, where the independent variable is assume to be t With independent variable of x 星期四, , 22:08:34 Slide 6 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

7 Example 7-1 Assume that the input signal is defined by
find the general solution to the ODE 星期四, , 22:08:34 Slide 7 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

8 Assume that the following conditions are given
Results Assume that the following conditions are given 星期四, , 22:08:34 Slide 8 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

9 星期四, , 22:08:34 Slide 9 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

10 the analytically solution to the equation can be obtained
Let the analytically solution to the equation can be obtained 星期四, , 22:08:34 Slide 10 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

11 The final solution is given by
星期四, , 22:08:34 Slide 11 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

12 Example 7-2 For input signal , solve with 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 12 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

13 Results 星期四, , 22:08:34 Slide 13 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

14 Example 7-3 Find the analytical solution to the differential equation sets Direct solution 星期四, , 22:08:34 Slide 14 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

15 7.1.3 Applications of Laplace Transforms
Transfer function: 星期四, , 22:08:34 Slide 15 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

16 If U(s) is given as a rational function
Then, the output signal can be expressed, after rearrangement of terms, by the following s-domain function With If U(s) is given as a rational function 星期四, , 22:08:34 Slide 16 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

17 Example 7-4 Given the input signal u(t)=e-5tcos(2t+1)+5 , assuming all zero initial conditions, solve analytically the differential equation 星期四, , 22:08:34 Slide 17 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

18 step 1: step 2: 星期四, , 22:08:34 Slide 18 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

19 Analytical output signal in time domain:
星期四, , 22:08:34 Slide 19 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

20 Using dsolve() function call
Step1: Step2: 星期四, , 22:08:34 Slide 20 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

21 The analytical solution is the same
Step3 The analytical solution is the same 星期四, , 22:08:34 Slide 21 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

22 7.1.4 Analytical solutions to linear state-space equations
Assume that the linear state-space model of a given system is where A,B,C,D are constant matrices, The analytical solutions for such an equation is 星期四, , 22:08:34 Slide 22 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

23 Example 7-5 For the input signal u(t) = 2 + 2e-3t sin 2t, find the analytical solutions to the system given by 星期四, , 22:08:34 Slide 23 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

24 Solution by direct integration
星期四, , 22:08:34 Slide 24 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

25 7.1.5 Analytical solutions to special nonlinear differential equations
Very few nonlinear differential equations can be analytically solved by dsolve() function An example for the analytical solution to a special nonlinear differential equation is demonstrated. Other examples which cannot be solved are also demonstrated. 星期四, , 22:08:34 Slide 25 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

26 Example 7-6 Solve nonlinear differential equation
Change the form of the original ODE: 星期四, , 22:08:34 Slide 26 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

27 Example 7-7 Try to find the analytical solutions to the well-known Van der Pol equation. The following command tested 星期四, , 22:08:34 Slide 27 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

28 7.2 Numerical Solutions to Ordinary Differential Equations
Overview of numerical solution algorithms Fixed-step Runge-Kutta algorithm and its MATLAB implementations Numerical solution to first-order differential equation sets Transforms to standard ordinary differential equations Validation of numerical solutions to ODEs 星期四, , 22:08:34 Slide 28 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

29 7.2.1 Overview of numerical solution algorithms
Explicit first-order differential equation Standard form where State vector Nonlinear functions 星期四, , 22:08:34 Slide 29 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

30 7.2.1.1 Numerical error and step-size problem
Euler algorithm: Consider IVP. Given x(t0), the initial state vector at time instant . The derivative in the left hand can be approximated by a simple Euler formula The solution can be approximated by 星期四, , 22:08:34 Slide 30 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

31 At time instant , the state vector is denoted by
So, suppose at any time instant tk ,the state vector is xk then, at the , Euler algorithm is given by h is called the step size. 星期四, , 22:08:34 Slide 31 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

32 Two reasons that we cannot reduce the step size h unlimitedly:
Slow down in computation Increase the cumulative errors Three considerations in numerically solving ODEs: Suitable step-size selection Improved algorithms Variable-step-size algorithms 星期四, , 22:08:34 Slide 32 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

33 7.2.2 Fixed-step Runge-Kutta algorithm and its MATLAB implementations
The fourth-order fixed step size Runge-Kutta algorithm: 星期四, , 22:08:34 Slide 33 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

34 The state vector for the next step:
where h is the step size The state vector for the next step: MATLAB syntax Loop structure can be used in the function See next slide the MATLAB implementations 星期四, , 22:08:34 Slide 34 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

35 星期四, , 22:08:34 Slide 35 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

36 7.2.3 Numerical solution to first-order differential equation sets
Runge-Kutta-Felhberg algorithm The current step is hk. Define 6 variables ki: State vector for the next step: 星期四, , 22:08:34 Slide 36 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

37 MATLAB functions for solving ordinary differential equations
Define an error vector: MATLAB functions for solving ordinary differential equations 星期四, , 22:08:34 Slide 37 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

38 Prepare the ODE's right hand side function (RHSF) under study as:
Modify the option parameters: 星期四, , 22:08:34 Slide 38 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

39 Solution Procedures Write mathematically the equation
Write MATLAB code for the equation M-function Anonymous function Inline function, not recommended Solve equation Draw results Verification of results 星期四, , 22:08:34 Slide 39 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

40 Example 7-8 Solve the following Lorenz model parameters
The initial values are 星期四, , 22:08:34 Slide 40 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

41 Describing the equation
M-function Anonymous function Inline function (not recommended) 星期四, , 22:08:34 Slide 41 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

42 MATLAB command for solutions
Phase space trajectory 星期四, , 22:08:34 Slide 42 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

43 Solving ODEs in MATLAB with additional arguments
Why to introduce additional arguments In the previous example, if parameters changes, no need to modify function additional arguments can be used New function format New calling command 星期四, , 22:08:34 Slide 43 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

44 Example 7-9 Prepare a MATLAB function with parameters for Lorenz equation. Then use the new function to find the numerical solutions for another set of parameters with additional parameters 星期四, , 22:08:34 Slide 44 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

45 Solution procedure in MATLAB
Phase space trajectory 星期四, , 22:08:34 Slide 45 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

46 Choose new parameters New calling command 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 46 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

47 7.2.4 Transforms to standard ordinary differential equations
Manipulating a single high-order ODE General high order ODE: with zero initial conditions select a set of state variables as 星期四, , 22:08:34 Slide 47 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

48 Then, the original high order ODE can be written as a set of first order ODEs:
with initial values 星期四, , 22:08:34 Slide 48 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

49 Example 7-10 Van der Pol equation With initial Selecting states
New ODE MATLAB code 星期四, , 22:08:34 Slide 49 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

50 MATLAB solutions A counter-example 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 50 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

51 A counter-example For the following parameters
Suggestions: DO NOT RUN the following Stiff equation algorithms should be used 星期四, , 22:08:34 Slide 51 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

52 Manipulating multiple high-order ODEs
State choosing method is not unique Suggestions: choose the state variables: 星期四, , 22:08:34 Slide 52 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

53 The new state equation is then
星期四, , 22:08:34 Slide 53 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

54 Example 7-11 Apollo satellite trajectory (x, y) is governed by
where and Initial states 星期四, , 22:08:34 Slide 54 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

55 Define a set of state variables: After conversion, the new ODE
Where And 星期四, , 22:08:34 Slide 55 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

56 MATLAB description 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 56 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

57 Solutions Verification 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 57 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

58 Step size plot Comments Should not rely too much on defaults
Better set precision control to Step size should be as small as Solutions should be verified 星期四, , 22:08:34 Slide 58 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

59 Example 7-12 Fixed step size Runge-Kutta algorithm where
星期四, , 22:08:34 Slide 59 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

60 Using a fixed step size 0.01:
星期四, , 22:08:34 Slide 60 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

61 Example 7-13 Solve the differential equation sets
Select the state variables: and 星期四, , 22:08:34 Slide 61 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

62 Substitute into the second eqn to find
The first order ODE can be constructed 星期四, , 22:08:34 Slide 62 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

63 With solve function One also finds 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 63 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

64 Transformation of differential matrix equations
The Lagrange equation Where matrices column vectors Selecting state vector 星期四, , 22:08:34 Slide 64 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

65 the state-space equation can be rewritten as
Where Thus the matrix equation can be solved with the ode45() or ode15s() functions 星期四, , 22:08:34 Slide 65 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

66 Example 7-14 Consider the inverted pendulum model expressed as
where q = [a,q1,q2]T, and a is the position of the cart, and q1, q2 are the angles of the two bars. The matrices are given by 星期四, , 22:08:34 Slide 66 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

67 The parameters 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 67 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

68 MATLAB description 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 68 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

69 Solving the inverted pendulum problem with the following MATLAB code
Original system unstable 星期四, , 22:08:34 Slide 69 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

70 7.2.5 Validation of numerical solutions to ODEs
It has been shown through examples that if the control parameters are not properly chosen, the solutions may not be correct. Thus the numerical solutions should be validated. The most effective control parameter is the RelTol property. The default value for it is 10-3, which is too large. It can be set respectively to 10-6 or even 10-8. 星期四, , 22:08:34 Slide 70 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

71 7.3 Numerical Solutions to Special Ordinary Differential Equations
Solutions of stiff differential equations Solutions of implicit differential equations Solutions to differential algebraic equations Solutions to delay differential equations 星期四, , 22:08:34 Slide 71 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

72 7.3.1 Solutions of stiff differential equations
In the Van der Pol equation, In many differential equations, the solutions to some states changes very rapidly while others may change very slowly. Stiff equations. An alternative function, ode15s(), can be used instead and this function has exactly the same syntax as that of the ode45() function. 星期四, , 22:08:34 Slide 72 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

73 Example 7-15 Find the numerical solutions to Van der Pol equation, when 星期四, , 22:08:34 Slide 73 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

74 Example 7-16 Solve the ODE Regarded as stiff in classical courses
The analytical solutions 星期四, , 22:08:34 Slide 74 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

75 Numerical solutions to the problem
星期四, , 22:08:34 Slide 75 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

76 Using a fixed step size:
For better results, one should reduce the step size, however slow 星期四, , 22:08:34 Slide 76 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

77 Example 7-17 Numerically solve the ODE Initial condition Solutions
星期四, , 22:08:34 Slide 77 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

78 Using variable step size:
Using ode15s() instead of ode45(): 星期四, , 22:08:34 Slide 78 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

79 7.3.2 Solutions of implicit differential equations
The so-called implicit differential equations are those who cannot be converted into the first-order explicit equations. The implicit equations can still be solved by the use of explicit equations. Or use of solver ode15i 星期四, , 22:08:34 Slide 79 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

80 Example 7-18 Given x1(0)=x2(0)=0 , numerically solve
By denoting x=[x1,x2]T, re-write the original ODE as follows: 星期四, , 22:08:34 Slide 80 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

81 where 星期四, , 22:08:34 Slide 81 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

82 Example 7-19 Given x(0)=[1,0,0,1]T, numerically solve
Define the state vector: Re-write the original implicit ODE: 星期四, , 22:08:34 Slide 82 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

83 Solve the Algebraic equation in the model
Describe the equation in MATLAB 星期四, , 22:08:34 Slide 83 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

84 continued from overleaf
The derivatives can be evaluated Solution process: 星期四, , 22:08:34 Slide 84 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

85 Use of ode15i(): It is a new ODE command in MATLAB 7.0 for solving implicit ODEs directly. General description of implicit ODEs: 星期四, , 22:08:34 Slide 85 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

86 Example 7-20 Using implicit ODE solution method, for initial state x(0)=[1,0,0,1]T State variables: 星期四, , 22:08:34 Slide 86 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

87 The differential equation can be rewritten as
Recall the form 星期四, , 22:08:34 Slide 87 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

88 Solutions 星期四, , 22:08:34 Slide 88 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

89 7.3.3 Solutions to differential algebraic equations
A more general form of the differential equations: is singular Differential algebraic equation Cannot use 星期四, , 22:08:34 Slide 89 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

90 Example 7-21 Given initial conditions, x1(0)=0.8, x2(0)=x3(0)=0.1, Numerically solve the following DAE: Using matrix form description for this DAE: 星期四, , 22:08:34 Slide 90 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

91 Solving the equation 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 91 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

92 Alternative solution method
We can also transform this DAE to the normal ODE. From the algebraic constraint: by substitution, we get An anonymous function can be written to describe the differential equations 星期四, , 22:08:34 Slide 92 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

93 Solving again 星期四, , 22:08:34 Slide 93 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

94 To use ode15i() command 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 94 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

95 Example 7-22 Solve when 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 95 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

96 7.3.4 Solutions to delay differential equations
General form of the DDEs where is the time delay for the state x(t) Implicit Runge-Kutta algorithm dde23() 星期四, , 22:08:34 Slide 96 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

97 Example 7-23 Numerically solve this DDE: Initial states
Select the state variables: 星期四, , 22:08:34 Slide 97 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

98 M-function description
New standard form M-function description 星期四, , 22:08:34 Slide 98 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

99 MATLAB solutions 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 99 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

100 Example 7-24 Neutral-type DDE Cannot be solved with dde23() function.
星期四, , 22:08:34 Slide 100 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

101 7.4 Solving Boundary Value Problems
Solutions of two-point boundary value problems Solutions of general boundary value problems 星期四, , 22:08:34 Slide 101 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

102 The above are the conditions at two boundaries a and b.
General mathematical description of boundary value problem for second-order differential equations: interval of interest: [a, b]. Study the solution when the following boundary conditions are specified: The above are the conditions at two boundaries a and b. 星期四, , 22:08:34 Slide 102 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

103 7.4.1 Solutions of two-point boundary value problems
Standard form Problem can be converted as Newton iteration: 星期四, , 22:08:34 Slide 103 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

104 where Solving this 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 104 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

105 where it is required to explicitly solve Prepare the MATLAB function:
星期四, , 22:08:34 Slide 105 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

106 Example 7-25 Solve the following boundary value problem to the nonlinear differential equations Derive the partial derivatives: We get 星期四, , 22:08:34 Slide 106 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

107 Analytical solution is Verification:
Solution process: Analytical solution is Verification: 星期四, , 22:08:34 Slide 107 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

108 7.4.2 Solutions of general boundary value problems
bvp5c() function for general BVPs Parameter initialization MATLAB descriptions to differential equations and boundary value problems 星期四, , 22:08:34 Slide 108 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

109 Example 7-26 Solve again the boundary value problem in Example 7.25 with the bvp5c() solver. Select states The new state equation MATLAB description 星期四, , 22:08:34 Slide 109 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

110 Rewrite the boundary conditions
The problem can be solved with Pay attention to the last command 星期四, , 22:08:34 Slide 110 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

111 If the boundary value problem is It can be rewritten as
The solution can be found by 星期四, , 22:08:34 Slide 111 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

112 Example 7-27 For a differential equation With Four conditions
find the parameters and solve the BVP 星期四, , 22:08:34 Slide 112 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

113 The equations can be written as
Let The equations can be written as MATLAB description 星期四, , 22:08:34 Slide 113 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

114 The problem can be solved with
星期四, , 22:08:34 Slide 114 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

115 7.5 Introduction to Partial Differential Equations
Solving a set of PDEs Mathematical description to the two-dimensional PDEs The GUI for the PDE Toolbox --- an introduction 星期四, , 22:08:34 Slide 115 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

116 7.5.1 Solving a set of PDEs The pdepe() command can be used to solve the following class of PDEs 星期四, , 22:08:34 Slide 116 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

117 Boundary conditions can be specified as
Initial conditions Simple MATLAB solutions of IC Solutions of PDE 星期四, , 22:08:34 Slide 117 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

118 Example 7-28 Solve the following PDE 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 118 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

119 The function Initial conditions Boundary conditions
星期四, , 22:08:34 Slide 119 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

120 Change the original PDE as the following:
Clearly, here , and also 星期四, , 22:08:34 Slide 120 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

121 The M-function describing the PDE
Specify the boundary conditions left bounds right bounds 星期四, , 22:08:34 Slide 121 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

122 Prepare the MATLAB function for BC:
Prepare the MATLAB function for IC: 星期四, , 22:08:34 Slide 122 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

123 Solution process: 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 123 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

124 7.5.2 Mathematical description to the two-dimensional PDEs
Four kinds of PDEs Elliptic Parabolic Hyperbolic Eigenvalue type 星期四, , 22:08:34 Slide 124 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

125 Elliptic PDEs General description of elliptic PDE: Gradient
where Gradient Divergence: 星期四, , 22:08:34 Slide 125 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

126 If c is a constant, the above can be simplified as
Elliptic PDEs: 星期四, , 22:08:34 Slide 126 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

127 Parabolic PDEs The general form of a parabolic PDE
If c is a constant, the above equation can be simplified as 星期四, , 22:08:34 Slide 127 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

128 Hyperbolic PDEs The general form of a hyperbolic PDE
If c is a constant, the above equation can be simplified 星期四, , 22:08:34 Slide 128 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

129 Eigenvalue PDEs An eigenvalue PDE problem is defined as
If c is a constant, the above equation can be simplified as 星期四, , 22:08:34 Slide 129 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

130 7.5.3 The GUI for the PDE Toolbox --- an introduction
PDE Toolbox --- an overview Start the PDE Toolbox GUI Type pdetool in MATLAB Four elements in this GUI Menu system Toolbar Set formula Solution regions 星期四, , 22:08:34 Slide 130 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

131 Drawing and defining the region in PDE solution
the button labeled as can be used to define the solution region. the button labeled as D, can be used to made triangular mesh within the solution region. Boundary conditions for PDEs Dirichlet BC: 星期四, , 22:08:34 Slide 131 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

132 Examples of PDE solution via PDE Toolbox
Neumann BC: Expanded form: where is the partial differential of u,w,r,t . The vector normal to x. Examples of PDE solution via PDE Toolbox 星期四, , 22:08:34 Slide 132 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

133 Example 7-29 Solving the following hyperbolic PDE:
星期四, , 22:08:34 Slide 133 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

134 Animation of the time varying solutions
Solving PDEs when parameters are not constants 星期四, , 22:08:34 Slide 134 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

135 Example 7-30 Assume that the partial differential equations are described as which is an elliptic PDE where Solve this PDE with u=0 on the boundary. 星期四, , 22:08:34 Slide 135 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

136 7.6 Solving Ordinary Differential Equations using Simulink Blocks
An introduction to Simulink Simulink --- relevant blocks Using Simulink for modeling and simulation of ODEs 星期四, , 22:08:34 Slide 136 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

137 7.6.1 An introduction to Simulink
1990 – first appearance of Simulink, with an old name of SimuLAB, renamed Simulink Simulink: two meanings simulation (simu) and model/block interconnection/link (link) Use odegroup to open self-defined model block library. 星期四, , 22:08:34 Slide 137 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

138 7.6.2 Simulink --- relevant blocks
Commonly used blocks: Input and output port blocks (In1, Out1) Clock block: generates time variable t Commonly used input blocks: Sine Step Constant Integrator block (Int): just to integrate the dynamic system Transport delay blocks (Transport Delay) 星期四, , 22:08:34 Slide 138 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

139 Mathematical operation blocks Mathematical function blocks
Gain blocks: Gain Sliding Gain Matrix Gain Mathematical operation blocks +, -, *, ÷ Mathematical function blocks Sin, exp Signal vectorization blocks: Mux DeMux 星期四, , 22:08:34 Slide 139 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

140 7.6.3 Using Simulink for modeling and simulation of ODEs
Build the corresponding Simulink model for ODE. Use sim( ) command to solve the Simulink block model. Get the ODE numerical solution. 星期四, , 22:08:34 Slide 140 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

141 Example 7-31 Solve Lorenz equation: with b=8/3, r=10, s=28, and initial conditions x1(0)= x2(0)= 0, x3(0)=10-10, Use Simulink to construct this model and obtain the simulation result. 星期四, , 22:08:34 Slide 141 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

142 Establish the block diagram Create model c7mlor1b.mdl Solve the system
Compare with ode45 results 星期四, , 22:08:34 Slide 142 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

143 Example 7-32 Solve the following DDE using Simulink.
Create model c7mdde2.mdl Solution process: 星期四, , 22:08:34 Slide 143 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

144 The first order state space model:
Assign the new states The first order state space model: 星期四, , 22:08:34 Slide 144 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

145 Example 7-33 Where t1=0.15, t2=0.5 Use Simulink to build this DDE system. 星期四, , 22:08:34 Slide 145 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

146 Enter the known matrices:
Create the model c7mdde3.mdl Solution process: 星期四, , 22:08:34 Slide 146 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

147 Chapter summary Functions 星期四, 2008-4- 24, 22:08:34
星期四, , 22:08:34 Slide 147 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

148 星期四, , 22:08:34 Slide 148 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

149 For general nonlinear ODE, it is not possible to obtain its analytical solution. So, must rely on numerical solutions. This chapter introduced the concept of numerical solution of ODEs starting with the simplest Euler algorithm. Then, for general numerical solutions, we introduced the basic idea and the related concept of step size. The MATLAB ODE solver ode45( ) has been introduced with several demo examples. 星期四, , 22:08:34 Slide 149 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

150 In initial value problem of ODEs can be solved easily when they are in the first-order explicit equations. If not, we introduced the conversion method using the concept of state variables. In particular, we introduced how to convert the high order ODEs into a set of first-order ODEs. Matrix differential equations are discussed, one may first convert the matrix differential equations into first-order explicit equations, then the equations can be solved. 星期四, , 22:08:34 Slide 150 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

151 When the ODE solution process is very slow, it is possible that the ODE is stiff and we must use stiff ODE solvers such as ode15s() for a reliable and fast solution. Additionally, we introduced other types of ODEs such as differential algebraic equations (DAEs), implicit ODEs, and delay differential equations (DDEs). The relevant MATLAB solution techniques for these special types of ODEs were introduced with examples. 星期四, , 22:08:34 Slide 151 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

152 For the boundary value problem (BVP) for second order ODEs, we can use the universal solver bvp5c() with examples. For partial differential equations (PDEs), we can use the ready commands provided in MATLAB PDE Toolbox. For 2D PDEs, we can use MATLAB PDE Toolbox via the GUI. This PDE toolbox is also useful for high dimensional PDEs. 星期四, , 22:08:34 Slide 152 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008

153 Simulink is an important dynamic system simulation platform within MATLAB. We can use the block diagram connections to construct any given dynamic system model using the existing Simulink block library. In this book, we focused more on Simulink basic knowledge and more on ODEs and DDEs. 星期四, , 22:08:34 Slide 153 (of 153) Dingyü Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008


Download ppt "Chapter 7 Differential Equation Problems"

Similar presentations


Ads by Google