Docsity

Scientific Programming Homework 8: Optimization Solutions, Assignments of Computer Science

Toggle sidebar
bg1
Page 1 of 1
CSCD 309: Scientific Programming
HW #8: Optimization
Due: 11am, Mon Jun 8 (scheduled end of Final Exam)
Put your work in a script file as previously.
1) Write a function called Babylonian that uses fixed-point iteration to find the square root of any
positive number, to a given tolerance on the change in x. Then call it to find the square roots of
5, 7, and 8 with a tolerance of 0.0001. Double-check the answers you get by squaring them.
2) Use bisect.m from the website to find the square roots of the same numbers to a tolerance of
0.0001. Double-check your answers as above.
3) Write some Matlab code that determines the number of digits of accuracy to which 3.14
represents ฯ€. I used the max and find functions to do this.
4) Use fixed-point iteration to solve the following system of equations. Iterate until the norm of
the change in x, y, and z is less than 0.0001. Plug your results back into the equations as a
sanity check.
x
2 + 20x +y2 + z2 - 20 = 0
x2 + 20y + z2 - 20 = 0
x2 + y2 - 40z = 0
5) Use fminbnd() to find a minimum of (x โ€“ 0.7)2 on the interval [0,1].
6) Use fminsearch() to solve the following problem: given the points in the following figure, find
p5 and p6 such that the sum of the 8 paths that link the points is minimal (there is no path from
p1 to p2 along the x axis). p1=(0,0) p2=(1.8,0) p3=(1.5,1) p4=(0.3,1.6). Display both the
locations of p5 and p6 and the total minimized distance. Note that the function argument to
fminsearch can be a function handle or a string with the name of an external function (.mat file).
0.5 1.0 1.5
0.5
1.0
1.5
p1
p2
p3
p4
p5 p6
x
y
7) In the file bisect.m you will find that the number of iterations is limited to a calculated
maximum. Explain why the number of iterations necessary to reach the target tolerance should
not be higher than the number determined by that calculation. IOW, show a derivation.

Partial preview of the text

Download Scientific Programming Homework 8: Optimization Solutions and more Assignments Computer Science in PDF only on Docsity!

Page 1 of 1

CSCD 309: Scientific Programming

HW #8: Optimization

Due: 11am, Mon Jun 8 (scheduled end of Final Exam)

Put your work in a script file as previously.

  1. Write a function called Babylonian that uses fixed-point iteration to find the square root of any positive number, to a given tolerance on the change in x. Then call it to find the square roots of 5, 7, and 8 with a tolerance of 0.0001. Double-check the answers you get by squaring them.

  2. Use bisect.m from the website to find the square roots of the same numbers to a tolerance of 0.0001. Double-check your answers as above.

  3. Write some Matlab code that determines the number of digits of accuracy to which 3. represents ฯ€. I used the max and find functions to do this.

  4. Use fixed-point iteration to solve the following system of equations. Iterate until the norm of the change in x, y, and z is less than 0.0001. Plug your results back into the equations as a sanity check. x 2 + 20x +y^2 + z 2 - 20 = 0 x^2 + 20y + z 2 - 20 = 0 x^2 + y 2 - 40z = 0

  5. Use fminbnd() to find a minimum of (x โ€“ 0.7)^2 on the interval [0,1].

  6. Use fminsearch() to solve the following problem: given the points in the following figure, find p 5 and p 6 such that the sum of the 8 paths that link the points is minimal (there is no path from p 1 to p 2 along the x axis). p 1 =(0,0) p 2 =(1.8,0) p 3 =(1.5,1) p 4 =(0.3,1.6). Display both the locations of p 5 and p 6 and the total minimized distance. Note that the function argument to fminsearch can be a function handle or a string with the name of an external function (.mat file).

0.5 1.0 1.

p

p

p

p

p p

x

y

  1. In the file bisect.m you will find that the number of iterations is limited to a calculated maximum. Explain why the number of iterations necessary to reach the target tolerance should not be higher than the number determined by that calculation. IOW, show a derivation.