\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\]
↓
\[\begin{array}{l}
t_0 := \frac{x + 1}{x + -1}\\
t_1 := \frac{x + 1}{1 - x}\\
t_2 := \frac{x}{x + 1}\\
t_3 := t_2 + t_0\\
\mathbf{if}\;x \leq -98000000:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 2000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t_3 \ne 0:\\
\;\;\;\;\frac{t_2 \cdot t_2 - t_1 \cdot t_1}{t_3}\\
\mathbf{else}:\\
\;\;\;\;t_2 - t_0\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{-3}{x} - \frac{1}{{x}^{2}}\right) + \left(\left(-\frac{1}{{x}^{4}}\right) + -3 \cdot \frac{1}{{x}^{3}}\right)\\
\end{array}
\]
(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
↓
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (+ x 1.0) (+ x -1.0)))
(t_1 (/ (+ x 1.0) (- 1.0 x)))
(t_2 (/ x (+ x 1.0)))
(t_3 (+ t_2 t_0)))
(if (<= x -98000000.0)
(/ -3.0 x)
(if (<= x 2000.0)
(if (!= t_3 0.0) (/ (- (* t_2 t_2) (* t_1 t_1)) t_3) (- t_2 t_0))
(+
(- (/ -3.0 x) (/ 1.0 (pow x 2.0)))
(+ (- (/ 1.0 (pow x 4.0))) (* -3.0 (/ 1.0 (pow x 3.0)))))))))double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
↓
double code(double x) {
double t_0 = (x + 1.0) / (x + -1.0);
double t_1 = (x + 1.0) / (1.0 - x);
double t_2 = x / (x + 1.0);
double t_3 = t_2 + t_0;
double tmp;
if (x <= -98000000.0) {
tmp = -3.0 / x;
} else if (x <= 2000.0) {
double tmp_1;
if (t_3 != 0.0) {
tmp_1 = ((t_2 * t_2) - (t_1 * t_1)) / t_3;
} else {
tmp_1 = t_2 - t_0;
}
tmp = tmp_1;
} else {
tmp = ((-3.0 / x) - (1.0 / pow(x, 2.0))) + (-(1.0 / pow(x, 4.0)) + (-3.0 * (1.0 / pow(x, 3.0))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x / (x + 1.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) :: t_3
real(8) :: tmp
real(8) :: tmp_1
t_0 = (x + 1.0d0) / (x + (-1.0d0))
t_1 = (x + 1.0d0) / (1.0d0 - x)
t_2 = x / (x + 1.0d0)
t_3 = t_2 + t_0
if (x <= (-98000000.0d0)) then
tmp = (-3.0d0) / x
else if (x <= 2000.0d0) then
if (t_3 /= 0.0d0) then
tmp_1 = ((t_2 * t_2) - (t_1 * t_1)) / t_3
else
tmp_1 = t_2 - t_0
end if
tmp = tmp_1
else
tmp = (((-3.0d0) / x) - (1.0d0 / (x ** 2.0d0))) + (-(1.0d0 / (x ** 4.0d0)) + ((-3.0d0) * (1.0d0 / (x ** 3.0d0))))
end if
code = tmp
end function
public static double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
↓
public static double code(double x) {
double t_0 = (x + 1.0) / (x + -1.0);
double t_1 = (x + 1.0) / (1.0 - x);
double t_2 = x / (x + 1.0);
double t_3 = t_2 + t_0;
double tmp;
if (x <= -98000000.0) {
tmp = -3.0 / x;
} else if (x <= 2000.0) {
double tmp_1;
if (t_3 != 0.0) {
tmp_1 = ((t_2 * t_2) - (t_1 * t_1)) / t_3;
} else {
tmp_1 = t_2 - t_0;
}
tmp = tmp_1;
} else {
tmp = ((-3.0 / x) - (1.0 / Math.pow(x, 2.0))) + (-(1.0 / Math.pow(x, 4.0)) + (-3.0 * (1.0 / Math.pow(x, 3.0))));
}
return tmp;
}
def code(x):
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))
↓
def code(x):
t_0 = (x + 1.0) / (x + -1.0)
t_1 = (x + 1.0) / (1.0 - x)
t_2 = x / (x + 1.0)
t_3 = t_2 + t_0
tmp = 0
if x <= -98000000.0:
tmp = -3.0 / x
elif x <= 2000.0:
tmp_1 = 0
if t_3 != 0.0:
tmp_1 = ((t_2 * t_2) - (t_1 * t_1)) / t_3
else:
tmp_1 = t_2 - t_0
tmp = tmp_1
else:
tmp = ((-3.0 / x) - (1.0 / math.pow(x, 2.0))) + (-(1.0 / math.pow(x, 4.0)) + (-3.0 * (1.0 / math.pow(x, 3.0))))
return tmp
function code(x)
return Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0)))
end
↓
function code(x)
t_0 = Float64(Float64(x + 1.0) / Float64(x + -1.0))
t_1 = Float64(Float64(x + 1.0) / Float64(1.0 - x))
t_2 = Float64(x / Float64(x + 1.0))
t_3 = Float64(t_2 + t_0)
tmp = 0.0
if (x <= -98000000.0)
tmp = Float64(-3.0 / x);
elseif (x <= 2000.0)
tmp_1 = 0.0
if (t_3 != 0.0)
tmp_1 = Float64(Float64(Float64(t_2 * t_2) - Float64(t_1 * t_1)) / t_3);
else
tmp_1 = Float64(t_2 - t_0);
end
tmp = tmp_1;
else
tmp = Float64(Float64(Float64(-3.0 / x) - Float64(1.0 / (x ^ 2.0))) + Float64(Float64(-Float64(1.0 / (x ^ 4.0))) + Float64(-3.0 * Float64(1.0 / (x ^ 3.0)))));
end
return tmp
end
function tmp = code(x)
tmp = (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
end
↓
function tmp_3 = code(x)
t_0 = (x + 1.0) / (x + -1.0);
t_1 = (x + 1.0) / (1.0 - x);
t_2 = x / (x + 1.0);
t_3 = t_2 + t_0;
tmp = 0.0;
if (x <= -98000000.0)
tmp = -3.0 / x;
elseif (x <= 2000.0)
tmp_2 = 0.0;
if (t_3 ~= 0.0)
tmp_2 = ((t_2 * t_2) - (t_1 * t_1)) / t_3;
else
tmp_2 = t_2 - t_0;
end
tmp = tmp_2;
else
tmp = ((-3.0 / x) - (1.0 / (x ^ 2.0))) + (-(1.0 / (x ^ 4.0)) + (-3.0 * (1.0 / (x ^ 3.0))));
end
tmp_3 = tmp;
end
code[x_] := N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
↓
code[x_] := Block[{t$95$0 = N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + 1.0), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 + t$95$0), $MachinePrecision]}, If[LessEqual[x, -98000000.0], N[(-3.0 / x), $MachinePrecision], If[LessEqual[x, 2000.0], If[Unequal[t$95$3, 0.0], N[(N[(N[(t$95$2 * t$95$2), $MachinePrecision] - N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision], N[(t$95$2 - t$95$0), $MachinePrecision]], N[(N[(N[(-3.0 / x), $MachinePrecision] - N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[((-N[(1.0 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]) + N[(-3.0 * N[(1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
↓
\begin{array}{l}
t_0 := \frac{x + 1}{x + -1}\\
t_1 := \frac{x + 1}{1 - x}\\
t_2 := \frac{x}{x + 1}\\
t_3 := t_2 + t_0\\
\mathbf{if}\;x \leq -98000000:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 2000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t_3 \ne 0:\\
\;\;\;\;\frac{t_2 \cdot t_2 - t_1 \cdot t_1}{t_3}\\
\mathbf{else}:\\
\;\;\;\;t_2 - t_0\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{-3}{x} - \frac{1}{{x}^{2}}\right) + \left(\left(-\frac{1}{{x}^{4}}\right) + -3 \cdot \frac{1}{{x}^{3}}\right)\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.3 |
|---|
| Cost | 9168 |
|---|
\[\begin{array}{l}
t_0 := \frac{x + 1}{x + -1}\\
t_1 := t_0 \cdot t_0\\
t_2 := \frac{x}{x + 1}\\
t_3 := t_2 \cdot t_2\\
t_4 := t_3 + t_1\\
t_5 := t_2 + t_0\\
\mathbf{if}\;x \leq -280000000:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 160000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t_5 \ne 0:\\
\;\;\;\;\frac{\begin{array}{l}
\mathbf{if}\;t_4 \ne 0:\\
\;\;\;\;\frac{t_2 \cdot \frac{\frac{x \cdot x}{x + 1} \cdot x}{\left(x + 1\right) \cdot \left(x + 1\right)} - t_1 \cdot t_1}{t_4}\\
\mathbf{else}:\\
\;\;\;\;t_3 - t_1\\
\end{array}}{t_5}\\
\mathbf{else}:\\
\;\;\;\;t_2 - t_0\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\frac{-3}{x}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.3 |
|---|
| Cost | 8016 |
|---|
\[\begin{array}{l}
t_0 := \frac{x + 1}{x + -1}\\
t_1 := \frac{x}{-1 - x}\\
t_2 := \frac{x + 1}{1 - x}\\
t_3 := t_2 \cdot \left(-t_2\right)\\
t_4 := \frac{x}{x + 1}\\
t_5 := t_4 + t_0\\
t_6 := \frac{-1 - x}{x + -1}\\
t_7 := t_6 \cdot t_6\\
\mathbf{if}\;x \leq -90000000:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 160000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t_5 \ne 0:\\
\;\;\;\;\frac{\begin{array}{l}
\mathbf{if}\;t_3 \ne 0:\\
\;\;\;\;\frac{t_7 \cdot t_7 - t_7 \cdot \left(t_1 \cdot t_1\right)}{t_3}\\
\mathbf{else}:\\
\;\;\;\;t_4 \cdot t_4 - t_0 \cdot t_0\\
\end{array}}{t_5}\\
\mathbf{else}:\\
\;\;\;\;t_4 - t_0\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\frac{-3}{x}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.3 |
|---|
| Cost | 3788 |
|---|
\[\begin{array}{l}
t_0 := \frac{x + 1}{x + -1}\\
t_1 := \frac{x + 1}{1 - x}\\
t_2 := \frac{x}{x + 1}\\
t_3 := t_2 + t_0\\
\mathbf{if}\;x \leq -98000000:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 170000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t_3 \ne 0:\\
\;\;\;\;\frac{t_2 \cdot t_2 - t_1 \cdot t_1}{t_3}\\
\mathbf{else}:\\
\;\;\;\;t_2 - t_0\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\frac{-3}{x}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.3 |
|---|
| Cost | 3788 |
|---|
\[\begin{array}{l}
t_0 := \frac{x + 1}{x + -1}\\
t_1 := \frac{x + 1}{1 - x}\\
t_2 := \frac{x}{x + 1}\\
t_3 := t_2 + t_0\\
\mathbf{if}\;x \leq -124000000:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 165000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t_3 \ne 0:\\
\;\;\;\;\frac{\frac{\frac{x \cdot x}{x + 1}}{x + 1} - t_1 \cdot t_1}{t_3}\\
\mathbf{else}:\\
\;\;\;\;t_2 - t_0\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\frac{-3}{x}\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 0.3 |
|---|
| Cost | 1096 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -115000000:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 165000000:\\
\;\;\;\;\frac{x}{x + 1} - \frac{x + 1}{x - 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{-3}{x}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 0.9 |
|---|
| Cost | 712 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x - \left(-2 \cdot x - 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-3}{x}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 0.9 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;1 - x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;\frac{-3}{x}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 1.3 |
|---|
| Cost | 456 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x - -1\\
\mathbf{else}:\\
\;\;\;\;\frac{-3}{x}\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 31.9 |
|---|
| Cost | 64 |
|---|
\[1
\]