This preview shows pages 1–2. Sign up to view the full content.
UNIVERSITY OF CALIFORNIA, BERKELEY
Engineering 7 – Spring 2009
Department of Civil and Environmental Engineering
Instructor: Professor Rector
1
Lab 11 [20 pts total]
Topics
:
Root finding, Function Handles
Assigned
:
Monday, 04/20/2009
Due
:
Monday, 04/27/2009
Type
:
Takehome
Notes on Root Finding
Recall that a root of an equation is a value that, when substituted for the independent variable (usually called
x
),
results in a value of zero for the dependent variable (usually called
y
). MATLAB has two library functions (
fzero
and
roots
) that can be used to solve for the roots of an equation. In this assignment you are asked to plot functions,
use a builtin MATLAB root finding function, and write separate functions for two iterative methods for root
finding.
Some root finding algorithms require an initial guess (i.e. NewtonRaphson method), while others require the user to
‘bound’ the root with a lower bound and an upper bound (i.e. bisection method). It is generally recommended to plot
a function prior to performing any root finding exercises. Plotting the function provides a reasonable initial guess for
the rootfinding algorithm (and/or appropriate upper and lower bounds). Plotting the function also provides
information on the number of roots contained within any given range.
1. MatLab Builtin Functions (3 pts total)
In this part, you will use the MATLAB builtin functions
fplot
to plot functions and
fzero
to solve equations.
Use the
help
command to find out how these commands work.
(a)
Plot the following function using MATLAB’s
fplot
function (or by using MATLAB’s general
plot
function). Include this plot and the MATLAB code calling the plot function in your report.
f(x) = 2*sin(2*x^3)+1.25*x0.5
(b)
Using MATLAB’s
fzero
, solve the following equation (i.e. find all the roots):
f(x) = 2*sin(2*x^3)+1.25*x0.5 = 0
Include all the MATLAB code used for this question, and the output in your report.
IMPORTANT NOTE: The actual numerical results in the examples provided in Question 2 and 3 may or
may not be correct. These examples are here only to give an idea of the type and format of the output.
2. Bisection Method of Root Finding (5 pts total)
The bisection method is an iterative algorithm for finding the roots of an equation. In this method, the user supplies
two values (
x1
and
x2
) that bracket the root.
Write a MATLAB function that finds the root(s) of an equation using the bisection method. This function should
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 Spring '08
 Patzek
 Environmental Engineering

Click to edit the document details