MATH 3795 Lecture 18. Numericl Solution of Ordinry Differentil Equtions. Dmitriy Leykekhmn Fll 2008 Gols Introduce ordinry differentil equtions (ODEs) nd initil vlue problems (IVPs). Exmples of IVPs. Existence nd uniqueness of solutions of IVPs. Dependence of the solution of n IVPs on prmeters. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 1
Systems of Ordinry Differentil Equtions. Given functions f 1,..., f n : R n+1 R nd sclrs y 0,1,..., y 0,n R, we wnt to find y 1, y 2,..., y n : R R such tht nd y 1(x) = f 1 (x, y 1 (x),..., y n (x)),. y n(x) = f n (x, y 1 (x),..., y n (x)) y 1 () = y 0,1,. y n () = y 0,n. (1) is clled system of first order ordinry differentil equtions (ODEs) nd (2) re clled initil conditions. Together it is clled n initil vlue problem (IVP). (1) (2) D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 2
Systems of Ordinry Differentil Equtions. If we define f : R n+1 R n, f(x, y 1,..., y n ) = we cn rewrite the system s where y 0 = (y 0,1,..., y 0,n ) T. y : R R n, y(x) = y (x) = f(x, y(x)) y() = y 0, f 1 (x, y 1..., y n ). f n (x, y 1..., y n ) y 1 (x). y n (x),, D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 3
n-th Order Differentil Eqution. Often, one hs to solve n-th order differentil equtions of the form z (n) (x) = g(x, z(x), z (x),..., z (n 1) (x)), x [, b] (3) with initil conditions z() = z 0, z () = z 1,..., z (n 1) () = z n 1. (3) cn be reformulted s systems of first order ODEs. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 4
n-th Order Differentil Eqution. If we introduce the functions y 1 (x) = z(x), y 2 (x) = z (x),. y n (x) = z (n 1) (x), then these functions stisfy the first order differentil equtions y 1(x) = y 2 (x), y 2(x) = y 3 (x),. y n 1(x) = y n (x), y n(x) = g(x, y 1 (x), y 2 (x),..., y n (x)), with initil conditions y 1 () = z 0, y 2 () = z 1,..., y n () = z n 1. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 5
n-th Order Differentil Eqution. If we introduce nd f(x, y 1,..., y n ) = y 0 = y 2 (x) y 3 (x). y n (x) g(x, y 1 (x),..., y n (x)) z 0 z 1. z n 1, then we rrive t the system of first order ODEs y (x) = f(x, y(x)), y() = y 0. Thus, it is sufficient to consider systems of first order ODEs. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 6
Exmple 1 (Predtor-Prey Model). Let s look t specil cse of n interction between two species, one of which the predtors ets the other the prey. Cndin lynx nd snowshoe hre Dt from pelt-trding records Pictures nd dt re from http://www.mth.duke.edu/eduction/ccp/mterils/diffeq/predprey/pred1.htm D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 7
Exmple 1 (Predtor-Prey Model). Mthemticl model. Assumptions. The predtor species is totlly dependent on the prey species s its only food supply. y(t) is the size of the predtor popultion t time t. The prey species hs n unlimited food supply; only predtor poses thret to its growth. x(t) is the size of the prey popultion t t. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 8
Exmple 1 (Predtor-Prey Model). Prey popultion. If there were no predtors, the second ssumption would imply tht the prey species grows exponentilly, i.e., x (t) = x(t). Since there re predtors, we must ccount for negtive component in the prey growth rte. Assumptions: The rte t which predtors encounter prey is jointly proportionl to the sizes of the two popultions. A fixed proportion of encounters leds to the deth of the prey. Predtor popultion. x (t) = x(t) bx(t)y(t). y (t) = cy(t) + px(t)y(t). D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 9
Exmple 1 (Predtor-Prey Model). Prey popultion. If there were no predtors, the second ssumption would imply tht the prey species grows exponentilly, i.e., x (t) = x(t). Since there re predtors, we must ccount for negtive component in the prey growth rte. Assumptions: The rte t which predtors encounter prey is jointly proportionl to the sizes of the two popultions. A fixed proportion of encounters leds to the deth of the prey. Predtor popultion. x (t) = x(t) bx(t)y(t). y (t) = cy(t) + px(t)y(t). Lotk-Volterr Predtor-Prey Model: (, b, c, p > 0 re constnts) x (t) = x(t) bx(t)y(t), y (t) = cy(t) + px(t)y(t). D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 9
Exmple 1 (Predtor-Prey Model). Solution of the Lotk-Volterr Predtor-Prey Model x (t) = x(t) bx(t)y(t), y (t) = cy(t) + px(t)y(t) with initil condition x(0) = 20, y(0) = 40 nd prmeters = 1, b = 0.02, c = 0.3, p = 0.005. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 10
Exmple 2 (Chemicl Rections). A rection involving the compounds A, B, C, D is written s σ A A + σ B B σ C C + σ D D. Here σ A, σ B, σ C, σ D re the stoichiometric coefficients. The compounds A, B re the rectnts, C, D re the products. The indictes tht the rection is irreversible. For reversible rection we use. For exmple, the reversible rection of crbon dioxide nd hydrogen to form methne plus wter is The stoichiometric coefficients re CO 2 + 4H 2 CH 4 + 2H 2 O. σ CO2 = 1, σ H2 = 4, σ CH4 = 1, σ H2O = 2. For ech rection we hve rte r (the number of rective events per second per unit volume, mesured in [mol/(sec L)]) of the rection tht together with the stoichiometric coefficients determines the chnge in concentrtions (mesured in [mol/l]) resulting from the rection. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 11
Exmple 2 (Chemicl Rections). For exmple, if the rte of the rection is r nd if denote the concentrtion of compound A,... by C A,..., we hve the following chnges in concentrtions: d dt C A(t) = σ A r..., d dt C B(t) = σ B r..., d dt C C(t) =... σ C r..., d dt C D(t) =... σ D r..., Usully the rection r is of the form r = kc α AC β B, where k is the rection rte constnt nd α, β re nonnegtive prmeters. The sum α + β is clled the order of the rection. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 12
Exmple 2 (Chemicl Rections. Autoctlytic rection.) Autoctlysis is term commonly used to describe the experimentlly observble phenomenon of homogeneous chemicl rection which shows mrked increse in rte in time, reches its pek t bout 50 percent conversion, nd the drops off. The temperture hs to remin constnt nd ll ingredients must be mixed t the strt for proper observtion. We consider the ctlytic therml decomposition of single compound A into two products B nd C, of which B is the utoctlytic gent. A cn decompose vi two routes, slow unctlyzed one (r 1 ) nd nother ctlyzed by B (r 3 ). The three essentil kinetic steps re A B + C A + B AB AB 2B + C Strt or bckground rection, Complex formtion, Autoctlytic step. Agin, we denote the concentrtion of compound A,... by C A,.... The rection rtes for the three rections re r 1 = k 1 C A, r 2 = k 2 C A C B, r 3 = k 3 C AB. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 13
Exmple 2 (Chemicl Rections.) The utoctlytic rection leds to system of ODEs dc A dt dc B dt dc AB dt dc C dt = k 1 C A k 2 C A C B, = k 1 C A k 2 C A C B + 2k 3 C AB, = k 2 C A C B k 3 C AB, = k 1 C A + k 3 C AB with k 1 = 0.0001, k 2 = 1, k 3 = 0.0008 nd initil vlues C A (0) = 1, C B (0) = 0, C AB (0) = 0, C C (0) = 0. Here time is mesured in [sec] nd concentrtions re mesured in [kmol/l]. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 14
Exmple 3. For given A R n n consider the liner IVP y (x) = Ay(x), x [0, ) y(0) = y 0. (4) Suppose there exist V = (v 1... v n ) C n n nd Λ = dig(λ 1,..., λ n ), λ j C, such tht (eigen decomposition) or, equivlently, Insert into (4) A = V ΛV 1 Av j = λ j v j, j = 1,..., n. (V 1 y) (x) = V 1 y (x) = V 1 AV V 1 y(x) = ΛV 1 y(x), x [0, ) V 1 y(0) = V 1 y 0. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 15
Exmple 3. Putting z := V 1 y we cn see tht z stisfies z (x) = Λz(x), x [0, ), z(0) = V 1 y 0 := z 0. Since Λ = dig(λ 1,..., λ n ), this is equivlent to z j(x) = λ j z j (x), x [0, ), z j (0) = z 0,j, j = 1,..., n. Unique solution z j (x) = e λjx z 0,j, j = 1,..., n. Hence, the unique solution of (4) is given by n y(x) = V z(x) = v j e λjx z 0,j. j=1 D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 16
Exmple 3. Consider We cn show A = 1 ( 1 2 5 2 1 A = ( 20.08 39.96 39.96 80.02 ) ( 100 0 0 0.1 ) ) 1 5 ( 1 2 2 1 ) = V ΛV 1. nd y 0 = (1, 1) T. Since V 1 y 0 = 1 5 ( 1 2 2 1 ) ( 1 1 ) = 1 5 ( 3 1 ) := z 0 D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 17
Exmple 3. This leds to z 1(x) = 100z 1 (x), z 1 (0) = 3 5 z 2(x) = 0.1z 2 (x), z 2 (0) = 1 5 D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 18
Existence nd Uniqueness of Solutions. Theorem (Existence Theorem of Peno) Let D R n+1 be domin, i.e. n open connected subset of R n with (, y 0 ) D. If f is continuous on D, then there exists δ > 0 such tht the IVP y (x) = f(x, y(x)), y() = y 0. hs solution on the intervl [ δ, + δ]. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 19
Existence nd Uniqueness of Solutions. Exmple Consider the IVP y (x) = y(x) 1/3, y(0) = 0, x 0. For rbitrry x > 0 the functions { 0, 0 x x y(x) = ± 2 3 [(x x)]3/2, x x. solve the IVP. Hence, the IVP hs infinitely mny solutions. Note tht the prtil derivtive of f(x, y) = y 1/3 with respect to y is singulr t y = 0. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 20
Existence nd Uniqueness of Solutions. Theorem (Existence nd Uniqueness Theorem of PicrdLindelöf) If f is continuous on D nd if there exists M > 0 such tht f(x, y) M for ll (x, y) D nd if f is Lipschitz continuous with respect to y on D = {(x, y) D : x δ, y y 0 δm}, i.e., if there exists L > 0 such tht f(x, y 1 ) f(x, y 2 ) L y 1 y 2 for ll (x, y 1 ), (x, y 2 ) D, then y (x) = f(x, y(x)), y() = y 0. hs unique solution on the intervl [ δ, + δ]. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 21
Existence nd Uniqueness of Solutions. The Picrd Lindelöf Theorem is bsed on the equivlence of the IVP y (x) = f(x, y(x)), y() = y 0. x [, b], nd the integrl eqution y(x) = y 0 + f(s, y(s))ds. The integrl of vector vlued function is defined component wise, i.e., f 1(s, y(s))ds f(s, y(s))ds =.. f n(s, y(s))ds D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 22
Dependence of the Solution of the ODE on Perturbtions of the Problem. Consider the two ODEs y (x) = f(x, y(x)), y() = y 0 (5) nd z (x) = g(x, z(x)), z() = z 0, (6) where f, g : R n+1 R n re given functions nd y 0, z 0 R n re given vectors. We view (6) s perturbtion of (5) nd we wnt to know wht the error between the exct solution y nd the solution of the perturbed problem z is. This question is lso interesting in the context of numericl solutions of IVPs D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 23
Dependence of the Solution of the ODE on Perturbtions of the Problem. Suppose there exist constnts ɛ 1, ɛ 2 > 0 such tht nd y 0 z 0 ɛ 1 f(x, y) g(x, y) ɛ 2 x R, y R n. Furthermore, suppose there exists L > 0 such tht f(x, y) f(x, z) L y z x R, y, z R n. Suppose tht the IVPs (5) nd (6) hve unique solutions y nd z. These solutions stisfy the integrl equtions nd y(x) = y 0 + z(x) = z 0 + f(s, y(s))ds (7) g(s, z(s))ds. (8) D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 24
Dependence of the Solution of the ODE on Perturbtions of the Problem. Subtrct (8) from (7) to get y(x) z(x) = y 0 z 0 + = y 0 z 0 + + f(s, y(s)) g(s, z(s))ds f(s, y(s)) f(s, z(s))ds f(s, z(s)) g(s, z(s))ds. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 25
Dependence of the Solution of the ODE on Perturbtions of the Problem. Tking the norm we get y(x) z(x) y 0 z 0 + + y 0 z 0 + }{{} ɛ 1 + f(s, y(s)) f(s, z(s))ds f(s, z(s)) g(s, z(s))ds f(s, y(s)) f(s, z(s)) ds }{{} L y(s) z(s) f(s, z(s)) g(s, z(s)) ds. }{{} ɛ 2 D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 26
Dependence of the Solution of the ODE on Perturbtions of the Problem. Hence if we define the error e(x) = y(x) z(x), then e(x) ɛ 1 + L e(s)ds + ɛ 2 (x ). D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 27
Dependence of the Solution of the ODE on Perturbtions of the Problem. Lemm (Gronwll Lemm) If h,w nd k re nonnegtive nd continuous on the intervl [, b] stisfying the inequlity h(x) w(x) + then h obeys the estimte k(s)h(s)ds x [, b], h(x) w(x) + e t k(s)ds k(t)w(t)dt. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 28
Dependence of the Solution of the ODE on Perturbtions of the Problem. Apply the Gronwlls lemm to the eqution e(x) ɛ 1 + ɛ 2 (x ) + L e(s)ds. Here h(x) = e(x) = y(x) z(x), w(x) = ɛ 1 + ɛ 2 (x ), nd k(x) = L. Thus, the error between the solution y of the originl IVP (5) nd the solution z of the perturbed IVP (6) obeys y(x) z(x) ɛ 1 + ɛ 2 (x ) + e L(x t) L[ɛ 1 + ɛ 2 (t )]dt = ɛ 1 e L(x ) + ɛ 2 L (el(x ) 1) x. (9) D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 29
Dependence of the Solution of the ODE on Perturbtions of the Problem. Exmple The solution of the differentil eqution y (x) = 3y(x), y(0) = 1 is given by y(x) = e 3x. The function f(x, y) = 3y is Lipschitz continuous with respect to y with Lipschitz constnt L = 3. The perturbed differentil eqution z (x) = 3z(x) + ɛ 2, z(0) = 1 + ɛ 1 hs the solution z(x) = (1 + ɛ 1 + ɛ2 3 )e3x ɛ2 3. Thus, y(x) z(x) = ɛ 1 e 3x + ɛ 2 3 (e3x 1) x [0, ) This shows tht the error estimte (9) is shrp. D. Leykekhmn - MATH 3795 Introduction to Computtionl Mthemtics Liner Lest Squres 30