MA 3457 / CS 4033

HW #1

1. (8 points) Taylor Series: Taylor polynomials are truncated Taylor Series and are often a good local

approximation of a function close to the point the series is expanded about. In this problem, you are

exploring the truncation error (remainder) when using the Taylor polynomial P2(x) for the function

f(x) = e

x

cos(x) about xo = 0.

(a) (4 points) Use P2(0.5) to approximate f(0.5). Find an upper bound for absolute error |f(0.5) −

P2(0.5)| using the truncation error (remainder) formula. Compare the error bound to the absolute

error.

(b) (4 points) Approximate R 1

0

f(x)dx using R 1

0

P2(x)dx. Find an upper bound for the error using

R 1

0

|R2(x)|dx and compare the bound to the absolute error.

Note: You may do this problem with or without code. Please include a detailed write-up as well as

commented m-files if you choose to utilize code for the error calculations.

2. (8 points) Machine Epsilon: Machine Epsilon is the maximum relative error for a specified rounding

procedure. Commonly, this is determined as the smallest floating point number that when added to

1, results in a floating point number greater than 1. In this problem you are exploring what machine

epsilon is in Matlab.

(a) (5 points) Write a program (m-file in MATLAB) that will find machine epsilon. One way to do

this is set an initial value, e.g. x=1, and repeatedly change it by making it smaller, e.g. x=x/2,

and check whether Matlab can still recognize that it is something greater than 0, e.g. checking to

see if x+1>x. Your code should utilize loops and/or conditional statements.

(b) (3 points) Comment on your machine epsilon value from your code and compare it with the built

in Matlab command that determines machine epsilon, which can be found by typing in eps in the

command window.

3. (8 points) Single and Double Precision: We briefly discussed that there are different floating point

representations of numbers. Single precision format uses 32 bits whereas double precision uses 64 bits.

As one might guess, single precision is often used when precision matters less and double precision

is used in scientific calculations. By default, everything in Matlab is double precision unless the user

specifies that it should be single precision.

Consider the following linear system A~x = ~b:

1 1 − α

1 + α 1

~x =

2 − α

2 + α

(a) (2 points) Verify by hand that the solution is ~x = (1, 1)T

.

(b) (4 points) In Matlab, determine the numerical solution when α =2e-3 by doing the direct calculation (recall there is a formula for the inverse of a 2×2 matrix and we can write the solution as

~x = A−1~b. Next, repeat this calculation in Matlab, specifying that α should be single precision

by adding the line α =single(α). (If you are getting the same answer, you might need to clear

previous variables by typing clear all at the top of the m-file or in the command window.

1

(c) (2 points) Comment on the exact solution versus the different solutions in single and double

precision.

4. (6 points) Loss of Significance: Subtractive Cancellation can increase error or reduce precision of a

final computed answer.

Consider the following functions:

f(x) = x(

√

x + 1 −

√

x)

g(x) = x

√

x + 1 + √

x

(a) (3 points) Verify by hand that g(x) is equivalent to f(x).

(b) (3 points) Compare the results of calculating f(500) and g(500) by hand using six digit rounding.

Note: An example of six-digit rounding is given here: 0.123456# would be replaced/approximated

by 0.123457 if # ≥ 5 or 0.123456 if # < 5.

2

MA 3457 / CS 4033

# MA 3457 / CS 4033 HW #1 SOLVED

Original price was: $35.00.$30.00Current price is: $30.00.

## Reviews

There are no reviews yet.