Results 1 to 3 of 3

Math Help - MATLAB HOMEWORK on bisectiion method. very urgent please help needed.

  1. #1
    Newbie
    Joined
    Sep 2008
    Posts
    10

    MATLAB HOMEWORK on bisectiion method. very urgent please help needed.

    HI i need help with how to find roots of a function using bisection method in matlab?

    can anyone help me?
    the question is:

    1.write a matlab function Bisection.m which takes as input a function f(x) and a bracketing interval[a b] and outputs the root of the function f(x). Hint: you will find the matlab function feval.m useful here.

    2. Use Bisection.m created in question 1 to find the smallest positive root of the equation:
    x^3-3.23*x^2-5.54*x+9.84=0.

    verify your result by
    1. Plotting the function in Matlab.
    2.by using the inbuilt matlab fzero function
    Submit in addition to your code ,plot of the error. How many iterations are required forthe error to be in order of 10^-3.

    It would be greatful to anyone who can provide me with a solution to this problem.i have tried doing this problem in matlab many times,but somewhere i m going wrong. it would be great if anyone can post the Matlab code to the solution of this problem along with the code for the graphs.
    Its very urgent.
    Thanks in advance.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Prove It's Avatar
    Joined
    Aug 2008
    Posts
    11,520
    Thanks
    1404
    Quote Originally Posted by mithilesh View Post
    HI i need help with how to find roots of a function using bisection method in matlab?

    can anyone help me?
    the question is:

    1.write a matlab function Bisection.m which takes as input a function f(x) and a bracketing interval[a b] and outputs the root of the function f(x). Hint: you will find the matlab function feval.m useful here.

    2. Use Bisection.m created in question 1 to find the smallest positive root of the equation:
    x^3-3.23*x^2-5.54*x+9.84=0.

    verify your result by
    1. Plotting the function in Matlab.
    2.by using the inbuilt matlab fzero function
    Submit in addition to your code ,plot of the error. How many iterations are required forthe error to be in order of 10^-3.

    It would be greatful to anyone who can provide me with a solution to this problem.i have tried doing this problem in matlab many times,but somewhere i m going wrong. it would be great if anyone can post the Matlab code to the solution of this problem along with the code for the graphs.
    Its very urgent.
    Thanks in advance.
    It's better if you show us your attempts, so that we can find where you're going wrong. We're not doing your work for you.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Sep 2008
    Posts
    10
    ok,sorry i didnt have any code tht time.
    but now i do,
    the problem is i m gettting the right answer i think,but i dont know how to plot the root estimates or something is wrong

    Here is what i have till now:


    function zero = bisection(f,a,b,tol)
    n=0

    fa = feval(f,a);
    fb = feval(f,b);
    while 1
    if ( abs(b-a) <= tol )
    zero = (a+b)/2;
    n=n+1
    return
    end
    c = (a + b)/2;
    fc = feval(f,c);
    if ( fa*fc > 0)
    a = c;
    fa = fc;
    else
    b = c;
    fb = fc;
    end
    end
    disp(n)
    root
    err=abs(b-a)

    here is what i get when i run the script file:

    >> function f =rt(x)
    f=x^3-3.23*x^2-5.54*x+9.84
    bisection('rt',0,2,(10^-3))
    n =
    1
    ans =
    1.2300

    I am not sure whether the number of iterations required n in this case is right. and also i donot know how to plot the error. so i need help with that.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Issue With MATLAB Homework Problem
    Posted in the Math Software Forum
    Replies: 2
    Last Post: March 2nd 2009, 02:48 AM
  2. Homework help needed
    Posted in the Algebra Forum
    Replies: 1
    Last Post: September 14th 2008, 08:31 PM
  3. homework help needed with differentiation
    Posted in the Calculus Forum
    Replies: 2
    Last Post: September 17th 2007, 06:49 PM
  4. Urgent Algebra homework help needed
    Posted in the Algebra Forum
    Replies: 5
    Last Post: May 2nd 2007, 08:43 AM

Search Tags


/mathhelpforum @mathhelpforum