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

• Oct 29th 2009, 11:54 PM
mustaqim
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
• Oct 30th 2009, 04:45 AM
CaptainBlack
Quote:

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
• Oct 30th 2009, 05:56 AM
elbarto
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
• Oct 30th 2009, 08:54 AM
mustaqim
how about to solve this problem using newton rhapson method
any idea on how to do it
• Oct 30th 2009, 12:29 PM
CaptainBlack
Quote:

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