Starting from:

$29.99

Computing Assignment – Root-Finding in Geometric Design

MACM 316 – Computing Assignment #2
Due Date: Friday October 9 at 11:00pm
Submission Instructions: You must upload one .pdf file to Crowdmark that consists of 2 pages
ONLY: page 1 is your report which should fit all of your results, discussion, data and figures into a single
page; and page 2 is a listing of your code. The deadline is 11:00pm on the due date. The actual due
time is set to 11:05pm – if Crowdmark indicates that you submitted late then you will be assigned a
grade of 0 on this assignment. Your TA has emailed you a Crowdmark link that you will use for the
entire semester to upload your assignment solutions.
• Review the Guidelines for Computing Assignments carefully.
• Acknowledge any collaborations or assistance from colleagues/TAs/instructor.
• If you have questions about this assignment or Matlab programming, you can obtain help by posting
your questions to the “Computing Assignment” discussion board in Canvas. This discussion board
will be checked regularly, and also monitored continuously during computational workshop hours.
Computing Assignment – Root-Finding in Geometric Design
Motivation: You have a part-time job stocking shelves at a local, family-owned lumber and building
supply store. In an effort to replace lost sales revenue during the pandemic, the owner has discovered
a market for a value-added product: custom-sized, folding picnic tables to satisfy the huge demand
from local restaurants that have recently opened outdoor patios. Knowing that you are an SFU student
with expert training in calculus and scientific computing, she has come to you for help in a method for
determining how to cut the lumber the correct size for each customer’s special needs.
Your boss presents you with the photograph in Figure 1, and a diagram showing the relevant dimensions
of the legs identified in Figure 2. The overall table dimensions are determined by the width w and height
Figure 1: Photograph of the picnic table design.
1
Figure 2: Diagram of the leg assembly, defining the various geometric parameters.
h of the leg assembly, whereas the choice of leg material determines the leg thickness b. The parameters
h, w and b all known ahead of time because of customers’ aesthetic and practical considerations (i.e.,
they are given constants). The remaining measurements for a, c, d1 and d2 indicated in the diagram in
Figure 2 must be determined before the legs can be manufactured.
Problem set-up: Armed with the promise of a big bonus, you apply your solid grounding in trigonometry to the leg geometry from Figure 2 and derive the following equations relating the various parameters
h = 2d2 sin θ, w = 2d2 cos θ + b2 and b = b2 sin θ, (1)
where θ represents the angle at which the legs meet the ground. Combining these equations to eliminate
d2 yields a single nonlinear equation for the unknown angle θ

:
w sin θ = h cos θ + b. (2)
The procedure for determining the leg dimensions required in the manufacturing process can now be
described as follows. First, solve Eq. (2) for θ. Then, the leg half-length d2 can be computed from the
first equation in (1). The other major leg measurement is d1 which can be found from
d1 = d2 − a − c,
where a and c are written in terms of tangents as
a =
b
tan α
and c =
b
tan θ
, with α =
π
2
− θ.
†As a “check” for correctness, setting b = 0 (a zero-thickness leg) gives h/w = tan θ – as expected!
2
Report specifications: After discussions with your boss, you have come up with the following list of
requirements for a report that will earn you your bonus:
(a) Express Eq. (2) as a nonlinear root-finding problem of the form f(θ) = 0, whose solution is the leg
angle θ. Implement the function in Matlab, by first defining variables corresponding to these table
specifications: w = 28, h = 25 and b = 3.5, all measured in inches‡
. Next, define f as a single-line
anonymous function§ of the form
f = @(theta) ...
Plot your function f(θ) on the interval θ ∈ [−π, π] and describe its overall behaviour, as well
as indicating the number of roots, and their approximate location. Your boss has one special
request: she understands that mathematical calculations for angles require working in radians, but
her cutting machines are calibrated in degrees. So she asks that all plots and numeric results be
reported in degrees instead.
(b) Apply three root-finding algorithms to determine the smallest positive root of f(θ) (call it θ

) to
within an error tolerance of 1 degree¶
:
• Bisection method, for which you can use the bisect2.m code from lectures.
• Fixed-point method, using fixedpt.m. You will first have to derive a suitable fixed-point
iteration of the form θk+1 = g(θk) that is equivalent to finding a root of f(θ).
• Newton’s method, using newton.m, which requires you to define a second function that computes the derivative f
0
(θ). Luckily, you remember the oft-overlooked calculus fact that the
usual differentiation formulas for trig functions only hold when the angle is measured in radians. So you need to be sure that your code performs all calculations in radians and does a
conversion to degrees for output/plotting purposes.
Use a very rough initial guess θ0 = 0 (or bracket [θ0, θ1] =
0,
π
2

) for each method based on your
plot from part (a). Compare the cost of the three methods for approximating θ

in terms of the
number of iterations required, and explain any differences you observe.
(c) Although it’s not obvious, an exact solution can be found for Eq. (2):
cos θ
∗ =
1
(h
2 + w2)

−bh +
p
b
2h
2 + (h
2 + w2)(w2 − b
2)

(3)
Implement this formula for the exact root θ

in your code (with Matlab’s inverse cosine function,
acos) and use it to compare the accuracy of your three approximations from part (b). Explain.
Note: I only want you to use Eq. (3) here, not derive it. But if you’re curious to see where it
comes from, try squaring both sides of Eq. (2) and applying the identity sin2
θ = 1 − cos2
θ.
(d) Using your most accurate approximation from part (b), determine the corresponding estimates of
the design parameters d1 and d2. Because customers paying top dollar for these tables demand
high quality and workmanship, your boss’s final requirement is that both of leg measurements d1
and d2 must be accurate to within a tolerance of 0.1 inches. Is your solution accurate enough?
Finis! Your bonus and a possible promotion to Assistant Manager await!
‡Why aren’t we using metric? Well, lumber is still sold inches and feet, and b = 3.5 inches is the actual dimension of a
finished “2-by-4” board that’s commonly used to build picnic tables.
§For help on anonymous functions see either the lecture notes, my Whirlwind Tour, or type “doc anonymous”.
¶Hint: Be very careful here. Your angle θ should be measured in degrees, but all trig functions in Matlab expect an
argument that’s measured in radians.
3

More products