1) Set Parameters:
g,d,p,ps,u, v0, es
2) Modified Secant Method
Allocate space for while loop
Establish stopping criteria, Es
Estimate new root
Calculate percent true error, Et
If Et > Es
continue next iteration i = i+1
else
end
Plot Error
3) Fixed Point Iteration
Allocate space for while loop
Insert fixed point iteration equation
Establish stopping criteria, Es
Estimate new root
Calculate percent true error, Et
If Et > Es
Continue loop
else
end
Plot convergence
Plot Approximate Error of each iteration
Plot True Error of each iteration
Figure 1: The plot of the settling velocity function using equation (8). The analytical root of the function is about v = 0.07m/s.
The numerical solution was initially solved by hand. The values are different than the respective values in calculated in MATLAB due to rounding errors. For example, the initial guess or Vo, calculated by hand is 0.1056m/s while the same value calculated in MATLAB is 0.1070m/s. This difference causes follow errors in subsequent hand calculations. Parts (a) and (b) of the solution are solved using the following given equations and parameters. The methodology is shown below.
Equation (2) was used to calculate the value after each of the given parameters was converted to base units. This value will be used as the initial guess for the modified secant method approximation shown in the Numerical Solution section.
A flow is said to be laminar if its Reynolds Number is less than 0.1 and turbulent for higher Reynolds Numbers. Since the calculated Reynolds Number for this flow is 15.1, it is a turbulent flow. Turbulent flows have chaotic streamlines, making it harder to model them.
The particle's settling velocity is approximated using both the modified secant method and fixed point iteration. The modified secant method is an open method for finding roots of equations. An open method is one that without defined interval bounds. This method requires one initial estimate for the root. Then, it bumps up the root by a small number, known as the perturbation fraction, to estimate the f'(x). This estimate provides the following iterative equation:
The first iteration of the modified secant method is below. Here, the error is high, because it is the first iteration. Also, the calculations were performed before the code was written, so the initial guess, Vo, causes the calculations to be slightly different than in the MATLAB program.
Fixed point iteration is another open method for finding roots of equations. Fixed point iteration predicts a new root from a previous estimate. First, the function f(x) is rearranged into the form x=g(x). Then, both function, x and g(x) are plotted. The point of intersection of the two functions is the analytical root of the function.
The modified secant method took four iterations to meet the error stopping criteria. According to the analytical solution, the true root of the function is approximately v = 0.07m/s. The convergence of the modified secant method on the true root of the function is found by plotting the approximation of each iteration over the number of iteration. Displayed in the graph below, the modified secant method quickly estimates the root value.
Figure 2: The convergence of the true root using the modified secant method is displayed by plotting the approximated values over the number of iterations.
The fixed point method took nine iterations to meet the error stopping criteria. The convergence on the true root using fixed point iteration is shown in the graph below. Since the y-axis is the same for Figure 1 and Figure 2, the effectiveness of each method can be compared easily. Using fixed point iteration, the true root was gradually estimated while the modified secant method quickly converged to the true root.
Figure 3: The convergence of the true root using fixed point iteration is displayed by plotting the approximated values over the number of iterations.
(e)
Fixed point iteration will converge on the true root for any positive initial guess. In the plot below, a positive initial guess could be anywhere on the blue line. For any initial guess, the first iteration will always move horizontally towards the root before intersecting the line y = x. At this same x-value, the y-value of the given velocity equation will be found. Then, a horizontal line will be drawn from this point to find a new value on the line y = x. Successive iterations will always move closer to the root.
Figure 4: The iterative new velocity over the iterative old velocity was plotted to display that fixed point iteration will converge on the root
Figure 5: The figure above shows the approximate percent error during every iteration using the two root finding methods.
The approximate percent error was calculated after each iteration of both root finding methods. After the first iteration, the approximate error was much higher using the modified secant method. However, after one more iteration, the approximate error using the modified secant method dipped below the same value using fixed point iteration.
Figure 5: The figure above displays the true error for each iteration using both the modified secant method and fixed point iteration.
Additionally, the true percent error of each method was calculated after each iteration. The true error was the same for both root finding methods after the percent error. For subsequent iterations, the true error using the modified secant method was lower than the true error using fixed point iteration.
Both the modified secant method and fixed point iteration proved to be effective root finding methods. In this instance, the modified secant method was more effective, because it converged on the the particle's settling velocity in less iterations. Although both methods are effective for this problem, for more complex problems with iterations in the hundreds or thousands, it is important to choose the best root finding method. The correct choice will take less time and computing storage. Since they are open root finding methods, they could diverge. To prevent the methods from diverging, the initial guesses are vital.
One source of error in the problem is that the flow of the liquid is turbulent. Turbulent flows have swirling currents and increased edge effects which can both increase error in an experiment. A turbulent flow can create chaotic movements of the liquid. In ideal conditions, there would be zero drag. This error causes the difference between the initial guess and the true root.
1) Set Parameters
Z, R, C, L, and the given function
upper and lower limit guesses
2) Employ Bisection Method
while the approx error > es
if root is guessed
break loop
if f(l)*f(b)<0
change upper limit to new bisection limit
else
change lower limit to new bisection limit
end
calculate new bisection limit
calculate new error
end
Plot approximate percent error
3) Use False Position Method
while the approx error > es
if f(l)*f(b)>0
change upper limit to xr
if f(l)*f(b)>0
change lower limit to xr
else
change lower limit to new bisection limit
end
calculate new error
add step to iterative variable
end
Plot approximate percent error
The analytical solution is the plot of the given impedance function after rearranging the formula into the form f(x) = 0. The root is the point where the function crosses the x-axis. The analytical root was found to be around x=39/Ohms.
Figure 1: The root is indicated by intersection of all three lines, or where the impedance function intersects the x-axis.
(a) Using MATLAB code, the iterations were found using both the bisection and false position methods for finding roots. The bisection method is closed method for finding the root of a real and continuous function that has 1 real root. In this method, the interval for approximating roots is halved during after each iteration, until the root is found or the error criteria is met.
Alternatively, the false position method uses properties of similar triangles to solve to approximate the position of a root. This is also a closed method for finding roots meaning that the boundaries need to be defined. Using this method, similar triangles can be drawn between the x-axis and the function both above and below the axis. Then the triangles can be set proportional to each other. A sample calculation of the first iteration is shown below.
(b) Using the bisection method, the error criteria was met in 18 iterations. The approximated angular velocity was initially much higher than the true root value. However, after the 5th iteration, the approximation dipped below the true root. Then, in subsequent iterations, the approximation oscillated above and below the true root of 39.047/Ohms. The analytical guess for the true root of the function was very accurate. The analytical solution yielded a value of 39/Ohms while the numerical solution provided a value of 39.047/Ohms.
Figure 2: The convergence of the bisection method on the true root is displayed above.
The approximate percent error of the bisection method was used. The error started off at 100% after the first iteration and it quickly dropped to below 10% in just 9 iterations.
Figure 3: The figure above displays the percent approximate error over the number of iterations using the bisection method. These percent approximate error after each iteration.
According to my code, the false position method required one iteration to meet the error stopping criteria while the bisection method required 18 iterations. This means that the false position method is more effective because it found the root of the function in less iterations. However, the actual number of iterations is likely more than one, and a coding error likely caused the error. The bisection method worked properly and took 18 iterations to meet the stopping criteria. This method was effective because it found the root of the function quickly. One characteristic of closed bracketing methods is that they always converge if bracketed properly. However, in using longer equations and more complex algorithms, it may be more effective to use an open root finding technique because they typically converge in fewer iterations.
a)
My partner's peer review comments were helpful in helping my initially alter my code and website. Before I started making changes to the initial submission, I read through the code review and made notes of the suggestions. Here are the changes I made based on the code review:
First, I kept general comments about open and closed methods as well as specific comments about each root finding method because my peer reviewer indicated this was very helpful.
I also kept my comments in the MATLAB code and wrote more to make the code easy to follow.
For problem 1, I added a plot showing the difference between the error for the two root finding methods.
For problem 2, I rearranged the equation, similar to the methodology followed in problem 1, to get a function that could be plotted in MATLAB.
I kept my pseudocode the same for problem 1, and added to the pseudocode for problem 2 even though the change seems superficial
For problem 2, I included the error for the bisection method inside the loop so I could plot each iteration.
b)
From reading my partner's code, I learned several things that helped me complete this assignment. One thing that I noticed in my partner's code was the complex use of functions inside functions. I analyzed this portion of code and concluded that the risk of incorrectly coding the functions outweighs the reward of not having to include long formulas in the main code. I think one of the issues with my initial code was improper use of function handles, so I wanted to make my code simpler by deleting them.
I did not gain much insight on problem 2 from reading my partner's code. My partner did not complete the false position method or error analysis and those were the parts that I struggled with most for the initial submission.
c)
For problem 1, I made many changes from the initial submission. First off, I rearranged the information that was in the analytical/numerical sections because Dr. Di Vittorio mentioned in class that the only analytical solution is the plot of the initial function. Thus, I moved all of my calculations to the numerical section. Additionally, I spent a lot of time working on the code for problem 1. I only had one graph initially, and even this was changed. I rewrote the equation and made it simpler, and the function was correctly plotted with a line across the x-axis to easily indicate the root. Five other graphs were included to display the convergence, true error, and approximate error using each root finding method. I included two different error plots because this has been a point of emphasis in class, and I was not sure which error would better represent the data.
For problem 2, I got the bisection method to plot by playing around with my code. I did this similar to problem 1, where I included the error inside the loop. Then I plotted the error over the number of iterations to show the change in error at each iteration.