Create a program that uses the False-Position method to estimate the zero of the
ID: 2087377 • Letter: C
Question
Create a program that uses the False-Position method to estimate the zero of the function f(x)= -0.1x^4 - 0.15x^3 -0.5x^2 -0.25x +12. You must solve the zero until the absolute value of the error is less than one-tenth of a percent, or E<0.01%.
The input to this funciton will be the initial guesses (xu and xl) and also the error criteria(E), and the outputs will be x, the error, and the number of iterations required. Name function: function [x,error,iterations] = Name (xu,xl,E)
Please include your psuedocode as comments within your program, The program itslef should also be well commened. You may use if, for, and while statements as well as basic math functions (+-*/) and the size command.
Thank you for your help
Explanation / Answer
function [x,error,iteration] = false_position(f,xu,xl,E)
a = xu;
b = xl;
iteration = 0;
error = 1;
if (f(a)*f(b)<0)
while (error>E)
c = a-f(a)*((a-b)/(f(a)-f(b)));
error = abs(f(c))/100;
a=b;
b=c;
root = c;
iteration=iteration+1;
end
else
fprintf('root is not bound');
end
x = root;
end
clear
f = @(x) -0.1*x.^4 - 0.15*x.^3 -0.5*x.^2 -0.25*x +12;
[X,error,iteration] = false_position(f,0,10,0.01)
X =
2.6380
error =
0.0026
iteration =
55
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.