I have to write a program which will calculate using false position method the maximum of a given equation. And at the end I need to return the root and a value of the function at that point. I am not getting the answer can anyone help? )

14 views (last 30 days)
%The root should be equal to 225, at least thats what i got when i did same question using bisection method
function [ xr ] = false_position( f,g, xl, xu )
w=1.75;
E=5*10.^5;
I=3*10.^5;
L=450;
g=@(x)(w/(120*E*I*L))*(-x.^5+2*L.^2*x.^3-L.^4*x);%orignal
f=@(x)(w/(120*E*I*L))*(-5*x.^4+6*L.^2*x.^2-L.^4);%derivative
xl=0;
xu=L;
if f(xl)*f(xu)>0
disp('error wrong end points')
else
xr=(xl*f(xu)-xu*f(xl))/(f(xu)-f(xl));
error=abs(f(xr));
while error>1e-4;
if f(xr)>0
xu=xr;
else
xl=xr;
end
xr=(xl*f(xu)-xu*f(xl))/(f(xu)-f(xl));
error=abs(f(xr));
end
fprintf('The point of maximum deflection is: %f\n', xr);
fprintf('The value of maximum deflection is: %f\n',g(xr));
end*

Answers (1)

Daniel Stankowski
Daniel Stankowski on 1 Apr 2018
could anyone help out?

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!