Questions tagged [catastrophic-cancellation]

For questions about catastrophic cancellation, the devastating loss of precision when small numbers are computed from large numbers, which themselves are subject to roundoff error.

Catastrophic cancellation is effect which appears in numerical computations, when in subtracting two numbers or some other operation the final result is smaller than rounding error.

21 questions
21
votes
1 answer

Why is 'catastrophic cancellation' called so?

I was studying Numerical Analysis by K. Mukherjee; there he discussed Loss of Significant Figures by Subtraction, as followed: In the subtraction of two approximate numbers, a serious type of error may be present when the numbers are nearly equal.…
user142971
16
votes
1 answer

Explain why catastrophic cancellation happens

After my own research, the following picture emerges as the most frequently used example of catastrophic cancellation (It is indeed used in my class). Could anyone explain why the plot takes that shape? (i.e., the widely fluctuating jagged line…
10
votes
3 answers

Avoiding numerical cancellation question for $\sin x -\sin y$ for $x \approx y$

When trying to avoid cancellation, one tries to reformulate the equation in order to avoid subtraction between almost equal terms. In $\sin (x) - \sin (y), x \approx y$ the suggested solution is to reformulate it to…
10
votes
2 answers

How does rewriting $x^2 -y^2$ as $(x+y)(x-y)$ avoid catastrophic cancellation?

Why is rewriting $x^2 -y^2$ as $(x+y)(x-y)$ a way to avoid catastrophic cancellation? We are still doing $(x-y)$. Is it because the last operation in the second form is a multiplication?
9
votes
2 answers

Avoiding catastrophic cancellation

Dear computational scientists, I have the following formula that I need to rewrite in order to avoid catastrophic cancellation. $y =\sqrt{\frac{1}{2}(1-\sqrt{1-x^{2})}}$ As x becomes smaller $\sqrt{1-x^{2}}$ approaches 1 so you will get 1 -…
6
votes
1 answer

how do you compute $\|c-a\| - \|b-a\|$ without catastrophic cancellation?

Given three points or vectors in the plane: \begin{align} \vec a &= (a_x,a_y) \\ \vec b &= (b_x,b_x) \\ \vec c &= (c_x,c_y) \end{align} How do you compute $\lVert \vec c - \vec a \rVert - \lVert \vec b - \vec a \rVert$, i.e. "how much…
Don Hatch
  • 1,277
5
votes
0 answers

Transforming sum with alternating signs into something less prone to catastrophic cancellation

I'm wrestling with this formula, formally a function of the vector $\pmb{F}$: $$\begin{aligned} S(\pmb{F}) &:=\sum_{a=0}^A (-1)^{A-a}\,\binom{A}{a}\, \Biggl[\sum_{b=0}^{A} F_b \, \binom{a}{b}\Big/\binom{K}{b}\Biggr]^B \\&\equiv \sum_{a=0}^A…
5
votes
1 answer

Explain this amazing cancellation of 4 terms to 40 digits

Define the following four rational numbers. $$ a = \frac{4243257079864535154162785598448178442416}{41016602865234375} \\ b = -\frac{143308384621912247542172258992236503771301}{1210966757832031250} \\ c =…
Jolyon
  • 242
3
votes
2 answers

Explanation for MATLAB floating point number calculation?

I am a beginner studying scientific computation, more specifically floating point numbers and precision in matlab. When testing the outputs of 2 of the following equations, I am not sure how matlab computed the results and why it is computed this…
3
votes
2 answers

Cancellation Problem in Borwein's quartic Algorithm for computing $\pi$

In the center of Borwein's Algorithm from 1985 occurs a term $$T_n = 1-\sqrt[4]{1-y_n^4}$$ with $y_n \to 0_+$. For small $y_n$ you need 4 times the precision of result $T_n$ due to cancellation. With the decomposition $$\sqrt[4]{1-y_n^4} =…
3
votes
1 answer

Avoiding catastrophic cancellation in $1-\operatorname{sinc}x$

When I try to calculate the function $f(x)=1-\operatorname{sinc}x$ for small values of $x$ I get large relative errors due to catastrophic cancellation. I want an accurate way to calculate $f(x)$ without using a series expansion or an iterative…
3
votes
3 answers

Avoiding catastrophic cancellation with $\sqrt{1+x} - 1$ for $x$ close to $0$

I'm trying to figure out how to avoid catastrophic cancellation for the following expression $$\sqrt{1+x} - 1$$ for $x$ being a number very close to $0$. Of course, the answer would come to $0$ unless the expression is changed around. Any…
3
votes
2 answers

Catastrophic cancellation problem: what is the relative error of this computation?

My book has the following problem (which is part of our ungraded homework in numerical analysis): Assume that you are solving the quadratic equation $ax^2 + bx + c = 0$, with $a = 1.22$, $b = 3.34$, $c = 2.28$, using a normalized floating-point…
1
vote
3 answers

Avoid catastrophic cancellation? but I can't see any?

As you can see here, the question is about part b. By using Matlab, the answer to the part a is -2.4, but by using "format long" to compute directly, the answer is -2.401923018799901, which I don't think the cancellation is catastrophic. Bty, I…
1
vote
1 answer

Show this sequence does not approximate $\int_0^1 \frac{x^n}{x+5}dx$ in machine arithmetic

I need a check on the following: Show that the sequence defined as $I_0=\log{\frac65}$, $$I_k + 5 I_{k-1} = \frac1k$$ $k=1,2,\ldots,n$ is not suitable to approximate, for $n$ large the value of the integral $\int_0^1 \frac{x^n}{x+5} dx$ Hint: start…
1
2