\[\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 -5 \cdot 10^{-21}:\\
\;\;\;\;\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)}\\
\mathbf{elif}\;t_1 \leq 4 \cdot 10^{-25}:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, x\right) + \left(x + -1\right) \cdot \left(-2 - x\right)}{\mathsf{fma}\left(x, x, x\right) \cdot \left(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 -5e-21)
(/
(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)))
(if (<= t_1 4e-25)
(* 2.0 (pow x -3.0))
(/
(+ (fma x x x) (* (+ x -1.0) (- -2.0 x)))
(* (fma x x x) (+ 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 <= -5e-21) {
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));
} else if (t_1 <= 4e-25) {
tmp = 2.0 * pow(x, -3.0);
} else {
tmp = (fma(x, x, x) + ((x + -1.0) * (-2.0 - x))) / (fma(x, x, x) * (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 <= -5e-21)
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)));
elseif (t_1 <= 4e-25)
tmp = Float64(2.0 * (x ^ -3.0));
else
tmp = Float64(Float64(fma(x, x, x) + Float64(Float64(x + -1.0) * Float64(-2.0 - x))) / Float64(fma(x, x, x) * Float64(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, -5e-21], 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], If[LessEqual[t$95$1, 4e-25], N[(2.0 * N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x + x), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] * N[(-2.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x + x), $MachinePrecision] * N[(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 -5 \cdot 10^{-21}:\\
\;\;\;\;\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)}\\
\mathbf{elif}\;t_1 \leq 4 \cdot 10^{-25}:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, x\right) + \left(x + -1\right) \cdot \left(-2 - x\right)}{\mathsf{fma}\left(x, x, x\right) \cdot \left(x + -1\right)}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.0 |
|---|
| Cost | 16072 |
|---|
\[\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(-2 - x\right)}{\mathsf{fma}\left(x, x, x\right) \cdot \left(x + -1\right)}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{-21}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 4 \cdot 10^{-25}:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.3 |
|---|
| Cost | 13508 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2573.6638080274306:\\
\;\;\;\;\frac{2}{{x}^{5}} + \frac{2}{{x}^{3}}\\
\mathbf{elif}\;x \leq 561.973078342743:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\frac{-2 - x}{1 + x}, x + -1, x\right)}{x}}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.1 |
|---|
| Cost | 7752 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2573.6638080274306:\\
\;\;\;\;\frac{\frac{\frac{2}{x} + \frac{\frac{2}{x} + -2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{elif}\;x \leq 561.973078342743:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{-2 - x}{1 + x}, x + -1, x\right)}{x \cdot x - x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.1 |
|---|
| Cost | 7752 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2573.6638080274306:\\
\;\;\;\;\frac{\frac{\frac{2}{x} + \frac{\frac{2}{x} + -2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{elif}\;x \leq 561.973078342743:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\frac{-2 - x}{1 + x}, x + -1, x\right)}{x}}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 0.2 |
|---|
| Cost | 6920 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -6885790.316889787:\\
\;\;\;\;\frac{\frac{\frac{2}{x} + \frac{\frac{2}{x} + -2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{elif}\;x \leq 561.973078342743:\\
\;\;\;\;\frac{1}{x + -1} + \frac{\frac{-2 - x}{1 + x}}{x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 0.3 |
|---|
| Cost | 3400 |
|---|
\[\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 -1 \cdot 10^{-10}:\\
\;\;\;\;t_0 + \frac{\frac{-2 - x}{1 + x}}{x}\\
\mathbf{elif}\;t_1 \leq 4 \cdot 10^{-25}:\\
\;\;\;\;\frac{\frac{\frac{2}{x} + \frac{\frac{2}{x} + -2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;t_0 + \left(x + 2 \cdot \left(-1 - x\right)\right) \cdot \frac{1}{x \cdot \left(1 + x\right)}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 0.3 |
|---|
| 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{\frac{-2 - x}{1 + x}}{x}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-10}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 4 \cdot 10^{-25}:\\
\;\;\;\;\frac{\frac{\frac{2}{x} + \frac{\frac{2}{x} + -2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 0.3 |
|---|
| Cost | 3016 |
|---|
\[\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{\frac{-2 - x}{1 + x}}{x}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-10}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 4 \cdot 10^{-25}:\\
\;\;\;\;\frac{\frac{\frac{2}{x} + \frac{-2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 1.2 |
|---|
| Cost | 1096 |
|---|
\[\begin{array}{l}
t_0 := \frac{\frac{2 + \frac{-2}{x}}{x \cdot x}}{x + -1}\\
\mathbf{if}\;x \leq -32.65887040153858:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.687349769880901 \cdot 10^{-12}:\\
\;\;\;\;\frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 1.2 |
|---|
| Cost | 1096 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -32.65887040153858:\\
\;\;\;\;\frac{\frac{\frac{2}{x} + \frac{-2}{x \cdot x}}{x}}{x + -1}\\
\mathbf{elif}\;x \leq 7.687349769880901 \cdot 10^{-12}:\\
\;\;\;\;\frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2 + \frac{-2}{x}}{x \cdot x}}{x + -1}\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 1.4 |
|---|
| Cost | 840 |
|---|
\[\begin{array}{l}
t_0 := \frac{\frac{2}{x \cdot x}}{x + -1}\\
\mathbf{if}\;x \leq -32.65887040153858:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.687349769880901 \cdot 10^{-12}:\\
\;\;\;\;\frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 1.4 |
|---|
| Cost | 840 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -32.65887040153858:\\
\;\;\;\;\frac{\frac{\frac{2}{x}}{x}}{x + -1}\\
\mathbf{elif}\;x \leq 7.687349769880901 \cdot 10^{-12}:\\
\;\;\;\;\frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{x \cdot x}}{x + -1}\\
\end{array}
\]
| Alternative 13 |
|---|
| Error | 15.9 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
t_0 := \frac{\frac{-1}{x}}{x}\\
\mathbf{if}\;x \leq -32.65887040153858:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.687349769880901 \cdot 10^{-12}:\\
\;\;\;\;\frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 14 |
|---|
| Error | 15.6 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
t_0 := \frac{-1}{x \cdot x}\\
\mathbf{if}\;x \leq -32.65887040153858:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.687349769880901 \cdot 10^{-12}:\\
\;\;\;\;\frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 15 |
|---|
| Error | 15.9 |
|---|
| Cost | 448 |
|---|
\[\frac{\frac{2}{x}}{x + -1}
\]
| Alternative 16 |
|---|
| Error | 61.8 |
|---|
| Cost | 192 |
|---|
\[\frac{1}{x}
\]
| Alternative 17 |
|---|
| Error | 30.5 |
|---|
| Cost | 192 |
|---|
\[\frac{-2}{x}
\]