ENA, Section 1.4, Mentioned, B

Percentage Accurate: 87.7% → 99.6%
Time: 19.2s
Alternatives: 7
Speedup: 1.0×

Specification

?
\[0.999 \leq x \land x \leq 1.001\]
\[\begin{array}{l} \\ \frac{10}{1 - x \cdot x} \end{array} \]
(FPCore (x) :precision binary64 (/ 10.0 (- 1.0 (* x x))))
double code(double x) {
	return 10.0 / (1.0 - (x * x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 10.0d0 / (1.0d0 - (x * x))
end function
public static double code(double x) {
	return 10.0 / (1.0 - (x * x));
}
def code(x):
	return 10.0 / (1.0 - (x * x))
function code(x)
	return Float64(10.0 / Float64(1.0 - Float64(x * x)))
end
function tmp = code(x)
	tmp = 10.0 / (1.0 - (x * x));
end
code[x_] := N[(10.0 / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{10}{1 - x \cdot x}
\end{array}

Sampling outcomes in binary64 precision:

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.

Accuracy vs Speed?

Herbie found 7 alternatives:

AlternativeAccuracySpeedup
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.

Initial Program: 87.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{10}{1 - x \cdot x} \end{array} \]
(FPCore (x) :precision binary64 (/ 10.0 (- 1.0 (* x x))))
double code(double x) {
	return 10.0 / (1.0 - (x * x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 10.0d0 / (1.0d0 - (x * x))
end function
public static double code(double x) {
	return 10.0 / (1.0 - (x * x));
}
def code(x):
	return 10.0 / (1.0 - (x * x))
function code(x)
	return Float64(10.0 / Float64(1.0 - Float64(x * x)))
end
function tmp = code(x)
	tmp = 10.0 / (1.0 - (x * x));
end
code[x_] := N[(10.0 / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{10}{1 - x \cdot x}
\end{array}

Alternative 1: 99.6% accurate, 0.1× speedup?

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

\\
\frac{-10}{\mathsf{fma}\left(x, x, -1\right)}
\end{array}
Derivation
  1. Initial program 87.9%

    \[\frac{10}{1 - x \cdot x} \]
  2. Step-by-step derivation
    1. sqr-neg87.9%

      \[\leadsto \frac{10}{1 - \color{blue}{\left(-x\right) \cdot \left(-x\right)}} \]
    2. remove-double-neg87.9%

      \[\leadsto \color{blue}{-\left(-\frac{10}{1 - \left(-x\right) \cdot \left(-x\right)}\right)} \]
    3. distribute-neg-frac87.9%

      \[\leadsto -\color{blue}{\frac{-10}{1 - \left(-x\right) \cdot \left(-x\right)}} \]
    4. distribute-frac-neg287.9%

      \[\leadsto \color{blue}{\frac{-10}{-\left(1 - \left(-x\right) \cdot \left(-x\right)\right)}} \]
    5. metadata-eval87.9%

      \[\leadsto \frac{\color{blue}{-10}}{-\left(1 - \left(-x\right) \cdot \left(-x\right)\right)} \]
    6. neg-sub087.9%

      \[\leadsto \frac{-10}{\color{blue}{0 - \left(1 - \left(-x\right) \cdot \left(-x\right)\right)}} \]
    7. associate--r-87.9%

      \[\leadsto \frac{-10}{\color{blue}{\left(0 - 1\right) + \left(-x\right) \cdot \left(-x\right)}} \]
    8. metadata-eval87.9%

      \[\leadsto \frac{-10}{\color{blue}{-1} + \left(-x\right) \cdot \left(-x\right)} \]
    9. +-commutative87.9%

      \[\leadsto \frac{-10}{\color{blue}{\left(-x\right) \cdot \left(-x\right) + -1}} \]
    10. sqr-neg87.9%

      \[\leadsto \frac{-10}{\color{blue}{x \cdot x} + -1} \]
    11. fma-define99.6%

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

    \[\leadsto \color{blue}{\frac{-10}{\mathsf{fma}\left(x, x, -1\right)}} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 99.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \frac{-10}{\left(x + -1\right) + x \cdot \left(x + -1\right)} \end{array} \]
(FPCore (x) :precision binary64 (/ -10.0 (+ (+ x -1.0) (* x (+ x -1.0)))))
double code(double x) {
	return -10.0 / ((x + -1.0) + (x * (x + -1.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (-10.0d0) / ((x + (-1.0d0)) + (x * (x + (-1.0d0))))
end function
public static double code(double x) {
	return -10.0 / ((x + -1.0) + (x * (x + -1.0)));
}
def code(x):
	return -10.0 / ((x + -1.0) + (x * (x + -1.0)))
function code(x)
	return Float64(-10.0 / Float64(Float64(x + -1.0) + Float64(x * Float64(x + -1.0))))
end
function tmp = code(x)
	tmp = -10.0 / ((x + -1.0) + (x * (x + -1.0)));
end
code[x_] := N[(-10.0 / N[(N[(x + -1.0), $MachinePrecision] + N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-10}{\left(x + -1\right) + x \cdot \left(x + -1\right)}
\end{array}
Derivation
  1. Initial program 87.9%

    \[\frac{10}{1 - x \cdot x} \]
  2. Step-by-step derivation
    1. sqr-neg87.9%

      \[\leadsto \frac{10}{1 - \color{blue}{\left(-x\right) \cdot \left(-x\right)}} \]
    2. remove-double-neg87.9%

      \[\leadsto \color{blue}{-\left(-\frac{10}{1 - \left(-x\right) \cdot \left(-x\right)}\right)} \]
    3. distribute-neg-frac87.9%

      \[\leadsto -\color{blue}{\frac{-10}{1 - \left(-x\right) \cdot \left(-x\right)}} \]
    4. distribute-frac-neg287.9%

      \[\leadsto \color{blue}{\frac{-10}{-\left(1 - \left(-x\right) \cdot \left(-x\right)\right)}} \]
    5. metadata-eval87.9%

      \[\leadsto \frac{\color{blue}{-10}}{-\left(1 - \left(-x\right) \cdot \left(-x\right)\right)} \]
    6. neg-sub087.9%

      \[\leadsto \frac{-10}{\color{blue}{0 - \left(1 - \left(-x\right) \cdot \left(-x\right)\right)}} \]
    7. associate--r-87.9%

      \[\leadsto \frac{-10}{\color{blue}{\left(0 - 1\right) + \left(-x\right) \cdot \left(-x\right)}} \]
    8. metadata-eval87.9%

      \[\leadsto \frac{-10}{\color{blue}{-1} + \left(-x\right) \cdot \left(-x\right)} \]
    9. +-commutative87.9%

      \[\leadsto \frac{-10}{\color{blue}{\left(-x\right) \cdot \left(-x\right) + -1}} \]
    10. sqr-neg87.9%

      \[\leadsto \frac{-10}{\color{blue}{x \cdot x} + -1} \]
    11. fma-define99.6%

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

    \[\leadsto \color{blue}{\frac{-10}{\mathsf{fma}\left(x, x, -1\right)}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-undefine87.9%

      \[\leadsto \frac{-10}{\color{blue}{x \cdot x + -1}} \]
    2. difference-of-sqr--199.4%

      \[\leadsto \frac{-10}{\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
  6. Applied egg-rr99.4%

    \[\leadsto \frac{-10}{\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
  7. Step-by-step derivation
    1. *-commutative99.4%

      \[\leadsto \frac{-10}{\color{blue}{\left(x - 1\right) \cdot \left(x + 1\right)}} \]
    2. +-commutative99.4%

      \[\leadsto \frac{-10}{\left(x - 1\right) \cdot \color{blue}{\left(1 + x\right)}} \]
    3. distribute-lft-in99.5%

      \[\leadsto \frac{-10}{\color{blue}{\left(x - 1\right) \cdot 1 + \left(x - 1\right) \cdot x}} \]
    4. *-commutative99.5%

      \[\leadsto \frac{-10}{\color{blue}{1 \cdot \left(x - 1\right)} + \left(x - 1\right) \cdot x} \]
    5. *-un-lft-identity99.5%

      \[\leadsto \frac{-10}{\color{blue}{\left(x - 1\right)} + \left(x - 1\right) \cdot x} \]
    6. sub-neg99.5%

      \[\leadsto \frac{-10}{\color{blue}{\left(x + \left(-1\right)\right)} + \left(x - 1\right) \cdot x} \]
    7. metadata-eval99.5%

      \[\leadsto \frac{-10}{\left(x + \color{blue}{-1}\right) + \left(x - 1\right) \cdot x} \]
    8. sub-neg99.5%

      \[\leadsto \frac{-10}{\left(x + -1\right) + \color{blue}{\left(x + \left(-1\right)\right)} \cdot x} \]
    9. metadata-eval99.5%

      \[\leadsto \frac{-10}{\left(x + -1\right) + \left(x + \color{blue}{-1}\right) \cdot x} \]
  8. Applied egg-rr99.5%

    \[\leadsto \frac{-10}{\color{blue}{\left(x + -1\right) + \left(x + -1\right) \cdot x}} \]
  9. Final simplification99.5%

    \[\leadsto \frac{-10}{\left(x + -1\right) + x \cdot \left(x + -1\right)} \]
  10. Add Preprocessing

Alternative 3: 99.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \frac{\frac{-10}{x + -1}}{x + 1} \end{array} \]
(FPCore (x) :precision binary64 (/ (/ -10.0 (+ x -1.0)) (+ x 1.0)))
double code(double x) {
	return (-10.0 / (x + -1.0)) / (x + 1.0);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = ((-10.0d0) / (x + (-1.0d0))) / (x + 1.0d0)
end function
public static double code(double x) {
	return (-10.0 / (x + -1.0)) / (x + 1.0);
}
def code(x):
	return (-10.0 / (x + -1.0)) / (x + 1.0)
function code(x)
	return Float64(Float64(-10.0 / Float64(x + -1.0)) / Float64(x + 1.0))
end
function tmp = code(x)
	tmp = (-10.0 / (x + -1.0)) / (x + 1.0);
end
code[x_] := N[(N[(-10.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{-10}{x + -1}}{x + 1}
\end{array}
Derivation
  1. Initial program 87.9%

    \[\frac{10}{1 - x \cdot x} \]
  2. Step-by-step derivation
    1. sqr-neg87.9%

      \[\leadsto \frac{10}{1 - \color{blue}{\left(-x\right) \cdot \left(-x\right)}} \]
    2. remove-double-neg87.9%

      \[\leadsto \color{blue}{-\left(-\frac{10}{1 - \left(-x\right) \cdot \left(-x\right)}\right)} \]
    3. distribute-neg-frac87.9%

      \[\leadsto -\color{blue}{\frac{-10}{1 - \left(-x\right) \cdot \left(-x\right)}} \]
    4. distribute-frac-neg287.9%

      \[\leadsto \color{blue}{\frac{-10}{-\left(1 - \left(-x\right) \cdot \left(-x\right)\right)}} \]
    5. metadata-eval87.9%

      \[\leadsto \frac{\color{blue}{-10}}{-\left(1 - \left(-x\right) \cdot \left(-x\right)\right)} \]
    6. neg-sub087.9%

      \[\leadsto \frac{-10}{\color{blue}{0 - \left(1 - \left(-x\right) \cdot \left(-x\right)\right)}} \]
    7. associate--r-87.9%

      \[\leadsto \frac{-10}{\color{blue}{\left(0 - 1\right) + \left(-x\right) \cdot \left(-x\right)}} \]
    8. metadata-eval87.9%

      \[\leadsto \frac{-10}{\color{blue}{-1} + \left(-x\right) \cdot \left(-x\right)} \]
    9. +-commutative87.9%

      \[\leadsto \frac{-10}{\color{blue}{\left(-x\right) \cdot \left(-x\right) + -1}} \]
    10. sqr-neg87.9%

      \[\leadsto \frac{-10}{\color{blue}{x \cdot x} + -1} \]
    11. fma-define99.6%

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

    \[\leadsto \color{blue}{\frac{-10}{\mathsf{fma}\left(x, x, -1\right)}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. frac-2neg99.6%

      \[\leadsto \color{blue}{\frac{--10}{-\mathsf{fma}\left(x, x, -1\right)}} \]
    2. metadata-eval99.6%

      \[\leadsto \frac{\color{blue}{10}}{-\mathsf{fma}\left(x, x, -1\right)} \]
    3. div-inv99.5%

      \[\leadsto \color{blue}{10 \cdot \frac{1}{-\mathsf{fma}\left(x, x, -1\right)}} \]
    4. fma-undefine87.9%

      \[\leadsto 10 \cdot \frac{1}{-\color{blue}{\left(x \cdot x + -1\right)}} \]
    5. distribute-neg-in87.9%

      \[\leadsto 10 \cdot \frac{1}{\color{blue}{\left(-x \cdot x\right) + \left(--1\right)}} \]
    6. metadata-eval87.9%

      \[\leadsto 10 \cdot \frac{1}{\left(-x \cdot x\right) + \color{blue}{1}} \]
    7. +-commutative87.9%

      \[\leadsto 10 \cdot \frac{1}{\color{blue}{1 + \left(-x \cdot x\right)}} \]
    8. sub-neg87.9%

      \[\leadsto 10 \cdot \frac{1}{\color{blue}{1 - x \cdot x}} \]
    9. *-commutative87.9%

      \[\leadsto \color{blue}{\frac{1}{1 - x \cdot x} \cdot 10} \]
  6. Applied egg-rr99.5%

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

      \[\leadsto \frac{-10}{\color{blue}{x \cdot x + -1}} \]
    2. difference-of-sqr--199.4%

      \[\leadsto \frac{-10}{\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
  8. Applied egg-rr99.4%

    \[\leadsto \frac{-1}{\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}} \cdot 10 \]
  9. Step-by-step derivation
    1. metadata-eval99.4%

      \[\leadsto \frac{-1}{\left(x + 1\right) \cdot \left(x - 1\right)} \cdot \color{blue}{{10}^{1}} \]
    2. metadata-eval99.4%

      \[\leadsto \frac{-1}{\left(x + 1\right) \cdot \left(x - 1\right)} \cdot {10}^{\color{blue}{\left(\frac{2}{2}\right)}} \]
    3. sqrt-pow298.4%

      \[\leadsto \frac{-1}{\left(x + 1\right) \cdot \left(x - 1\right)} \cdot \color{blue}{{\left(\sqrt{10}\right)}^{2}} \]
    4. associate-*l/98.4%

      \[\leadsto \color{blue}{\frac{-1 \cdot {\left(\sqrt{10}\right)}^{2}}{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
    5. sqrt-pow299.4%

      \[\leadsto \frac{-1 \cdot \color{blue}{{10}^{\left(\frac{2}{2}\right)}}}{\left(x + 1\right) \cdot \left(x - 1\right)} \]
    6. metadata-eval99.4%

      \[\leadsto \frac{-1 \cdot {10}^{\color{blue}{1}}}{\left(x + 1\right) \cdot \left(x - 1\right)} \]
    7. metadata-eval99.4%

      \[\leadsto \frac{-1 \cdot \color{blue}{10}}{\left(x + 1\right) \cdot \left(x - 1\right)} \]
    8. metadata-eval99.4%

      \[\leadsto \frac{\color{blue}{-10}}{\left(x + 1\right) \cdot \left(x - 1\right)} \]
    9. *-commutative99.4%

      \[\leadsto \frac{-10}{\color{blue}{\left(x - 1\right) \cdot \left(x + 1\right)}} \]
    10. associate-/r*99.4%

      \[\leadsto \color{blue}{\frac{\frac{-10}{x - 1}}{x + 1}} \]
    11. sub-neg99.4%

      \[\leadsto \frac{\frac{-10}{\color{blue}{x + \left(-1\right)}}}{x + 1} \]
    12. metadata-eval99.4%

      \[\leadsto \frac{\frac{-10}{x + \color{blue}{-1}}}{x + 1} \]
  10. Applied egg-rr99.4%

    \[\leadsto \color{blue}{\frac{\frac{-10}{x + -1}}{x + 1}} \]
  11. Add Preprocessing

Alternative 4: 99.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \frac{-10}{\left(x + -1\right) \cdot \left(x + 1\right)} \end{array} \]
(FPCore (x) :precision binary64 (/ -10.0 (* (+ x -1.0) (+ x 1.0))))
double code(double x) {
	return -10.0 / ((x + -1.0) * (x + 1.0));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (-10.0d0) / ((x + (-1.0d0)) * (x + 1.0d0))
end function
public static double code(double x) {
	return -10.0 / ((x + -1.0) * (x + 1.0));
}
def code(x):
	return -10.0 / ((x + -1.0) * (x + 1.0))
function code(x)
	return Float64(-10.0 / Float64(Float64(x + -1.0) * Float64(x + 1.0)))
end
function tmp = code(x)
	tmp = -10.0 / ((x + -1.0) * (x + 1.0));
end
code[x_] := N[(-10.0 / N[(N[(x + -1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-10}{\left(x + -1\right) \cdot \left(x + 1\right)}
\end{array}
Derivation
  1. Initial program 87.9%

    \[\frac{10}{1 - x \cdot x} \]
  2. Step-by-step derivation
    1. sqr-neg87.9%

      \[\leadsto \frac{10}{1 - \color{blue}{\left(-x\right) \cdot \left(-x\right)}} \]
    2. remove-double-neg87.9%

      \[\leadsto \color{blue}{-\left(-\frac{10}{1 - \left(-x\right) \cdot \left(-x\right)}\right)} \]
    3. distribute-neg-frac87.9%

      \[\leadsto -\color{blue}{\frac{-10}{1 - \left(-x\right) \cdot \left(-x\right)}} \]
    4. distribute-frac-neg287.9%

      \[\leadsto \color{blue}{\frac{-10}{-\left(1 - \left(-x\right) \cdot \left(-x\right)\right)}} \]
    5. metadata-eval87.9%

      \[\leadsto \frac{\color{blue}{-10}}{-\left(1 - \left(-x\right) \cdot \left(-x\right)\right)} \]
    6. neg-sub087.9%

      \[\leadsto \frac{-10}{\color{blue}{0 - \left(1 - \left(-x\right) \cdot \left(-x\right)\right)}} \]
    7. associate--r-87.9%

      \[\leadsto \frac{-10}{\color{blue}{\left(0 - 1\right) + \left(-x\right) \cdot \left(-x\right)}} \]
    8. metadata-eval87.9%

      \[\leadsto \frac{-10}{\color{blue}{-1} + \left(-x\right) \cdot \left(-x\right)} \]
    9. +-commutative87.9%

      \[\leadsto \frac{-10}{\color{blue}{\left(-x\right) \cdot \left(-x\right) + -1}} \]
    10. sqr-neg87.9%

      \[\leadsto \frac{-10}{\color{blue}{x \cdot x} + -1} \]
    11. fma-define99.6%

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

    \[\leadsto \color{blue}{\frac{-10}{\mathsf{fma}\left(x, x, -1\right)}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-undefine87.9%

      \[\leadsto \frac{-10}{\color{blue}{x \cdot x + -1}} \]
    2. difference-of-sqr--199.4%

      \[\leadsto \frac{-10}{\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
  6. Applied egg-rr99.4%

    \[\leadsto \frac{-10}{\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
  7. Final simplification99.4%

    \[\leadsto \frac{-10}{\left(x + -1\right) \cdot \left(x + 1\right)} \]
  8. Add Preprocessing

Alternative 5: 87.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{10}{1 - x \cdot x} \end{array} \]
(FPCore (x) :precision binary64 (/ 10.0 (- 1.0 (* x x))))
double code(double x) {
	return 10.0 / (1.0 - (x * x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 10.0d0 / (1.0d0 - (x * x))
end function
public static double code(double x) {
	return 10.0 / (1.0 - (x * x));
}
def code(x):
	return 10.0 / (1.0 - (x * x))
function code(x)
	return Float64(10.0 / Float64(1.0 - Float64(x * x)))
end
function tmp = code(x)
	tmp = 10.0 / (1.0 - (x * x));
end
code[x_] := N[(10.0 / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{10}{1 - x \cdot x}
\end{array}
Derivation
  1. Initial program 87.9%

    \[\frac{10}{1 - x \cdot x} \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 6: 18.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \frac{-10}{x + -1} \end{array} \]
(FPCore (x) :precision binary64 (/ -10.0 (+ x -1.0)))
double code(double x) {
	return -10.0 / (x + -1.0);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (-10.0d0) / (x + (-1.0d0))
end function
public static double code(double x) {
	return -10.0 / (x + -1.0);
}
def code(x):
	return -10.0 / (x + -1.0)
function code(x)
	return Float64(-10.0 / Float64(x + -1.0))
end
function tmp = code(x)
	tmp = -10.0 / (x + -1.0);
end
code[x_] := N[(-10.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{-10}{x + -1}
\end{array}
Derivation
  1. Initial program 87.9%

    \[\frac{10}{1 - x \cdot x} \]
  2. Step-by-step derivation
    1. sqr-neg87.9%

      \[\leadsto \frac{10}{1 - \color{blue}{\left(-x\right) \cdot \left(-x\right)}} \]
    2. remove-double-neg87.9%

      \[\leadsto \color{blue}{-\left(-\frac{10}{1 - \left(-x\right) \cdot \left(-x\right)}\right)} \]
    3. distribute-neg-frac87.9%

      \[\leadsto -\color{blue}{\frac{-10}{1 - \left(-x\right) \cdot \left(-x\right)}} \]
    4. distribute-frac-neg287.9%

      \[\leadsto \color{blue}{\frac{-10}{-\left(1 - \left(-x\right) \cdot \left(-x\right)\right)}} \]
    5. metadata-eval87.9%

      \[\leadsto \frac{\color{blue}{-10}}{-\left(1 - \left(-x\right) \cdot \left(-x\right)\right)} \]
    6. neg-sub087.9%

      \[\leadsto \frac{-10}{\color{blue}{0 - \left(1 - \left(-x\right) \cdot \left(-x\right)\right)}} \]
    7. associate--r-87.9%

      \[\leadsto \frac{-10}{\color{blue}{\left(0 - 1\right) + \left(-x\right) \cdot \left(-x\right)}} \]
    8. metadata-eval87.9%

      \[\leadsto \frac{-10}{\color{blue}{-1} + \left(-x\right) \cdot \left(-x\right)} \]
    9. +-commutative87.9%

      \[\leadsto \frac{-10}{\color{blue}{\left(-x\right) \cdot \left(-x\right) + -1}} \]
    10. sqr-neg87.9%

      \[\leadsto \frac{-10}{\color{blue}{x \cdot x} + -1} \]
    11. fma-define99.6%

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

    \[\leadsto \color{blue}{\frac{-10}{\mathsf{fma}\left(x, x, -1\right)}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. frac-2neg99.6%

      \[\leadsto \color{blue}{\frac{--10}{-\mathsf{fma}\left(x, x, -1\right)}} \]
    2. metadata-eval99.6%

      \[\leadsto \frac{\color{blue}{10}}{-\mathsf{fma}\left(x, x, -1\right)} \]
    3. div-inv99.5%

      \[\leadsto \color{blue}{10 \cdot \frac{1}{-\mathsf{fma}\left(x, x, -1\right)}} \]
    4. fma-undefine87.9%

      \[\leadsto 10 \cdot \frac{1}{-\color{blue}{\left(x \cdot x + -1\right)}} \]
    5. distribute-neg-in87.9%

      \[\leadsto 10 \cdot \frac{1}{\color{blue}{\left(-x \cdot x\right) + \left(--1\right)}} \]
    6. metadata-eval87.9%

      \[\leadsto 10 \cdot \frac{1}{\left(-x \cdot x\right) + \color{blue}{1}} \]
    7. +-commutative87.9%

      \[\leadsto 10 \cdot \frac{1}{\color{blue}{1 + \left(-x \cdot x\right)}} \]
    8. sub-neg87.9%

      \[\leadsto 10 \cdot \frac{1}{\color{blue}{1 - x \cdot x}} \]
    9. *-commutative87.9%

      \[\leadsto \color{blue}{\frac{1}{1 - x \cdot x} \cdot 10} \]
  6. Applied egg-rr99.5%

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

      \[\leadsto \frac{-10}{\color{blue}{x \cdot x + -1}} \]
    2. difference-of-sqr--199.4%

      \[\leadsto \frac{-10}{\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
  8. Applied egg-rr99.4%

    \[\leadsto \frac{-1}{\color{blue}{\left(x + 1\right) \cdot \left(x - 1\right)}} \cdot 10 \]
  9. Step-by-step derivation
    1. metadata-eval99.4%

      \[\leadsto \frac{-1}{\left(x + 1\right) \cdot \left(x - 1\right)} \cdot \color{blue}{{10}^{1}} \]
    2. metadata-eval99.4%

      \[\leadsto \frac{-1}{\left(x + 1\right) \cdot \left(x - 1\right)} \cdot {10}^{\color{blue}{\left(\frac{2}{2}\right)}} \]
    3. sqrt-pow298.4%

      \[\leadsto \frac{-1}{\left(x + 1\right) \cdot \left(x - 1\right)} \cdot \color{blue}{{\left(\sqrt{10}\right)}^{2}} \]
    4. associate-*l/98.4%

      \[\leadsto \color{blue}{\frac{-1 \cdot {\left(\sqrt{10}\right)}^{2}}{\left(x + 1\right) \cdot \left(x - 1\right)}} \]
    5. sqrt-pow299.4%

      \[\leadsto \frac{-1 \cdot \color{blue}{{10}^{\left(\frac{2}{2}\right)}}}{\left(x + 1\right) \cdot \left(x - 1\right)} \]
    6. metadata-eval99.4%

      \[\leadsto \frac{-1 \cdot {10}^{\color{blue}{1}}}{\left(x + 1\right) \cdot \left(x - 1\right)} \]
    7. metadata-eval99.4%

      \[\leadsto \frac{-1 \cdot \color{blue}{10}}{\left(x + 1\right) \cdot \left(x - 1\right)} \]
    8. metadata-eval99.4%

      \[\leadsto \frac{\color{blue}{-10}}{\left(x + 1\right) \cdot \left(x - 1\right)} \]
    9. associate-/r*99.4%

      \[\leadsto \color{blue}{\frac{\frac{-10}{x + 1}}{x - 1}} \]
    10. sub-neg99.4%

      \[\leadsto \frac{\frac{-10}{x + 1}}{\color{blue}{x + \left(-1\right)}} \]
    11. metadata-eval99.4%

      \[\leadsto \frac{\frac{-10}{x + 1}}{x + \color{blue}{-1}} \]
  10. Applied egg-rr99.4%

    \[\leadsto \color{blue}{\frac{\frac{-10}{x + 1}}{x + -1}} \]
  11. Taylor expanded in x around 0 18.8%

    \[\leadsto \frac{\color{blue}{-10}}{x + -1} \]
  12. Add Preprocessing

Alternative 7: 9.5% accurate, 7.0× speedup?

\[\begin{array}{l} \\ 10 \end{array} \]
(FPCore (x) :precision binary64 10.0)
double code(double x) {
	return 10.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 10.0d0
end function
public static double code(double x) {
	return 10.0;
}
def code(x):
	return 10.0
function code(x)
	return 10.0
end
function tmp = code(x)
	tmp = 10.0;
end
code[x_] := 10.0
\begin{array}{l}

\\
10
\end{array}
Derivation
  1. Initial program 87.9%

    \[\frac{10}{1 - x \cdot x} \]
  2. Step-by-step derivation
    1. sqr-neg87.9%

      \[\leadsto \frac{10}{1 - \color{blue}{\left(-x\right) \cdot \left(-x\right)}} \]
    2. remove-double-neg87.9%

      \[\leadsto \color{blue}{-\left(-\frac{10}{1 - \left(-x\right) \cdot \left(-x\right)}\right)} \]
    3. distribute-neg-frac87.9%

      \[\leadsto -\color{blue}{\frac{-10}{1 - \left(-x\right) \cdot \left(-x\right)}} \]
    4. distribute-frac-neg287.9%

      \[\leadsto \color{blue}{\frac{-10}{-\left(1 - \left(-x\right) \cdot \left(-x\right)\right)}} \]
    5. metadata-eval87.9%

      \[\leadsto \frac{\color{blue}{-10}}{-\left(1 - \left(-x\right) \cdot \left(-x\right)\right)} \]
    6. neg-sub087.9%

      \[\leadsto \frac{-10}{\color{blue}{0 - \left(1 - \left(-x\right) \cdot \left(-x\right)\right)}} \]
    7. associate--r-87.9%

      \[\leadsto \frac{-10}{\color{blue}{\left(0 - 1\right) + \left(-x\right) \cdot \left(-x\right)}} \]
    8. metadata-eval87.9%

      \[\leadsto \frac{-10}{\color{blue}{-1} + \left(-x\right) \cdot \left(-x\right)} \]
    9. +-commutative87.9%

      \[\leadsto \frac{-10}{\color{blue}{\left(-x\right) \cdot \left(-x\right) + -1}} \]
    10. sqr-neg87.9%

      \[\leadsto \frac{-10}{\color{blue}{x \cdot x} + -1} \]
    11. fma-define99.6%

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

    \[\leadsto \color{blue}{\frac{-10}{\mathsf{fma}\left(x, x, -1\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 9.5%

    \[\leadsto \color{blue}{10} \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 2024143 
(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))))