lecture 5

19
 MA-108 Ordinary Dierential Equations M.K. Keshari Department of Mathematics Indian Institute of Technology Bombay Powai, Mumbai - 76 16th March, 2015 D3 - Lecture 5 M.K. Keshari  D3 - Lec ture 5

Upload: teju1996cool

Post on 03-Nov-2015

218 views

Category:

Documents


0 download

DESCRIPTION

3

TRANSCRIPT

  • MA-108 Ordinary Differential Equations

    M.K. Keshari

    Department of MathematicsIndian Institute of Technology Bombay

    Powai, Mumbai - 76

    16th March, 2015D3 - Lecture 5

    M.K. Keshari D3 - Lecture 5

  • Numerical Methods

    We have seen some methods to solve y = f(x, y) withy(x0) = y0. Today we will see some methods to find anapproximate solution.

    Ex. Solve y = 1 + 2xy, y(0) = 3.The solution is given by

    y(x) = y1(x) [ x0

    f(x)

    y1dx+ C ] = ex

    2[ x0ex

    2dx+ C ].

    The solution to IVP is y = ex2[ x0ex

    2dx+ 3 ].

    Q. How do we actually find a solution? Using the directionfield, we can understand the solution.

    Finding the direction field involved estimating what thetangent to the solution curve looks like at every point.

    Eulers Method uses the same idea to give a numericalapproximation to the solution.

    M.K. Keshari D3 - Lecture 5

  • Eulers method

    Let y = f(x, y), y(x0) = y0. Choose equally distancedpoints xi = x0 + h i for i = 1, . . . , k and let yi isapproximation to y(xi).

    Then, Eulers method gives an approximate solution to y(x) atthese points. The idea is to approximate the integral curve atthese point by the line, tangent to it at that point.

    At (x0, y0), the tangent line is given by

    y(x) = y0 + f(x0, y0)(x x0).Then an approximation for y(xi) is given by

    yi = y(xi1) + hf(xi1, y(xi1))

    Then y1 = y0 + hf(x0, y0) is an approximation for y(x1).In general, we do not know y(xi1) and hence define

    yi = yi1 + hf(xi1, yi1).

    M.K. Keshari D3 - Lecture 5

  • Examples

    Let y =1 + x

    1 y2 = f(x, y), y(2) = 3; h = 0.1.Using yi = yi1 + hf(xi1, yi1), Eulers method gives

    y1 = 3 + f(2, 3) 0.1 = 2.9625

    y2 = y1 + f(2.1, 2.9625) 0.1 = 2.92263583

    y3 = y2 + f(2.2, 2.92263583) 0.1 = 2.88020564

    y4 = y3 + f(2.3, 2.90661298) 0.1 = 2.8349728

    y5 = y4 + f(2.4, 2.8349728) 0.1 = 2.78665724

    y6 = y5 + f(2.5, 2.78665724) 0.1 = 2.73492387

    y7 = y6 + f(2.6, 2.73492387) 0.1 = 2.67936667

    y8 = y7 + f(2.7, 2.67936667) 0.1 = 2.61948649

    M.K. Keshari D3 - Lecture 5

  • Errors

    Let us solve y =1 + x

    1 y2 = f(x, y), y(2) = 3; by separablemethod.

    y y3

    3= x+

    x2

    2+ C; C = 10.

    Let us compare our solution by Euler methods approximatesolution up to four decimals.

    X Y(X) Approx Y(X) Exact Error 2.1 2.9625 2.9613162498 0.00118375022.2 2.92263583 2.9201289618 0.00250686822.3 2.88020564 2.876207308467 0.0039983315332.4 2.8349728 2.833552901083 0.0014198989172.5 2.78665724 2.7790111491 0.00764609092.6 2.73492387 2.7250089161 0.0099149539

    M.K. Keshari D3 - Lecture 5

  • Order of Error

    Euler method has two kinds of errors. One because ofapproximating y(xi) by yi, called a truncation error.The other, because of evaluating, say up to 8 decimals, calledthe roundoff error.

    The truncation error at the ith step is given by

    Ti = y(xi+1) y(xi) hf(xi, y(xi))Assume that f , fx and fy are continuous and bounded for all(x, y) in some open rectangle. Then y exists, sincey(x) = f(x, y(x));

    y(x) = fx(x, y(x)) + fy(x, y(x))y = [fx + fyf ](x, y(x))

    Then y(x) is also bounded in the region, say [x0, b]. Taylorsapproximation theorem says that

    y(xi+1) = y(xi)+hy(xi)+

    h2

    2y(xi), for some xi (xi, xi+1)

    M.K. Keshari D3 - Lecture 5

  • Since y(xi) = f(xi, y(xi)), Taylors expansion gives

    y(xi+1) y(xi) hf(xi, y(xi) = h2

    2y(xi)

    But y is bounded, say by M , therefore truncation error

    Ti = y(xi+1) y(xi) hf(xi, y(xi)) Mh2

    2.

    This says that the local truncation error is of the order of h2

    or O(h2).

    Thus if the step size h is halved, then the error shoulddecrease by a factor of 4. However, this is not all the error.This error is attained at every xi. Since it will now take twiceas many steps to get to the same point, the accumulated errorwill increase.

    Taking this into account, it will show that the total truncationerror, in the Euler method is to the order of h i.e. O(h).

    M.K. Keshari D3 - Lecture 5

  • 1 140100092 GANGAM VAMSHI CHANDRA2 140100101 POTLURI VACHAN DEEP3 140100112 ARAVIND SANKAR P4 140260002 SANJANA SHAMMY SABU5 140260011 REEBHU BHATTACHARYYA6 140260024 JAY PRAKASH7 14B030008 JHUNJHUNWALA RISHI RANDHIR8 14B030021 JAYNEEL PAREKH9 14B030032 ANIL KUMAR RIWAL10 14D100009 PRAJESH ARVIND JANGALE11 14D100018 SHARANG BHAGDIKAR12 140100006 MUTHA ADITYA SANTOSH13 140100023 KARAN JAIN14 140100039 GAIKWAD ABHAY DASHARATH15 140100051 SHITANSHU DEHGAL16 140100061 AMOGH DIXIT17 140100075 NEERESH PRIYADARSHI18 140100103 VENKATA PRAVEEN BOKINALA19 140260003 SAURABH SUSHIL KUMAR

    M.K. Keshari D3 - Lecture 5

  • Improved Euler Method

    Even though the idea in Eulers method is simple, this is notusually the recommended method of approximation.

    We note, the main task in using the numerical method, is tocompute yi+1 using previous yis, in particular f(xi, yi). Wewant a method which gives us a good approximation withfewer computations of f(xi, yi).

    The Improved Euler method, approximates the value of y forx [xi, xi+1], by the line y(xi) +mi(x xi) where

    mi =f(xi, y(xi)) + f(xi+1, y(xi+1))

    2is the average of slopes of intgegral curve at xi and xi+1.Thus we define

    yi+1 = yi +h

    2[f(xi, yi) + f(xi+1, yi+1) ].

    M.K. Keshari D3 - Lecture 5

  • Improved Euler Method: Example

    But we do not know the value of yi+1. We replace this by theyi+1, we would have computed in the Euler method. That is,

    yi+1 = yi +h

    2[f(xi, yi) + f(xi+1, yi + hf(xi, yi)) ].

    Ex. Let y =1 + x

    1 y2 , y(2) = 3; h = 0.1. Then

    y1 = 3 +0.1

    2(f(2, 3) + f(2.1, 3 + 0.1 f(2, 3)) = 2.961317914

    y2 = 2.961317914 +0.1

    2(f(2.1, 2.967747619) +

    f(2.2, 2.961317914 + 0.1f(2.1,)) = 2.920132727X Y(X) EM Y(X) IEM Y(X) Exact

    2.1 2.9625 2.961317914 2.96131624982.2 2.92263583 2.920132727 2.9201289618

    M.K. Keshari D3 - Lecture 5

  • Improved Euler Method: Example

    Clearly, this is already an improvement over Euler Method.

    It can be shown that the local truncation error in the ImprovedEuler Method is O(h3) (this is O(h2) in Eulers mathod).

    The total truncation error is O(h2) (this is O(h) in Eulersmethod).

    Exercise. Find approximate values of e by applying Eulermethod and Improved Euler method to the problem,

    y = y, y(0) = 1.

    Use a step size of h = 0.5.

    M.K. Keshari D3 - Lecture 5

  • Runge Kutta Method

    A more accurate approximation is given by the Runge-Kuttamethod. This is the most widely used approximation method.In this method, the local truncation error is O(h5) and thetotal truncation error is O(h4).

    It uses super slope. Here yi+1 is given by the formula

    yi+1 = yi +h

    6(Ai + 2Bi + 2Ci +Di), where

    Ai = f(xi, yi) Eulers slope

    Bi = f

    (xi +

    h

    2, yi +

    h

    2Ai

    )Ci = f

    (xi +

    h

    2, yi +

    h

    2Bi

    )Di = f (xi + h, yi + hCi)

    M.K. Keshari D3 - Lecture 5

  • Second Order Linear ODEs

    Now that were sort of comfortable with first order ODEs(both linear and non-linear), lets step up the difficulty level.Well look at second order linear ODEs. Recall that a generalsecond order linear ODE is of the form

    a2(x)d2y

    dx2+ a1(x)

    dy

    dx+ a0(x)y = g(x).

    An ODE of the form

    d2y

    dx2+ p(x)

    dy

    dx+ q(x)y = r(x)

    is called a second order linear ODE in standard form.Though there is no formula to find all the solutions of such anODE, we study the existence, uniqueness and number ofsolutions of such ODEs.

    M.K. Keshari D3 - Lecture 5

  • Second Order Linear ODEs

    If r(x) 0 in the equation above, i.e.,d2y

    dx2+ p(x)

    dy

    dx+ q(x)y = 0,

    then the ODE is said to be homogeneous. Otherwise it iscalled nonhomogeneous. Remember this usage is in the spiritof MA 106.

    M.K. Keshari D3 - Lecture 5

  • Initial Value Problem

    An initial value problem of a second order linear ODE is of theform:

    y + p(x)y + q(x)y = r(x); y(x0) = a, y(x0) = b,

    where p(x), q(x) and r(x) are assumed to be continuous onan interval I with x0 I.

    M.K. Keshari D3 - Lecture 5

  • Example

    Ex. Solve y + y = 0. This is an example of a second orderlinear ODE. . How to solve this?

    Observe that sinx and cosx satisfy this equation. Any scalarmultiple of sine or cosine function is also a solution. . In fact,every linear combination c1 sinx+ c2 cosx is a solution.

    Ex. Solve y y = 0. It is easy to see that ex is a solution.But, so is ex! Again every linear combination c1ex + c2ex isa solution.

    Are these all the solutions? If not, what are the othersolutions, and how to find them? If yes, why are these the onlysolutions?

    M.K. Keshari D3 - Lecture 5

  • Solving IVPs

    LetC(I) = {f : I R | f is continuous}

    C1(I) = {f : I R | f, f are continuous}

    C2(I) = {f : I R | f, f , f are continuous}Check: C(I), C1(I), C2(I) are vector spaces with addition andscalar multiplication defined as:

    (f + g)(x) = f(x) + g(x), x I,

    (k f)(x) = kf(x), k R, x I.

    M.K. Keshari D3 - Lecture 5

  • Solving IVPs

    DefineL : C2(I) C(I)

    byL(f) = f + p(x)f + q(x)f.

    Check: L is a linear transformation; i.e.,

    L(cf + dg) = cL(f) + dL(g),

    for all c, d R and for all f, g C2(I).Aside: Associated to any linear transformation, you would lookat two important vector spaces. What are they?The null space of L, denoted by N(L) is

    N(L) = {f C2(I) | L(f) = f + p(x)f + q(x)f = 0}.Thus, N(L) consists of solutions of the ODE

    y + p(x)y + q(x)y = 0.

    M.K. Keshari D3 - Lecture 5

  • Uniqueness Theorem

    Recall that in the first order world, existence and uniquenesswas easy to prove in the linear case, whereas one need anontrivial result in the non-linear case. In the second orderworld, we need a nontrivial result in the linear case itself.

    Theorem

    Consider the IVP

    y + p(x)y + q(x)y = 0, y(x0) = a, y(x0) = b,

    where p(x) and q(x) are continuous on an interval I. Thenthere is a unique solution to the IVP on I.

    Well skip the proof.

    M.K. Keshari D3 - Lecture 5