- 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) = ex cos(x) about xo = 0.
- 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.
- Approximate using. Find an upper bound for the error using
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.
- 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.
- Write a program (m-file in MATLAB) that will find machine epsilon. One way to dothis 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.
- Comment on your machine epsilon value from your code and compare it with the builtin Matlab command that determines machine epsilon, which can be found by typing in eps in the command window.
- 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:
- (2 points) Verify by hand that the solution is ~x = (1,1)T.
- (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 22 matrix and we can write the solution as
~x = A1~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
- (2 points) Comment on the exact solution versus the different solutions in single and doubleprecision.
- (6 points) Loss of Significance: Subtractive Cancellation can increase error or reduce precision of a final computed answer.
Consider the following functions:
- Verify by hand that g(x) is equivalent to f(x).
- 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.
Reviews
There are no reviews yet.