You are on page 1of 2

# Lab 3-B: Root Finding Using Mathematica

Objective: to find the values of x that make f(x) = 0 using Mathematica package
Procedure: Use the following built-in functions
1- "Solve" built-in function: to get all symbolic roots for nth order polynomials
(n < 4). The format is
Solve [f(x) = = 0]

## (Important: Note that "S" is capital and use = =)

2- "NSolve" built-in function: to get all numerical roots for nth order
polynomials (all n ). The format is
NSolve [f(x) = = 0]
3- FindRoot built-in function: to get numerical roots for all types of functions
(polynomials, transcendental, exponential, etc.). You can get one root at a
time. The format is;
FindRoot[f(x) = = 0,{x,x0}] where x0 is the initial guess.
The procedure for each built-in function is illustrated using the following examples.
Example
Find all roots for f ( x ) x 2 x 1 .

a) Using Solve built-in function: If you type the following and enter (Shift +
Return) or Enter

Solve x ^ 2 Sqrt x 1 0
Mathematica gives the following output:

Input:
Output:

## c) Using FindRoot built-in function:

Input:
Output:
More examples and exercises are given inn the mathematica file for Lab 3-B
Exercises: Solve the problems for application 1 (open channel flow) and application 2
(beam deflection) using Mathematica.