0% found this document useful (0 votes)
53 views4 pages

ME 2016 Spring 24 Homework 3

This document describes Homework 3, which involves implementing the Bisection and False Position root-finding methods to solve a problem involving determining the depth of water in a tank given a target volume. Students are asked to: 1) Write code to apply the two methods and plot the solutions and convergence rates. 2) Consider a tank with parameters H=6m, R1=1.5m, R2=3m and solve for a target volume of 40m3. 3) Discuss the relative convergence rates of the two methods in a report, commenting on which converges faster and why. Extra credit is offered for implementing a Modified False Position method.

Uploaded by

Pedro T
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views4 pages

ME 2016 Spring 24 Homework 3

This document describes Homework 3, which involves implementing the Bisection and False Position root-finding methods to solve a problem involving determining the depth of water in a tank given a target volume. Students are asked to: 1) Write code to apply the two methods and plot the solutions and convergence rates. 2) Consider a tank with parameters H=6m, R1=1.5m, R2=3m and solve for a target volume of 40m3. 3) Discuss the relative convergence rates of the two methods in a report, commenting on which converges faster and why. Extra credit is offered for implementing a Modified False Position method.

Uploaded by

Pedro T
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ME 2016 - Computing Techniques (Spring 2024)

Homework 3

Due: February 7, 2024

Professionalism (20 pts) Points

Report includes problem description and discussion in complete sentences 2


Report includes header/footer (name, date, course #, assignment #, page #) 2
Code includes header (name, date, description, input/output variable definitions) 2
Code runs without error 4
Command window output is easily legible 4
Extraneous command window output is suppressed 2
Plots are well-formatted (axis labels, legend, units, appropriate line/marker styles) 4
TOTAL 20

Tank problem (80 pts) Points

Correct f (h) reported 5


Bisection and False-Position implemented in separate function files 5
Bisection and False-Position are general (not specific to tank problem) 10
Uses function handle to store, pass, and evaluate f (h) 5
Correct solution via Bisection method 20
Correct solution via False-Position method 20
Includes plots requested in (b) and (c) 5
Discussion is complete and makes sense 10
TOTAL 80

Extra credit (5 pts) 5

Total Points: _______ /100


ME 2016 - Computing Techniques (Spring 2024)

Homework 3

Due: February 7, 2024

Learning Objectives
• To implement Bisection and False-Position (bracketing) methods of root-finding and compare their convergence
rates for a problem of interest.

Problem description

Figure 1: Schematic of circular cone frustum tank holding water.

The volume of water, V , in the circular cone frustum tank in Figure 1 can be computed as

𝜋𝜋ℎ
𝑉𝑉(ℎ, 𝑟𝑟) = (𝑅𝑅12 + 𝑅𝑅1 𝑟𝑟 + 𝑟𝑟 2 ) (1)
3
where the largest water radius, r, can be expressed as a function of the water height, h, as

𝑅𝑅2 −𝑅𝑅1
𝑟𝑟(ℎ) = 𝑅𝑅1 + ℎ( ) (2)
𝐻𝐻

In (1) and (2), 𝑅𝑅1 and 𝑅𝑅2 are the bottom and top tank radii, respectively; and H is the height of the tank. Write a
Matlab code that:
(a) Uses the Bisection and False-Position methods to determine the depth of water, h = h∗, so that the tank holds
a target volume, V = Vt, of water. Hint: You will need to define a function, f (h), that you wish to make zero.
(b) Plots the solution, (h∗, V (h∗)), found using each root-finding method (on one plot) on top of a curve of volume
as a function of h, to verify that the correct root was found in all cases. Hint: Your solutions should be two points that
intersect the curve at the value of Vt. To draw the curve, you will need to define a function, V (h), that differs from (1) in
that it is a function of only h and not r.
(c) Plots the absolute approximate percent relative error, |εa|, over the iterations for each root-finding method
(on a single plot with the error axis in log scale), to compare their relative convergence rates. Hint: Use semilogy.
ME 2016 Homework 3 Due: February 7, 2024

Your implementation
• Your code should be written in a script file, Script_DepthOfWater.m, that also defines a function handle to
the equation, f (h), of which we wish to find the root
• The script should call two separate function files, bisection.m, falsePosition.m, that accept a function handle
to f(h), and implement the two different root-finding methods in a general way (i.e., they should not be
specific to the tank problem).
o These functions should implement the complete solutions, not a single iteration for each method.
E.g., bisection.m outputs 2 vectors, containing all found roots and all corresponding errors (see
Figure 2, next page). Please note that other functions might require a different set of input
arguments, depending on the specific method.
o Functions should print to the command window for each iteration (in an easily legible way - hint:
use fprintf): the lower and upper bounds of the bracketing interval, the root estimate, the value of
f(h), and the absolute approximate percent relative error, |εa|.

Consider the following parameters when employing the different root-finding methods.
• Use the initial lower and upper bounds of the bracketing interval, hℓ = 0 and hu = H.
• In both cases, stop your algorithm when your absolute approximate percent relative error drops below a
specified percent tolerance of εs = 10−4 or when you reach a maximum of 30 iterations, whichever occurs
first.
Consider the following tank parameters: H = 6 m, R1 = 1.5 m, R2 = 3 m, and solve the problem for a target volume, Vt
= 40 m3.

Your discussion
In your report, comment on the relative convergence rates of the Bisection and False-Position methods. Which one
converges faster? How do you know? Is this always expected to be the case (e.g., for other problems)?

Deliverables
Please place all files described below (e.g., .docx, .pdf, .m) in a zipped folder and upload to Canvas using the
following naming convention: “HW# FamilyName FirstName.zip.”
(a) Professionally-formatted report. Please provide a brief description of the problem, the function you are
finding the root of (f (h)), images of plots output by your code, a screenshot of the command window output from
your code, and your discussion. Be sure to format your report professionally. Each of your plots should include
meaningful axis labels with units (when appropriate), a legible legend, and marker/line styles to make the
curves/points easily distinguishable. Matlab’s “grid on” and “box on” commands are also suggested. Your report
should include a header/footer with your name, date, course number, assignment number, and page numbers.
(b) Professionally-formatted source code. Include Script_DepthOfWater.m, bisection.m, falsePosition.m, and
any other functions (if any) that you wrote to complete the assignment. Please be sure that your code runs
immediately upon download and unarchiving of your zip file, with no additional dependencies that need to be
acquired. Be sure to format your code professionally. At the top of each script/function, include your name, the
date, and a description of the file - for functions also define all input and output variables. Use comments and
indenting for code readability.
ME 2016 Homework 3 Due: February 7, 2024

Figure 2: Possible header of bisection.m

Extra credit [5 points]

Implement the Modified False-Position method to solve the water tank problem. Add the Modified False-Position
method results to the previously discussed plots. Include the additional “modifiedFalsePosition.m” file (called by the
primary Script_DepthOfWater.m) with your submission. Add the Mod. False-Position method results discussion to
the appropriate sections in the report.

You might also like