Implementing Solutions of Nonlinear equations in one variable using - - PowerPoint PPT Presentation
Implementing Solutions of Nonlinear equations in one variable using - - PowerPoint PPT Presentation
1 Implementing Solutions of Nonlinear equations in one variable using Excel and Maple ICTCM 2020 2 Purpose To demonstrate how a student in undergraduate Numerical Methods class would use the Excel, a commonly available tool, and Maple,
Purpose
To demonstrate how a student in
undergraduate Numerical Methods class would use the Excel, a commonly available tool, and Maple, a computational tool available by subscription, to solve a mathematical nonlinear model, developed for a real-world problem.
2
The presentation includes
The mathematical model, Ascertaining the number of negative and positive zeros using
Descartes rule;
Find the domain of the zeros for the given equation, using
bounds of real zeros;
Find the subintervals which contain the real zeros, using the
mean value theorem;
Program Bisection, Regula Falsi and Newton Raphson
methods, in both Excel and Maple;
Compare the computational efficiency of the three methods.
3
Sample Real World Problem1
A can in the shape of a right circular cylinder is to be constructed to contain 1000 cm3. The circular top and bottom of the can must have a radius of 0.25 cm more than the radius of the can so that the excess can be used to form a seal with the side. The sheet material being formed into the side of the can must also be 0.25 cm longer than the circumference of the can so that the seal can be formed. Find, to within 10−4, the minimal amount of material needed to construct the can.
1 Numerical Analysis, 9th Edition, Richard Burden and J. Douglas Faires, Cengage, ISBN-13: 978-0-538-73351-9
4
Nonlinear Mathematical Model of the Problem
To finding the result of interest, we solve for the root of the mathematical equation, based on the original problem. 𝑔 𝑠 = 4π2 r 4 +πr3−2000 πr -500 =0
5
Preprocessing the Equation of interest
(i) The degree of the polynomial is four, hence it has four roots. (ii) By Descartes rule of sign, the function has three negative and one positive root. (iii) Find the domain of the roots using the bounds of real zeros (the synthetic division method) and subdividing the domain to find the interval containing the positive root we get the interval of interest to be [0, 6.93].
6
Pseudocode for the BiSection Method
An approximate root of the continuous function 𝑔(𝑦) = 0, on the interval [𝑏, 𝑐], where 𝑔(𝑏) ∙ 𝑔(𝑐) < 0, is given by 𝑞 ≈ ൗ
(𝑏+𝑐) 2
INPUT endpoints a, b; error limit or tolerance TOL. OUTPUT approximate solution 𝑞. 1 Set iteration index 𝑗 = 0; 2 Set 𝑞0 = (𝑐 + 𝑏)/2 3 While error (= 𝑔(𝑞𝑗)) ≥ TOL do Steps 3–6 4 if 𝑔(𝑏) ∙ 𝑔(𝑞𝑗) > 0 then set 𝒃 = 𝒒𝒋 else set 𝒄 = 𝒒𝒋 5 increment 𝑗 = 𝑗 + 1 6 Set 𝑞𝑗 = 𝑏 + (𝑐 + 𝑏)/2; (Compute next 𝑞𝑗.) 7 OUTPUT (𝑞𝑗) (Approximation of root value within the error)
7
Pseudocode for the Regula Falsi Method
An approximate root of the continuous function 𝑔(𝑦) = 0, on the interval [𝑏, 𝑐], where 𝑔(𝑏) ∙ 𝑔(𝑐) < 0, is given by 𝑞 ≈ ൗ
(𝑏 𝑔 𝑐 −𝑐 𝑔(𝑏)) (𝑔 𝑐 −𝑔 𝑏 )
INPUT endpoints a, b; error limit or tolerance TOL. OUTPUT approximate solution 𝑞. 1 Set iteration index 𝑗 = 0; 2 Set 𝑞0 = ൗ
(𝑏 𝑔 𝑐 −𝑐 𝑔(𝑏)) (𝑔 𝑐 −𝑔 𝑏 )
3 While error (= 𝑔(𝑞𝑗)) ≥ TOL do Steps 3–6 4 if 𝑔(𝑏) ∙ 𝑔(𝑞𝑗) > 0 then set 𝒃 = 𝒒𝒋 else set 𝒄 = 𝒒𝒋 5 increment 𝑗 = 𝑗 + 1 6 Set 𝑞𝑗 = ൗ
(𝑏 𝑔 𝑐 −𝑐 𝑔(𝑏)) (𝑔 𝑐 −𝑔 𝑏 ) (Compute next 𝑞𝑗.)
7 OUTPUT (𝑞𝑗) (Approximation of root value within the error)
8
Pseudocode for the Newton Raphson Method
An approximate root of the continuous function 𝑔(𝑦) = 0, on the interval [𝑏, 𝑐], where 𝑔(𝑏) ∙ 𝑔(𝑐) < 0, is given by 𝑞 ≈ ൗ
(𝑏 𝑔 𝑐 −𝑐 𝑔(𝑏)) (𝑔 𝑐 −𝑔 𝑏 )
INPUT endpoints a, b; error limit or tolerance TOL. OUTPUT approximate solution 𝑞. 1 Set iteration index 𝑗 = 0; 2 Set 𝑞0 = 𝑏 − ൗ
(𝑔(𝑏)) (𝑔′ 𝑏 )
3 While error (= 𝑔(𝑞𝑗)) ≥ TOL do Steps 3–6 4 increment 𝑗 = 𝑗 + 1 6 Set 𝑞𝑗 = 𝑞𝑗−1 − ൗ
(𝑔(𝑞𝑗−1)) (𝑔′ 𝑞𝑗−1 ) (Compute next 𝑞𝑗.)
7 OUTPUT (𝑞𝑗) (Approximation of root value within the error)
9
Summary of test results for
Method Tool Number of Iterations Approximate Root Value Bisection Excel 17 5.4192 Maple 5 5.4192 Regula Falsi Excel 14 5.4192 Maple 5 5.4192 Newton Raphson Excel 4 5.4192 5.4192 Maple 4 TOL = 10−4
10
In Summary
- 1. The behavior of methods was as predicted.
In other words, the tests validated the computational efficiency of each method:
- 1. Newton Raphson
- 2. Regula Falsi
- 3. Bisection