Anda di halaman 1dari 4

In the Name of God Numerical Methods Sharif University of Technology CE 40215/216

Homework 1 Oct, 2013


Reminders: Typing the solutions has extra mark. Collaboration is permitted, but you must write the solutions by yourself without assistance. Getting solutions from outside sources such as the Web or students not enrolled in the class is strictly forbidden. Late submissions will be treated according to the course policy.

Problems: 1. Assume that the length of a pen and the height of Milad Tower are to be measured using devices Meter1 and Meter2 scaled up to millimeter and meter respectively. The exact values of length and height are given as 15.49 cm and 435.6 m. (a) What are the measured values? How many digits of mantissa does each have? (b) Find the absolute and relative error of both measurements. (c) Compare the accuracy and precision of them. (Express all of your answers in normalized form.)

2. Suppose that f (x, y ) = f1 (x, y ) f2 (x, y ) where f1 (x, y ) = x y and f2 (x, y ) = x2 + y 2 + xy . Given the table below:
exact value measured value x 6.81 6.9 y 7.17 7.1

(a) Draw process graph for f and nd its upper bounds of absolute and relative errors. (b) Simplify f using algebraic equations. Which form of f is prefered? Prove your answer. (c) Give reasons as to why the relative error of f1 and the absolute error of f2 are so high.
1

3. Consider the Taylor series of arcsin(x): arcsin(x) =


(2n)! 2n+1 n=0 4n (n!)2 (2n+1) x

(a) Let n = 3 and calculate arcsin(0.5) in radians and convert the result to degrees afterwards. Check the accuracy of your answer. (b) Find the absolute and relative error of part (a). (c) Explain that what kind(s) of error does exist? (Do your calculations with 4 oating digits)

4. Assume that we use a machine that works with 5 oating digits. What is the result of the following function if x0 = 100000? Do algebraic calculations on the function and simplify it. What is the result now? 1 x+1 x

f (x) =

Note: In case of overow, digits of lower signicance are ignored in this machine.

5. Consider a machine in which the numbers are represented in a 16-bit binary oating point format shown below:
sign 1 unsigned mantissa 9 exponent 6

(a) Represent (0.7)49 in the above format? What kind(s) of error does this representation contain? (b) Now imagine that the numbers are represented in a 5-bit twos complement format. What will be the result of the following operations? i. ii. iii. iv. 14 + 8 13 6 9 15 7 10

6. The following is the result of a shooting competition between the contestants A and B. Compare the precision and accuracy of each contestants shots.
A B 6 10 7 5 6 9 5 2 5 4

21 7. Compute the volume of a sphere with a radius of . Try to achieve the best answer. 2+1 (Let 2 = 1.41 and = 3.14 and do your calculations with 5 digits mantissa.) Hint: To approximate the exact value of the volume, use more precise amounts for and . Getting help from MATLAB is recommended. 2

8. The position of a particle(x) is given in terms of time(t) via the equation: x = 0.13t3 0.29t2 + t + 0.2679 Calculate the position in t = 0.4576(s). (Do your calculations with 4 digits mantissa.)

9. The Stirling approximation Sn = n 2n( )n e

is used to approximate n! = 1 2 ... n, where n is quite large. Let e = 2.7183 and = 3.1416, estimate 10! using this approximation. What are the absolute and relative errors? (Do your calculations with 4 oating digits.)

MATLAB Problem: Write a MATLAB function calculating absolute and relative error of the following equation. The function receives four arguments: the value of x, the value of y , the absolute error of x and the absolute error of y .
xy 2y x+y

The output is a 1 2 vector containing the values of the absolute and relative errors respectively. (Be aware of the IO format and the names of your function and the .m le) Sample input: ch1 90123456(x, y, ex, ey ) Sample output: [abs err rel err] Note: It is only expected that your function returns what you have been asked. Please do not display anything.

Anda mungkin juga menyukai