Propose an algorithm for computing the following expression

Propose an algorithm for computing the following expression that avoids the loss of precision: f(x) = squareroot 1/1 - x - squareroot 1/cos (x) for x ~ 0.

Solution

Consider the reduction formula ln(1 + x) = 2 ln(1 + y)

where 1 + y = 1 + x = 1 + x 1 + 1 + x .

It could be better to work with the function log1p defined by log1p(x) = ln(1 + x) to avoid loss of precision (this time in the argument rather than in the function).

Then log1p(x) = 2log1p x 1 + 1 + x avoids loss of significance when |x| is small. However, note that argument reduction for ln or log1p is more expensive than that for exp or expm1, because of the square root.

 Propose an algorithm for computing the following expression that avoids the loss of precision: f(x) = squareroot 1/1 - x - squareroot 1/cos (x) for x ~ 0.Solut

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site