0% found this document useful (0 votes)
21 views5 pages

ME 310 Spring 2024 SS 4 and HW 4

Uploaded by

hiloje7193
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)
21 views5 pages

ME 310 Spring 2024 SS 4 and HW 4

Uploaded by

hiloje7193
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/ 5

Middle East Technical University

Department of Mechanical Engineering


ME 310 Numerical Methods
Spring 2024 (Dr. Cuneyt Sert)
Study Set 4

For Homework 4 submit the answers of questions 1, 2, 4 and 5. Their grade percentages are not known at this
point. It will be decided later.

Assigned: 23/04/2024 – Due: 06/05/2024, 10:30

Homework Rules and Suggestions:

 This assignment can be done individually or as a team of two students. Everything in your report should be the result of
your own work or your team’s work. You are allowed to discuss the questions with your classmates and teaching staff up
to a certain detail on ODTUClass. You are not allowed to use an AI tool such as ChatGPT in writing codes or other parts of
your report.
 Put the following honor pledge at the top of your homework report and behave accordingly.
“I understand that this is an individual/team assignment. I affirm that I have not given or received any unauthorized help
on this assignment, and that this work is my own/team’s.”
 If you do the homework as a team, put the percent contribution of each member at the beginning of your report.
 If you’ve exchanged ideas with other students outside ODTUClass, you need to put their names and the extent of your
discussion at the beginning of your report.
 You need to submit a printed report. It is what we will be grading. You also need to upload the same report as a PDF
document (not a Word document) together with all other files (such as codes) to ODTUClass. Name your MATLAB files
properly. Follow MATLAB file naming rules such as “File names cannot start with a number”, “They cannot contain special
characters or spaces”, etc.
 Late submission is not allowed unless you have a valid excuse. In such a case, you need let the whole teaching team know
about it before the submission deadline, unless it is an emergency.
 Make sure that the codes in your report are formatted properly. Use a small sized, fixed width font and make sure that lines
are not wrapped. If your code is very long, you can shorten it by getting rid of its noncritical parts and putting a note about
this. Note that we grade what we see in your printed report. Do not expect us to run your codes for you to generate results,
figures, etc. You should do that yourself and put all the results in your report.
 In writing your codes, follow good programming practices such as “use explanatory header lines”, “explain inputs and
outputs of functions”, “use self-explanatory variable names”, “use comments”, “use empty lines and spaces for readability”,
“use indentation for code blocks”, “divide long lines into multiple lines using MATLAB’s ‘…’ syntax”, etc.
 Pay attention to the format of your report. It should look like a serious academic work, not like a high school student work.
Font types and sizes, page margins, empty spaces on pages, equations, figures, tables, captions, colors, etc. are all important
to give the desired “academic work feeling”. Language used is also important. Reports with poor use of English will be
penalized.
 Do not provide an unnecessarily long report. The shorter your report, the better it is, as long as it answers the questions
properly. Avoid wasting paper. Print on both sides of sheets. Avoid using color unless it is really necessary. Format your
report properly with small but readable fonts, small margins, no unnecessarily large figures, no useless spaces, etc. to
reduce the number of sheets. Do not use a cover page.
 There are more than 100 students, and we can spend only about 10 minutes to grade each report. Your report should be
easy to read and understand. We should be able to find the results and judge their correctness easily. We should not get
lost in your report. The more we struggle to understand your report, the lower your grade will be. Use figures and tables
cleverly for this purpose.
 Reports with only figures, tables and codes, but no text, comments or discussions will not get a good grade. Start answering
each question with one paragraph of introduction. Even when a question does not specifically ask for a discussion or a
comment, you need to write a few sentences on the key points and your key findings/learnings.
 Figures and tables should be numbered and should have captions (at the bottom for figures and at the top for tables). Their
titles should be self-explanatory, i.e., we should be able understand everything about the table or figure just by reading its
title. They should all be referred properly in the written text (such as “… as shown in Fig. 3” or “… (See Table 2)”).
 Do not use any Appendices in your report.
 Do not forget to put a numbered reference list at the end of your report if you use references. In that case, you need to
refer to the references in the text.
 If you are inexperienced in programming, converting an idea/algorithm into a code and writing it in a bug-free way can be
time consuming and frustrating. This is not something that can be done at the last minute. You are advised to start working
on the assignments as soon as they are assigned.
1
Reading Assignments:

Self-learning is an important skill. Not everything can be discussed in lectures. You need to learn certain things by yourself.

R1) Read page 366 of the 8th edition to learn how to calculate 𝜀𝑎 for the golden section search method.

R2) Read page 384 of the 8th edition to learn how the derivatives of the Hessian matrix can be evaluated approximately when
exact derivatives are not available for a 2D problem.

R3) Read the Epilogue section of Part 4 (page 445 of 8th edition). Part 4 includes 4 chapters and its epilogue is at the end of
Chapter 16. What we call “Chapter 4 Optimization” in our lectures is this 4th part of the textbook.

Questions:

Q1. The design variables of Salvador.m code are the three link angles. The problem solved in this code is a 3D, non-linear,
unconstrained optimization problem. Change the code such that there are only two links of length 7 and 5. The second link,
with the initial length of 5, is capable of changing its length in the range [2, 8], i.e. it can stretch and shorten. This problem is a
3D, non-linear, constrained optimization problem, with design variables being two link angles and one link length. MATLAB’s
fmincon function (see Handout 5) can be used instead of fsolve to solve this problem.
Modify the code to solve this problem. Show the changed parts of the code and explain the changes made.
Upload a short screen recording to demonstrate how the new robot works.
Hint: MATLAB’s fsolve makes use of a function vector {𝑓}, with 2 functions in it, and calculates the sum of their squares by
itself. But fmincon directly needs the cost function 𝑓12 + 𝑓22 that needs to be minimized. You need to calculate this sum in the
kinematics function of Salvador.m.
Hint: Closing the figure window of Salvador.m may be impossible if something goes wrong during its operation, which can
happen as you are modifying the code for this question. In such a case, use the command close all force in the command
window.

Q2. The growth rate of a yeast that produces an antibiotic is a function of the food concentration 𝑐.
11𝑐
𝑓=
10 + 0.2𝑐 + 𝑐 2 + 0.3𝑐 3
The growth rate goes to zero at very low concentrations due to food limitation. It also goes to zero at high concentrations due
to toxicity effects.

a) Plot the function and locate its maximum and the concentration at which the maximum occurs.
b) Use MATLAB’s fminbnd function (See Handout 5) to locate the maximum. Show the iteration details in your report.
c) Use golden section search to find the value of 𝑐 at which the growth rate is maximized. Start with an interval of [0, 10]. Show
all the details of hand calculations for the first three iterations and tabulate the results. Do NOT write a code.
d) Repeat part (c) using quadratic interpolation starting with points 0, 5, 10. Drop the point with the minimum 𝑓 value after
each iteration, and continue with the remaining three points.
e) Repeat part (c) using Newton’s method starting with the initial guess of 1.
f) Repeat part (e), but use the following approximations for the derivatives with 𝛿 = 0.1
𝑓(𝑥𝑖 + 𝛿𝑥𝑖 ) − 𝑓(𝑥𝑖 − 𝛿𝑥𝑖 ) 𝑓(𝑥𝑖 + 𝛿𝑥𝑖 ) − 2𝑓(𝑥𝑖 ) + 𝑓(𝑥𝑖 − 𝛿𝑥𝑖 )
𝑓 ′ (𝑥𝑖 ) ≈ , 𝑓 ′′ (𝑥𝑖 ) ≈
2𝛿𝑥𝑖 (𝛿𝑥𝑖 )2

2
Q3. A lifeguard sees a swimmer in distress, with the two positioned as shown.
If the lifeguard runs at a speed of 5 m/s and swims at 1 m/s, what is the Lifeguard
Beach
optimal path for the lifeguard to reach the swimmer in the shortest time?
Formulate an optimization problem whose solution is the point along the 30 m
shoreline at which the lifeguard should enter the water. Using the optimal Shoreline
path, how long will it take the lifeguard to reach the swimmer?
80 m
40 m

Sea
Swimmer

Q4. A fence is to be constructed to enclose land in the shape of a semicircle adjacent to a


rectangle. If the length of the fence is restricted to 300 m, formulate the problem of 𝑅
determining the dimensions 𝑅 and 𝐻 that correspond to the maximum enclosed land area.
a) Derive equations for the objective function 𝑓 and the constraint. Plot the contours of 𝑓 and
the constraint equation together to obtain a graphical solution. See Handout 5 for plotting 𝐻
contour lines.
b) Use one of MATLAB’s built-in optimization functions (see Handout 5) to solve the problem.
Provide the code used and the result obtained.

Q5. Contour lines corresponding to 𝑓 = 1, 15, 100, 300, 1000, 2000, 3000 of
function 𝑓(𝑥, 𝑦) = 5𝑥 4 + 4𝑥 2 𝑦 − 𝑥𝑦 3 + 4𝑦 4 − 𝑥 are shown.
a) Find the minimum of this function and its location using one of MATLAB’s built-
in optimization functions (See handout 5).
b) Solve the problem using Newton’s Method starting from point (5, 4). Perform
three iterations by hand and show all the details. You do not need to write a code.
c) Repeat part (b) using the optimum steepest descent method. Compare the
performance of this solution with the previous one.

Q6. Write a MATLAB code to solve Rosenbrock's "banana function" problem (see Handout 5) using non-optimum steepest
descent method. Your code should generate a contour plot of the function, and on top of it show the solution of each step with
a dot. When the iterations are over, all the dots will give us the path followed from the initial guess to the final solution.
Perform solutions starting from (-1.9, 2). Try different values for the parameter that controls the distance moved in each
iteration and discuss how this selection affects accuracy and speed of convergence.

Show the iteration results of each run in tabulated form and provide plots showing convergence paths.

3
Q7. Following web site lists some well-known test functions that are used to
compare the convergence characteristics of different optimization methods.
https://en.wikipedia.org/wiki/Test_functions_for_optimization
As an example, the one shown on the right is called Himmelblau’s function
with several local extremes. Select a few of these functions and find their
minimum points using MATLAB’s built-in routines.

Q8. Automobile doors are often reinforced by aluminum beams to help absorb
side impact energy and reduce injury to passengers from side impacts.
Formulate and solve the problem of designing a minimum weight beam of
rectangular cross section with the following constraints.
a) The bending stress induced in the beam, assumed to be simply supported,
during the impact should not exceed 140 MPa. The impact energy absorbed
by the beam can be approximated as
1 𝑚2 (𝑣1 − 𝑣2 )2
𝐸=
2 (1 + 𝑚2 /𝑚1 )
where 𝑚1 and 𝑚2 are the masses of the two impacting vehicles and 𝑣1 and 𝑣2
are their speeds at the time of impact. The impact force induced (𝐹𝑖 ) at the
middle of the beam is given by 𝐹𝑖 = 2𝐸/𝑠, where 𝑠 is the net crush distance
during impact. The bending stress induced in a simply supported beam due to
central concentrated load (𝐹𝑖 ) can be expressed as
3𝐹𝑖 𝑙
𝜎𝑏 =
2𝑤𝑑 2
where 𝑙, 𝑤, and 𝑑 are the length, width and depth of the beam. Use 𝑣1 = 0, 𝑣2 = 16 km/h, 𝑚1 = 𝑚2 = 1250 kg, 𝑠 = 20 cm,
𝑙 = 60 cm.
b) The width and depth of the beam should not be less than 0.6 cm.
c) The depth of the beam should not exceed the width of the beam.

Q9. A blood vessel branches from an artery at an angle


𝜃. Under steady, laminar flow conditions, the resistance
for blood flowing along the path ABC, 𝑅𝐴𝐵𝐶 , can be
computed as
𝐿1 𝐿2
𝑅𝐴𝐵𝐶 = 𝐾 ( + )
𝑑14 𝑑24
where 𝐾 is a constant parameter, 𝑑1 and 𝑑2 are the
diameters of the artery and the vessel, 𝐿1 and 𝐿2 are the
lengths of the artery and the vessel, which are related to
the angle by
𝐿1 = 𝐿 − 𝐻 cot(𝜃) , 𝐿2 = 𝐿 − 𝐻 csc(𝜃)
Given 𝐻 = 2.5 mm, 𝐿 = 10 mm, 𝑑1 = 1 mm, and 𝑑2 = 0.75 mm, determine the angle that minimizes 𝑅𝐴𝐵𝐶 .

4
Q10. For a jet in steady, level flight, thrust force balances drag force and lift
force balances weight. Under these conditions, the optimal cruise speed
occurs when the ratio of drag force to speed is minimized. The drag
coefficient can be computed as
𝐶𝐿2
𝐶𝐷 = 𝐶𝐷0 +
𝜋𝐴𝑅
where 𝐶𝐷0 is the drag coefficient at zero lift, 𝐶𝐿 is the lift coefficient, and 𝐴𝑅
is the aspect ratio of wings. For steady, level flight, the lift coefficient can be computed as
2𝑊
𝐶𝐿 =
𝜌𝑉 2 𝐴
where 𝑊 is jet’s weight (N), 𝜌 is air density (kg/m3), 𝑉 is jet’s speed (m/s), and 𝐴 is wing’s planform area (m2). The drag force
can then be computed as
𝐶𝐷
𝐹𝐷 = 𝑊
𝐶𝐿
Use these formulas to determine the optimal cruise speed for a 670 kN jet flying at 10 km above sea level. Use 𝐴 = 150 m2,
𝐴𝑅 = 6.5, 𝐶𝐷0 = 0.018, and 𝜌 = 0.413 kg/m3.

Q11. In a similar fashion to the case study described in section 16.4 of our
textbook, develop the potential energy function for the shown mass-
spring system. Develop contour and surface plots. Minimize the potential
energy function in order to determine the equilibrium displacements 𝑥1
and 𝑥2 given the forcing function 𝐹 = 100 N, and the spring constants
𝑘𝑎 = 20 and 𝑘𝑏 = 15 N/m.

Q12. a) Use one of MATLAB’s built-in functions (see Handout 5) to solve the following 2D linear programming problem.
𝑓 = −8𝑥1 − 11𝑥2
5𝑥1 + 4𝑥2 ≤ 40 , − 𝑥1 + 3𝑥2 ≤ 12
𝑥1 ≥ 0 , 𝑥2 ≥ 0
b) Perform a graphical solution by plotting the contour lines of 𝑓, together with the constraint equations.

You might also like