Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2009
Introduction
Newtons second law to compute velocity v of a falling mass m as a function of time t c dv =g v dt m where g is gravitational constant, m is mass and c is drag coecient Eq. (1) is composed of unknown function, and its derivatives Such equation is called dierential equation or rate equation
Abu Hasan Abdullah 2009 1
(1)
Introduction
In Eq. (1) v = quantity being dierentiated, i.e. dependent variable t = quantity w.r.t. which dv is dierentiated, i.e. independent variable When function involves ONE independent variable, the equation is called the ordinary dierential equation. When function involves TWO or MORE independent variables, the equation is called the partial dierential equation.
2009
RHS of Eq. (2) is an indenite integral because limits of integration are not specied Eq. (2) can be solved analytically, assuming v = 0 at t = 0 to yield v(t) = gm 1 e(c/m)t c
2009
Order of ODE
Dierential equations are classied as to the order: First order equationhighest derivative is rst derivative dv c =g v dt m Second order equationhighest derivative is second derivative, for example equation describing position x of mass-spring system with damping d2 x dx m 2 + c + kx = 0 dt dt where c is gravitational constant and k is mass and c is drag coecient Similarly, nth order dierential equation would include nth derivative.
Abu Hasan Abdullah 2009 4
(3)
Order of ODE
Higher order dierential equation can be reduced to a system of rst order equations. For Eq. (3) above, we do it by dening dx y= dt which is dierentiated to yield dy d2x = 2 dt dt Eqs. (4) and (5) are then substituted into Eq. (3) to yield dy m + cy + kx = 0 dt
Abu Hasan Abdullah 2009
(4)
(5)
(6)
Order of ODE
Eq. (6) can be re-arranged into dy cy + kx = =0 dt m (7)
Thus Eqs. (4) and (7) are two rst order equations that are equivalent to the original second order equation, i.e. Eq. (3).
2009
Linearization
A linear ODE is one that t the general form an(x)y (n) + . . . + a1(x)y + a0(x)y = f (x) (8)
where y (n) is nth derivative of y w.r.t. x, a is specied function of x and c is specied function of x Eq. (8) is linear because there are NO products or nonlinear function of dependent variable y and its derivatives Why linear ODE are important? Because they can be solved analytically. In contrast, most nonlinear equations cannot be solved exactly!!
Abu Hasan Abdullah 2009 7
Linearization
Take an example of motion of a swinging pendulum governed by d2 g + sin = 0 dt2 l Eq. (9) is nonlinear because of the term sin To obtain solution, we linearize Eq. (9) by assuming, for small values of sin which, on substitution into Eq. (9), yields a linear form d2 g + =0 2 dt l
Abu Hasan Abdullah 2009
(9)
(10)
(11)
8
Linearization
(12)
(13)
Eq. (17) also describes the behaviour of a polynomial but in a dierent manner than Eq. (16)i.e. it gives rate of change of y w.r.t. x, which is a slope.
Abu Hasan Abdullah 2009 12
Eq. (18) is identical to Eq. (16) with one notable exception1 in Eq. (16) being replaced by C in Eq. (18) and C is the constant of integration which is arbitrary.
Abu Hasan Abdullah 2009 13
2009
14
2009
15
2009
18
2009
20
2009
21
2009
22
2009
23
2. Optionally, write the known solution into ytrue.m function y=ytrue(x) y = -0.5*x.^4 + 4*x.^3 - 10*x.^2 + 8.5*x + 1;
2009
24
2009
26
2009
27
(23)
(24)
2009
29
(25)
The two slopesEqs. (23) and (25)are combined to obtain average slope for the interval
o yi + yi+1 f (xi, yi ) + f (xi+1, yi+1) = y= 2 2
(26)
2009
30
(27)
Eq. (27) is known as the corrector equation Heuns method is the basis of many other predictor-corrector methods
2009
31
2009
32
2009
33
This average slope is then fed into the corrector equation (Eq. (27)) to give an estimate at x = 1 y1 = 2 + 4.701082(1) = 6.701082
2009
34
2009
35
2. Optionally, write the known solution into ytrue1.m function y=ytrue1(x) y = (4/1.3)*(exp(0.8*x) - exp(-0.5*x)) + 2*exp(-0.5*x);
2009
36
2009
38
where (xi, yi , h) is an increment function which is a representative slope over the interval and given by = a1k1 + a2k2 + . . . + ankn (29)
2009
39
2009
40
2009
41
(34)
(35)
(36)
(37) (38)
(39)
where f (xi, yi), by chain-rule dierentiation, yields f (x, y) f (x, y) dy f (xi , yi) = + x y dx
(40)
2009
44
2009
45
2009
46
f + x (43)
and collecting terms we get yi+1 = yi + a1f (xi, yi) + a2f (xi , yi) h+ f 2 f + a2q11f (xi, yi) h + O(h3) a2p1 x y
Abu Hasan Abdullah 2009
(44)
47
We now have 3 simultaneous equations containing 4 unknown constants hence, theres no unique solution. However, assuming a value for one of the constants, we can determine the other 3! Consequently, there is a family of second order RK methods rather than a single version!
Abu Hasan Abdullah 2009 48
(45)
1 2 1 2
2009
50
and p1 = q11 = 1.
(53)
where k1 = f (xi, yi ) k2 = f (xi + h, yi + k1h) : slope at begining of interval : slope at end of interval (54) (55)
2009
51
(57) (58)
2009
52
Choosing a2 = 2 provides a minimum bound on the truncation error for second 3 order RK algorithms. It leads to a1 = 1 and p1 = q11 = 3 , and yields 3 4 yi+1 = yi + where k1 = f (xi, yi)
3 3 k2 = f (xi + 4 h, yi + 4 k1h) 1 3 k1 2 + 3 k2 h
(59)
(60) (61)
2009
53
To use Eq. (62), values for a1, a2, a3, p1, p2, q11, q21 and q22 must rst be determined.
Abu Hasan Abdullah 2009 54
(66)
k3 = f (xi + h, yi hk1 + 2hk2) See Section 9.7.3 on page 658 of Rao (2002) for details.
Abu Hasan Abdullah 2009 55
(67)
k4 = f (xi + h, yi + hk3)
2009
56
2009
57
3 2 k1 = 2(0.0) + 12(0.0) 20(0.0) + 8.5 = 8.5000 3 2 k2 = 2(0.0 + 0.5 0.5) + 12(0.0 + 0.5 0.5) 20(0.0 + 0.5 0.5) + 8.5 = 4.2188 3 2 k3 = 2(0.0 + 0.5 0.5) + 12(0.0 + 0.5 0.5) 20(0.0 + 0.5 0.5) + 8.5 = 4.2188 3 2 k4 = 2(0.0 + 0.5) + 12(0.0 + 0.5) 20(0.0 + 0.5) + 8.5 = 1.2500
Hence, estimate at x = 0.5 is
yi+1 = yi + 1 (k1 + 2k2 + 2k3 + k4 )h 6 1 y(0.5) = 1 + 8.5 + 2(4.21875) + 2(4.21875) + 1.25 0.5 = 3.2188 6
2009
58
At x = 0.5
k1 = 2(0.5)3 + 12(0.5)2 20(0.5) + 8.5 = 1.25000 k2 = 2(0.5 + 0.5 0.5)3 + 12(0.0 + 0.5 0.5)2 20(0.0 + 0.5 0.5) + 8.5 = 0.5938 k3 = 2(0.0 + 0.5 0.5)3 + 12(0.0 + 0.5 0.5)2 20(0.0 + 0.5 0.5) + 8.5 = 0.5938 k4 = 2(0.5 + 0.5)3 + 12(0.5 + 0.5)2 20(0.5 + 0.5) + 8.5 = 1.50000
Hence, estimate at x = 1.0 is
1 yi+1 = yi + 6 (k1 + 2k2 + 2k3 + k4 )h 1 y(1.0) = 1 + 1.2500 + 2(0.5938) + 2(0.5938) 1.5000 0.5 = 3.0000 6
2009
59
from x = 0 to x = 0.5 with step size of 0.5 and initial condition of y(0) = 2.
2009
60
2. Optionally, write the known solution into ytrue1.m function y=ytrue1(x) y = (4/1.3)*(exp(0.8*x) - exp(-0.5*x)) + 2*exp(-0.5*x);
2009
61
2009
62
2009
63
2009
64
2009
65
2009
67
2009
69
(68)
2009
70
(69)
(70)
4. System of ODE represented by the rst order Eqs. (69) and (70) can be then be written into a user-dened function in Matlab called, say iv0.m, as shown below function ydot=iv0(t,y) y1dot = y(2); y2dot = -3*y(2) - y(1) + 5; ydot = [y1dot;y2dot];
2009
72
2009
73
dx dt
2009
74
2009
75
2. Matlab script to solve the above ODE and plotting its solutions may take the following form: % callvdpol.m -- program to call vdpol.m function to solve % the classic van der Pol equation tspan=[0 20]; % time span yo = [2; 0]; % initial condition [t,y] = ode45(vdpol,tspan,yo); % solve the ODE-IVP plot(t,y(:,1),t,y(:,2),--) xlabel(time) ylabel(y1dot and y2dot) title(van der Pol Solution)
Abu Hasan Abdullah 2009 76
2009
77
2009
78
(73b)
2009
79
(74)
80
Subsituting Eqs. (75), (74) and (72) into Eq. (71) and making substitution dx3/dt = d3x1/dt3, etc. yields dx3 = 3x3 5x2 7x1 + 6 dt This is the third equation of the system. (76)
2009
81
2009
82
2009
83
2009
84
conditions are specied at the dierent values of the independent variable; in this case at x = 0 and x = L, where y = y0 y = yL @ x=0 @ x=L
2009
85
2009
86
2009
87
2009
88
2009
89
2009
90
2009
91
2009
92
A cooling n extending from a hot furnace, assuming heat ows only in x-direction d2 T kA 2 hP (T T) = 0 dx (83)
2009
93
2009
94
2009
95