Problem 1 Within MATLAB do:
- 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.
- Issue the command help range rk1 and read through the documentation in detail.
- 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.
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.
Elevation 45 degreesElevation 60 degrees |
0 2000 4000 6000 8000 10000 12000 14000 16000 18000
x coordinate (meters)
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.
Problem 3 As demonstrated during yesterdays lecture the problem of computing a sum of positive numbers
is substantially more complicated than it would appear! This exercise illustrates highlights the problem and shows how calculate an upper bound for the error.
- Copy the script lab1/scripts/l1p3.m to lab1/work/my l1p3.m.
- Edit my l1p3 so that it uses simple sum to compute
using single/double precision and ascending/descending order, a total of 4 different calculations.
- 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.
- Copy function simple sum to lab1/work/my simple sum.
- 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 = 224 in single precision and u = 253 in double precision.
- Edit my l1p3 so that it displays the running error bound right next to the actual error.
- Verify that the absolute value of the error is bounded by the running error bound.
- Which order of summation is the most accurate?
Reviews
There are no reviews yet.