\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\]
↓
\[\begin{array}{l}
t_0 := x \cdot \left(1 + x\right)\\
t_1 := \left(\frac{1}{1 + x} + \frac{-2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-10}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, x\right) + \left(x + -1\right) \cdot \left(x - \mathsf{fma}\left(x, 2, 2\right)\right)}{\mathsf{fma}\left(x, x, x\right) \cdot \left(x + -1\right)}\\
\mathbf{elif}\;t_1 \leq 10^{-12}:\\
\;\;\;\;2 \cdot \left({x}^{-5} + {x}^{-3}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1, t_0, \mathsf{fma}\left(-1, x, 1\right) \cdot \left(x + 2 \cdot \left(-1 - x\right)\right)\right)}{t_0 \cdot \mathsf{fma}\left(-1, x, 1\right)}\\
\end{array}
\]
(FPCore (x)
:precision binary64
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
↓
(FPCore (x)
:precision binary64
(let* ((t_0 (* x (+ 1.0 x)))
(t_1 (+ (+ (/ 1.0 (+ 1.0 x)) (/ -2.0 x)) (/ 1.0 (+ x -1.0)))))
(if (<= t_1 -2e-10)
(/
(+ (fma x x x) (* (+ x -1.0) (- x (fma x 2.0 2.0))))
(* (fma x x x) (+ x -1.0)))
(if (<= t_1 1e-12)
(* 2.0 (+ (pow x -5.0) (pow x -3.0)))
(/
(fma -1.0 t_0 (* (fma -1.0 x 1.0) (+ x (* 2.0 (- -1.0 x)))))
(* t_0 (fma -1.0 x 1.0)))))))double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
↓
double code(double x) {
double t_0 = x * (1.0 + x);
double t_1 = ((1.0 / (1.0 + x)) + (-2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if (t_1 <= -2e-10) {
tmp = (fma(x, x, x) + ((x + -1.0) * (x - fma(x, 2.0, 2.0)))) / (fma(x, x, x) * (x + -1.0));
} else if (t_1 <= 1e-12) {
tmp = 2.0 * (pow(x, -5.0) + pow(x, -3.0));
} else {
tmp = fma(-1.0, t_0, (fma(-1.0, x, 1.0) * (x + (2.0 * (-1.0 - x))))) / (t_0 * fma(-1.0, x, 1.0));
}
return tmp;
}
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 code(x)
t_0 = Float64(x * Float64(1.0 + x))
t_1 = Float64(Float64(Float64(1.0 / Float64(1.0 + x)) + Float64(-2.0 / x)) + Float64(1.0 / Float64(x + -1.0)))
tmp = 0.0
if (t_1 <= -2e-10)
tmp = Float64(Float64(fma(x, x, x) + Float64(Float64(x + -1.0) * Float64(x - fma(x, 2.0, 2.0)))) / Float64(fma(x, x, x) * Float64(x + -1.0)));
elseif (t_1 <= 1e-12)
tmp = Float64(2.0 * Float64((x ^ -5.0) + (x ^ -3.0)));
else
tmp = Float64(fma(-1.0, t_0, Float64(fma(-1.0, x, 1.0) * Float64(x + Float64(2.0 * Float64(-1.0 - x))))) / Float64(t_0 * fma(-1.0, x, 1.0)));
end
return tmp
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]
↓
code[x_] := Block[{t$95$0 = N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-10], N[(N[(N[(x * x + x), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] * N[(x - N[(x * 2.0 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x + x), $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-12], N[(2.0 * N[(N[Power[x, -5.0], $MachinePrecision] + N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * t$95$0 + N[(N[(-1.0 * x + 1.0), $MachinePrecision] * N[(x + N[(2.0 * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[(-1.0 * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
↓
\begin{array}{l}
t_0 := x \cdot \left(1 + x\right)\\
t_1 := \left(\frac{1}{1 + x} + \frac{-2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-10}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, x\right) + \left(x + -1\right) \cdot \left(x - \mathsf{fma}\left(x, 2, 2\right)\right)}{\mathsf{fma}\left(x, x, x\right) \cdot \left(x + -1\right)}\\
\mathbf{elif}\;t_1 \leq 10^{-12}:\\
\;\;\;\;2 \cdot \left({x}^{-5} + {x}^{-3}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1, t_0, \mathsf{fma}\left(-1, x, 1\right) \cdot \left(x + 2 \cdot \left(-1 - x\right)\right)\right)}{t_0 \cdot \mathsf{fma}\left(-1, x, 1\right)}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.0 |
|---|
| Cost | 22600 |
|---|
\[\begin{array}{l}
t_0 := \left(\frac{1}{1 + x} + \frac{-2}{x}\right) + \frac{1}{x + -1}\\
t_1 := \frac{\mathsf{fma}\left(x, x, x\right) + \left(x + -1\right) \cdot \left(x - \mathsf{fma}\left(x, 2, 2\right)\right)}{\mathsf{fma}\left(x, x, x\right) \cdot \left(x + -1\right)}\\
\mathbf{if}\;t_0 \leq -2 \cdot 10^{-10}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 10^{-12}:\\
\;\;\;\;2 \cdot \left({x}^{-5} + {x}^{-3}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.3 |
|---|
| Cost | 20360 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1972.7549491055456:\\
\;\;\;\;2 \cdot \left({x}^{-5} + {x}^{-3}\right)\\
\mathbf{elif}\;x \leq 0.05591673386039308:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\frac{x - \mathsf{fma}\left(x, 2, 2\right)}{1 + x}, x + -1, x\right)}{x}}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{2}{{x}^{3}} + \frac{2}{{x}^{7}}\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.2 |
|---|
| Cost | 16072 |
|---|
\[\begin{array}{l}
t_0 := \left(\frac{1}{1 + x} + \frac{-2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_0 \leq -20:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 10^{-12}:\\
\;\;\;\;2 \cdot \left({x}^{-5} + {x}^{-3}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\frac{x - \mathsf{fma}\left(x, 2, 2\right)}{1 + x}, x + -1, x\right)}{x}}{x + -1}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.2 |
|---|
| Cost | 15304 |
|---|
\[\begin{array}{l}
t_0 := \left(\frac{1}{1 + x} + \frac{-2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_0 \leq -20:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 10^{-12}:\\
\;\;\;\;2 \cdot \left({x}^{-5} + {x}^{-3}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\frac{-2 - x}{1 + x}, x + -1, x\right)}{x}}{x + -1}\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 0.5 |
|---|
| Cost | 7752 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -51841659923.4166:\\
\;\;\;\;\frac{\frac{\frac{2}{x} + \frac{-2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{elif}\;x \leq 365.63712801122784:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\frac{-2 - x}{1 + x}, x + -1, x\right)}{x}}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{{x}^{5}} + \frac{2}{x \cdot \left(x \cdot x\right)}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 0.5 |
|---|
| Cost | 7432 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -51841659923.4166:\\
\;\;\;\;\frac{\frac{\frac{2}{x} + \frac{-2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{elif}\;x \leq 365.63712801122784:\\
\;\;\;\;\frac{1}{x + -1} + \frac{x + 2 \cdot \left(-1 - x\right)}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{{x}^{5}} + \frac{2}{x \cdot \left(x \cdot x\right)}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 0.2 |
|---|
| Cost | 3272 |
|---|
\[\begin{array}{l}
t_0 := \frac{1}{x + -1}\\
t_1 := \left(\frac{1}{1 + x} + \frac{-2}{x}\right) + t_0\\
t_2 := t_0 + \frac{x + 2 \cdot \left(-1 - x\right)}{x \cdot \left(1 + x\right)}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-10}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{\frac{2}{x} + \frac{-2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 0.2 |
|---|
| Cost | 3144 |
|---|
\[\begin{array}{l}
t_0 := \frac{1}{x + -1}\\
t_1 := \left(\frac{1}{1 + x} + \frac{-2}{x}\right) + t_0\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-10}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{\frac{2}{x} + \frac{-2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-2 - x\right) \cdot \frac{1}{x \cdot \left(1 + x\right)}\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 0.2 |
|---|
| Cost | 3144 |
|---|
\[\begin{array}{l}
t_0 := \frac{1}{x + -1}\\
t_1 := \left(\frac{1}{1 + x} + \frac{-2}{x}\right) + t_0\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{x + \left(x + -1\right) \cdot \frac{-2 - x}{1 + x}}{x}}{x + -1}\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{\frac{\frac{2}{x} + \frac{-2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(-2 - x\right) \cdot \frac{1}{x \cdot \left(1 + x\right)}\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 0.7 |
|---|
| Cost | 1224 |
|---|
\[\begin{array}{l}
t_0 := \frac{\frac{\frac{2}{x} + \frac{-2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{if}\;x \leq -1972.7549491055456:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.05591673386039308:\\
\;\;\;\;x \cdot -2 + \frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 0.5 |
|---|
| Cost | 1224 |
|---|
\[\begin{array}{l}
t_0 := \frac{\frac{\frac{2}{x} + \frac{-2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{if}\;x \leq -51841659923.4166:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 365.63712801122784:\\
\;\;\;\;\frac{1}{x + -1} + \frac{\frac{-2 - x}{1 + x}}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 0.5 |
|---|
| Cost | 1224 |
|---|
\[\begin{array}{l}
t_0 := \frac{\frac{\frac{2}{x} + \frac{-2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{if}\;x \leq -51841659923.4166:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 365.63712801122784:\\
\;\;\;\;\left(\frac{1}{1 + x} + \frac{-2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 13 |
|---|
| Error | 0.7 |
|---|
| Cost | 1096 |
|---|
\[\begin{array}{l}
t_0 := \frac{\frac{2 + \frac{-2}{x}}{x \cdot x}}{x + -1}\\
\mathbf{if}\;x \leq -1972.7549491055456:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.05591673386039308:\\
\;\;\;\;x \cdot -2 + \frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 14 |
|---|
| Error | 1.0 |
|---|
| Cost | 840 |
|---|
\[\begin{array}{l}
t_0 := \frac{\frac{2}{x \cdot x}}{x + -1}\\
\mathbf{if}\;x \leq -1972.7549491055456:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.05591673386039308:\\
\;\;\;\;x \cdot -2 + \frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 15 |
|---|
| Error | 1.0 |
|---|
| Cost | 840 |
|---|
\[\begin{array}{l}
t_0 := \frac{\frac{\frac{2}{x}}{x}}{x + -1}\\
\mathbf{if}\;x \leq -1972.7549491055456:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.05591673386039308:\\
\;\;\;\;x \cdot -2 + \frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 16 |
|---|
| Error | 15.9 |
|---|
| Cost | 448 |
|---|
\[\frac{\frac{2}{x}}{x + -1}
\]
| Alternative 17 |
|---|
| Error | 10.6 |
|---|
| Cost | 448 |
|---|
\[-1 + \left(1 + \frac{-2}{x}\right)
\]
| Alternative 18 |
|---|
| Error | 31.1 |
|---|
| Cost | 192 |
|---|
\[\frac{-2}{x}
\]
| Alternative 19 |
|---|
| Error | 61.9 |
|---|
| Cost | 64 |
|---|
\[1
\]