MATLAB

profileballerina
384hw1ss15.pdf

MAE 384. Advanced Mathematical Methods for Engineers. Homework Assignment 1. Due May 21.

1. Write the following numbers in 32-bit single-precision standard form (as stored in a computer).

(a) 66.25

(b) .06298828125

(c) -30952

2. Convert the following to decimal format:

(a) 1100101

(b) 10001101.001

(c) 10110001110001.01010111

3. Consider the function

f(x) = 1−cosx sinx

Notice that, for small x, the numerator consists of a subtraction of two numbers close to each

other in size (both near 1), and the denominator is also a small number.

(a) Find the solution for x = 0.001 to six digits, including zeros. Be sure to round your

result to 6 digits at each calculation step.

(b) Use MATLAB (format long) to calculate f(0.001). Consider this to be the true value.

Find the true relative error between cases (a) and (b).

(c) Multiply f(x) by 1+cosx 1+cosx

and be sure to simplify your expression. (Recall that sin2 x +

cos2 x = 1.) Then find the value of the new f(x) for x = 0.001 to 6 digits. (Round at

each step in the calculation.) Find the true relative error, and compare with your results

in (b). Explain your result.

4. Write a MATLAB program to find cosx to a prescribed error input by the user. Use the series

solution, given by

cosx = ∞∑ n=0

(−1)n (2n)!

x(2n)

(Recall that 0! = 1.) Find cos(π 3 ) to within a relative error of 0.0001. Use an estimated

relative approximation error given by

εa =

∣∣∣∣Sn −Sn−1Sn ∣∣∣∣

Note that Sn is the value of the summation for n terms in the series.

You should present your solution to this problem formally:

(a) Statement of the problem (1 sentence)

(b) How you solved the problem (a few sentences and, possibly, a flow chart)

(c) Results (value of cos(π 3 ), error, number of terms required)

(d) Discussion (anything you may want to add)

(e) MATLAB code