Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop a computer program to find the root of the following function: P = ( - m + 4 ) e - 0 . 5

Develop a computer program to find the root of the following function:
P =(-m+4)e-0.5m -2
using the following three methods:
(a) Bisection (initial guesses of ml =0.5 and mu =1.5).
(b) Newton-Raphson (initial guess of m0=1.5).
(c) Secant (initial guesses of m-1=0.2 and m0=0.7).
Perform iterations until the approximate percent relative error falls below 0.005%. For this problem, it is Mandatory to use MatLab. However, you are not allowed to use any built-in functions in MatLab that are not available in the other compilers. >>% Function definition
P = @(m)(m +4)* exp(-0.5* m)-2;
% Bisection method
ml =0.5;
mu =1.5;
max_iterations =1000;
tolerance =0.00005; %0.005% as a decimal
for i =1:max_iterations
fm = P(ml);
fu = P(mu);
m =(ml + mu)/2;
fp = P(m);
% Check for convergence
if abs(fp)< tolerance
break;
end
% Update interval
if fm * fp <0
mu = m;
else
ml = m;
end
end
fprintf('Bisection Method: Root =%.6f, Iterations =%d
', m, i);
% Newton-Raphson method
m0=1.5;
for i =1:max_iterations
f0= P(m0);
f0_prime =(P(m0+0.0001)- P(m0))/0.0001; % Numerical derivative
m1= m0- f0/ f0_prime;
% Check for convergence
if abs((m1- m0)/ m1)< tolerance
break;
end
m0= m1;
end
fprintf('Newton-Raphson Method: Root =%.6f, Iterations =%d
', m1, i);
% Secant method
m_minus1=0.2;
m0_secant =0.7;
for i =1:max_iterations
f_minus1= P(m_minus1);
f0_secant = P(m0_secant);
m1_secant = m0_secant - f0_secant *(m0_secant - m_minus1)/(f0_secant - f_minus1);
% Check for convergence
if abs((m1_secant - m0_secant)/ m1_secant)< tolerance
break;
end
m_minus1= m0_secant;
m0_secant = m1_secant;
end ANS: fprintf('Secant Method: Root =%.6f, Iterations =%d
', m1_secant, i);
Bisection Method: Root =1.500000, Iterations =1000
Newton-Raphson Method: Root =2.292386, Iterations =4
Secant Method: Root =2.292386, Iterations =5. as last expert gave me the code and when i performed it is showing that 1000 iterations in bisection and soon for other methods. but his sample results is just showing 18 iterations. so can i get a proper solution that how many iterations will be required and allong with the answers of all the iterations.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

9. Describe the characteristics of power.

Answered: 1 week ago