With Matlab Problem 1: Write a MATLAB program that implements all the nonlinear
ID: 3729095 • Letter: W
Question
With Matlab
Problem 1: Write a MATLAB program that implements all the nonlinear equations root finding algorithms we discussed in class. The program should display a menu with a list of methods names in addition to an exit option. Once an option is selected, a function of the specified algorithm should be invoked. Each algorithm should ask for its necessary inputs. Remember that Muller, Bairstow and roots only works with polynomials. siler, pairstow and roots only w 1. Bisection 2. False Position 3. Fixed-Point iteration 4. Newton 5. Secant 6. Modified Secant 7. MATLAB fzero 8. Muller 9. Bairstow 10. MATLAB roots 11. ExitExplanation / Answer
Solution:
The bisection method in MATLAB is given below, please repost them as separate and segregate them, Thanks.
function [ r ] = bisection( func, x, y, N, eps_step, eps_abs )
if ( func(x) == 0 )
r = x;
return;
elseif ( func(y) == 0 )
r = y;
return;
elseif ( func(x) * func(y) > 0 )
error( 'func(x) and func(y) need to have an opposite sign' );
end
%Iterating N times
for k = 1:N
% Finding the mid-point
mid = (x + y)/2;
%check if the root is found byt he function
if ( func(mid) == 0 )
r = mid;
return;
elseif ( func(c)*func(x) < 0 )
y = mid;
else
x = mid;
end
if ( b - x < eps_step )
if ( abs( func(x) ) < abs( func(y) ) && abs( func(x) ) < eps_abs )
r = x;
return;
elseif ( abs( func(y) ) < eps_abs )
r = y;
return;
end
end
end
error( 'the method is not converging' );
end
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.