# Thread: how to write matlab function for solving equation using bisection method

1. ## how to write matlab function for solving equation using bisection method

my group was given this equation to be solved using matlab software,but i dont know how to write down the function

f(x) = [(4+x)/ (42-2x) 2(30-x)] – 0.015
Lower limit = 0
Upper limit = 20
Єs = 0.5 %

The zero lies approximately at 16 using graphical method
Now I need to solve this using bisection method using matlab software

2. Originally Posted by mustaqim
my group was given this equation to be solved using matlab software,but i dont know how to write down the function

f(x) = [(4+x)/ (42-2x) 2(30-x)] – 0.015
Lower limit = 0
Upper limit = 20
Єs = 0.5 %

The zero lies approximately at 16 using graphical method
Now I need to solve this using bisection method using matlab software
Try searching for "matlab bisection" you will find a number of hits among which are:

http://www.mathhelpforum.com/math-he...on-method.html

http://www.mathhelpforum.com/math-he...on-method.html

CB

3. Matlab has some built_in functions that you may use to check your results too.

Code:
EDU>> help fsolve
This is a very handy routine for root finding. Since you mentioned the bracketing method specifically, the first link CB gave you should be all you need to solve your problem as there is no "fancy" code in that routine so only a basic understanding of Matlab is required.

Regards Elbarto

4. how about to solve this problem using newton rhapson method
any idea on how to do it

5. Originally Posted by mustaqim
how about to solve this problem using newton rhapson method
any idea on how to do it
A search of MHF using the search string "matlab newton" turns up lots of hits including:

http://www.mathhelpforum.com/math-he...on-method.html

http://www.mathhelpforum.com/math-he...od-matlab.html

CB