\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\]
↓
\[\begin{array}{l}
t_0 := \frac{1}{1 + x}\\
t_1 := \frac{1}{x + -1}\\
t_2 := \left(t_0 + \frac{-2}{x}\right) + t_1\\
\mathbf{if}\;t_2 \leq -20:\\
\;\;\;\;t_0 + \left(t_1 + \frac{-2}{x}\right)\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{2}{{x}^{5}} + 2 \cdot \left({x}^{-3} + {x}^{-7}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \frac{\frac{x + \left(x + -1\right) \cdot -2}{x + -1}}{x}\\
\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 (/ 1.0 (+ 1.0 x)))
(t_1 (/ 1.0 (+ x -1.0)))
(t_2 (+ (+ t_0 (/ -2.0 x)) t_1)))
(if (<= t_2 -20.0)
(+ t_0 (+ t_1 (/ -2.0 x)))
(if (<= t_2 5e-8)
(+ (/ 2.0 (pow x 5.0)) (* 2.0 (+ (pow x -3.0) (pow x -7.0))))
(+ t_0 (/ (/ (+ x (* (+ x -1.0) -2.0)) (+ x -1.0)) x))))))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 = 1.0 / (1.0 + x);
double t_1 = 1.0 / (x + -1.0);
double t_2 = (t_0 + (-2.0 / x)) + t_1;
double tmp;
if (t_2 <= -20.0) {
tmp = t_0 + (t_1 + (-2.0 / x));
} else if (t_2 <= 5e-8) {
tmp = (2.0 / pow(x, 5.0)) + (2.0 * (pow(x, -3.0) + pow(x, -7.0)));
} else {
tmp = t_0 + (((x + ((x + -1.0) * -2.0)) / (x + -1.0)) / x);
}
return tmp;
}
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
↓
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 1.0d0 / (1.0d0 + x)
t_1 = 1.0d0 / (x + (-1.0d0))
t_2 = (t_0 + ((-2.0d0) / x)) + t_1
if (t_2 <= (-20.0d0)) then
tmp = t_0 + (t_1 + ((-2.0d0) / x))
else if (t_2 <= 5d-8) then
tmp = (2.0d0 / (x ** 5.0d0)) + (2.0d0 * ((x ** (-3.0d0)) + (x ** (-7.0d0))))
else
tmp = t_0 + (((x + ((x + (-1.0d0)) * (-2.0d0))) / (x + (-1.0d0))) / x)
end if
code = tmp
end function
public static double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
↓
public static double code(double x) {
double t_0 = 1.0 / (1.0 + x);
double t_1 = 1.0 / (x + -1.0);
double t_2 = (t_0 + (-2.0 / x)) + t_1;
double tmp;
if (t_2 <= -20.0) {
tmp = t_0 + (t_1 + (-2.0 / x));
} else if (t_2 <= 5e-8) {
tmp = (2.0 / Math.pow(x, 5.0)) + (2.0 * (Math.pow(x, -3.0) + Math.pow(x, -7.0)));
} else {
tmp = t_0 + (((x + ((x + -1.0) * -2.0)) / (x + -1.0)) / x);
}
return tmp;
}
def code(x):
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0))
↓
def code(x):
t_0 = 1.0 / (1.0 + x)
t_1 = 1.0 / (x + -1.0)
t_2 = (t_0 + (-2.0 / x)) + t_1
tmp = 0
if t_2 <= -20.0:
tmp = t_0 + (t_1 + (-2.0 / x))
elif t_2 <= 5e-8:
tmp = (2.0 / math.pow(x, 5.0)) + (2.0 * (math.pow(x, -3.0) + math.pow(x, -7.0)))
else:
tmp = t_0 + (((x + ((x + -1.0) * -2.0)) / (x + -1.0)) / x)
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(1.0 / Float64(1.0 + x))
t_1 = Float64(1.0 / Float64(x + -1.0))
t_2 = Float64(Float64(t_0 + Float64(-2.0 / x)) + t_1)
tmp = 0.0
if (t_2 <= -20.0)
tmp = Float64(t_0 + Float64(t_1 + Float64(-2.0 / x)));
elseif (t_2 <= 5e-8)
tmp = Float64(Float64(2.0 / (x ^ 5.0)) + Float64(2.0 * Float64((x ^ -3.0) + (x ^ -7.0))));
else
tmp = Float64(t_0 + Float64(Float64(Float64(x + Float64(Float64(x + -1.0) * -2.0)) / Float64(x + -1.0)) / x));
end
return tmp
end
function tmp = code(x)
tmp = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
end
↓
function tmp_2 = code(x)
t_0 = 1.0 / (1.0 + x);
t_1 = 1.0 / (x + -1.0);
t_2 = (t_0 + (-2.0 / x)) + t_1;
tmp = 0.0;
if (t_2 <= -20.0)
tmp = t_0 + (t_1 + (-2.0 / x));
elseif (t_2 <= 5e-8)
tmp = (2.0 / (x ^ 5.0)) + (2.0 * ((x ^ -3.0) + (x ^ -7.0)));
else
tmp = t_0 + (((x + ((x + -1.0) * -2.0)) / (x + -1.0)) / x);
end
tmp_2 = 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[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -20.0], N[(t$95$0 + N[(t$95$1 + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-8], N[(N[(2.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(N[Power[x, -3.0], $MachinePrecision] + N[Power[x, -7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(N[(N[(x + N[(N[(x + -1.0), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]]]]
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
↓
\begin{array}{l}
t_0 := \frac{1}{1 + x}\\
t_1 := \frac{1}{x + -1}\\
t_2 := \left(t_0 + \frac{-2}{x}\right) + t_1\\
\mathbf{if}\;t_2 \leq -20:\\
\;\;\;\;t_0 + \left(t_1 + \frac{-2}{x}\right)\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{2}{{x}^{5}} + 2 \cdot \left({x}^{-3} + {x}^{-7}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \frac{\frac{x + \left(x + -1\right) \cdot -2}{x + -1}}{x}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.5 |
|---|
| Cost | 13640 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -51841659923.4166:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\mathbf{elif}\;x \leq 365.63712801122784:\\
\;\;\;\;\frac{1}{1 + x} + \frac{\frac{x + \left(x + -1\right) \cdot -2}{x + -1}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{{x}^{5}} + \frac{2}{{x}^{3}}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.2 |
|---|
| Cost | 8712 |
|---|
\[\begin{array}{l}
t_0 := \frac{1}{1 + x}\\
t_1 := \left(t_0 + \frac{-2}{x}\right) + \frac{1}{x + -1}\\
t_2 := t_0 + \frac{\frac{x + \left(x + -1\right) \cdot -2}{x + -1}}{x}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-10}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-14}:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.4 |
|---|
| Cost | 8456 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -51841659923.4166:\\
\;\;\;\;2 \cdot {x}^{-3}\\
\mathbf{elif}\;x \leq 365.63712801122784:\\
\;\;\;\;\frac{1}{1 + x} + \frac{\frac{x + \left(x + -1\right) \cdot -2}{x + -1}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-4}{x \cdot x} + \left(\frac{-2}{x} + \frac{-8}{{x}^{3}}\right)}{\left(1 + x\right) \cdot \left(x \cdot \frac{x + -1}{2 - x}\right)}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.4 |
|---|
| Cost | 3016 |
|---|
\[\begin{array}{l}
t_0 := \frac{1}{1 + x}\\
t_1 := \left(t_0 + \frac{-2}{x}\right) + \frac{1}{x + -1}\\
t_2 := t_0 + \frac{\frac{2 - x}{x + -1}}{x}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-10}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{2}{x \cdot \left(x \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 0.6 |
|---|
| Cost | 1480 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -51841659923.4166:\\
\;\;\;\;\frac{\frac{-2}{x}}{\left(1 + x\right) \cdot \left(x \cdot \frac{x + -1}{2 - x}\right)}\\
\mathbf{elif}\;x \leq 13305.34583500944:\\
\;\;\;\;\frac{1}{1 + x} + \frac{\frac{x + \left(x + -1\right) \cdot -2}{x + -1}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{x \cdot \left(x \cdot x\right)}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 0.6 |
|---|
| Cost | 1224 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -51841659923.4166:\\
\;\;\;\;\frac{\frac{-2}{x}}{\left(1 + x\right) \cdot \left(x \cdot \frac{x + -1}{2 - x}\right)}\\
\mathbf{elif}\;x \leq 13305.34583500944:\\
\;\;\;\;\frac{1}{1 + x} + \frac{\frac{2 - x}{x + -1}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{x \cdot \left(x \cdot x\right)}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 0.8 |
|---|
| Cost | 840 |
|---|
\[\begin{array}{l}
t_0 := \frac{2}{x \cdot \left(x \cdot x\right)}\\
\mathbf{if}\;x \leq -1972.7549491055456:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.05591673386039308:\\
\;\;\;\;x \cdot -2 + 2 \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 1.0 |
|---|
| Cost | 712 |
|---|
\[\begin{array}{l}
t_0 := \frac{2}{x \cdot \left(x \cdot x\right)}\\
\mathbf{if}\;x \leq -1972.7549491055456:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.05591673386039308:\\
\;\;\;\;\frac{-2}{x} - x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 31.1 |
|---|
| Cost | 192 |
|---|
\[\frac{-2}{x}
\]
| Alternative 10 |
|---|
| Error | 61.9 |
|---|
| Cost | 64 |
|---|
\[-1
\]