Numerical Methods
Numerical Methods
1
𝑛 = 1, 𝑚𝑎𝑥𝑖𝑚𝑢𝑚 𝑎𝑏𝑠𝑜𝑙𝑢𝑡𝑒 𝑒𝑟𝑟𝑜𝑟 = × 10−1 = 0.05
2
1
𝑛 = 2, 𝑚𝑎𝑥𝑖𝑚𝑢𝑚 𝑎𝑏𝑠𝑜𝑙𝑢𝑡𝑒 𝑒𝑟𝑟𝑜𝑟 = × 10−2 = 0.005
2
Example
Given that 𝑥 = 8.7 and 𝑦 = 0.3, each correct to one decimal place, find
(a) the value of 𝑥𝑦 and an estimate of the relative error in calculating this quantity.
1
(b) the value of 𝑦 − 𝑥 giving your answer, with error bounds to one significant figure, to
appropriate accuracy.
Suggested Solution
There are two approaches that we can use:
(a) First we need a working / mid value. We can use the approximated value to get the working
value
𝑥𝑦 = 8.7 × 0.3 = 2.61
1
We also want the maximum absolute error in each value given by 2 × 10−1 = 0.05, hence
8.65 ≤ 𝑥 < 8.75 and 0.25 ≤ 𝑦 < 0.35
Relative error can be calculated using the sum of relative errors,
0.05 0.05
𝑅𝑒𝑙𝑎𝑡𝑖𝑣𝑒 𝑒𝑟𝑟𝑜𝑟 = + = 0.172413793 ≈ 17%.
8.7 0.3
1 1
(𝑦 − 𝑥) = 0.25 − 8.65 = 0.134393063
𝑚𝑖𝑛
1
Working value/ mid value= 2 (0.235714285 + 0.134393063) = 0.185053674 = 0.19 (2 𝑠𝑓)
1
Maximum absolute error = 2 (0.235714285 − 0.134393063) = 0.050660611 = 0.05 (1 𝑠𝑓)
1
Therefore (𝑦 − 𝑥) = 0.19 ± 0.05 ( 2 𝑠𝑓)
𝛿𝑦 𝑑𝑦 𝒅𝒚
≈ 𝑑𝑥 ⇒ 𝜹𝒚 ≈ 𝒅𝒙 𝜹𝒚. This is an important result that we can use to find a change in 𝑦 if the
𝛿𝑥
change in 𝑥 is known since 𝑦 depends on 𝑥 in a given relationship such as 𝑦 = 𝑓(𝑥). In this
relationship, if 𝑥 is changed by a small amount 𝛿𝑥 then the new value is 𝑥 + 𝛿𝑥. A change in 𝑥
will also result in a corresponding change in 𝑦 given by 𝒚 + 𝜹𝒚 = 𝒇(𝒙 + 𝜹𝒙). This relationship
can be used to evaluate functions such as √16.01 or 𝑠𝑖𝑛31° without using a calculator.
Example
Example
The formula 𝑇 = 2√𝑙 can be used to estimate the period 𝑇 seconds of a pendulum of length 𝑙
𝑑𝑇
metres. Obtain and hence estimate the relative error in 𝑇 corresponding to a 1% relative error
𝑑𝑙
in 𝑙 [ZIMSEC]
Suggested Solution
𝑑𝑇 1 1 1
= 2 × × 𝑙 −2 =
𝑑𝑙 2 √𝑙
𝛿𝑇 𝑑𝑇 𝑑𝑇
≈ ⇒ 𝛿𝑇 ≈ 𝛿𝑙
𝛿𝑙 𝑑𝑙 𝑑𝑙
1 𝛿𝑙 1 𝑙
⇒𝛿𝑇 ≈ 𝛿𝑥. Now given that relative error in 𝑙 is 1% then = 100 ⇒ 𝛿𝑙 = 100
√𝑙 𝑙
1 𝑙 √𝑙
∴ 𝛿𝑇 ≈ × =
√𝑙 100 100
𝛿𝑇 √𝑙 1 1 1
Relative error in 𝑇 is given by = 100 × 2√𝑙 = 200 = 2 %∎
𝑇
Example
Suggested Solution
1 3 3
𝑑𝑦 1
𝑦 = (2𝑥 − 1)−2 and so 𝑑𝑥 = − 2 (2𝑥 − 1)−2 × 2 = −(2𝑥 − 1)−2
3
𝑑𝑦 𝑑𝑦 1
, 𝑎𝑡 𝑥 = 5, is 𝑑𝑥 = −(9)−2 = − 27
𝑑𝑥
𝛿𝑥 5
Relative error in 𝑥, ⇒ = − 100
𝑥
𝑥 1 1
⇒𝛿𝑥 = − = − , since 𝑥 = 5. Also when 𝑥 = 5, 𝑦 = from the given relationship.
20 4 3
1 1
∴ 𝛿𝑦 = − ×−
27 4
𝛿𝑦 1 1 1
Relative error in 𝑦 = = − 27 × − 4 × 3 × 100 = 36 × 100 = 2.78%∎
𝑦
Numerical methods do not produce exact solutions but gives approximate solutions, hence there
are errors inherent in the solutions. Before solving the equation, there is need to identify the
approximate location of the roots. When solving the equation, then we solve with approximate
solution in mind.
There are two methods that we can use, curve sketching or sign change. This enables us to
identify two consecutive integers between which a root lies. Curve sketching is also divided into
two:
Sketching the function 𝑦 = 𝑓(𝑥) and the root is located where 𝑓(𝑥) crosses the 𝑥 axis
(𝑓(𝑥) = 0) This may be challenging to do because in most cases the equation we wish to
solve using numerical methods cannot be solved by exact methods such as factorization.
The second method makes use of the sign change. It uses the argument that if a graph of 𝑓(𝑥) is
continuous and crosses the line 𝑦 = 0 or 𝑓(𝑥) = 0 between two consecutive integers 𝑎 and 𝑏 then the
root 𝛼 lies between these integers such that 𝑎 < 𝛼 < 𝑏 if the values of 𝑦; 𝑓(𝑎) and 𝑓(𝑏) have different
signs. Alternatively a root 𝛼 lies between 𝑎 and 𝑏 if 𝒇(𝒂). 𝒇(𝒃) < 𝟎.
Example
(a) Show by sketching two appropriate graphs, that the equation 𝑥 3 + 3𝑥 − 3 = 0 has only one real root.
(b) Show by calculation, that the root of the equation in (a) lies between 𝑥 = 0,8 and
𝑥=1
Suggested Solution
(a) The equation can be rearranged as 𝑥 3 = 3 − 3𝑥, so we can draw two graphs of 𝑔(𝑥) = 𝑥 3 and
From the graph there is only one intersection point of 𝑔(𝑥) = 𝑥 3 and ℎ(𝑥) = 3 − 3𝑥 so there is only one
real root, 𝛽 of 𝑥 3 + 3𝑥 − 3 = 0.
(b) To show that there is a root between 𝑥 = 0.8 and 𝑥 = 1, we note the equation must be written in the
form 𝑓(𝑥) = 0, so 𝑥 3 + 3𝑥 − 3 = 0 ⇒ 𝑓(𝑥) = 𝑥 3 + 3𝑥 − 3
𝑓(2) = 22 − 3(2) + 1 = −1
𝑓(3) = 32 − 3(3) + 1 = +1
Since there is a sign change then there is a root between 𝑥 = 2 and 𝑥 = 3∎
1 1
Using 𝑥𝑛+1 = 3−𝑥 and taking 𝑥1 = 2 (2 + 3) = 2.5
𝑛
1
𝑥2 = =2
3 − 2.5
1
𝑥3 = =1
3−2
1
𝑥4 = = 0.5
3−1
1
𝑥2 = 3 − = 2,666666667 = 2.6667 (4 𝑑𝑝)
3
1
𝑥3 = 3 − = 2.6250 (4 𝑑𝑝)
2.6667
1
𝑥4 = 3 − = 2.619047619 = 2.6190 (4 𝑑𝑝)
2.625
1
𝑥5 = 3 − = 2.618181818 = 2.6182 (4 𝑑𝑝)
2.619
The root is therefore 𝑥 = 2.62 (3 𝑠𝑓)∎
NOTE: If the number of iterations is not specified, do enough iterations until to consecutive iterations
agree to a specified degree of accuracy. Also an arrangement may not converge as 𝑥1 , 𝑥2 ⋯ maybe
divergent.
Example
3 +1)
2(𝑥𝑛
Use the iterative formula 𝑥𝑛+1 = 2 , where 𝑥0 = 1, to calculate 𝑥1, 𝑥2 and 𝑥3 giving your answers
3𝑥𝑛
correct to 6 decimal places.
Given that the iteration converges, find and simplify an equation in 𝑥 whose real root is approximated by
this iteration.
Hence write down the exact value of this root. Find the absolute errors 𝑒1 , 𝑒2 , 𝑒3 in the first three
approximations 𝑥1 , 𝑥2 , 𝑥3 , giving your answers to 6 decimal places. [ZIMSEC]
Suggested Solution
𝑥0 = 1
3
2(1 + 1)
𝑥1 = = 1.333333333 = 1.333333 (6 𝑑𝑝)
3(12 )
2(1.3333333 + 1)
𝑥2 = = 1.263888889 = 1.263889 (6 𝑑𝑝)
3(1.3333332 )
2(1.2638893 + 1)
𝑥3 = = 1.259933493 = 1.259933 (6 𝑑𝑝)
3(1.2638892 )
To find the root approximated by this iteration, we set both 𝑥𝑛 and 𝑥𝑛+1 equal to 𝑥 and simplify.
2(𝑥 3 +1)
Therefore 𝑥 = 3𝑥 2
⇒ 3𝑥 3 = 2𝑥 3 + 2 ⇒ 𝑥 3 = 2 is the equation.
3
The exact value of 𝑥 is 𝑥 = √2 = 1.25992105
The absolute errors are therefore
𝑒1 = 1.333333333 − 1.25992105 = 0.073412283 = 0.073412 (6 𝑑𝑝)
From the graph, as we change the values 𝑥0 , 𝑥1 , 𝑥2 , 𝑥3 ⋯ we get closer to the root 𝛽 of the equation
𝑓(𝑥) = 0.
If we take one tangent at 𝑥 = 𝑥𝑜 as below:
𝑥0 (𝑓 ′ (𝑥0 )) − 𝑓(𝑥0 )
𝑥1 =
(𝑓 ′ (𝑥0 ))
𝑓(𝑥0 )
𝑥1 = 𝑥0 − [ ′ ]
(𝑓 (𝑥0 ))
𝑓(𝑥𝑛 )
⇒ 𝑥𝑛+1 = 𝑥𝑛 − [ ′ ]
(𝑓 (𝑥𝑛 ))
𝑓 ′ (𝑥) = 𝑐𝑜𝑠𝑥 − 1
Now we can write the Newton –Raphson method paying particular attention to its structure. Thus
1
sin 𝑥𝑛 − 𝑥𝑛 + 2
𝑥𝑛+1 = 𝑥𝑛 − [ ]
cos 𝑥𝑛 − 1
Now we can use this iterative formula to find the root of the equation
𝑥0 = 1
1
𝑠𝑖𝑛1 − 1 +
𝑥1 = 1 − [ 2] = 1 − (−0.742816396) = 1.742816397
𝑐𝑜𝑠1 − 1
1
𝑠𝑖𝑛1.7428 − 1.7428 +
𝑥2 = 1.7428 − [ 2] = 1.522886966
𝑐𝑜𝑠1.7428 − 1
1
𝑠𝑖𝑛1.52289 − 1.52289 + 2
𝑥3 = 1.52289 − [ ] = 1.497643637
𝑐𝑜𝑠1.52289 − 1
1
𝑠𝑖𝑛1.49764 − 1.49764 + 2
𝑥4 = 1.49764 − [ ] = 1.497300452
𝑐𝑜𝑠1.49764 − 1
1
𝑠𝑖𝑛1.4973 − 1.4973 + 2
𝑥5 = 1.4973 − [ ] = 1.497300389
𝑐𝑜𝑠1.4973 − 1
By increasing the number of trapezia between 𝑎 and 𝑏 we obtain a more accurate approximation. The
increased number of trapezia gives a more linear side to the curved part thereby minimising the unwanted
area( Over estimate) or cutting off required area(Under estimate)
The trapezium rule is therefore developed using this concept of the trapezium but with an increased
number of trapezia as shown below:
We can now use these ordinates to calculate the values of the function
1
𝑦1 = = 0.707106781
√2
1
𝑦2 = = 0.554700196
√1 + 9
4
1
𝑦3 = = 0.447213595
√5
1
𝑦4 = = 0.371390676
√1 + 25
4
1
𝑦5 = = 0.316227766
√10
1 1
∴ 𝐴𝑟𝑒𝑎 = . [0.707106781 + 0.316227766 + 2(0.554700196 + 0.447213595 + 0.371390676)]
2 2
= 0.94248587
= 0.942 (3 𝑑. 𝑝. ) ∎
Example
(a) Sketch the graph of the function 𝑦 = −𝐼𝑛𝑥
(b) Use the trapezium rule with three ordinates to estimate the area bounded by the curve 𝑦 = −𝐼𝑛𝑥, the
lines 𝑥 = 2 and 𝑥 = 3, giving your answer correct to four decimal places.
3
(c) (i) Evaluate ∫2 −𝐼𝑛𝑥 𝑑𝑥 , correct to four decimal places.
(ii) Hence calculate the percentage error in using the rule to estimate the area. Explain why the trapezium
rule gives an underestimate of the area.
3−2 1 1
(b) With 3 ordinates ℎ = 2
= 2, so the ordinates are at 𝑥 = 2, 𝑥 = 2 2 , 𝑥 = 3.
∫ −𝐼𝑛𝑥 𝑑𝑥 = −𝑥𝐼𝑛𝑥 + ∫ 𝑑𝑥
3
3
∫ −𝐼𝑛𝑥 𝑑𝑥 = [−𝑥𝐼𝑛𝑥 + 𝑥]
2 2
= (−3𝐼𝑛3 + 3) − (−2𝐼𝑛2 + 2)
= −3𝐼𝑛3 + 3 + 2𝐼𝑛2 − 2
The trapezium rule gives an underestimate of the area since the trapezia cuts off part the area as shown on
the diagram.∎
Example
𝜋
(a) By sketching the graphs of 𝑦 = 𝑡𝑎𝑛𝑥 and 𝑦 = 4𝑥 on a single diagram for 0 ≤ 𝑥 ≤ 2 , show that the
equation 𝑡𝑎𝑛𝑥 = 4𝑥 has exactly one positive root.
(b) Show , by calculation , that the root of the equation lies between 1 and 1.5.
(c) Show that the Newton-Raphson structure can be written in the form
𝑥𝑛 𝑡𝑎𝑛2 𝑥𝑛 − 𝑡𝑎𝑛𝑥𝑛 + 𝑥𝑛
𝑡𝑎𝑛2 𝑥𝑛 − 3
(d) Use the structure in (𝑐) once starting with 𝑥1 = 1.4, to estimate the root correct to 4 decimal
places.[ZIMSEC]
Suggested Solution
(a)
From the graph there is only one intersection point hence the equation tan 𝑥 = 4𝑥 only one root 𝛽
(b) From the equation 𝑡𝑎𝑛𝑥 = 4𝑥, then 𝑓(𝑥) = 𝑡𝑎𝑛𝑥 − 4𝑥
𝑦1 = √(1 + 𝑠𝑖𝑛0) = 1
𝜋
𝑦2 = √(1 + 𝑠𝑖𝑛 ) = 1.306562965
4
Example
The tangent at the point 𝑃(𝑥𝑛 ; 𝑥𝑛2 − 2) to the curve 𝑦 = 𝑥 2 − 2 meets the 𝑥 − 𝑎𝑥𝑖𝑠 at point 𝑄(𝑥𝑛+1 ; 0).
If 𝑥𝑛 > 0, show that
𝑥𝑛2 + 2
𝑥𝑛+1
2𝑥𝑛
Starting with 𝑥1 = 2, use this iterative formula to find successive approximations 𝑥2 , 𝑥3 for the positive
root of the equation 𝑥 2 − 2 = 0.
Hence show that
577
𝑥4 =
408
577
Find the error, to 1 significant figure, in using as an approximation to √2.
408
Suggested Solution
𝑑𝑦
The gradient of the tangent at 𝑃 is = 2𝑥 = 2𝑥𝑛 , since 𝑃(𝑥𝑛 ; 𝑥𝑛2 − 2). The equation of tangent 𝑃𝑄 is:
𝑑𝑥
3 2
(2) + 2 17
𝑥3 = =
3 12
2 (2)
577
𝐸𝑟𝑟𝑜𝑟 = − √2 = 0.000002123 = 0.000002 (1 𝑠. 𝑓. )∎
408