You are on page 1of 4

Computer Lab 2

Roots

Jackson Pankratz
7887546
Oct 6, 2021
Mech 2150: Numerical Methods
Objective:

The main objective of this project is to determine the root of a non-linear function using
different numerical methods (bracketing and open methods) inside of MATLAB.

Problem Definition:

The problem introduced in this lab involves solving a non-linear equation provided as
Equation 1 in the lab manual. This equation is called an equation of state which was developed
by Beattie and Bridgeman. Included in this equation are many variables including:

T: Temperature (K) 293 K


P: Pressure (atm) 25 atm
R: Ideal Gas Constant (atm*L/mol*K) 0.08206 atm*L/mol*K
a: Constant 1 -0.106
b: Constant 2 0.057
c: Constant 3 -0.00001
V: Volume (m3) ?

Under these conditions, the equation must be solved for V using 5 different numerical
methods using MATLAB. All of these methods must solve for V to a minimum error (Es) of
1x10-5 %. Each method must return the root that it determined, the approximate error of that root,
and the number of iterations required. The methods used are:

- Bisection Method
- False Position Method
- Newton-Raphson Method
- Secant Method
- Simple Fixed-Point Iteration Method

Results:

Results from trial 1 using 0.01 as an upper guess and 0.001 as a lower guess can be seen
in Figure 1. These initial guesses came from the rough brackets given in the lab manual. For
methods that only require one initial guess (Newton Raphson and Simple FPI), the lower guess
was used as the initial guess. The ‘root’ in these tables represents the final volume (V).

Figure 1
Figure 2 displays results using a lower guess of 0.00001 and an upper guess of 0.1.
Again, the methods that only require one guess used the lower guess as the initial guess.

Figure 2

Discussion:

Bisection Method: For small values like these the bisection method was one of the
slowest methods to reach the target approximate error. When tested with lg and ug values of
0.0017 and 0.002 respectively, this method still took 21 iterations to reach the desired error.
When given initial values of 0.001 and 0.1 (much further away from the root) it only took 5 extra
iterations at 26 total. This shows that as the bisection method gets closer and closer to the root
the approximate error decreases exponentially slower.

False Position Method: The false position method was much faster than the bisection
method when using the initial guesses of 0.01 and 0.001 as it only took 6 iterations to reach the
desired error. This method also seems unaffected by a significantly lower, lower guess. When lg
was changed to 0.0000001, the iterations required didn’t change. However, when the upper guess
was changed to be one decimal point higher at 0.1, it took 58 iterations to reach the same desired
error. This could be because one scenario when the false position method does poorly is when
the root is significantly closer to one initial guess than the other.

Newton Raphson Method: This was consistently the best preforming method for most of the
guesses tested and only required one initial guess. It performed extremely well for very low
guesses like 0.00000001 however, it performed very poorly for higher values up to 0.7 taking 16
iterations.

Secant Method: This was also one of the best performing methods, it did not do as well as the
Newton Raphson method for the very small initial guesses, but it was actually more efficient for
the very high initial guesses all the way up to 0.7. although when both initial guesses were well
above the root (like 0.7 and 0.6) it did take up to 11 iterations to achieve the desired error.

Simple Fixed-Point Iteration: This method took 1 more iteration than the previous 2 methods for
the basic test, however it was the most consistent method overall. It was able to take very high or
very low guesses and solve them in only a few extra iterations, like starting at a guess of 5 and
only taking 6 iterations to achieve the desired error. One important thing to note is that with
guesses above 0.7 all other methods would focus on a different root of approximately 0.95
except this method.
For the majority of the tests, the bisection method took the most iterations to solve for the
root to the desired percent error. This is because the bisection method is very random and just
checks the middle of the two guesses every iteration with no consideration for the shape of the
function.

Summary:

This Lab showed how the different root finding methods performed under different
situations. It was incredibly easy to test different initial guesses and compare results once all of
the MATLAB files were created. Based on the overall performance, and for the wide range of
initial guesses it worked for, the Simple Fixed-Point Iteration method was the most efficient for
this particular function.

References:

Makers of MATLAB and Simulink. (n.d.). Retrieved from


https://www.mathworks.com/?s_tid=gn_logo

You might also like