0% found this document useful (0 votes)
11 views7 pages

ESci 118 - LabEx 3 - Lab Guide (Open Methods)

NUMERICAL FOR ENGINEERS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

ESci 118 - LabEx 3 - Lab Guide (Open Methods)

NUMERICAL FOR ENGINEERS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

ESci 118 – Numerical Solutions to Engineering Problems

Laboratory Exercise no. 3:


Open Methods
Introduction
The previous laboratory exercise dealt with bracketing methods in
root-finding which requires an initial bracket in order to approach the value of
a root. In order to successfully estimate the root, the chosen initial bracket
should contain the root itself – the two points being on opposite sides of the
root. The goal is to narrow the bracket down using various techniques in
order to obtain a more precise estimate of the root after each iteration.
In this exercise, we will be dealing with open methods which is
another class of root-finding algorithms which does not require that the root
to be inside a bracket. It requires one or two initial points that is relatively
close to the root but not necessary containing the root. The first technique is
called Newton-Raphson method which uses one initial point near the root
then projecting a tangent line to the x-axis to obtain a closer estimate of the
root. This requires evaluating the derivative of the root which represents the
slope of the tangent line at the initial point.
The second technique is called secant method. Rather than using the
slope of the tangent line at an initial point, it uses to points close to the root
and connects the two points with a line that projects to the x-axis. In this way,
a closer estimate of the root can also be obtained for each iteration. In
bracketing methods, it is required that the two initial points selected are on
opposite sides of the root. But in secant method, the two points may lie on
opposite sides or on the same side, and it will still be able to approach the
said root.

Learning Outcomes
1. Familiarize the procedure of open methods for root-finding.
2. Apply open methods in approximating roots of equations.
3. Recognize the importance and advantages and disadvantages of
using open methods in root-finding over the classical algebraic
manipulation and the bracketing methods.

Materials

• Desktop Computer (or Laptop) with MS Excel or Python

Procedure
Problem
Evaluate 𝑥 for

𝑥2 − 𝑥 = 1
ESci 118 – Numerical Solutions to Engineering Problems

using algebraic manipulation and by the two open methods. Target an


accuracy of 9 correct decimal digits for the numeric methods.

Step 1: Algebraic manipulation.

The equation becomes:

𝑥2 − 𝑥 − 1 = 0

Obtaining the roots algebraically requires the quadratic formula (which is


derived from completing the squares).

−𝑏 ± √𝑏2 − 4𝑎𝑐
𝑥=
2𝑎

Substituting values to the quadratic formula gives us the exact values of the
two real roots:

1 − √5
𝑥1 = ≅ −0.6180339887
2
1 + √5
𝑥2 = ≅ 1.618033989
2

Step 2: Graphing Method.

In order to find the value of 𝑥 in 𝑥 2 − 𝑥 = 1, we need to find the root/s of

𝑓(𝑥) = 𝑥 2 − 𝑥 − 1

To start the graphing method, we first choose an initial range to try to guess
where the root/s are located. Say we take the initial range of −2 ≤ 𝑥 ≤ 2. In
MS Excel, our first column will be for 𝑥, and the 2nd column is 𝑓 (𝑥). We start
with −2, and choose an interval, say 0.1. Thus, our next value of 𝑥 will be −1.9,
we then extend this series of numbers by selecting the two cells and then
dragging the bottom right corner of the selection box. This prompts MS Excel
to fill in the numbers according to the interval of 0.1. We then extend these
values of 𝑥 until the last number is 2.
ESci 118 – Numerical Solutions to Engineering Problems

Figure 1. List of x values from -2 to 2 with interval of 0.1

Next, we fill in the formula for 𝑓(𝑥). In cell B2, type in the Excel formula for
𝑓(𝑥) and extend the formula for all listed values of 𝑥.

Figure 2. Excel formula for f(x) extended to the range.

We then review the values of 𝑓(𝑥) and locate the range/s where the values
changes signs. This indicates that the graph has crossed the x-axis and
therefore indicates the root/s. In this case, we find that the two roots are
located within the ranges of −0.7 to −0.6, and 1.6 to 1.7.

Figure 3. The two ranges where roots are located.


ESci 118 – Numerical Solutions to Engineering Problems

Step 3: Newton-Raphson Method.

Our iteration formula for Newton-Raphson method is

𝑓(𝑥𝑖 )
𝑥𝑖+1 = 𝑥𝑖 −
𝑓′(𝑥𝑖 )

We require the derivative of 𝑓 (𝑥) = 𝑥 2 − 𝑥 − 1, giving us

𝑓 ′ (𝑥) = 2𝑥 − 1

To apply the iteration formula in MS Excel, our column labels will be: Iteration,
𝒙, 𝒇(𝒙), and 𝒇′ (𝒙). For the first entry in the x column, we will input our initial
point that is fairly close to the desired root. Say for example, we are trying to
approach the first root that is between −0.7 and −0.6, we can use 𝑥 = −0.7 as
our initial point (at Iteration 0). For the f(x) column, we will simply code the
formula of 𝑓(𝑥) where the 𝑥 value is referred to the value in the x column at
the same iteration. And for the f’(x) column, we will code the formula for
𝑓 ′ (𝑥).

Figure 4. Coding the formulas for f(x) and f’(x).

For the next value of 𝑥 (Iteration 1), we will code the iteration formula where
the 𝑥𝑖 is referred to the value in the x column in the previous iteration
(Iteration 0).

Figure 5. Using the iteration formula to obtain the next value of x.

Finally, we will extend the formulas of all columns to the number of iterations
desired.
ESci 118 – Numerical Solutions to Engineering Problems

Figure 6. Extending the Newton-Raphson method to 5 iterations.

In this case, we were able to approach the value of the first root to 9 decimal
digits of accuracy after only the 3rd iteration. Perform the same method to
estimate the second root.

Step 4: Secant Method.

In secant method, we need two initial values of 𝑥 that are fairly close to the
desired root. Say for example, we desire to approach the first root, we can use
initial values of −0.8 and −0.7. This means that we need to start at iteration
“−1”. Then, we can code the formula of 𝑓(𝑥) for each.

Figure 7. Coding the formulas for f(x) in secant method.

Then, for Iteration 1, we will apply our iteration formula for secant method
which is

(𝑥𝑖−1 )𝑓(𝑥𝑖 ) − (𝑥𝑖 )𝑓 (𝑥𝑖−1 )


𝑥𝑖+1 =
𝑓 (𝑥𝑖 ) − 𝑓(𝑥𝑖−1 )

where 𝑖 + 1 is referred to Iteration 1; 𝑖 is referred to Iteration 0; and 𝑖 − 1 is


referred to Iteration “−1”.
ESci 118 – Numerical Solutions to Engineering Problems

Figure 8. Applying the secant method iteration formula.

Finally, we will extend the formulas of all columns to the number of iterations
desired.

Figure 9. Extending the Secant method to 5 iterations.

In this case, we were able to approach the value of the first root to 9 decimal
digits of accuracy after only the 4th iteration. Perform the same method to
estimate the second root.

As a form of personal study, try to implement these two open methods in


Python.

Guide questions and instructions on how to prepare


and submit the laboratory report:
Your Laboratory Report should have the following contents:

Introduction
• Write your own introductory paragraph/s for this exercise.
• Learning outcomes
• Problem statement

Methods
• In your own words explain the method performed
ESci 118 – Numerical Solutions to Engineering Problems

Results & Discussion


• Display the tabulated results for each of the numeric methods
highlighting the final result (with the required accuracy) and the
number of iterations required to achieve the required accuracy.
• Discuss the comparison between the methods in terms of concept,
ease of implementation, and their efficiency or speed of approaching
the exact value.
• Discuss the advantages and disadvantages you perceive about these
numeric methods over the classical algebraic method and the
bracketing methods.
• Make a summary of all these observations and relate them to
potential applications or usefulness to the study of civil engineering.

References
• Show references (if any) in APA style.

Other formatting instructions:


• Use the template provided by the instructor.
• Include figures as necessary.

Submission instructions:
• Save as a PDF file with file name format:
LASTNAME_Firstname_LabEx3_ESci_118.pdf (if individual)
LASTNAME1_LASTNAME2_LabEx3_ESci_118.pdf (if by pair)
• Submit to the instructor via email: [email protected]
• Deadline: 3 working days (at 5:00 PM) after conducting the lab
exercise.

You might also like