×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Root finding for multiple roots using bisection method

Root finding for multiple roots using bisection method

Root finding for multiple roots using bisection method

(OP)

I need help with the following root finding problem using the Bisection method

I want to find all roots between 0 and 3.5 for the following function:

y=sin(x^2)/e^(0.1*x)  0<x<3.5

I want a script to call the function three times to find these roots.

We know the 3 roots are between 1.5 and 2.0, 2.3 and 2.6, 2.9 and 3.2 so I want to use these for my right and left limits of x and be passed from the function to the bisection script.

I am having troubles with the function code and passing the left and right limits to the script. Here is what I have for script:


F_low=sin(x_low^2)/exp(x_low*0.1);
F_high=sin(x_high^2)/exp(x_high*0.1);
tolerance=0.01
F_x=100;

while abs(F_x) > tolerance
    root=(x_low+x_high)/2;
      F_x=sin(root^2)/exp(root*0.1);
    
    if F_x*F_high > 0  % remove the right half of the interval because
        x_high=root;   % F_x and F_high have the same sign.
        F_high=F_x;
    else               % remove the left half of the interval because
        x_low=root;    % F_x and F_low have the same sign.
        F_low=F_x;
    end
    disp([x_low x_high F_x])
   
end


Here is what I have for the function:

function X=mybysection(x_low,x_high)


for i=1:3;
      if i==1
           x_low(i)=1.5
           x_high(i)=2.0
       elseif i==2
           x_low(i)=2.3
           x_high(i)=2.6
       else
           x_low(i)=2.9
           x_high(i)=3.2
       end
   end


I'm unsure about the syntax to call these right and left limits into the script from the function

RE: Root finding for multiple roots using bisection method

Why do you have to determine how you want the job done?  Wouldn't you describe the problem and the application and those in the industry can provide you with their wisdom.

RE: Root finding for multiple roots using bisection method

Matlab has various tools for root finding there is no need to write your own. Have a look at the help information for "fzero" (finds a root near the given starting value) and "fminbnd" (minimises a function between given bounds - you can use it to find roots by minimising the square of your function)

M

--
Dr Michael F Platten

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources