\[\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 -10:\\
\;\;\;\;t_0 + \left(t_1 + \frac{-2}{x}\right)\\
\mathbf{elif}\;t_2 \leq 10^{-29}:\\
\;\;\;\;\frac{-4 \cdot {x}^{-2}}{\frac{2}{x} + x \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\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 -10.0)
(+ t_0 (+ t_1 (/ -2.0 x)))
(if (<= t_2 1e-29)
(/ (* -4.0 (pow x -2.0)) (+ (/ 2.0 x) (* x -2.0)))
t_2))))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 <= -10.0) {
tmp = t_0 + (t_1 + (-2.0 / x));
} else if (t_2 <= 1e-29) {
tmp = (-4.0 * pow(x, -2.0)) / ((2.0 / x) + (x * -2.0));
} else {
tmp = t_2;
}
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 <= (-10.0d0)) then
tmp = t_0 + (t_1 + ((-2.0d0) / x))
else if (t_2 <= 1d-29) then
tmp = ((-4.0d0) * (x ** (-2.0d0))) / ((2.0d0 / x) + (x * (-2.0d0)))
else
tmp = t_2
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 <= -10.0) {
tmp = t_0 + (t_1 + (-2.0 / x));
} else if (t_2 <= 1e-29) {
tmp = (-4.0 * Math.pow(x, -2.0)) / ((2.0 / x) + (x * -2.0));
} else {
tmp = t_2;
}
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 <= -10.0:
tmp = t_0 + (t_1 + (-2.0 / x))
elif t_2 <= 1e-29:
tmp = (-4.0 * math.pow(x, -2.0)) / ((2.0 / x) + (x * -2.0))
else:
tmp = t_2
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 <= -10.0)
tmp = Float64(t_0 + Float64(t_1 + Float64(-2.0 / x)));
elseif (t_2 <= 1e-29)
tmp = Float64(Float64(-4.0 * (x ^ -2.0)) / Float64(Float64(2.0 / x) + Float64(x * -2.0)));
else
tmp = t_2;
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 <= -10.0)
tmp = t_0 + (t_1 + (-2.0 / x));
elseif (t_2 <= 1e-29)
tmp = (-4.0 * (x ^ -2.0)) / ((2.0 / x) + (x * -2.0));
else
tmp = t_2;
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, -10.0], N[(t$95$0 + N[(t$95$1 + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e-29], N[(N[(-4.0 * N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 / x), $MachinePrecision] + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\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 -10:\\
\;\;\;\;t_0 + \left(t_1 + \frac{-2}{x}\right)\\
\mathbf{elif}\;t_2 \leq 10^{-29}:\\
\;\;\;\;\frac{-4 \cdot {x}^{-2}}{\frac{2}{x} + x \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.2 |
|---|
| Cost | 6920 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{\frac{-4}{x \cdot x}}{\frac{2}{x} + x \cdot -2}\\
\mathbf{elif}\;x \leq 11500:\\
\;\;\;\;\left(\frac{1}{1 + x} + \frac{-2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{{x}^{3}}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.4 |
|---|
| Cost | 3016 |
|---|
\[\begin{array}{l}
t_0 := \left(\frac{1}{1 + x} + \frac{-2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_0 \leq -10:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 10^{-29}:\\
\;\;\;\;\frac{\frac{-4}{x \cdot x}}{\frac{2}{x} + x \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.4 |
|---|
| Cost | 3016 |
|---|
\[\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 -10:\\
\;\;\;\;t_0 + \left(t_1 + \frac{-2}{x}\right)\\
\mathbf{elif}\;t_2 \leq 10^{-29}:\\
\;\;\;\;\frac{\frac{-4}{x \cdot x}}{\frac{2}{x} + x \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.1 |
|---|
| Cost | 1096 |
|---|
\[\begin{array}{l}
t_0 := \frac{\frac{-4}{x \cdot x}}{\frac{2}{x} + x \cdot -2}\\
\mathbf{if}\;x \leq -0.0001:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\frac{-2}{x} + x \cdot -2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 10.7 |
|---|
| Cost | 840 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{-1}{x} + \frac{1}{x}\\
\mathbf{elif}\;x \leq 0.65:\\
\;\;\;\;\frac{-2}{x} + x \cdot -2\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + -1} + \frac{-1}{x}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 10.6 |
|---|
| Cost | 840 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.65:\\
\;\;\;\;\frac{1}{1 + x} + \frac{-1}{x}\\
\mathbf{elif}\;x \leq 0.65:\\
\;\;\;\;\frac{-2}{x} + x \cdot -2\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + -1} + \frac{-1}{x}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 11.0 |
|---|
| Cost | 712 |
|---|
\[\begin{array}{l}
t_0 := \frac{-1}{x} + \frac{1}{x}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 10.8 |
|---|
| Cost | 712 |
|---|
\[\begin{array}{l}
t_0 := \frac{-1}{x} + \frac{1}{x}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{-2}{x} + x \cdot -2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 15.9 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
t_0 := \frac{-1}{x \cdot x}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+77}:\\
\;\;\;\;1 + \frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 30.8 |
|---|
| Cost | 192 |
|---|
\[\frac{-2}{x}
\]
| Alternative 11 |
|---|
| Error | 61.9 |
|---|
| Cost | 64 |
|---|
\[1
\]