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, a computational tool available by subscription, to solve a mathematical nonlinear model, developed for a real-world problem.
The presentation includes 3 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.
Sample Real World Problem 1 4 A can in the shape of a right circular cylinder is to be constructed to contain 1000 cm 3 . 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
Nonlinear Mathematical Model of the Problem 5 To finding the result of interest, we solve for the root of the mathematical equation, based on the original problem. 𝑔 𝑠 = 4π 2 r 4 +πr 3 − 2000 πr -500 =0
6 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].
Pseudocode for the BiSection Method 7 An approximate r oot 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 𝑞 . Set iteration index 𝑗 = 0; 1 Set 𝑞 0 = (𝑐 + 𝑏)/2 2 While error (= 𝑔(𝑞 𝑗 )) ≥ TOL do Steps 3 – 6 3 if 𝑔(𝑏) ∙ 𝑔(𝑞 𝑗 ) > 0 then set 𝒃 = 𝒒 𝒋 else set 𝒄 = 𝒒 𝒋 4 increment 𝑗 = 𝑗 + 1 5 Set 𝑞 𝑗 = 𝑏 + (𝑐 + 𝑏)/2 ; (Compute next 𝑞 𝑗 .) 6 7 OUTPUT ( 𝑞 𝑗 ) (Approximation of root value within the error)
Pseudocode for the Regula Falsi Method 8 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 𝑞 . Set iteration index 𝑗 = 0; 1 (𝑏 𝑔 𝑐 −𝑐 𝑔(𝑏)) Set 𝑞 0 = ൗ 2 (𝑔 𝑐 −𝑔 𝑏 ) While error (= 𝑔(𝑞 𝑗 )) ≥ TOL do Steps 3 – 6 3 if 𝑔(𝑏) ∙ 𝑔(𝑞 𝑗 ) > 0 then set 𝒃 = 𝒒 𝒋 else set 𝒄 = 𝒒 𝒋 4 increment 𝑗 = 𝑗 + 1 5 (𝑏 𝑔 𝑐 −𝑐 𝑔(𝑏)) Set 𝑞 𝑗 = ൗ (𝑔 𝑐 −𝑔 𝑏 ) (Compute next 𝑞 𝑗 .) 6 7 OUTPUT ( 𝑞 𝑗 ) (Approximation of root value within the error)
Pseudocode for the Newton Raphson Method 9 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 𝑞 . Set iteration index 𝑗 = 0; 1 (𝑔(𝑏)) Set 𝑞 0 = 𝑏 − ൗ 2 (𝑔 ′ 𝑏 ) While error (= 𝑔(𝑞 𝑗 )) ≥ TOL do Steps 3 – 6 3 increment 𝑗 = 𝑗 + 1 4 (𝑔(𝑞 𝑗−1 )) Set 𝑞 𝑗 = 𝑞 𝑗−1 − (𝑔 ′ 𝑞 𝑗−1 ) (Compute next 𝑞 𝑗 .) ൗ 6 7 OUTPUT ( 𝑞 𝑗 ) (Approximation of root value within the error)
Summary of test results for TOL = 10 −4 10 Method Tool Number of Approximate Iterations Root Value Bisection Excel 17 5.4192 Maple 5 5.4192 Regula Falsi Excel 14 5.4192 Maple 5 5.4192 Newton Excel 4 5.4192 Raphson 5.4192 Maple 4
In Summary 11 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
Recommend
More recommend