Você está na página 1de 3

Compulsory Problems Problem 1: Encode the following algorithm and run it to determine the smallest positive number that

can be represented on the computer you are using: input s <--- 1.0 for k=1,2,3,...,100 do s <--- 0.5 s t <--- s + 1.0 if t <= 1.0 then s <--- 2.0 s output k-1, s stop endif end Do this for both single precision and double precision floating point numbers.

Problem 2: Evaluate the expression y=(x^2 + 1.0)^(0.5)-1.0 in two ways (a.) y <- (x^2 + 1.0)^(0.5)-1.0 (b.) y <x^2/[(x^2+1.0)^(0.5)+1.0]

for small values of x, x=0.1, 0.01 and 0.001, Determine the fractional error in both the methods of performing the subtraction. Which method is superior, and why? Problem 3: It is desired to calculate all integral powers of the number x= (sqrt(5.)-1.)/2. It turns out that the integral powers of x satisfy a simple recursive relation x^ (n+1) = x ^ (n-1) - x^ n Show that the above recurrence relation is unstable by calculating x ^ 16, x^ 30, x^40 and x^50 from the recurrence relation and comparing with the actual values

obtained by using inbuilt function e.g., pow(a,b) in C.

Supplementary Problems
Problem 1: Given x_ n = (1/3) ^ n, it turns out that the integral powers of (1/3) satisfy a simple recursive relation x_ (n+1) = (13/3) x_n - (4/3) x_(n-1) with x_0 = 1 and x_1 = (1/3) Show that the above recurrence relation is unstable by calculating x_15, x_30, x_40 and x_50 from the recurrence relation and comparing with the actual values. Problem 2: The recurrence relation y_ (n+1) = e - (n+1) y_ n

(where e is the base of natural algorithm) can be obtained from integration by parts to the integral y_n = int { x^n e^x dx } with limits 0 and 1 [int stands for integral]. Show that the above recurrence relation is unstable by calculating y_15 and y_20 from the recurrence relation. Problem 3: Compute the dot product of the following two vectors x = [ 2.718281823, -3.141592654, 1.414213562, 0.5772156649, 0.3010299957] and y = [1486.2497, 878366.9879, -22.37492, 4773714.647, 0.000185049 ] Compute the summation in four ways (i) forward order Summation { x_i y_i } for i = 1, n (ii) reverse order Summation { x_i y_i } for i = n, 1 (iii) largest to smallest order (add positive numbers in order from largest to smallest, then add negative numbers in order from smallest to largest and then add the two partial sums) (iv) smallest to largest order (reverse order of adding in the previous method) Use both single & double precision for a total of eight answers. Compare the results with the correct value 1.006571 E -9.

Problem 4: Consider the logistic map x_(n+1)=A*x_n*(1-x_n) where x_n is the n-th iteration for 0 <= x <=1. Here A is a constant. Vary the value of A from 0.89 to 3.995 in an interval of 0.0125 in each step . a) For each value of A, note the values of x_n for 15 < n < 200. Then make a plot of X_n versus A and see the bifurcation and chaos. (check the attached postscript file with this assignment page to see how the plot of x_n vs A will look like.) b) For A = 4.0, choose two points x and x' where x'=x+0.01 and iterate. Plot log (|x_n-x'_n|/0.01) as a function of n. See if it is approaching a straight line.

Você também pode gostar