ENA, Section 1.4, Mentioned, B

?

Percentage Accurate: 87.7% → 99.6%
Time: 4.7s
Precision: binary64
Cost: 6720

?

\[0.999 \leq x \land x \leq 1.001\]
\[\frac{10}{1 - x \cdot x} \]
\[\frac{-10}{\mathsf{fma}\left(x, x, -1\right)} \]
(FPCore (x) :precision binary64 (/ 10.0 (- 1.0 (* x x))))
(FPCore (x) :precision binary64 (/ -10.0 (fma x x -1.0)))
double code(double x) {
	return 10.0 / (1.0 - (x * x));
}
double code(double x) {
	return -10.0 / fma(x, x, -1.0);
}
function code(x)
	return Float64(10.0 / Float64(1.0 - Float64(x * x)))
end
function code(x)
	return Float64(-10.0 / fma(x, x, -1.0))
end
code[x_] := N[(10.0 / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(-10.0 / N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision]
\frac{10}{1 - x \cdot x}
\frac{-10}{\mathsf{fma}\left(x, x, -1\right)}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 5 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Bogosity?

Bogosity

Derivation?

  1. Initial program 87.6%

    \[\frac{10}{1 - x \cdot x} \]
  2. Simplified99.6%

    \[\leadsto \color{blue}{\frac{-10}{\mathsf{fma}\left(x, x, -1\right)}} \]
    Step-by-step derivation

    [Start]87.6%

    \[ \frac{10}{1 - x \cdot x} \]

    sub-neg [=>]87.6%

    \[ \frac{10}{\color{blue}{1 + \left(-x \cdot x\right)}} \]

    +-commutative [=>]87.6%

    \[ \frac{10}{\color{blue}{\left(-x \cdot x\right) + 1}} \]

    neg-sub0 [=>]87.6%

    \[ \frac{10}{\color{blue}{\left(0 - x \cdot x\right)} + 1} \]

    associate-+l- [=>]87.6%

    \[ \frac{10}{\color{blue}{0 - \left(x \cdot x - 1\right)}} \]

    sub0-neg [=>]87.6%

    \[ \frac{10}{\color{blue}{-\left(x \cdot x - 1\right)}} \]

    neg-mul-1 [=>]87.6%

    \[ \frac{10}{\color{blue}{-1 \cdot \left(x \cdot x - 1\right)}} \]

    associate-/r* [=>]87.6%

    \[ \color{blue}{\frac{\frac{10}{-1}}{x \cdot x - 1}} \]

    metadata-eval [=>]87.6%

    \[ \frac{\color{blue}{-10}}{x \cdot x - 1} \]

    fma-neg [=>]99.6%

    \[ \frac{-10}{\color{blue}{\mathsf{fma}\left(x, x, -1\right)}} \]

    metadata-eval [=>]99.6%

    \[ \frac{-10}{\mathsf{fma}\left(x, x, \color{blue}{-1}\right)} \]
  3. Final simplification99.6%

    \[\leadsto \frac{-10}{\mathsf{fma}\left(x, x, -1\right)} \]

Alternatives

Alternative 1
Accuracy99.6%
Cost6720
\[\frac{-10}{\mathsf{fma}\left(x, x, -1\right)} \]
Alternative 2
Accuracy13.5%
Cost580
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 1:\\ \;\;\;\;10\\ \mathbf{else}:\\ \;\;\;\;\frac{-10}{x \cdot x}\\ \end{array} \]
Alternative 3
Accuracy87.7%
Cost576
\[\frac{1}{1 - x \cdot x} \cdot 10 \]
Alternative 4
Accuracy87.7%
Cost448
\[\frac{10}{1 - x \cdot x} \]
Alternative 5
Accuracy9.5%
Cost64
\[10 \]

Reproduce?

herbie shell --seed 2023178 
(FPCore (x)
  :name "ENA, Section 1.4, Mentioned, B"
  :precision binary64
  :pre (and (<= 0.999 x) (<= x 1.001))
  (/ 10.0 (- 1.0 (* x x))))