0% found this document useful (0 votes)
121 views

Lab 3-B: Root Finding Using Mathematica

This document provides instructions for using built-in Mathematica functions to find the roots of functions: Solve to find all symbolic roots of polynomials up to order 4, NSolve to find all numerical roots of polynomials of any order, and FindRoot to find single numerical roots of any function by providing an initial guess. It gives examples of using these functions to find the roots of f(x)=x^2-x-1 and indicates that more examples and exercises are in the Mathematica file for this lab.

Uploaded by

nidhalsaada
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views

Lab 3-B: Root Finding Using Mathematica

This document provides instructions for using built-in Mathematica functions to find the roots of functions: Solve to find all symbolic roots of polynomials up to order 4, NSolve to find all numerical roots of polynomials of any order, and FindRoot to find single numerical roots of any function by providing an initial guess. It gives examples of using these functions to find the roots of f(x)=x^2-x-1 and indicates that more examples and exercises are in the Mathematica file for this lab.

Uploaded by

nidhalsaada
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 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:

b) Using NSolve built-in function:


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.

You might also like