5DV005 – Lab 1 (Solution)

$ 29.99
Category:

Description

Problem 1 Within MATLAB do:
1. Issue the command help bal. This prints a summary of the MATLAB files contained
in the folder bal. These files are for solving problems in external ballistics, i.e. fire
control of artillery.
2. Issue the command help range rk1 and read through the documentation in detail.
3. Execute the minimal working example range rk1 MWE1.
Remark 1 The function range rk1 demonstrates the standard that is expect from you!
In particular, all your codes must contain the call sequence, a complete description of all
input and output variables, as well as a minimal working example. Moreover, all code
must contain frequent and helpful comments. Software which does not adhere to this
standard will not be accepted.
2
Problem 2 Copy the script lab1/scripts/l1p2.m into lab1/work/my l1p2.m. Your
task is to modify my l1p2.m so that it produces the output shown in Figure ?? and
renders the graphics shown in Figure ??. These are the MATLAB commands which you will
need: fprintf, plot, axis equal, xlabel, ylabel, grid, axis, print.
Flag Range (meters) TOI (seconds)
1 16844.662 66.33
1 14998.963 81.57
Figure 1: The output of l1p2 after completion.
0 2000 4000 6000 8000 10000 12000 14000 16000 18000
x coordinate (meters)
0
2000
4000
6000
8000
10000
y coordinate (meters)
Elevation 45 degrees
Elevation 60 degrees
Figure 2: The trajectory of a two shells fired at using elevations of 45 degrees and 60
degrees
Remark 2 In general, I recommend that you export figures from MATLAB at .eps files.
You can convert the file fig.eps to .pdf format using the command ps2pdf -DEPSCrop
fig.ps. This crops the white space and produces a file called fig.pdf.
3
Problem 3 As demonstrated during yesterday’s lecture the problem of computing a sum
of positive numbers
s =
Xm
i=1
ai
is substantially more complicated than it would appear! This exercise illustrates highlights
the problem and shows how calculate an upper bound for the error.
1. Copy the script lab1/scripts/l1p3.m to lab1/work/my l1p3.m.
2. Edit my l1p3 so that it uses simple sum to compute
s =
Xm
i=1
1
i
, m = 222
using single/double precision and ascending/descending order, a total of 4 different
calculations.
3. Edit my l1p3 so that compute the error associated with each value of s. An exceedingly accurate value of the true sum s can be obtained using double precision and
the function kahan sum.
4. Copy function simple sum to lab1/work/my simple sum.
5. Edit my simple sum to include the computation of a running error bound Eb, such
that
|s − sˆ| ≤ Eb, Eb = µu
where s is the true value of the sum, ˆs is computed value of s and u is the unit
roundoff, see [?], Section 4.3, Algorithm 7. Be mindful of the fact that u = 2−24 in
single precision and u = 2−53 in double precision.
6. Edit my l1p3 so that it displays the running error bound right next to the actual
error.
7. Verify that the absolute value of the error is bounded by the running error bound.
8. Which order of summation is the most accurate?

Reviews

There are no reviews yet.

Be the first to review “5DV005 – Lab 1 (Solution)”

Your email address will not be published. Required fields are marked *