MB4018 Differential equations Part II http://www.staff.ul.ie/natalia/mb4018.html Prof. Natalia Kopteva Spring 2015 MB4018 (Spring 2015) Differential equations Part II 0 / 69
Section 1 Second-Order Linear ODEs (involve second-order derivatives) A second-order ODE is called linear if it can be written as y + p(x) y + q(x) y = R(x) ( ) for some functions p(x) and q(x), called the coefficients. and some function R(x) called the right-hand side. Otherwise it is called nonlinear. E.g., y + x y = cos x is linear; while y y + x y + y 3 = 0 is nonlinear........................................................................ In the linear case ( ): if R(x) = 0, it is called homogeneous; if R(x) 0, it is called nonhomogeneous. Section 1 Second-Order Linear ODEs 1 / 69
A general solution of ( ) is a formula that describes all solutions of ( ) as particular cases. Example: for the ODE 2x 2 y x y 2 y = 4, the general solution is y = C 1 x 2 + C 2 1 x 2 (where C 1, C 2 are arbitrary constants). NOTE: A general solution of a linear second-order ODE must involve two arbitrary constants........................................................................ A particular solution is found by obtaining values for the 2 arbitrary constants from 2 initial or boundary conditions, e.g., y(x 0 ) = A, y (x 0 ) = B Initial conditions y(x 0 ) = A, y(x 1 ) = B Boundary conditions Section 1 Second-Order Linear ODEs 2 / 69
1.1 Homogeneous ODEs y + p(x) y + q(x) y = 0 ( ) (it s ( ) with R(x) = 0)....................................................................... SUPERPOSITION PRINCIPLE: If y 1 (x) and y 2 (x) are any 2 solutions of ( ), then A y 1 (x) + B y 2 (x) is also a solution of ( ) for any real A and B. Proof: y 1 + p(x) y 1 + q(x) y 1 = 0 y 2 + p(x) y 2 + q(x) y 2 = 0 (A y 1 + B y 2 ) + p(x) (A y 1 + B y 2 ) + q(x) (A y 1 + B y 2 ) = 0....................................................................... Section 1 Second-Order Linear ODEs 3 / 69
A general solution of a homogeneous linear second-order ODE always has the form: y = C 1 y 1 (x) + C 2 y 2 (x) where C 1, C 2 are arbitrary constants, y 1 (x), y 2 (x) are two different particular solutions of the ODE such that y 1(x) y 2 (x) constant. Such particular solutions are called linearly independent. CONCLUSION: It suffices to find 2 linearly independent particular solutions to construct a general solution for equation ( ). Example: for the ODE 2x 2 y x y 2 y = 0, and y 1 (x) = x 2, y 2 (x) = 1 x are two particular solutions, so a general solution is y = C 1 x 2 + C 2 1 x, where C 1, C 2 are arbitrary constants........................................................................ Section 1 Second-Order Linear ODEs 4 / 69
Problems for 1.1 1 Consider the initial-value problem x 2 y 7xy + 15y = 0, y(1) = 1, y (1) = 0. 1 Check that the functions x 5 and x 3 are particular solutions of the above ODE. 2 Check that x 5 and x 3 are linearly independent. 3 Hence construct a general solution of the above ODE. 4 Solve the above initial-value problem, i.e. find a unique solution of the ODE that satisfies the 2 initial conditions. 2 Consider the boundary-value problem x 2 y + 3xy 3y = 0, y(1) = 1, y(2) = 31 8. 1 Check that the functions x and x 3 are particular solutions of the above ODE. 2 Check that x and x 3 are linearly independent. 3 Hence construct a general solution of the above ODE. 4 Solve the above boundary-value problem, i.e. find a unique solution of the ODE that satisfies the 2 boundary conditions. Section 1 Second-Order Linear ODEs 5 / 69
1.2 Homogeneous ODEs with Constant Coefficients If the coefficients p(x) and q(x) in ( ) are constant, this ODE is called a linear ODE with constant coefficients. Consider the homogeneous and nonhomogeneous cases separately........................................................................ Consider a homogeneous linear second-order ODE with constant coefficients: y + b y + c y = 0 To find a solution, we make a conjecture that it has the form y = e r x ( ) with some (unknown at this stage) constant r. To find r: substitute our guess in ( ): y = e rx y = r e r x y = r 2 e r x so substitution in ( ) yields: r 2 e r x + b r e r x + c e r x = 0 r 2 + b r + c = 0 ( ) this quadratic equation is called auxiliary (characteristic) for ODE ( ). Its roots are r = b ± b 2 4c 2. Section 1 Second-Order Linear ODEs 6 / 69
Case 1: let b 2 4c > 0. Then ( ) has 2 distinct real roots r 1 and r 2. So ODE ( ) has 2 different particular solutions y 1 = e r1x and y 2 = e r2x. So general solution is y = C 1 e r1x + C 2 e r 2x Section 1 Second-Order Linear ODEs 7 / 69
Case 2: let b 2 4c = 0. Then ( ) has only one root r 1 = b 2 so ODE ( ) has a particular solution y 1 = e r 1x. But to get a general solution, we need another particular solution y 1! First, rewrite ( ) as y + b y + b2 4 y = 0. Make another solution guess y 2 = x e r1x. To check, whether y 2 is indeed a solution, substitute it into our ODE: y 2 = (1 + x r 1) e r 1x y 2 = (2 r 1 + x r1 2) er 1x Hence y 2 + b y 2 + b2 4 y 2 = [ (2 r 1 + x r1 2) + b (1 + x r 1) + b2 4 }{{ x] } er1x = 0 =0 as r 1 = b 2 (Ex.) Hence y 2 (x) is indeed another particular solution of ( ) so the general solution y = C 1 y 1 (x) + C 2 y 2 (x) becomes y = (C 1 + C 2 x) e r1x. Section 1 Second-Order Linear ODEs 8 / 69
Case 3: let b 2 4c < 0 similar to Case 1: ( ) has 2 distinct roots, but they are complex: r 1 = α + i β and r 2 = α i β. As in Case 1, the ODE ( ) has a general solution y = C 1 e r1x + C 2 e r2x = C 1 e (α+i β) x + C 2 e (α i β) x where C 1, C 2 are arbitrary complex constants. To restrict this formula to real functions and constants, recall that e (α+i β) x = e α x e i β x = e α x( cos(β x) + i sin(β x) ) e (α i β) x = e α x e i β x = e α x( cos(β x) i sin(β x) ) These imply: y(x) = e α x( (C 1 + C 2 ) cos(β x) + i (C }{{} 1 C 2 ) sin(β x) ) }{{} C 1 C 2 Finally, a general solution of ( ) is written as y = e α x( C 1 cos(β x) + C 2 sin(β x)) (where C 1, C 2 are arbitrary real constants). Section 1 Second-Order Linear ODEs 9 / 69
For a homogeneous linear second-order ODE with constant coefficients: y + b y + c y = 0 ( ) Summary: Roots of ( ) General Solution of ( ) (1) b 2 4c > 0 2 real roots: r 1, r 2 y = C 1 e r 1x + C 2 e r 2x (2) b 2 4c = 0 1 real root r 1 = b 2 y = (C 1 + C 2 x) e r 1x (3) b 2 4c < 0 2 complex roots: r 1,2 = α ± i β y = e α x( C 1 cos(β x) + C 2 sin(β x) ) where r 2 + b r + c = 0 ( ) Section 1 Second-Order Linear ODEs 10 / 69
Examples: 1 y + y 2 y = 0. S: r 2 + r 2 = 0 r = 1± 1 2 4 ( 2) 2 r 1 = 2, r 2 = 1 y 1 = e 2x, y 2 = e x y = C 1 e 2x + C 2 e x 2 16 y 8 y + y = 0. S: 16 r 2 8 r + 1 = 0 r = 8± 8 2 4 16 2 16 = 1 4 single real root y = (C 1 + C 2 x) e x/4 3 y + 4 y + 13 y = 0 S: r 2 + 4 r + 13 = 0 r = 4± 4 2 4 13 2 = 2 ± 9 r = 2 ± 3 i: r 1 = 2 + 3 i, r 2 = 2 3 i (i.e. α = 2, β = 3) y = e 2 x( C 1 cos(3 x) + C 2 sin(3 x) ) Section 1 Second-Order Linear ODEs 11 / 69
Problems for 1.2 1 Find the general solutions of the following differential equations: 1 y y = 0 2 y 2y 3y = 0 3 y + 4y = 0 4 4y + 4y + y = 0 2 Find the solution of the following initial-value problems 1 y + 4y = 0, y(0) = 0, y (0) = 1; 2 y + 4y + 5y = 0, y(0) = 1, y (0) = 0; 3 y 6y + 13y = 0, y(π/2) = 0, y (π/2) = 2; 4 y + y = 0, y(π/3) = 2, y (π/3) = 4. Section 1 Second-Order Linear ODEs 12 / 69
1.3 Physical Example: Damped Mass-Spring System A mass m is attached to a spring with spring constant k, and to a dashpod with damping coefficient c. Its displacement at time t (w.r.t. the rest point) is x(t). RECALL: By Newton s Second Law: mass acceleration = force m a = } k {{ x } } {{ c v } damping force is proportional to v Here a = d 2 x dt 2 Hook s force is proportional to x So x(t) satisfies the ODE: is the acceleration, v = dx dt is the velocity. m d 2 x dt 2 + c dx dt + k x = 0 (with positive constants m, c, k > 0). Section 1 Second-Order Linear ODEs 13 / 69
(a) c = 0, i.e. no damping: called simple harmonic motion, m r 2 + 0 r + k = 0 has complex roots r 1,2 = ±i k x(t) = C 1 cos( m t) + C k 2 sin( m t) k m....................................................................... (b) c > 0, c 2 < 4mk, i.e. Damped Oscillator: m r 2 + c r + k = 0 ( ) has roots r 1,2 = c± c 2 4mk 2m i.e. r 1,2 = c 2m ± i β with β = 4mk c 2 2m x(t) = e 2m c t ( C 1 cos(β t) + C 2 sin(β t) )....................................................................... Section 1 Second-Order Linear ODEs 14 / 69
....................................................................... (c) c 2 = 4mk, i.e. Critically Damped case: ( ) has a single root: r 1 = c 2m x(t) = (C 1 + C 2 t) e 2m c t no oscillations....................................................................... (d) c 2 > 4mk, i.e. Overdamped case: ( ) has 2 real roots r 1 < r 2 < 0 x(t) = C 1 e r1t + C 2 e r 2t decay, no oscillations.......................................................................... Section 1 Second-Order Linear ODEs 15 / 69
Problems for 1.3 1 The motion of a certain spring-mass system is governed by the differential equation x + 0.125x + x = 0 where x = x(t) is measured in feet and t in seconds. If x(0) = 2 and x (0) = 0, determine the position of mass at any time................................................................... 2 The motion of a certain spring-mass system is governed by the differential equation x + c x + x = 0 where x = x(t) is measured in feet and t in seconds, and c is the damping coefficient. How large should one choose the damping coefficient c so that there are no oscillations? Section 1 Second-Order Linear ODEs 16 / 69
1.4 Nonhomogeneous Linear ODEs Consider a nonhomogeneous linear second-order ODE y + p(x) y + q(x) y = R(x) ( ) The corresponding homogeneous equation: y h + p y h + q y h = 0 ( )....................................................................... If y p (x) is any particular solution of ( ), while y h (x) is any solution of ( ), then y p (x) + y h (x) is also a solution of ( ). y y p + p y p + q y p = R(x) Proof: h + p y h + q y h = 0 (y p + y h ) + p (y p + y h ) + q (y p + y h ) = R(x)....................................................................... Section 1 Second-Order Linear ODEs 17 / 69
Hence, general solution of nonhomogeneous equation ( ) = particular general solution solution of ( ) + of homogeneous equation ( ) }{{} this must involve 2 arbitrary constants To find a general solution of nonhomogeneous equation ( ): Step 1: Find a general solution of the corresponding homogeneous equation ( ) (e.g., as in 1.2). Step 2: Add a particular solution of ( ). To find this, there are various methods; two of them are Method of Undetermined Coefficients (see 1.5) Variation of Parameters (see 1.6) Section 1 Second-Order Linear ODEs 18 / 69
1.5 Method of Undetermined Coefficients Method of Undetermined Coefficients applies to the constant-coefficient y + b y + c y = R(x) ( ) R(x) Try y p (x) = α α x + β α x 2 + β x + γ A A x + B A x 2 + B x + C polynomial of degree n another poly of the same degree n α e kx A e kx (α + β x) e kx (A x + B) e kx α cos(kx) + β sin(kx) A cos(kx) + B sin(kx) (α x + β) cos(kx) + (γ x + δ) sin(kx)(a x + B) cos(kx) + (C x + D) sin(kx) }{{} Make this guess, substitute in ( ), then choose A, B, C... in y p (x) so that y p + b y p + c y p = R(x)... Section 1 Second-Order Linear ODEs 19 / 69
Examples: 1 y + y = x 2 Step 1: y h + y h = 0 homogeneous r 2 + 1 = 0 r = ±i y h = C 1 cos x + C 2 sin x Step 2: We guess that y p = A x 2 + B x + C (see the Table) y p = 2A x + B y p = 2A Substitute in the ODE: }{{} 2A + (A x 2 + B x + C) = x }{{} 2 =y p =y p A x 2 + B x + (2A + C) = 1 x 2 A = 1, B = 0, (2A + C) = 0 C = 2A = 2 y p = 1 x 2 2 + 0 x = x 2 2 Finally, a general solution: y = (x 2 2) + C 1 cos x + C 2 sin x Section 1 Second-Order Linear ODEs 20 / 69
2 y y 2y = 10 cos t subject to y(0) = 0 and y (0) = 2. Plan: (i) find a general solution of the ODE; (ii) use the initial conditions. (i) Step 1: y h y h 2y h = 0 homogeneous r 2 r 2 = 0 r 1 = 2, r 2 = 1 y h = C 1 e 2t + C 2 e t Step 2: Our guess is y p = A cos t + B sin t y p = A sin t + B cos t y p = A cos t B sin t So y p y p 2y p = cos t ( A B 2 A ) + sin t ( B + A 2 B ) = cos t ( 3 A B ) + sin t ( A 3 B ) = 10 cos t } 3 A B = 10 A 3 B = 0 B = 1, A = 3 y p = 3 cos t sin t General solution: y = ( 3 cos t sin t) + C 1 e 2t + C 2 e t Section 1 Second-Order Linear ODEs 21 / 69
Example 2 (continued): (ii) Use initial conditions y(0) = 0: 0 = ( 3 cos }{{ 0} sin }{{} 0) + C 1 1 + C 2 1 C 1 + C 2 = 3 =1 =0 y (0) = 2: Note that y = (3 sin t cos t) + 2 C 1 e 2t C 2 e t 2 = (3 sin }{{} 0 cos }{{ 0} ) + 2 C 1 1 C 2 1 2 C 1 C 2 = 3 } C =0 =1 1 + C 2 = 3 2 C 1 C 2 = 3 C 1 = 2, C 2 = 1 y = ( 3 cos t sin t) + 2 e 2t + e t Section 1 Second-Order Linear ODEs 22 / 69
Remark 1 Remark 1: Consider y + b y + c y = R 1 (x) + R 2 (x) ( ) If y 1 + b y 1 + c y 1 = R 1 (x) and y 2 + b y 2 + c y 2 = R 2 (x) then y 1 + y 2 is a particular solution of ( ). Section 1 Second-Order Linear ODEs 23 / 69
Further Examples: 3 y + 4y = sin t + 2 e t. Step 1: y h + 4y h = 0 homogeneous r 2 + 4 = 0, r = ±2 i y h = C 1 cos(2t) + C 2 sin(2t) Step 2: R(x) Try y p (x) = Our Table sin t A cos t + B sin t e t C e t Remark 1 sin t + 2 e t A cos t + B sin t + C e t So y p = A cos t + B sin t + C e t y p = A cos t B sin t+c e t y p +4y p = ( A cos t B sin t +C e t) +4 ( A cos t +B sin t +C e t) 3 A = 0 = 3 A cos t + 3 B sin t + 5 C e t = sin t + 2 e t 3 B = 1 A = 0, B = 1 3, C = 2 5 y p = 1 3 sin t + 2 5 e t 5 C = 2 General solution: y = 1 3 sin t + 2 5 e t + C 1 cos(2t) + C 2 sin(2t) Section 1 Second-Order Linear ODEs 24 / 69
(Very Important) Remark 2 If the guess from the Table happens to be a particular solution of the homogeneous equation ( ), then use y p = x (guess from Table ). If the new guess also happens to be a particular solution of the homogeneous equation ( ), then use y p = x 2 (guess from Table ) Section 1 Second-Order Linear ODEs 25 / 69
Further Examples:................................................... 4 y 2 y 3 y = e x Step 1: y h = C 1 e 3x + C 2 e x (check!) Step 2: The Table suggests: y p = A e x, but it is a particular case of y h : it s clear from the y h formula (set C 1 = 0 and C 2 = A); alternatively, one can see this directly: (A e x ) 2 (A e x ) 3 (A e x ) = 0 e x. Clearly, y p = A e x doesn t work! By Remark 2, try y p = x A e x : y p = A (1 x) e x, y p = A (x 2) e x y p 2 y p 3 y p = A ( (x 2) 2 (1 x) 3 x ) e x = A ( 4) e x = e x 4A = 1 A = 1 4 y p = 1 4 x e x y = 1 4 x e x + C 1 e 3x + C 2 e x Section 1 Second-Order Linear ODEs 26 / 69
5 y + 4y + 4y = e 2t Step 1: r 2 + 4r + 4 = 0 r = 2 single root y h = (C 1 + C 2 t) e 2t Step 2: The Table suggests y p = A e 2t But (A e 2t ) + 4(A e 2t ) + 4(A e 2t ) = 0, e 2t (can be checked directly; of from the y h formula...) By Remark 2, try y p = t A e 2t again won t work as By Remark 2, now try (t A e 2t ) + 4(t A e 2t ) + 4(t A e 2t ) = 0, e 2t (can be checked directly; of from the y h formula...) y p = t 2 A e 2t y p = (2t 2t 2 ) A e 2t, y p = (2 8t + 4t 2 ) A e 2t y p + 4y p + 4y p = ( (2 8t + 4t 2 ) + 4 (2t 2t 2 ) + 4 t 2) A e 2t = 2 A e 2t = e 2t A = 1 2 y p = 1 2 t2 e 2t y = 1 2 t2 e 2t + (C 1 + C 2 t) e 2t Section 1 Second-Order Linear ODEs 27 / 69
6 y + 4y = 8 cos(2t) Step 1: y h = C 1 cos(2t) + C 2 sin(2t) (see Example 3). Step 2: The Table suggests y p = A cos(2t) + B sin(2t) But will NOT work as it s a particular case of the y h formula... By Remark 2, try y p = t (A cos(2t) + B sin(2t) ) y p + 4y p = 4 B cos(2t) + 4 ( A) sin(2t) = 8 cos(2t) B = 2, A = 0 so y p = 2t sin(2t) Finally, we get the Answer: y = 2t sin(2t) + C 1 cos(2t) + C 2 sin(2t) NOTE: this phenomenon is referred to as resonance (see the prime text...) Section 1 Second-Order Linear ODEs 28 / 69
Problems for 1.5 1 Find general solutions of the following differential equations: 1 y 2y 3y = 2x 2 y 2y 3y = 11 + cos x................................................................... 3 y y = 5 sin(3x) 4 y y = e x 5 y y = e x 6 y y = 3 7 y y = 7x 8 y y = x e 2x................................................................... 9 y 2y + 3y = x 3 10 y 4y = e 2x 11 y 3y = 2e 2x sin x Section 1 Second-Order Linear ODEs 29 / 69
2 Find unique solutions of the following initial-value problems 1 y + y 2y = e x + e 2x, y(0) = 0, y (0) = 4/3 2 y + 4y = 3x cos x, y(0) = 1, y(π/4) = 0 3 y 4y + 4y = e 2x, y(0) = y (0) = 0 3 Find unique solutions of the following initial-value problems 1 4y 4y + y = 5 2 e x/2, y(0) = 1, y (0) = 3 2 y + 3y = 10 sin x 6, y(0) = 3, y (0) = 0 3 y 2y 3y = 8e 3x, y(0) = 4, y (0) = 2 4 y 2y + 5y = 25 x 2, y(0) = 1.6, y (0) = 4. Section 1 Second-Order Linear ODEs 30 / 69
1.6 Variation of Parameters Applies to y + p(x) y + q(x) y = R(x) ( ) NOTE: the coefficients are NOT necessarily constant! Step 1: Find a general solution of the corresponding homogeneous equation y h + p y h + q y h = 0 ( ) (e.g., as in 1.2): So we get y = C 1 y 1 (x) + C 2 y 2 (x) ( ) Step 2: Replace the constants C 1 and C 2 in (***) by the unknown functions u(x) and v(x): y = u(x) y 1 (x) + v(x) y 2 (x) ( ) Step 3: Next, find u(x) and v(x) such that ( ) gives a particular solution of ( ) (more detail on next page) Step 4: Finally, add ( ) to ( ), to get a general solution: y = u(x) y 1 (x) + v(x) y 2 (x) + C 1 y 1 (x) + C 2 y 2 (x) Section 1 Second-Order Linear ODEs 31 / 69
Step 3 more DETAIL: substitute ( ) in our ODE ( ) y = u(x) y 1 (x) + v(x) y 2 (x) ( ) (i) Evaluate y (x): y = [u y 1 + v y 2 ] + [u y 1 + v y 2 ] always ASSUME u y 1 + v y 2 = 0 This greatly simplifies y : y = u y 1 + v y 2 (ii) Evaluate y (x): y = [u y 1 + v y 2 ] + [u y 1 + v y 2 ] (iii) Substitute y (x), y (x) and y(x) in in our ODE ( ); combining this with y 1 + py 1 + qy 1 = 0 and y 2 + py 2 + qy 2 = 0 yields u y 1 + v y 2 = R(x)....................................................................... CONCLUSION: Step 3 reduces to solving the system of 2 equations for u and v : u y 1 + v y 2 = 0 ; u y 1 + v y 2 = R(x) Section 1 Second-Order Linear ODEs 32 / 69
....................................................................... CONCLUSION (from previous page): Step 3 reduces to solving the system of 2 equations for u and v : u y 1 + v y 2 = 0 ; u y 1 + v y 2 = R(x)....................................................................... This matrix form of this system is [ ] [ ] [ ] y1 y 2 u 0 y 1 y 2 v = R(x) and the solution is u (x) = y 2 R(x) W (x), v (x) = y 1 R(x) W (x), where W (x) = y 1 y 2 y 2 y 1 It remains to apply integration: y2 R(x) u(x) = W (x), v(x) = y1 R(x) W (x), where W (x) = y 1 y 2 y 2 y 1........................... End of Step 3........................... Section 1 Second-Order Linear ODEs 33 / 69
EXAMPLES: Using variation of parameters, find the general solutions of the following ODEs. 1 y 5y + 6y = 2e x. Answer: y(x) = e x + C 1 e 2x + C 2 e 3x. NOTE: Variation of parameters is not the best method for this example. But this method works for any R(x). 2 y + 2y + y = e x ln x. [ x 2 3x 2 ] Answer: y(x) = ln x 2 4 + C 1 + C 2 x e x. Section 1 Second-Order Linear ODEs 34 / 69
Problems for 1.6 Find general solutions of the following differential equations using variation of parameters : 1 y 5y + 6y = 2e x Answer: y = e x + C 1 e 2x + C 2 e 3x 2 y y = sin 2 x 3 y 4y + 4y = e2x 1 + x 4 y + 4y + 4y = x 2 e 2x ; Answer: y = e 2x ln x + C 1 e 2x + C 2 x e 2x 5 y 2y + y = ex 1 + x 2 ; Answer: y = 1 2 ex ln(1 + t 2 ) + x e x tan 1 x + C 1 e x + C 2 x e x Section 1 Second-Order Linear ODEs 35 / 69
1.7 Euler Equations Euler Equations are equations of the type x 2 y + b x y + c y = R(x) ( ) where x > 0, and b and c are constants. NOTE: This is a linear second-order ODE. The coefficients are NOT constant, but 1.1, 1.4 and 1.6 apply........................................................................ A simple TRICK reduces this ODE to the constant-coefficient case: Now, a calculation using d dx = dt d dx = 1 x d dt and then (CHECK!!!) d 2 y dt 2 Let t = ln x x = e t dx d dt and dt + (b 1) dy dt + c y = R(e t ) dx = d dx ln x = 1 x yields....................................................................... Section 1 Second-Order Linear ODEs 36 / 69
NOTE: depending on R(x), it may be convenient to apply this trick to the original nonhomogeneous equation or to its homogeneous version only........................................................................ EXAMPLES: 1 Find general solutions for the following homogeneous Euler equations: 1 x 2 y 7xy + 15y = 0 Answer: y(x) = C 1 x 5 + C 2 x 3 (see Problems for 1.1). 2 x 2 y + xy + y = 0 Answer: y(x) = C 1 cos(ln x) + C 2 sin(ln x). Section 1 Second-Order Linear ODEs 37 / 69
NOTE: depending on R(x), it may be convenient to apply the substitution t = ln x to the original nonhomogeneous equation (as we shall demonstrate in Examples 2.1-2.2) or to its homogeneous version only (as we shall show in Example 2.3; then variation of parameters may be used...)........................................................................ EXAMPLES: 2 Find general solutions for the following nonhomogeneous Euler equations: 1 x 2 y 7xy + 15y = x 2 Answer: y(x) = 1 3 x 2 + C 1 x 5 + C 2 x 3. 2 x 2 y 2y = 3x 2 1 Answer: y(x) = 1 2 + x 2 ln x + C 1 x 2 + C 2 x 1.................................................................... 3 x 2 y 2xy + 2y = 4x 2 Answer: y(x) = 4x 2 ln x + C 1 x + C 2 x 2. Solution: Here we shall use the substitution t = ln x find a solution of the corresponding homogeneous equation. Then we shall use variation of parameters to find a particular solution of the nonhomogeneous equation. (Hint: don t forget to rewrite as y +... for variation of parameters). Section 1 Second-Order Linear ODEs 38 / 69
Problems for 1.7 1 Find general solutions for the following homogeneous Euler equations: 1 x 2 y + 4xy + 2y = 0 Answer: y(x) = C 1 x 1 + C 2 x 2. 2 x 2 y 4xy 6y = 0 Answer: y(x) = C 1 x 6 + C 2 x 1. 3 x 2 y + 3xy + 1.25 y = 0 Answer: y(x) = C 1 x 1 cos( 1 2 ln x) + C 2x 1 sin( 1 2 ln x). 4 x 2 y + 5xy + 4y = 0 Answer: y(x) = C 1 x 2 + C 2 x 2 ln x. 5 x 2 y xy + 5y = 0 Answer: y(x) = C 1 x cos(2 ln x) + C 2 x sin(2 ln x). 6 x 2 y + 7xy + 10y = 0 Answer: y(x) = C 1 x 3 cos(ln x) + C 2 x 3 sin(ln x). Section 1 Second-Order Linear ODEs 39 / 69
2 Find general solutions for the following nonhomogeneous Euler equations: 1 x 2 y + 4xy + 2y = x 3 5 Answer: y(x) = 1 20 x 3 5 2 + C 1x 1 + C 2 x 2. 2 x 2 y 4xy 6y = 3 sin(2 ln x) Answer: y(x) = 3 3 20 cos(2 ln x) 20 sin(2 ln x) + C 1x 6 + C 2 x 1. 3 x 2 y 3xy + 4 y = x 2 ln x Answer: y(x) = 1 6 x 2 (ln x) 3 + C 1 x 2 + C 2 x 2 ln x. 3 Find general solutions for the following nonhomogeneous Euler equations using variation of parameters. 1 x 2 y 7xy + 15y = x 2 Answer: y(x) = 1 3 x 2 + C 1 x 5 + C 2 x 3. 2 x 2 y + 4xy + 2y = x 3 5 Answer: y(x) = 1 20 x 3 5 2 + C 1x 1 + C 2 x 2. Section 1 Second-Order Linear ODEs 40 / 69
Section 3 Numerical Solution of First-Order ODEs Consider the Initial-Value Problem y = f (x, y), y(x 0 ) = y 0 ( ) this can be interpreted as that at each x, the slope of the curve y(x) is f (x, y)........................................................................ If we can NOT solve ( ) explicitly, we can find approximate values y n y(x n ) at the points x n = x 0 + n h:....................................................................... Section 3 Numerical Solution of First-Order ODEs 41 / 69
3.1 Euler Method Integrate y = f (x, y) over the interval [x n, x n+1 ]: xn+1 x n y dx }{{} = x n+1 x n =y(x) x n+1 =y(x n+1 ) y(x n ) xn f (x, y) dx So y(x n+1 ) y(x n ) = x n+1 x n f (x, y(x)) dx h f (x n, y(x n )) here we used the Rectangular Rule of Numerical Integration Now, we replace the exact values y(x n ) by approximate values y n, and also replace by =, and so get the definition of a numerical method: y(x n+1 ) y n+1 = y n + h f (x n, y n ) ( ) called the Euler Method. NOTE: one can rewrite ( ) as y(x 0 ) = y 0 (use Initial Condition) y(x 0 + h) y 1 = y 0 + h f (x 0, y 0 ) y(x 0 + 2h) y 2 = y 1 + h f (x 1, y 1 ) y(x 0 + 3h) y 3 = y 2 + h f (x 2, y 2 ) i.e. the computation goes as y 0 y 1 y 2 y 3 Section 3 Numerical Solution of First-Order ODEs 42 / 69
INTERPRETATION: note that y n+1 y n x n+1 x n = y n+1 y n h = f (x n, y n ), }{{} by the Euler method ( ) i.e. the slope of the computed solution on each (x n, x n+1 ) is f (x n, y n ):....................................................................... Section 3 Numerical Solution of First-Order ODEs 43 / 69
Example: consider the IVP: y = x + y subject to y(0) = 0. Exercise: show that the exact solution is y(x) = e x x 1. Euler Method: Choose h = 0.2 so x n = x 0 + h n = 0.2 n ; y(0) = y 0 = 0 Using f (x, y) = x + y one gets y(x n+1 ) = y(0.2[n + 1]) y n+1 = y n + h f (x n, y n ) = y n + 0.2 (x n + y n ) n x n = 0.2n computed y n exact y(x n ) error y(x n ) y n 0 0 0 0 0 1 0.2 0 0.021 0.021 2 0.4 0.04 0.092 0.052 3 0.6 0.128 0.222 0.094 4 0.8 0.274 0.426 0.152 Error y(x n ) y n : at each step, the Euler method picks up an error of order h 2, but the error accumulate from step to step, so at x = x n, the error is of order n h 2 = (nh) h = x n h h. }{{} length of the interval Section 3 Numerical Solution of First-Order ODEs 44 / 69
Problems for 3.1 1 Use the Euler method with the following step sizes h to approximate y(0.4) given that y = cos y and y(0) = 0: 1 h = 0.2 Answer: y 2 = 0.3960133. 2 h = 0.1 Answer: y 4 = 0.393123. 3 h = 0.05 Answer: y 8 = 0.3914895. Section 3 Numerical Solution of First-Order ODEs 45 / 69
3.2 The improved Euler Method (Predictor-Corrector) y(x n+1 ) y(x n ) = x n+1 x n f (x, y(x)) dx 1 2 }{{} h [ f (x n, y(x n )) + f (x n+1, y(x n+1 )) ] Recall from 23.1 here we use the Trapezoidal Rule of Numerical Integration. If we replace the exact values y(x n ) by approximate values y n, and also replace by =, then we get a numerical method: y n+1 = y n + 1 2 h [ f (x n, y n ) + f (x n+1, y n+1 ) ]. This method is expected to be more accurate that the Euler method. However, we have the unknown value y n+1 on the right-hand side!! To get an easier-to-implement method, replace this y n+1 by the Euler approximation from 23.1 (that we now denote yn+1 ), so we arrive at Improved Euler Method y(x 0 ) = y 0 ; y n+1 = y n + h f (x n, y n ) = predictor stage; y(x n+1 ) y n+1 = y n + 1 2 h [ f (x n, y n ) + f (x n+1, y n+1 )] = corrector stage Section 3 Numerical Solution of First-Order ODEs 46 / 69
Example: consider the IVP: y = x + y subject to y(0) = 0. Improved Euler Method: Choose h = 0.2 so x n = x 0 + h n = 0.2 n. y(0) = y 0 = 0 Note that f (x, y) = x + y so yn+1 = y n + h f (x n, y n ) = y n + 0.2 (x n + y n ) Next we get: y(x n+1 ) y n+1 = y n + 1 2 h [ f (x n, y n ) + f (x n+1, y n+1 )] = y n + 0.1 [ (x n + y n ) + (x n+1 + y n+1 )] n x n predictor yn corrected y n exact y(x n ) error y(x n ) y n 0 0 0 0 0 0 1 0.2 0 0.02 0.0214 0.0014 2 0.4 0.064 0.0884 0.0918 0.0034 3 0.6 0.1861 0.2158 0.2221 0.0063 4 0.8 0.3790 0.4153 0.4255 0.0102 Section 3 Numerical Solution of First-Order ODEs 47 / 69
....................................................................... Error y(x n ) y n : at each step, the Improved Euler method picks up an error of order h 3, but the error accumulate from step to step, so at x = x n, the error is of order n h 3 = (nh) h 2 = x n h 2 h 2. }{{} length of the interval E.g.: at x n = 1 the error is of order x n h 2 = 1 h 2 = h 2 (x n = 1 is a representative choice as it s not too big, not too small). So the Improved Euler Method is a second-order method (while the Euler method of 23.1 is a first-order method)........................................................................ In real-world applications, one uses more accurate methods, e.g., Fourth-Order Runge-Kutta methods (see the prime text for further details). Its error at x = x n is of order n h 5 = (nh) h 4 = x n h 4 ; }{{} length of the interval in particular, at x n = 1, the error is of order h 4........................................................................ Section 3 Numerical Solution of First-Order ODEs 48 / 69
Another Example: consider the IVP: y = x y subject to y(0) = 1 on [0, 1] with the step size h = 0.2 using the Euler and the Improved Euler methods. Exercise: show that the exact solution is y(x) = x 1 + 2 e x. Solution: We have f (x, y) = x y, x 0 = 0, and y(0) = y 0 = 1 also h = 0.2 so x n = x 0 + h n = 0.2 n for n = 0,, 5. (a) Euler: y(x n+1 ) y n+1 = y n + h f (x n, y n ), So y n+1 = y n + 0.2 (x n y n ) subject to y 0 = 1. (b) Improved Euler: y n+1 = y n + h f (x n, y n ) = y n + 0.2 (x n y n ) (as above). Next we get: y(x n+1 ) y n+1 = y n + 1 2 h [ f (x n, y n ) + f (x n+1, y n+1 )] = y n + 0.1 [ ( x n }{{} 0.2 n y n ) + ( x }{{} n+1 yn+1 )] 0.2 (n+1) Section 3 Numerical Solution of First-Order ODEs 49 / 69
Numerical Results: Euler Improved Euler n x n y n error y(x n ) y n y n error y(x n ) y n 0 0 1 0 1 0 1 0.2 0.8 0.037 0.84 0.0025 2 0.4 0.68 0.061 0.7448 0.0041 3 0.6 0.624 0.073 0.7027 0.0051 4 0.8 0.619 0.079 0.7042 0.0055 5 1.0 0.655 } 0.080 {{ 0.7414 }} 0.0057 {{} the error is over 10% the error is less than 1%! Section 3 Numerical Solution of First-Order ODEs 50 / 69
Problems for 3.2 1 Use the improved Euler method with the following step sizes h to approximate y(0.4) given that y = cos y and y(0) = 0: 1 h = 0.2 Answer: y 2 = 0.38838702. 2 h = 0.1 Answer: y 4 = 0.3894091087. 3 h = 0.05 Answer: y 8 = 0.3896590944. 2 Write down the iterative scheme of the Improved Euler method applied to the initial value problem y = x + y 2, y(0) = 2 with step size h = 0.2. Evaluate the approximations of y(0.2) and y(0.4) obtained using this scheme. Answer: y(0.2) 2.4441311 and y(0.4) 2.993432. 3 Write down the iterative scheme of the Improved Euler method applied to the initial value problem y = x 3 + y, y(0) = 3 with step size h = 0.1. Evaluate the approximations of y(0.1) and y(0.2) obtained using this scheme. Answer: y(0.2) 3.35647795. Section 3 Numerical Solution of First-Order ODEs 51 / 69
4 Write down the iterative scheme of the Improved Euler method applied to the initial value problem y = ln(2y x), y(0) = 2 with step size h = 0.2. Evaluate the approximations of y(0.2) and y(0.4) obtained using this scheme. Answer: y(0.4) 2.589318685. 5 Write down the iterative scheme of the Improved Euler method applied to the initial value problem y = e x y 2, y(0) = 1 with step size h = 0.1. Evaluate the approximations of y(0.1), y(0.2) and y(0.3) obtained using this scheme. Answer: y(0.3) 1.114066113. 6 Write down the iterative scheme of the Improved Euler method applied to the initial value problem y = e xy, y(0) = 0 with step size h = 0.2. Evaluate the approximations of y(0.2), y(0.4) and y(0.6) obtained using this scheme. Answer: y(0.6) 0.6936552968. Section 3 Numerical Solution of First-Order ODEs 52 / 69
7 Write down the iterative scheme of the Improved Euler method applied to the initial value problem y = x y 2, y(0) = 2 with step size h = 0.1. Evaluate the approximations of y(0.1), y(0.2) and y(0.3) obtained using this scheme. Answer: y(0.3) 1.292497. 8 Write down the iterative scheme of the Improved Euler method applied to the initial value problem y = cos(x + y), y(0) = 0 with step size h = 0.1. Evaluate the approximations of y(0.1) and y(0.2) obtained using this scheme. Answer: y(0.2) 0.1941. Section 3 Numerical Solution of First-Order ODEs 53 / 69
Section 2 Boundary Value Problems 2.1 Examples Consider a second-order linear ODE y + p(x) y + q(x) y = R(x) ( ) RECALL: A particular solution is found by obtaining values for the 2 arbitrary constants in its general solution from 2 initial or boundary conditions, e.g., y(x 0 ) = A, y (x 0 ) = B Initial conditions y(x 0 ) = A, y(x 1 ) = B Boundary conditions NOTE: An Initial-Value Problem (i.e. an ODE subject to initial conditions) typically has a unique solution. For Boundary-Value Problems (i.e. and ODE subject to boundary conditions) the situation is much more complex. We shall illustrate this considering a few examples. Section 2 Boundary Value Problems 54 / 69
Boundary Conditions Terminology Typically there are 2 boundary conditions for a second-order ODE: at some x 0 and x 1 > x0. There are 3 types of boundary conditions: y(x k ) = A y (x k ) = A αy (x k ) + βy(x k ) = A called a Dirichlet boundary condition called a Neumann boundary condition called a mixed boundary condition Section 2 Boundary Value Problems 55 / 69
Example 1: [Homogeneous ODE] y + y = 0 (it general solution is y(x) = C 1 cos x + C 2 sin x) subject to the following boundary conditions 1 y(0) = y(1) = 0 Answer: UNIQUE solution y(x) = 0 2 y(0) = y(π) = 0 Answer: y(x) = C sin x ( solutions) 3 y(0) = 2, y(π) = 0 Answer: NO solutions 4 y (0) = y( π 2 ) = 0 Answer: y(x) = C cos x ( solutions) 5 y (0) = y( π 2 + ε) = 0 for ε 0, 0 Answer: UNIQUE solution y(x) = 0 Section 2 Boundary Value Problems 56 / 69
Example 1 : [NON-Homogeneous ODE] y + y = 3 (it general solution is y(x) = 3 + C 1 cos x + C 2 sin x) subject to the following boundary conditions 1 y(0) = y(1) = 0 Answer: UNIQUE solution y(x) = 3 cos x 3 cos 1 sin 1 sin x 2 y(0) = y(π) = 0 Answer: NO solutions 3 y(0) = 2, y(π) = 0 Answer: NO solutions 4 y (0) = y( π 2 ) = 0 Answer: NO solutions 5 y (0) = y( π 2 + ε) = 0 for ε 0, 0 Answer: UNIQUE solution... Section 2 Boundary Value Problems 57 / 69
Example 2: [Another Homogeneous ODE] y 2y 3y = 0 (it general solution is y(x) = C 1 e x + C 2 e 3x ) subject to the following boundary conditions 1 y(0) = 5, y(+ ) = 0 Answer: UNIQUE solution y(x) = 5e x 2 y (0) = 3, y(+ ) = 0 Answer: UNIQUE solution y(x) = 3e x 3 y (0) 2y(0) = 7, y (+ ) = 0 Answer: UNIQUE solution y(x) = 7 3 e x Section 2 Boundary Value Problems 58 / 69
Example 3: [similar-looking Homogeneous ODE] y + 4y + 5y = 0 (it general solution is y(x) = C 1 e 2x cos x + C 2 e 2x sin x) subject to the following boundary conditions 1 y(0) = 5, y(+ ) = 0 Answer: ( solutions) y(x) = 5e 2x cos x + Ce 2x sin x 2 y (0) = 0, y(+ ) = 0 Answer: ( solutions) y(x) = Ce 2x [cos x + 2 sin x] 3 y (0) 2y(0) = 7, y (+ ) = 0 Answer: ( solutions) y(x) = Ce 2x cos x + (7 3C)e 2x sin x Section 2 Boundary Value Problems 59 / 69
Problems for 2.1 1 Solve all above examples in detail. 2 (I) Find general solutions of the following differential equations. (II)Describe all solutions of each ODE subject to the given boundary conditions. How many solutions does this boundary value problem have? 1 y + 5y + 6y = 0 subject to y (0) = 0, y (+ ) = 0 2 y + 5y + 6y = 3e 2x subject to y (0) = 0, y(+ ) = 0 3 y + 4y = 3e 2x subject to y (0) = 0, y(+ ) = 0................................................................... 4 y + y = 0 subject to y (0) = y (π) = 0 5 y + 4y = 0 subject to y (0) = y (π) = 0 6 y + 5y = 0 subject to y (0) = y (π) = 0 7 y + 9y = 0 subject to y (0) = y (π) = 0 Section 2 Boundary Value Problems 60 / 69
Answers Problems for 2.1 2 (I) Find general solutions of the following differential equations. (II)Describe all solutions of each ODE subject to the given boundary conditions. How many solutions does this boundary value problem have? 1 y + 5y + 6y = 0, y (0) = y (+ ) = 0 Answer: y(x) = C [ e 2x 2 3 e 3x] 2 y + 5y + 6y = 3e 2x, y (0) = y(+ ) = 0 Answer: y(x) = 3x e 2x e 3x + C [ e 2x 2 3 e 3x] 3 y + 4y = 3e 2x, y (0) = y(+ ) = 0 Answer: NO solutions................................................................... 4 y + y = 0, y (0) = y (π) = 0 Answer: y(x) = C 1 cos x 5 y + 4y = 0, y (0) = y (π) = 0 Answer: y(x) = C 1 cos(2x) 6 y + 5y = 0, y (0) = y (π) = 0 Answer: y(x) = 0 7 y + 9y = 0, y (0) = y (π) = 0 Answer: y(x) = C 1 cos(3x) Section 2 Boundary Value Problems 61 / 69
2.2 BVPs with λ In this section, we shall consider Boundary Value Problems that involve a parameter λ. TASK: solve the given BVP (= ODE + 2 boundary conditions) for all real values of λ........................................................................ NOTE: such problems are called Eigenproblems; they are very important in the theory of Partial Differential Equations. For each real λ there is at least one solution y(x) = 0, called the trivial solution. For certain values of λ, this solution is NOT unique and there are other, nontrivial solutions. Such values of λ are called Eigenvalues, while the corresponding nontrivial solutions are called Eigenfunctions........................................................................ Section 2 Boundary Value Problems 62 / 69
EXAMPLE: (I) For each value of λ, describe all solutions of the following boundary value problem: y + λy = 0 subject to y(0) = y(π) = 0 (II) Specify the values of λ for which nontrivial solutions occur. HINT: one typically considers 3 cases λ = 0, λ < 0 and λ > 0... ANSWER: (I) For λ = n 2, where n = 1, 2, 3,, the general solution is y(x) = C sin(nx); For all other values of λ, there is a unique solution y(x) = 0. (II) Nontrivial solutions occur for λ = n 2, where n = 1, 2, 3,. Section 2 Boundary Value Problems 63 / 69
Problems for 2.2 TASK: (I) For each value of λ, describe all solutions of each of the following boundary value problems. (II) Specify the values of λ for which nontrivial solutions occur. 1 y + λy = 0 subject to y(0) = y (1) = 0 2 y + λy = 0 subject to y (0) = y (1) = 0 3 y + λy = 0 subject to y (0) = y(π) = 0 4 y + λy = 0 subject to y(0) = y(1) = 0.................................................................. 5 y + λy = 0 subject to y( π) = y(π) and y ( π) = y (π) 6 y + λy = 0 subject to y (0) = 0 and y (1) + λ y(1) = 0 Section 2 Boundary Value Problems 64 / 69
1 y + λy = 0 subject to y(0) = y (1) = 0 ANSWER: (I) For λ = ( π 2 + πn)2, where n = 0, 1, 2, 3,, the general solution is y(x) = C sin([ π 2 + πn]x); For all other values of λ, there is a unique solution y(x) = 0. (II) Nontrivial solutions occur for λ = ( π 2 + πn)2, where n = 0, 1, 2, 3,. 2 y + λy = 0 subject to y (0) = y (1) = 0 ANSWER: (I) For λ = 0 the general solution is y(x) = C; for λ = (πn) 2, where n = 1, 2, 3,, the general solution is y(x) = C cos(πnx); For all other values of λ, there is a unique solution y(x) = 0. (II) Nontrivial solutions occur for λ = 0 and λ = (πn) 2, where n = 1, 2, 3,. Section 2 Boundary Value Problems 65 / 69
3 y + λy = 0 subject to y (0) = y(π) = 0 ANSWER: (I) For λ = ( 1 2 + n)2, where n = 0, 1, 2, 3,, the general solution is y(x) = C cos([ 1 2 + n]x); For all other values of λ, there is a unique solution y(x) = 0. (II) Nontrivial solutions occur for λ = ( 1 2 + n)2, where n = 0, 1, 2, 3,. 4 y + λy = 0 subject to y(0) = y(1) = 0 ANSWER: (I) For λ = (πn) 2, where n = 1, 2, 3,, the general solution is y(x) = C sin(πnx); For all other values of λ, there is a unique solution y(x) = 0. (II) Nontrivial solutions occur for λ = (πn) 2, where n = 1, 2, 3,. Section 2 Boundary Value Problems 66 / 69
5 y + λy = 0 subject to y( π) = y(π) and y ( π) = y (π) ANSWER: (I) For λ = 0 the general solution is y(x) = C; for λ = n 2, where n = 1, 2, 3,, the general solution is y(x) = C 1 cos(nx) + C 2 sin(nx); For all other values of λ, there is a unique solution y(x) = 0. (II) Nontrivial solutions occur for λ = 0 and λ = n 2, where n = 1, 2, 3,. 6 y + λy = 0 subject to y (0) = 0 and y (1) + λ y(1) = 0 ANSWER: (I) For λ = 0 the general solution is y(x) = C; for λ = [ π 4 + πn]2, where n = 1, 2, 3,, the general solution is y(x) = C cos([ π 4 + πn]x); For all other values of λ, there is a unique solution y(x) = 0. (II) Nontrivial solutions occur for λ = 0 and λ = [ π 4 + πn]2, where n = 1, 2, 3,. Section 2 Boundary Value Problems 67 / 69
FINAL EXAM Q 3+4 PROBLEM TYPES that may be given: Euler Equations ( 1.7 combined with 1.2+ 1.4+ 1.5) Variation of Parameters ( 1.6 combined with 1.2+ 1.4) Boundary-Value Problem / Initial-Value Problem (All of the above combined with 2.1 / given initial conditions.) For each value of λ, describe all solutions of a given boundary value problem. Specify the values of λ for which nontrivial solutions occur. ( 2.2 combined with 1.2+ 2.1) Euler method / Improved Euler method ( 3.1 / 3.2) FINAL EXAM Q 3+4 68 / 69
FINAL EXAM Q 3+4 What formulas will be given USEFUL FORMULAE: The method of Variation of Parameters for the equation y + p(x)y + q(x)y = R(x) yields a particular solution in the form u y 1 + v y 2, where y 1 and y 2 are linearly independent solutions of the corresponding homogeneous equation, while u and v satisfy u y 1 + v y 2 = 0, u y 1 + v y 2 = R(x). Method of Undetermined Coefficients Right-Hand Side Possible Particular Solution α A α x + β A x + B α x 2 + β x + γ A x 2 + B x + C α e kx A e kx (α + β x) e kx (A x + B) e kx α cos(kx) + β sin(kx) A cos(kx) + B sin(kx) (α x + β) cos(kx) + (γ x + δ) sin(kx) (A x + B) cos(kx) + (C x + D) sin(kx) FINAL EXAM Q 3+4 69 / 69