Show that ln(x − √ x 2 − 1) = − ln(x + √ x 2 − 1). (b) Use
MATLAB (codes provided below) to compute values using these two
formulas with x = k×107 , k = 1, 2, 3, · · · , 9. Draw a table to
compare the results you obtain. (4 columns: x, result using
formula–1, result using formula–2, difference).
1. (a) Show that In(x - V.x2 - 1) – In(x + V.x2 - 1). (b) Use MATLAB (codes provided below) to compute values using these two formulas with x = kx 10", k=1, 2, 3, ..., 9. Draw a table to compare the results you obtain. (4 columns: I, result using formula-1, result using formula-2, difference). clear all format long f1 = @(x) log(x-sqrt(x.^2-1)); % define function 1 f2 = @(x)-log(x+sqrt(x.^2-1)); % define function 2 xlist (1:9) '*10^7; % compute values at x locations [xlist, f1(xlist),f2(xlist), abs (f1 (xlist)-f2(xlist))] = (c) Explain why the results using two formulas (from part (b)) are different and which one is more suitable for numerical computation.
2. Consider the Taylor expansion .22 23 In(1+1)=r- + 2 3 +...+ +(-1)"+12" + ..., 4 n and we can use a truncated series of N terms to approximate In(1.1). (a) Modify the MATLAB codes below to implement this approximation. (b) Test using N = 5, 10, 12, and calculate the absolute errors and relative errors. (c) How do the errors from part (b) change as N increases? Why? % approximate exponential function using taylor expansion clear all format long x = 1.2; N = 10; exact_value = exp(x); approx_sum = 0; for n = 0:N current_term = 1/factorial (n) *xºn; approx_sum = approx_sum + current_term; end ? abs_error = abs(approx_sum - exact_value); disp([' exact', approx', disp([exact_value, approx_sum, abs_error]) A-err'])
Show that ln(x − √ x 2 − 1) = − ln(x + √ x 2 − 1). (b) Use MATLAB (codes provided below) to compute values using these t
-
- Site Admin
- Posts: 899559
- Joined: Mon Aug 02, 2021 8:13 am