Ch.8 Numerical Methods
Ch.8 Numerical Methods
𝑑𝑑2 𝑦𝑦 𝑑𝑑𝑑𝑑
Example 4: The curve 𝑦𝑦 = 𝑓𝑓(𝑥𝑥) satisfies the differential equation = sin 𝑥𝑥 + 𝑦𝑦 2 + .
This topic offers methods to estimate several problems that you may not be able to solve analytically Example 2: Use the midpoint formula to estimate the value at 𝑥𝑥 = 2.75 of the particular solution to the differential 𝜋𝜋 𝑑𝑑𝑑𝑑
𝑑𝑑𝑑𝑑 2 𝑑𝑑𝑑𝑑
You will be able to find numerical solutions for first-order differential equations and extend one of the 𝑑𝑑𝑑𝑑 When 𝑥𝑥 = , 𝑦𝑦 = 1 and = 3.
equation = 𝑥𝑥 2 + 𝑦𝑦 3 , which passes through the point (2,3), using a step length of 0.25. 2 𝑑𝑑𝑑𝑑
methods to find numerical solutions of second order differential equations. You will also be able to 𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 𝑦𝑦1 −𝑦𝑦0 𝑑𝑑 2𝑦𝑦 𝑦𝑦1 −2𝑦𝑦0 +𝑦𝑦−1 𝜋𝜋
Use the approximations ( ) ≈ and ( ) ≈ , with ℎ = 8 to estimate the value of 𝑦𝑦
𝑑𝑑𝑑𝑑 0 ℎ 𝑑𝑑𝑑𝑑 2 0 ℎ2
approximate definite integrals using Simpson’s rule. These methods are relevant in computing- 5𝜋𝜋
computers often use these methods to find solutions to problems rather than solving it analytically. 𝑥𝑥0 = 2, 𝑦𝑦0 = 3, ℎ = 0.25 when 𝑥𝑥 = .
8
𝑥𝑥1 = 2.25
Write down the information you know and compare
Solving first-order differential equations 𝑥𝑥2 = 2.5 𝜋𝜋 𝑑𝑑𝑑𝑑 𝜋𝜋
to the information that you need. Write down the information that you know and 𝑥𝑥0 =, 𝑦𝑦 = 1, ( )0 = 3, ℎ =
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 2 0 𝑑𝑑𝑑𝑑 4
Methods to solve first-order differential equations of the form = 𝑓𝑓(𝑥𝑥, 𝑦𝑦) have been explored previously, but in ( )0 = 22 + 33 = 31 compare to the information that you need- we need
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 5𝜋𝜋
some cases it might be difficult or impossible to solve using an analytic method. When using an analytical method, to find 𝑦𝑦1 . 𝑥𝑥1 =
Notice that with the midpoint formula, the smallest 8
you find a general solution, the use the conditions given in the question to find the particular solution. The general
solution corresponds to an infinite set of curves (which can be illustrated by a tangent field or compass point value of the index 𝑟𝑟 that we can calculate 𝑦𝑦𝑟𝑟+1 for is 𝑑𝑑 2 𝑦𝑦 𝜋𝜋
𝑑𝑑𝑑𝑑 ( 2 )0 = sin � � + 12 + 3
diagram by considering the gradients) and the particular solution narrows this down to one particular curve. 𝑟𝑟 = 1, thus we will be calculating 𝑦𝑦2 . To do this, we 𝑦𝑦1 = 𝑦𝑦0 + ℎ( ) 𝑑𝑑 2 𝑦𝑦 𝑑𝑑𝑑𝑑 4
𝑑𝑑𝑑𝑑 0 Find ( ) using the initial conditions.
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 2 0 8 + √2
need to calculate ( )1 , but we can’t do this without 𝑦𝑦1 = 2 + 0.25(31) = 9.75 = = 4.7071 …
𝑑𝑑𝑑𝑑
By considering the gradients, we can solve differential equations iteratively- this is especially useful for equations 𝑦𝑦1 , so we must use Euler’s formula to find 𝑦𝑦1 . 2
that cannot be solved analytically. 𝑑𝑑𝑑𝑑 𝑦𝑦1 − 𝑦𝑦−1
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 ( )0 ≈
Calculate ( )1 by substituting 𝑥𝑥1 and 𝑦𝑦1 into . ( ) = 2.252 + 9.752 = 100.125 𝑑𝑑𝑑𝑑 2ℎ
• Euler’s method for approximating solutions to first-order differential equations is given by
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 1 𝑦𝑦1 − 𝑦𝑦−1 3𝜋𝜋
𝑑𝑑𝑑𝑑 𝑦𝑦1 − 𝑦𝑦0 3= ⇒ 𝑦𝑦1 − 𝑦𝑦−1 =
𝑑𝑑𝑑𝑑 Use the approximations for and 2 to form
𝑑𝑑𝑑𝑑 𝑑𝑑2 𝑦𝑦 𝜋𝜋 ÷ 4 4
( )0 ≈ 𝑦𝑦2 = 𝑦𝑦0 + 2ℎ( ) 𝑑𝑑 2 𝑦𝑦 𝑦𝑦1 − 2𝑦𝑦0 + 𝑦𝑦−1
𝑑𝑑𝑑𝑑 ℎ
Find 𝑦𝑦2 by using the midpoint formula. 𝑑𝑑𝑑𝑑 1 𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑
simultaneous equations in 𝑦𝑦1 and 𝑦𝑦−1 . ( 2 )0 =
Which can also be written as an iterative formula 𝑦𝑦2 = 2 + 2(0.25)(100.125) 𝑑𝑑𝑑𝑑 ℎ2
𝑑𝑑𝑑𝑑 𝑦𝑦2 = 52.0625 8 + √2 𝑦𝑦1 − 2 + 𝑦𝑦−1
𝑦𝑦𝑟𝑟+1 ≈ 𝑦𝑦𝑟𝑟 + ℎ( )𝑟𝑟 , 𝑟𝑟 = 0,1,2, … = ⇒ 2.725895 = 𝑦𝑦1 + 𝑦𝑦−1
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 2 𝜋𝜋
( )2
Find ( )2 .
𝑑𝑑𝑑𝑑 ( )2 = 2.52 + 52.06253 8
This finds the y-value of the differential equation given an initial condition, which can then be used to find the 𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑
= 141121.8596 3𝜋𝜋
𝑑𝑑𝑑𝑑
gradient at this initial point, denoted ( )0 . We then approximate the next point on the solution curve by moving 𝑦𝑦1 − 𝑦𝑦−1 =
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 4
a small amount along the tangent line, this small line is denoted ℎ, and finding gradient at this new point. 𝑦𝑦3 = 𝑦𝑦1 + 2ℎ( )2 Solve the equations simultaneously. 𝑦𝑦1 + 𝑦𝑦−1 = 2.725895
Calculate 𝑦𝑦3 using the midpoint method. 𝑑𝑑𝑑𝑑
= 9.75 + 2(0.25)( 141121.8596) 2𝑦𝑦1 = 5.08209
= 70570.67981 ≈ 70570.680 (to 3 d.p.) 𝑦𝑦1 = 2.5410
Example 1: Use Euler’s method to estimate the value at 𝑥𝑥 = 2 of the particular solution to the differential equation
𝑑𝑑𝑑𝑑
= √3𝑒𝑒 𝑥𝑥 + 4𝑒𝑒 𝑦𝑦 using two iterations, which passes through the point (1,2).
𝑑𝑑𝑑𝑑 Simpson’s rule
Solving second-order differential equations 𝑏𝑏
Euler’s method can be extended to find approximate solutions to second-order differential equations of the form Simpson’s rule is a way of estimating the value of a definite integral of the form 𝐼𝐼 = ∫𝑎𝑎 𝑓𝑓(𝑥𝑥)𝑑𝑑𝑑𝑑. If you consider
Work out the step size ℎ. As we start at 𝑥𝑥 = 1, and need to estimate the value at
𝑑𝑑2 𝑦𝑦 𝑑𝑑𝑑𝑑 the curve 𝑓𝑓(𝑥𝑥), the integral is the area under this curve. Simpson’s rule splits the curve up into sections, but
𝑥𝑥 = 2 in two steps, the step size will be ℎ = 0.5 = 𝑓𝑓(𝑥𝑥, 𝑦𝑦, )
𝑑𝑑𝑑𝑑 2 𝑑𝑑𝑑𝑑 unlike the trapezium rule, instead of approximating the sections of the curve by a straight line, the sections are
𝑑𝑑𝑑𝑑
Calculate ( )0 . 𝑑𝑑𝑑𝑑 Euler’s method for approximating solutions to second-order differential equations is given by
• paired off and a quadratic curve approximates each curve- because of this, Simpson’s rule only works for an even
𝑑𝑑𝑑𝑑 ( ) = �3𝑒𝑒 + 4𝑒𝑒 2 𝑑𝑑 2 𝑦𝑦 𝑦𝑦1 − 2𝑦𝑦0 + 𝑦𝑦−1
𝑑𝑑𝑑𝑑 0 ( 2 )0 ≈ number of strips
Calculate 𝑦𝑦1 using the iterative formula. 𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 ℎ2 • Simpson’s rule for 2𝑛𝑛 strips of width ℎ is given by:
𝑦𝑦𝑟𝑟+1 ≈ 𝑦𝑦𝑟𝑟 + ℎ( ) This can also be written iteratively as 𝑏𝑏
1
𝑑𝑑𝑑𝑑 𝑟𝑟 𝑑𝑑 2 𝑦𝑦 � 𝑓𝑓(𝑥𝑥)𝑑𝑑𝑑𝑑 ≈ ℎ(𝑦𝑦0 + 4(𝑦𝑦1 + 𝑦𝑦3 + ⋯ + 𝑦𝑦2𝑛𝑛−1 ) + 2(𝑦𝑦2 + 𝑦𝑦4 + ⋯ + 𝑦𝑦2𝑛𝑛−2 ) + 𝑦𝑦2𝑛𝑛 )
𝑦𝑦𝑟𝑟+1 ≈ 2𝑦𝑦𝑟𝑟 − 𝑦𝑦𝑟𝑟−1 + ℎ2 ( 2 )𝑟𝑟 , 𝑟𝑟 = 0,1,2, … 𝑎𝑎 3
𝑑𝑑𝑑𝑑 This formula is not given in the formula book so will need to be learned- it can be more easily
𝑦𝑦1 = 2 + 0.5(�3𝑒𝑒 + 4𝑒𝑒 2 ) Once again, you may need to use Euler’s formula to find missing values if necessary. It is also important to pay
𝑑𝑑2 𝑦𝑦 remembered by the informal definition:
𝑑𝑑𝑑𝑑
Calculate ( )1 . close attention to the indexes of 𝑦𝑦 and , it is very easy to get them mixed up! 𝑏𝑏
1
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 2
Using the step size, we know that 𝑥𝑥1 = 𝑥𝑥0 + ℎ = 1.5, and � 𝑓𝑓(𝑥𝑥)𝑑𝑑𝑑𝑑 ≈ ℎ((sum of end points) + 4(sum of odd values) + 2(sum of even values))
𝑎𝑎 3
we have calculated that 𝑦𝑦1 = 2 + 0.5(√3𝑒𝑒 + 4𝑒𝑒 2 ). Example 3: For the second-order differential equation
𝑑𝑑2 𝑦𝑦
= 𝑥𝑥 2 − 𝑦𝑦 2 . When 𝑥𝑥 = 0, 𝑦𝑦 = 1 and
𝑑𝑑𝑑𝑑
= 2. Use the
𝑑𝑑𝑑𝑑 2 𝑑𝑑𝑑𝑑
𝑑𝑑𝑑𝑑 𝑑𝑑 2 𝑦𝑦 When attempting exam questions with Simpson’s rule, the best plan is to construct a table of the 𝑥𝑥 and 𝑦𝑦-values.
( )1 = �3𝑒𝑒1.5 + 4𝑒𝑒 2+0.5(√3𝑒𝑒+4𝑒𝑒 ) 𝑑𝑑𝑑𝑑 𝑦𝑦1 −𝑦𝑦0 𝑦𝑦1 −2𝑦𝑦0 +𝑦𝑦−1
2
https://bit.ly/pmt-cc
https://bit.ly/pmt-edu https://bit.ly/pmt-cc