You are on page 1of 3

Locating root of single nonlinear equation by using Matlab

Numerical and Computing Methods

Locating root of single nonlinear equation by using Matlab

Solution of nonlinear algebraic equations with Matlab FZERO scalar nonlinear zero finding

Matlab function for solving a single nonlinear algebraic equation Finds the root of a continuous function of one variable Syntax: x = fzero(fun,xo)

fun is the name of the user provided Matlab m-file function (fun.m) that evaluates & returns the LHS of f(x) = 0. xo is an initial guess for the solution of f(x) = 0.

Algorithm uses a combination of bisection, secant, and inverse quadratic interpolation methods.

Matlab Tutorial cont.

Solution of a single nonlinear algebraic equation:

f ( x)

1 1 6 0 2 2 ( x 3) 0.01 ( x 0.9) 0.04

Write Matlab m-file function, fun.m:

Call fzero from the Matlab command line to find the solution:
>> xo = 0; >> fzero('fun',xo) ans = 0.5376

Different initial guesses, xo, can give different solutions:


>> fzero('fun',1) ans = 1.2694 >> fzero('fun',4) ans = 3.4015

You might also like