Question

Problem 3: (a) Fine the root for the equation given below using the Bisection and Newton-Raphson Numerical Methods (Assume in
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Matlab code for Bisection method:

eqn= @(x) (x^6)+(5*x^5)+(x^4*exp(3*x))-cos (2*x+0.3465)-20;

answer = p(eqn,0,1)

function p = bisection(f,a,b)
% f - function

% a- guess 1

% b- guess 2
if f(a)*f(b)>0
disp('change guess')
else
p = (a + b)/2;
err = abs(f(p));
while err > 1e-7
if f(a)*f(p)<0
b = p;
else
a = p;
end
p = (a + b)/2;
err = abs(f(p));
end
end

Matlab code for Newton-Raphson method:

syms x;
f=(x^6)+(5*x^5)+(x^4*exp(3*x))-cos (2*x+0.3465)-20; %Enter the Function here
g=diff(f); %The Derivative of the Function
epsilon = 0.0001;
x0 = input('Enter the intial approximation:');
for i=1:100
f0=vpa(subs(f,x,x0)); %Calculating the value of function at x0
f0_der=vpa(subs(g,x,x0)); %Calculating the value of function derivative at x0
y=x0-f0/f0_der; % The Formula
err=abs(y-x0);
if err<epsilon %checking the amount of error at each iteration
break
end
x0=y;
end
y = y - rem(y,10^-n); %Displaying upto required decimal places
fprintf('The Root is : %f \n',y);
fprintf('No. of Iterations : %d\n',i);

Add a comment
Know the answer?
Add Answer to:
Problem 3: (a) Fine the root for the equation given below using the Bisection and Newton-Raphson ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 6.5 Employ the Newton-Raphson method to determine a real root for 4x20.5 using initial guesses of...

    6.5 Employ the Newton-Raphson method to determine a real root for 4x20.5 using initial guesses of (a) 4.52 f(x) 15.5x Pick the best numerical technique, justify your choice and then use that technique to determine the root. Note that it is known that for positive initial guesses, all techniques except fixed-point iteration will eventually converge. Perform iterations until the approximate relative error falls below 2 %. If you use a bracket- ing method, use initial guesses of x 0 and...

  • (la) Determine the root of the x – ez* + 5 = 0 using the Newton-Raphson...

    (la) Determine the root of the x – ez* + 5 = 0 using the Newton-Raphson method with equation initial guess of xo = 1. Perform the computation until the percentage error is less than 0.03%. (1b) Employ bisection method to determine the root of the f(x)=x* – 3x + 7 =0) using equation two initial guesses of x; =-2.1 and x;, =-1.8 . Perform three iterations and calculate the approximate relative error for the third iteration. What is the...

  • use C programing to solve the following exercise. Compute a root of the equation 4. (20 points) e-3 cos(x)-o using (a) Bisection Method between 0 and I. (b) Newton Method using an initial guess of...

    use C programing to solve the following exercise. Compute a root of the equation 4. (20 points) e-3 cos(x)-o using (a) Bisection Method between 0 and I. (b) Newton Method using an initial guess of I. Use e0.00001 Show that Newton Method has a faster convergence than Bisection Method Compute a root of the equation 4. (20 points) e-3 cos(x)-o using (a) Bisection Method between 0 and I. (b) Newton Method using an initial guess of I. Use e0.00001 Show...

  • 45-3. Modify the code used in Example 4 to find the root only at f(x)<0.01 using...

    45-3. Modify the code used in Example 4 to find the root only at f(x)<0.01 using Newton-Rephson Method without showing any iteration. Also find the root of equation, f(x) = x 9-3x -10, take initial guess, Xo=2 العقدة College of 9:05 mybb.qu.edu.ca Numerical Methods (Lab.) GENG 300 Summer 2020 5.1.2 Open Methods - Newton-Raphson Method f(x) *1+1 = x; - Matlab Code Example:4 function mynewtraph.t1.x0,-) XXO for ilin x - x - x)/1 x) disp 1 x) <0.01 break end...

  • clearvars close all clc tol = 0.0001; % this is the tolerance for root identification xold...

    clearvars close all clc tol = 0.0001; % this is the tolerance for root identification xold = 0.5; % this is the initial guess test = 1; % this simply ensures we have a test value to enter the loop below. %If we don't preallocate this, MATLAB will error when it trys to start the %while loop below k = 1; %this is the iteration counter. Similar to "test" we need to preallocate it %to allow the while loop to...

  • Matlab problem using newton raphson to find square root of number

    Need help modifying my Matlab script below (myscript calculates the square root of a number. using a Newton-Raphson method with 1 as the initial guess, calculates true and estimated error, and shows each iteration).-I need to create three new functions each of which should be called in the main script. These functions are needed to replace code that is currently in my script shown below.-I need to create these functions:A function to find f(x)A function to find f '(x) ?A...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT