Question

In: Advanced Math

Using the bisection method:     Make a program to use this method using the following three...

Using the bisection method:
    Make a program to use this method using the following three functions and use it to find the root of this function f (x) = x * x * x-8.
a) A function so that the user between xlower and xupper that meets the value of the function has a different sign and if he does not ask for new values.
b) A function to find the root and call it bisection and perform a maximum of iterations (maximum approximations of the root). All estimated root values have to be printed.
c) A function to obtain the values of the function.

Solutions

Expert Solution


%%Matlab code for finding root using newton secant bisection and false
clear all
close all

%function for which root have to find
fun=@(x) x.*x.*x-8;

xx=linspace(-2,3);
yy=fun(xx);

plot(xx,yy)
xlabel('x')
ylabel('f(x)=x^3-8')
title('x vs. f(x) plot')

[root]=bisection_method(fun,-2,3,1000);
fprintf('\tRoot using Bisection method is %f.\n',root)
hold on
plot(root,fun(root),'r*')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Matlab function for Bisection Method
function [root]=bisection_method(fun,x0,x1,maxit)
if fun(x0)<=0
    t=x0;
    x0=x1;
    x1=t;
end
fprintf('\nRoot using Bisection method\n')
%f(x1) should be positive
%f(x0) should be negative
k=10; count=0;
while k>5*10^-10
    count=count+1;
    xx(count)=(x0+x1)/2;
    mm=double(fun(xx(count)));
    if mm>=0
        x0=xx(count);
    else
        x1=xx(count);
    end
    err(count)=abs(fun(x1));
    k=abs(fun(x1));
    if count>=maxit
        break
      
    end
    %
end
fprintf('\tAfter %d iteration root using Bisection method is %f\n',count,xx(count))
root=xx(end);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Related Solutions

7. Finding Roots Using the Bisection Method Write a function that implements the "bisection method" for...
7. Finding Roots Using the Bisection Method Write a function that implements the "bisection method" for finding the roots of function. The signature of your function should look like def find_root(f,a,b,n): where n is the maximum number of iterations of to search for the root. The code should follow this algorithm: We are given a continuous function f and numbers a and b and with a<b with f(a)<0<f(b). From the intermediate value theorem we know that there exists a c...
Using Google sheets: On a spreadsheet show how to use the bisection method to solve the...
Using Google sheets: On a spreadsheet show how to use the bisection method to solve the equation cosā”(x)=x numerically to at least four decimal place accuracy
excel problem Find the roots of the functions given using the bisection method. Use the graph...
excel problem Find the roots of the functions given using the bisection method. Use the graph of each function to choose points that bracket the root of interest. a. f(x) x-x^1/3-2 b.f(x)=xtanx-1 c.f(x)=x^4-e^x+1 d.f(x)x^2e^x-1
Use matlab code for bisection method and regula falsi. Thank you!
Use matlab code for bisection method and regula falsi. Thank you!
USING BISECTION METHOD, FIND THE ROOT OF 0.5e^x - 5x + 2 = 0 ON THE...
USING BISECTION METHOD, FIND THE ROOT OF 0.5e^x - 5x + 2 = 0 ON THE INTERVAL [ 0 , 1 ] UP TO 3 DECIMAL PLACES. USE NEWTON'S METHOD TO APPROXIMATE THE ROOT OF f(x)=x^2-5    IN THE INTERVAL  [ 2 , 3 ] UP TO 4 DECIMAL PLACES.
a) you can see a program for using bisection search to find the square root of...
a) you can see a program for using bisection search to find the square root of x: x = 25 epsilon = 0.01 low = 0.0 high = max(1.0, x) guess = (low + high) / 2 numberofguesses = 1 while abs(guess ** 2 - x) > epsilon : print('low =', low, 'high = ', high, 'guess = ', guess) if guess** 2 > x : # the guess is too high, so move high down to guess high =...
Write a program using multiple functions. Make use of an array to store data Make use...
Write a program using multiple functions. Make use of an array to store data Make use of searching techniques Read data from a file Write data to a file Instructions: In this lab, you will be examining a set of stock collected over a twenty four day period. Be sure to make use of an array to store these stocks. You will be required to read in the data points from a file. Write a function to read in the...
Make a program for LAGRANGE INTERPOLATION METHOD using C++ program and can be evaluated both polynomial...
Make a program for LAGRANGE INTERPOLATION METHOD using C++ program and can be evaluated both polynomial and Transcendental Functions.
I am asked to find the square roots using the bisection method for x * x...
I am asked to find the square roots using the bisection method for x * x - a = 0. I was wondering how the bisection method is performed. Let's suppose a = 9, so I would need to find the roots of x * x - 9 = 0. Also, from the 1st equation, when would the bisection method NOT output a root?
Use the bisection method to approximate the root of f(x)=x-cosx in the range [0.0,1.5]. Stop when...
Use the bisection method to approximate the root of f(x)=x-cosx in the range [0.0,1.5]. Stop when the error is less than 0.002%
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT