CS 221 Fall 2011 Problem Set 5
CS 221 Fall 2011 Problem Set 5
Out: Saturday, 26 November
Due: 23:59:59 Saturday, 3 December
Note: There is no penalty for turning in this
problem set late, but submissions will not be accepted after
solutions are posted on or about Friday, 9
December.
Please read the submission instructions carefully.
Failure to submit the proper items may cost you points.
For any problem you use MATLAB to solve,
create a record of your calculations in MATLAB, using
the diary command. Name the diary file "PS5-#", where "#" is
the problem number, e.g. "1a".
Problem 1: Solving Nonlinear Equations
Use either MATLAB or Excel's root-finding methods to solve the
following problems:
-
The distance d traveled by a projectile launched at velocity v
at angle θ (neglecting air resistance and assuming flat
ground) is given by d =
(v²/g) sin 2θ, where g is the
gravitational constant (use 9.8 meters/second²).
Find the angle θ (in degrees) at which a projectile, launched with
initial velocity of 100 m/sec, should be launched so that it
travels exactly 900 meters.
-
Find the fifth root of 200, i.e. the number x such
that x5=200.
-
The van der Waals equation relates pressure P (in atm.),
volume V (in L), and temperature T (in K) for real gas:
P = (nRT)/(V-b) - (n²a)/V²
where n is the number of moles, R = 0.08206
(L atm)/(mole K) is the gas constant, and a
and b are material constants. Consider 1.5 moles of Nitrogen
(a=1.39 L² atm/mole², b=0.03919 L/mole)
at 25° C stored in a pressure vessel. Determine the volume of
the vessel if the pressure is 13.5 atm.
Problem 2: Solving Systems of Linear Equations
Solve the following systems of linear equations Ax=b using
MATLAB or Excel:
-
A =
10 -1 3 0 77
0 2 -5 3 6
21 -4 0 -14.5 17
3 12 1.5 37 -9
-4 5 -3 22 0
b =
-58
37
249
448
67
-
A =
-17.9 -1.9 -12.0 -20.5 -2.9 9.6 -5.8 7.9 8.6 -0.6
8.4 -21.3 29.0 -3.5 0.2 5.2 -2.9 -13.3 -13.6 -1.9
-8.8 -8.3 8.2 -8.2 -2.6 -0.2 -8.4 -23.2 4.5 -2.1
1.0 13.5 13.7 -15.7 -17.5 -0.3 -11.2 -14.4 -8.4 -3.0
-5.4 -10.7 -10.5 5.0 -2.8 -7.9 25.2 3.3 -3.3 0.2
3.0 9.6 -4.6 2.8 -8.3 10.1 16.5 3.9 5.5 0.5
-6.0 1.2 -2.7 0.3 -9.7 -1.3 3.0 4.5 10.3 8.2
4.8 14.3 10.9 -13.3 -11.5 -7.1 -12.5 -1.3 -11.1 15.2
7.3 -19.6 -2.7 11.2 -5.3 13.5 -8.6 1.8 12.6 4.6
17.1 -1.9 7.0 3.5 -20.0 -2.2 -1.7 -4.7 6.6 -2.0
b =
-2.6
-197.1
-272.7
-382.2
75.4
239.9
164.9
-133.0
172.9
-75.0
(Note: For the second problem, a text file containing A
is here, and one for b is
here.
Problem 3: Curve-Fitting
As described in lecture, nonlinear equations can often be transformed
into a linear form by taking logarithms or other algebraic
manipulations. Once a relationship is in linear or polynomial form,
it is easy to use MATLAB's polyfit() function to find the
coefficients of the equation that minimize the residual errors.
Here is a table of nonlinear equations and their corresponding linear
forms:
Nonlinear Equation
| Linear Form
|
y = bxm
|
ln(y) = mln(x) + ln(b)
|
y = bemx
|
ln(y) = mx + ln(b)
|
y = 1/(mx + b)
|
1/y = mx + b
|
y = (mx)/(x + b)
|
1/y = b/mx + 1/m
|
-
The resistance, R of a tungsten wire as a function of
temperature can be modeled with the equation
R = R0[1 + α(T-T0)]
where R0 is the resistance corresponding to
temperature T0, and α is the temperature
coefficient of resistance. Determine R0 and
α such that the equation will best fit the following data. Use
T0=20° C.
T (° C)
| 20 | 100 | 180 | 260 | 340 | 420 | 500
|
R (Ω)
| 500 | 676 | 870 | 1060 | 1205 | 1410 | 1565
|
-
A hot-wire anemometer is a device for measuring flow velocity by
measuring the cooling effect of the flow on the resistance of a hot
wire. The data obtained in calibration tests are as follows (also
contained in this file). The first column is the
velocity u (in ft/sec) and the second column the
voltage V in volts.
4.72 7.18
12.49 7.30
20.03 7.37
28.33 7.42
37.47 7.47
41.43 7.50
48.38 7.53
55.06 7.55
66.77 7.58
59.16 7.56
54.45 7.55
47.21 7.53
42.75 7.51
32.71 7.47
25.43 7.44
8.18 7.28
Determine the coefficients A and B of the exponential
function u=AeBV that best fit the data.
(Hint: transform the equation as suggested by the
above table and use MATLAB's polyfit() function.)
-
The following measurements were recorded in a study on the growth of
trees.
Age (years)
| 5 | 10 | 15 | 20 | 25 | 30 | 35
|
Height (m)
| 5.2 | 7.8 | 9 | 10 | 10.6 | 10.9 | 11.2
|
We want to use the data to derive an equation Height = H(Age)
to predict tree height as a function of age. Determine which of the
nonlinear equations in the above table gives the best fit for this
data, and determine the appropriate coefficients.
Submission Instructions
To submit your solutions, follow these steps:
- Create a single document containing the answers to all the problems.
(plain text or PDF or Microsoft Word are all OK formats).
-
For any problem you use MATLAB to solve,
include any scripts you wrote and a record of your
calculations in MATLAB, recorded with
the diary command. Name the diary file "PS5-#", where "#" is
the problem number, e.g. "1a".
- If you use Excel, submit the spreadsheet
you used to solve the problem.
Create a folder titled Last_First_PS5 (replacing "Last" and "First"
with your actual names) on the Desktop.
Move the files you are supposed to turn in into that folder.
Nothing else should be in the folder.
Create a zip file containing the folder and its contents.
(The main
course web page has instructions for creating
a zip archive.)
Important: Verify that the contents of the zip
archive are correct. It should contain the directory (folder) and the
three files, and nothing else. (Do this by double-clicking the zip
file.)
Upload the zip archive via
the CS Portal.
Important: save the folder and its contents to a
flash drive or elsewhere, for
two reasons: (i) in case something goes wrong with your submission;
and (ii) we will sometimes build on your solutions in later
problems.
Very Important: save the number the submission
system gives after you upload your submission. It is
the only acceptable proof that you uploaded your file.