3frac (problem 3.3.3)

Percentage Accurate: 69.1% → 98.9%
Time: 8.8s
Alternatives: 7
Speedup: 1.7×

Specification

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

\\
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\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: 69.1% accurate, 1.0× speedup?

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

\\
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\end{array}

Alternative 1: 98.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ 2 \cdot {x}^{-3} \end{array} \]
(FPCore (x) :precision binary64 (* 2.0 (pow x -3.0)))
double code(double x) {
	return 2.0 * pow(x, -3.0);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 2.0d0 * (x ** (-3.0d0))
end function
public static double code(double x) {
	return 2.0 * Math.pow(x, -3.0);
}
def code(x):
	return 2.0 * math.pow(x, -3.0)
function code(x)
	return Float64(2.0 * (x ^ -3.0))
end
function tmp = code(x)
	tmp = 2.0 * (x ^ -3.0);
end
code[x_] := N[(2.0 * N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
2 \cdot {x}^{-3}
\end{array}
Derivation
  1. Initial program 68.6%

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
  2. Step-by-step derivation
    1. +-commutative68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\frac{1}{x + 1} - \frac{2}{x}\right)} \]
    2. associate-+r-68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) - \frac{2}{x}} \]
    3. sub-neg68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) + \left(-\frac{2}{x}\right)} \]
    4. remove-double-neg68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(-\left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    5. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(0 - \left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    6. associate-+l-68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{0 - \left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    7. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{-\left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    8. distribute-neg-frac268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \color{blue}{\left(-\frac{1}{\left(-x\right) - 1}\right)}\right) + \left(-\frac{2}{x}\right) \]
    9. distribute-frac-neg268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) + \color{blue}{\frac{2}{-x}} \]
    10. associate-+r+68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\left(-\frac{1}{\left(-x\right) - 1}\right) + \frac{2}{-x}\right)} \]
    11. +-commutative68.6%

      \[\leadsto \frac{1}{x - 1} + \color{blue}{\left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right)} \]
    12. remove-double-neg68.6%

      \[\leadsto \color{blue}{\left(-\left(-\frac{1}{x - 1}\right)\right)} + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    13. distribute-neg-frac268.6%

      \[\leadsto \left(-\color{blue}{\frac{1}{-\left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    14. sub0-neg68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{0 - \left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    15. associate-+l-68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(0 - x\right) + 1}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    16. neg-sub068.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(-x\right)} + 1}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
  3. Simplified68.6%

    \[\leadsto \color{blue}{\frac{1}{x + -1} + \left(\frac{-2}{x} - \frac{1}{-1 - x}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 98.4%

    \[\leadsto \color{blue}{\frac{2}{{x}^{3}}} \]
  6. Step-by-step derivation
    1. div-inv98.4%

      \[\leadsto \color{blue}{2 \cdot \frac{1}{{x}^{3}}} \]
    2. pow-flip99.0%

      \[\leadsto 2 \cdot \color{blue}{{x}^{\left(-3\right)}} \]
    3. metadata-eval99.0%

      \[\leadsto 2 \cdot {x}^{\color{blue}{-3}} \]
  7. Applied egg-rr99.0%

    \[\leadsto \color{blue}{2 \cdot {x}^{-3}} \]
  8. Add Preprocessing

Alternative 2: 98.7% accurate, 1.7× speedup?

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

\\
2 \cdot \frac{\frac{\frac{1}{x}}{x}}{x}
\end{array}
Derivation
  1. Initial program 68.6%

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
  2. Step-by-step derivation
    1. +-commutative68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\frac{1}{x + 1} - \frac{2}{x}\right)} \]
    2. associate-+r-68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) - \frac{2}{x}} \]
    3. sub-neg68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) + \left(-\frac{2}{x}\right)} \]
    4. remove-double-neg68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(-\left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    5. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(0 - \left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    6. associate-+l-68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{0 - \left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    7. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{-\left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    8. distribute-neg-frac268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \color{blue}{\left(-\frac{1}{\left(-x\right) - 1}\right)}\right) + \left(-\frac{2}{x}\right) \]
    9. distribute-frac-neg268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) + \color{blue}{\frac{2}{-x}} \]
    10. associate-+r+68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\left(-\frac{1}{\left(-x\right) - 1}\right) + \frac{2}{-x}\right)} \]
    11. +-commutative68.6%

      \[\leadsto \frac{1}{x - 1} + \color{blue}{\left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right)} \]
    12. remove-double-neg68.6%

      \[\leadsto \color{blue}{\left(-\left(-\frac{1}{x - 1}\right)\right)} + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    13. distribute-neg-frac268.6%

      \[\leadsto \left(-\color{blue}{\frac{1}{-\left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    14. sub0-neg68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{0 - \left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    15. associate-+l-68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(0 - x\right) + 1}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    16. neg-sub068.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(-x\right)} + 1}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
  3. Simplified68.6%

    \[\leadsto \color{blue}{\frac{1}{x + -1} + \left(\frac{-2}{x} - \frac{1}{-1 - x}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 98.4%

    \[\leadsto \color{blue}{\frac{2}{{x}^{3}}} \]
  6. Step-by-step derivation
    1. div-inv98.4%

      \[\leadsto \color{blue}{2 \cdot \frac{1}{{x}^{3}}} \]
    2. pow-flip99.0%

      \[\leadsto 2 \cdot \color{blue}{{x}^{\left(-3\right)}} \]
    3. metadata-eval99.0%

      \[\leadsto 2 \cdot {x}^{\color{blue}{-3}} \]
  7. Applied egg-rr99.0%

    \[\leadsto \color{blue}{2 \cdot {x}^{-3}} \]
  8. Step-by-step derivation
    1. metadata-eval99.0%

      \[\leadsto 2 \cdot {x}^{\color{blue}{\left(-1 \cdot 3\right)}} \]
    2. pow-pow98.7%

      \[\leadsto 2 \cdot \color{blue}{{\left({x}^{-1}\right)}^{3}} \]
    3. inv-pow98.7%

      \[\leadsto 2 \cdot {\color{blue}{\left(\frac{1}{x}\right)}}^{3} \]
    4. cube-mult98.7%

      \[\leadsto 2 \cdot \color{blue}{\left(\frac{1}{x} \cdot \left(\frac{1}{x} \cdot \frac{1}{x}\right)\right)} \]
    5. inv-pow98.7%

      \[\leadsto 2 \cdot \left(\frac{1}{x} \cdot \left(\color{blue}{{x}^{-1}} \cdot \frac{1}{x}\right)\right) \]
    6. inv-pow98.7%

      \[\leadsto 2 \cdot \left(\frac{1}{x} \cdot \left({x}^{-1} \cdot \color{blue}{{x}^{-1}}\right)\right) \]
    7. pow-prod-up98.8%

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

      \[\leadsto 2 \cdot \left(\frac{1}{x} \cdot {x}^{\color{blue}{-2}}\right) \]
  9. Applied egg-rr98.8%

    \[\leadsto 2 \cdot \color{blue}{\left(\frac{1}{x} \cdot {x}^{-2}\right)} \]
  10. Step-by-step derivation
    1. associate-*l/98.9%

      \[\leadsto 2 \cdot \color{blue}{\frac{1 \cdot {x}^{-2}}{x}} \]
    2. *-lft-identity98.9%

      \[\leadsto 2 \cdot \frac{\color{blue}{{x}^{-2}}}{x} \]
  11. Simplified98.9%

    \[\leadsto 2 \cdot \color{blue}{\frac{{x}^{-2}}{x}} \]
  12. Step-by-step derivation
    1. metadata-eval98.9%

      \[\leadsto 2 \cdot \frac{{x}^{\color{blue}{\left(-1 - 1\right)}}}{x} \]
    2. pow-div98.9%

      \[\leadsto 2 \cdot \frac{\color{blue}{\frac{{x}^{-1}}{{x}^{1}}}}{x} \]
    3. inv-pow98.9%

      \[\leadsto 2 \cdot \frac{\frac{\color{blue}{\frac{1}{x}}}{{x}^{1}}}{x} \]
    4. pow198.9%

      \[\leadsto 2 \cdot \frac{\frac{\frac{1}{x}}{\color{blue}{x}}}{x} \]
  13. Applied egg-rr98.9%

    \[\leadsto 2 \cdot \frac{\color{blue}{\frac{\frac{1}{x}}{x}}}{x} \]
  14. Add Preprocessing

Alternative 3: 67.9% accurate, 2.1× speedup?

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

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

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
  2. Step-by-step derivation
    1. +-commutative68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\frac{1}{x + 1} - \frac{2}{x}\right)} \]
    2. associate-+r-68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) - \frac{2}{x}} \]
    3. sub-neg68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) + \left(-\frac{2}{x}\right)} \]
    4. remove-double-neg68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(-\left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    5. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(0 - \left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    6. associate-+l-68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{0 - \left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    7. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{-\left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    8. distribute-neg-frac268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \color{blue}{\left(-\frac{1}{\left(-x\right) - 1}\right)}\right) + \left(-\frac{2}{x}\right) \]
    9. distribute-frac-neg268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) + \color{blue}{\frac{2}{-x}} \]
    10. associate-+r+68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\left(-\frac{1}{\left(-x\right) - 1}\right) + \frac{2}{-x}\right)} \]
    11. +-commutative68.6%

      \[\leadsto \frac{1}{x - 1} + \color{blue}{\left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right)} \]
    12. remove-double-neg68.6%

      \[\leadsto \color{blue}{\left(-\left(-\frac{1}{x - 1}\right)\right)} + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    13. distribute-neg-frac268.6%

      \[\leadsto \left(-\color{blue}{\frac{1}{-\left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    14. sub0-neg68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{0 - \left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    15. associate-+l-68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(0 - x\right) + 1}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    16. neg-sub068.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(-x\right)} + 1}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
  3. Simplified68.6%

    \[\leadsto \color{blue}{\frac{1}{x + -1} + \left(\frac{-2}{x} - \frac{1}{-1 - x}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 67.2%

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

    \[\leadsto \color{blue}{\frac{-1}{x}} \]
  7. Step-by-step derivation
    1. expm1-log1p-u5.3%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{-1}{x}\right)\right)} \]
    2. expm1-undefine66.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{-1}{x}\right)} - 1} \]
    3. log1p-undefine66.9%

      \[\leadsto e^{\color{blue}{\log \left(1 + \frac{-1}{x}\right)}} - 1 \]
    4. metadata-eval66.9%

      \[\leadsto e^{\log \left(\color{blue}{\left(--1\right)} + \frac{-1}{x}\right)} - 1 \]
    5. div-inv66.9%

      \[\leadsto e^{\log \left(\left(--1\right) + \color{blue}{-1 \cdot \frac{1}{x}}\right)} - 1 \]
    6. mul-1-neg66.9%

      \[\leadsto e^{\log \left(\left(--1\right) + \color{blue}{\left(-\frac{1}{x}\right)}\right)} - 1 \]
    7. distribute-neg-in66.9%

      \[\leadsto e^{\log \color{blue}{\left(-\left(-1 + \frac{1}{x}\right)\right)}} - 1 \]
    8. add-exp-log66.9%

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

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

      \[\leadsto \left(\color{blue}{1} + \left(-\frac{1}{x}\right)\right) - 1 \]
    11. mul-1-neg66.9%

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

      \[\leadsto \left(1 + \color{blue}{\frac{-1}{x}}\right) - 1 \]
    13. add-sqr-sqrt32.0%

      \[\leadsto \left(1 + \color{blue}{\sqrt{\frac{-1}{x}} \cdot \sqrt{\frac{-1}{x}}}\right) - 1 \]
    14. sqrt-unprod67.2%

      \[\leadsto \left(1 + \color{blue}{\sqrt{\frac{-1}{x} \cdot \frac{-1}{x}}}\right) - 1 \]
    15. frac-times67.2%

      \[\leadsto \left(1 + \sqrt{\color{blue}{\frac{-1 \cdot -1}{x \cdot x}}}\right) - 1 \]
    16. metadata-eval67.2%

      \[\leadsto \left(1 + \sqrt{\frac{\color{blue}{1}}{x \cdot x}}\right) - 1 \]
    17. metadata-eval67.2%

      \[\leadsto \left(1 + \sqrt{\frac{\color{blue}{1 \cdot 1}}{x \cdot x}}\right) - 1 \]
    18. frac-times67.2%

      \[\leadsto \left(1 + \sqrt{\color{blue}{\frac{1}{x} \cdot \frac{1}{x}}}\right) - 1 \]
    19. sqrt-unprod35.2%

      \[\leadsto \left(1 + \color{blue}{\sqrt{\frac{1}{x}} \cdot \sqrt{\frac{1}{x}}}\right) - 1 \]
    20. add-sqr-sqrt67.4%

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

    \[\leadsto \color{blue}{\left(1 + \frac{1}{x}\right) - 1} \]
  9. Step-by-step derivation
    1. associate--l+67.4%

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

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

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

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

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

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

Alternative 4: 6.3% accurate, 5.0× speedup?

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

\\
\frac{1}{x}
\end{array}
Derivation
  1. Initial program 68.6%

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
  2. Step-by-step derivation
    1. +-commutative68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\frac{1}{x + 1} - \frac{2}{x}\right)} \]
    2. associate-+r-68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) - \frac{2}{x}} \]
    3. sub-neg68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) + \left(-\frac{2}{x}\right)} \]
    4. remove-double-neg68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(-\left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    5. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(0 - \left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    6. associate-+l-68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{0 - \left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    7. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{-\left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    8. distribute-neg-frac268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \color{blue}{\left(-\frac{1}{\left(-x\right) - 1}\right)}\right) + \left(-\frac{2}{x}\right) \]
    9. distribute-frac-neg268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) + \color{blue}{\frac{2}{-x}} \]
    10. associate-+r+68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\left(-\frac{1}{\left(-x\right) - 1}\right) + \frac{2}{-x}\right)} \]
    11. +-commutative68.6%

      \[\leadsto \frac{1}{x - 1} + \color{blue}{\left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right)} \]
    12. remove-double-neg68.6%

      \[\leadsto \color{blue}{\left(-\left(-\frac{1}{x - 1}\right)\right)} + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    13. distribute-neg-frac268.6%

      \[\leadsto \left(-\color{blue}{\frac{1}{-\left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    14. sub0-neg68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{0 - \left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    15. associate-+l-68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(0 - x\right) + 1}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    16. neg-sub068.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(-x\right)} + 1}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
  3. Simplified68.6%

    \[\leadsto \color{blue}{\frac{1}{x + -1} + \left(\frac{-2}{x} - \frac{1}{-1 - x}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 67.2%

    \[\leadsto \frac{1}{x + -1} + \color{blue}{\frac{-1}{x}} \]
  6. Step-by-step derivation
    1. +-commutative67.2%

      \[\leadsto \color{blue}{\frac{-1}{x} + \frac{1}{x + -1}} \]
    2. clear-num67.2%

      \[\leadsto \color{blue}{\frac{1}{\frac{x}{-1}}} + \frac{1}{x + -1} \]
    3. frac-2neg67.2%

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

      \[\leadsto \frac{1}{\frac{x}{-1}} + \frac{\color{blue}{-1}}{-\left(x + -1\right)} \]
    5. frac-add67.3%

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

    \[\leadsto \color{blue}{\frac{x + \left(x + 1\right)}{x \cdot \left(x + 1\right)}} \]
  8. Taylor expanded in x around 0 6.6%

    \[\leadsto \color{blue}{\frac{1}{x}} \]
  9. Add Preprocessing

Alternative 5: 5.0% accurate, 5.0× speedup?

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

\\
\frac{-1}{x}
\end{array}
Derivation
  1. Initial program 68.6%

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
  2. Step-by-step derivation
    1. +-commutative68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\frac{1}{x + 1} - \frac{2}{x}\right)} \]
    2. associate-+r-68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) - \frac{2}{x}} \]
    3. sub-neg68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) + \left(-\frac{2}{x}\right)} \]
    4. remove-double-neg68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(-\left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    5. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(0 - \left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    6. associate-+l-68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{0 - \left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    7. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{-\left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    8. distribute-neg-frac268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \color{blue}{\left(-\frac{1}{\left(-x\right) - 1}\right)}\right) + \left(-\frac{2}{x}\right) \]
    9. distribute-frac-neg268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) + \color{blue}{\frac{2}{-x}} \]
    10. associate-+r+68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\left(-\frac{1}{\left(-x\right) - 1}\right) + \frac{2}{-x}\right)} \]
    11. +-commutative68.6%

      \[\leadsto \frac{1}{x - 1} + \color{blue}{\left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right)} \]
    12. remove-double-neg68.6%

      \[\leadsto \color{blue}{\left(-\left(-\frac{1}{x - 1}\right)\right)} + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    13. distribute-neg-frac268.6%

      \[\leadsto \left(-\color{blue}{\frac{1}{-\left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    14. sub0-neg68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{0 - \left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    15. associate-+l-68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(0 - x\right) + 1}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    16. neg-sub068.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(-x\right)} + 1}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
  3. Simplified68.6%

    \[\leadsto \color{blue}{\frac{1}{x + -1} + \left(\frac{-2}{x} - \frac{1}{-1 - x}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 67.2%

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

    \[\leadsto \color{blue}{\frac{-1}{x}} \]
  7. Add Preprocessing

Alternative 6: 5.0% accurate, 5.0× speedup?

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

\\
\frac{-2}{x}
\end{array}
Derivation
  1. Initial program 68.6%

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
  2. Step-by-step derivation
    1. +-commutative68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\frac{1}{x + 1} - \frac{2}{x}\right)} \]
    2. associate-+r-68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) - \frac{2}{x}} \]
    3. sub-neg68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) + \left(-\frac{2}{x}\right)} \]
    4. remove-double-neg68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(-\left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    5. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(0 - \left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    6. associate-+l-68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{0 - \left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    7. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{-\left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    8. distribute-neg-frac268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \color{blue}{\left(-\frac{1}{\left(-x\right) - 1}\right)}\right) + \left(-\frac{2}{x}\right) \]
    9. distribute-frac-neg268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) + \color{blue}{\frac{2}{-x}} \]
    10. associate-+r+68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\left(-\frac{1}{\left(-x\right) - 1}\right) + \frac{2}{-x}\right)} \]
    11. +-commutative68.6%

      \[\leadsto \frac{1}{x - 1} + \color{blue}{\left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right)} \]
    12. remove-double-neg68.6%

      \[\leadsto \color{blue}{\left(-\left(-\frac{1}{x - 1}\right)\right)} + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    13. distribute-neg-frac268.6%

      \[\leadsto \left(-\color{blue}{\frac{1}{-\left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    14. sub0-neg68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{0 - \left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    15. associate-+l-68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(0 - x\right) + 1}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    16. neg-sub068.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(-x\right)} + 1}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
  3. Simplified68.6%

    \[\leadsto \color{blue}{\frac{1}{x + -1} + \left(\frac{-2}{x} - \frac{1}{-1 - x}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 5.3%

    \[\leadsto \color{blue}{\frac{-2}{x}} \]
  6. Add Preprocessing

Alternative 7: 3.4% accurate, 15.0× speedup?

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

\\
1
\end{array}
Derivation
  1. Initial program 68.6%

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1} \]
  2. Step-by-step derivation
    1. +-commutative68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\frac{1}{x + 1} - \frac{2}{x}\right)} \]
    2. associate-+r-68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) - \frac{2}{x}} \]
    3. sub-neg68.5%

      \[\leadsto \color{blue}{\left(\frac{1}{x - 1} + \frac{1}{x + 1}\right) + \left(-\frac{2}{x}\right)} \]
    4. remove-double-neg68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(-\left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    5. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{\left(0 - \left(-x\right)\right)} + 1}\right) + \left(-\frac{2}{x}\right) \]
    6. associate-+l-68.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{0 - \left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    7. neg-sub068.5%

      \[\leadsto \left(\frac{1}{x - 1} + \frac{1}{\color{blue}{-\left(\left(-x\right) - 1\right)}}\right) + \left(-\frac{2}{x}\right) \]
    8. distribute-neg-frac268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \color{blue}{\left(-\frac{1}{\left(-x\right) - 1}\right)}\right) + \left(-\frac{2}{x}\right) \]
    9. distribute-frac-neg268.5%

      \[\leadsto \left(\frac{1}{x - 1} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) + \color{blue}{\frac{2}{-x}} \]
    10. associate-+r+68.6%

      \[\leadsto \color{blue}{\frac{1}{x - 1} + \left(\left(-\frac{1}{\left(-x\right) - 1}\right) + \frac{2}{-x}\right)} \]
    11. +-commutative68.6%

      \[\leadsto \frac{1}{x - 1} + \color{blue}{\left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right)} \]
    12. remove-double-neg68.6%

      \[\leadsto \color{blue}{\left(-\left(-\frac{1}{x - 1}\right)\right)} + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    13. distribute-neg-frac268.6%

      \[\leadsto \left(-\color{blue}{\frac{1}{-\left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    14. sub0-neg68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{0 - \left(x - 1\right)}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    15. associate-+l-68.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(0 - x\right) + 1}}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
    16. neg-sub068.6%

      \[\leadsto \left(-\frac{1}{\color{blue}{\left(-x\right)} + 1}\right) + \left(\frac{2}{-x} + \left(-\frac{1}{\left(-x\right) - 1}\right)\right) \]
  3. Simplified68.6%

    \[\leadsto \color{blue}{\frac{1}{x + -1} + \left(\frac{-2}{x} - \frac{1}{-1 - x}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 3.4%

    \[\leadsto \frac{1}{x + -1} + \color{blue}{\frac{x - 2}{x}} \]
  6. Taylor expanded in x around inf 3.4%

    \[\leadsto \color{blue}{1} \]
  7. Add Preprocessing

Developer Target 1: 99.2% accurate, 1.7× speedup?

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

\\
\frac{2}{x \cdot \left(x \cdot x - 1\right)}
\end{array}

Reproduce

?
herbie shell --seed 2024141 
(FPCore (x)
  :name "3frac (problem 3.3.3)"
  :precision binary64
  :pre (> (fabs x) 1.0)

  :alt
  (! :herbie-platform default (/ 2 (* x (- (* x x) 1))))

  (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))