Please I need help with how to give a PRESENTATION (behavior in comparison of ea
ID: 3209719 • Letter: P
Question
Please I need help with how to give a PRESENTATION (behavior in comparison of each method) of the result of the roots of the following equations:
1. f(x) = x2 2 = 0
2. f(x) = x4 12x^3+47x^2-60x = 0
3. f(x) = f(x) = x4 12x^3+47x^2-60x+24 = 0
4. f(x) = f(x) = x4 12x^3+47x^2-60x+24.1 = 0
5. f(x) = sin(x) – cos(2x) = 0
6. f(x) = x5 7x^2+11x-5 = 0
7. f(x) = sin(x) – cos(x) = 0
Using MATLAB in at least 10 iterations each of the following methods:
1. Newton’s Method
2. Secant Method
3. Finite Difference Method
4. Line Search Method
Thank you.
Explanation / Answer
I have given the codes for the two(Newton and secant) of the methods listed. For comparison, you have to show the fastness of convergence of these methods and show advantages and disadvantages of these methods which I have already attached. You can also find some more advantages and disadvantages in standard books and web. I hope it helps and good luck for your presentation.
a. Newton's Method
The user is supposed to input the function (f), the derivate (df) an initial guess (x0) the tolerance (tol) and the number of iterations(N).
Convergence of Newton’s Method
Newton’s method converges quadratically. When carrying out this method the system converges quite rapidly once the approximation is close to the actual solution of the nonlinear system. This is seen as an advantage because Newton’s method may require less iterations, compared to another method with a lower rate of convergence, to reach the solution. However, when the system does not converge, this is an indicator that an error in the computations has occured, or a solution may not exist.
Advantages and Disadvantages of Newton’s Method
One of the advantages of Newton’s method is that its not too complicated in form and it can be used to solve a variety of problems. The major disadvantage associated with Newton’s method, is that Jacobian J(x), as well as its inversion has, to be calculated for each iteration. Calculating both the Jacobian matrix and its inverse can be quite time consuming depending on the size of your system is. Another problem that we may be challenged with when using Newton’s method is that it may fail to converge. If Newton’s method fails to converge this will result in an oscillation between points.
b. Secant Method
% Find the roots of using Secant Method
% func --> function is taken by user
% like sin(x) or x^2 + x - 1 or any other but use the same format
% i.e. use paranthesis as used above with 'x' for sin, cos,... etc
% and spacing between '+' or '-' operation
% a --> Xn-1
% b --> Xn
% c --> Xn+1
% maxerr --> Maximum Error in Root
syms x;
func = x^2 -2;
a = input('Ener Lower Limit: ');
b = input('Ener Upper Limit: ');
maxerr = input('Enter Maximum Error: ');
f = inline(func);
c = (a*f(b) - b*f(a))/(f(b) - f(a));
disp(' Xn-1 f(Xn-1) Xn f(Xn) Xn+1 f(Xn+1)'); disp([a f(a) b f(b) c f(c)]);
while abs(f(c)) > maxerr
end
display(['Root is x =' num2str(c)]);
The Secant Method only requires one function input, f(x), but two initial guesses. It uses these to approximate the derivative then move to the x axis and repeat the process.
The Newton-Raphson Method requires two functions to be input, f(x) and f'(x), and one initial guess.
Both these methods are following the tangent line of the function to the x-axis then reiterating to bound the root.
I think the Secant Method is interesting because it converges faster or slower depending on how far away your initial guesses are.
c. Finite Difference Method
I think finite difference method is not used to find roots. Rather it is used for finding the values of f(x) in ODEs and PDEs. It is used for calculating the derivatives of functions. It is not a root finding method.
d. Line search Method
This line search method is also used for finding minima or maxima. It is generally used for optimization.