Motivation: Finite difference methods are an important method for approximating solutions of differential equations. We

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Motivation: Finite difference methods are an important method for approximating solutions of differential equations. We

Post by answerhappygod »

Motivation Finite Difference Methods Are An Important Method For Approximating Solutions Of Differential Equations We 1
Motivation Finite Difference Methods Are An Important Method For Approximating Solutions Of Differential Equations We 1 (136.8 KiB) Viewed 59 times
Motivation: Finite difference methods are an important method for approximating solutions of differential equations. We have seen an example in Lecture 05,pp.13−15, where the solution of a boundary value problem was approximated using finite differences. A similar method can be used for initial value problems, as in the first part below. Finite difference methods will be an important topic again in Lecture 11 when we discuss solving the Black Scholes PDE in pricing financial options. The following example is chosen for practice. An approximation to the solution is implemented in Matlab ( besselj). This gives us an easy way to check the accuracy of our solution. Consider the initial value problem x2uν′′​(x)+xuν′​(x)+(x2−ν2)uν​(x)=0,0<x<T with the boundary conditions uν​(0)=αν​,uν​(0)=βν​. Set ν=1,α1​=0,β1​=1/2 and T=10. For N∈N let xn​=Tn/N for n=0,1,2,…,N. The goal is to estimate the function u1​(x). Let Un​≈u1​(xn​),n=0,1,2,…,N. i) Define a variable N in Matlab and set it to 106. Define a variable T in Matlab and set it to 10 . ii) Define a row vector x such that the nth entry is (n−1)T/N for n=1,2,…,N+1. iii) Define a row vector U of length N+1 in Matlab. Using the initial values, set U(1) to 0 and use the approximation u1′​(0)=21​≈T/NU1​−U0​​ to define U(2). Note that because an index in Matlab cannot be 0 , in the implementation we start from U(1) rather than U(0). Thus the value Un​ is stored in Matlab in U(n+1). iv) We use a central difference method to approximate u1′′​(x), that is, u1′′​(xn​)≈T2/N2Un+1​−2Un​+Un−1​​ v) We use a forward difference method to approximate u1′​(x), that is, u1′​(xn​)≈T/NUn+1​−Un​​. Substitute (2) and (3) into (1) to obtain an expression involving Un+1​,Un​,Un−1​. See Lecture 05 , pages 13 and 14 , to give you an idea on how to do this. Note that in the lecture example it was necessary to solve a linear system; this is not necessary here, as you can solve for Un+1​ and obtain a function in terms of Un​ and Un−1​. Then, using the boundary conditions, compute the values of Un+1​ for n=1,2,…,N−1. vi) The solution to the above equation is the Bessel function of the first kind with index 1. In Matlab this function can be computed using bessel j(1,x). Compute the infinity norm of the difference between your approximation U and bessel j(1,x) (where x is from part ii)). Store the difference in the variable normbessel1 and use fprintf to print the value of normbessel1. To get full marks, this error has to be smaller than 10−5.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply