The following Code has been developed to compute given funct

The following Code has been developed to compute given function y(x) using Bisection method to estimate the third root, until ea is smaller than 0.5%. Modify the given code to compute the given y(x) by using the False-position method y = x^4 - 12x^3 + 49x^2 - 78x + 40 The code: function: function m = bisection(f, interval_low, interval_high, toler) y1 = feval(f, interval_low); y2 = feval(f, interval_high); i = 0; if y1 * y2 > 0 m = \'Error\' return end disp(\'Iter low high x0\'); while (abs(interval_high - interval_low) >= toler) i = i + 1; m = (interval_high + interval_low)/2; y3 = feval(f, m); if y3 = 0 fprintf(\'Root at x = %f \ \ \', m);| return end fprintf(\'%2i \\t %f \\t %f \ \', i-1, interval_low, interval_high, m); if y1 * y3 > 0 interval_low = m; y1 = y3; else interval_high = m; end end w = feval (f, m); fprintf(\'\ x = %f produces f(x) = %f \ %i iterations\ \', m, y3, i-1); fprintf(\'Approximation value with tolerance = %f \ \', toler); Main function: my_fun = @(x) x^4-12*x^3+49*x^v2-78*x+40; interval_low = -1; interval_high = 1; tolerance = .5; x = bisection(my_fun, interval_lowr interval_high, tolerance); Program code: X=3;| A = X/3; E= 1.0e-6; Delta = A^3 - X; while(abs(Delta) > E) A = (1/3) * (2*A + (X/A/^2)); Delta = A^3 - X; fprintf(\'Cube root: %f Actual value: %f Estimated cube: %f \ \', A, X, A^3); end

Solution

I wrote the Matlab code for the False-position method:-

Use this code to find the roots of the given equation.

display(\'Equation is x^4-12x^3+49x^2-78x+40=0\')
i=1;
while(i)
xl=input(\'Enter lower value:\');
xu=input(\'Enter upper value: \');
e=input(\'Enter accuracy: \');
if equan(xl)*equan(xu)<0
i=0;
else

warning(\'Enter proper range\');
end
end
if equan(xl)<0
xn=xl;
xp=xu;
else
xn=xu;
xp=xl;
end

xm=xl;
while (abs(equan(xm))>e)
xm=(xn*equan(xp)-xp*equan(xn))/(equan(xp)-equan(xn));
if equan(xm)<0
xn=xm;
else
xp=xm;
end
end

This the required Matlab code for the False-position method tto find the root of the given equation.

 The following Code has been developed to compute given function y(x) using Bisection method to estimate the third root, until ea is smaller than 0.5%. Modify t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site