\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\]
↓
\[\frac{\frac{\frac{2}{x}}{1 + x}}{-1 + x}
\]
(FPCore (x)
:precision binary64
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
↓
(FPCore (x) :precision binary64 (/ (/ (/ 2.0 x) (+ 1.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) {
return ((2.0 / x) / (1.0 + x)) / (-1.0 + x);
}
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
code = ((2.0d0 / x) / (1.0d0 + x)) / ((-1.0d0) + x)
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) {
return ((2.0 / x) / (1.0 + x)) / (-1.0 + x);
}
def code(x):
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0))
↓
def code(x):
return ((2.0 / x) / (1.0 + x)) / (-1.0 + x)
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)
return Float64(Float64(Float64(2.0 / x) / Float64(1.0 + x)) / Float64(-1.0 + x))
end
function tmp = code(x)
tmp = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
end
↓
function tmp = code(x)
tmp = ((2.0 / x) / (1.0 + x)) / (-1.0 + x);
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_] := N[(N[(N[(2.0 / x), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(-1.0 + x), $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
↓
\frac{\frac{\frac{2}{x}}{1 + x}}{-1 + x}
Alternatives
| Alternative 1 |
|---|
| Error | 1.1 |
|---|
| Cost | 840 |
|---|
\[\begin{array}{l}
t_0 := \frac{2}{\left(x \cdot \left(x + -1\right)\right) \cdot x}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.85:\\
\;\;\;\;\frac{-2}{x} - \left(x + x\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 1.0 |
|---|
| Cost | 840 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{2}{\left(x \cdot \left(x + -1\right)\right) \cdot x}\\
\mathbf{elif}\;x \leq 0.85:\\
\;\;\;\;\frac{-2}{x} - \left(x + x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-2}{x}}{\left(1 - x\right) \cdot x}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 1.0 |
|---|
| Cost | 840 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{2}{\left(x \cdot \left(x + -1\right)\right) \cdot x}\\
\mathbf{elif}\;x \leq 0.85:\\
\;\;\;\;\frac{-2}{x} - \left(x + x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-2}{1 - x}}{x \cdot x}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 14.8 |
|---|
| Cost | 712 |
|---|
\[\begin{array}{l}
t_0 := \frac{-1}{x \cdot x}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{-2}{x} - \left(x + x\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 10.1 |
|---|
| Cost | 712 |
|---|
\[\begin{array}{l}
t_0 := \frac{2}{x} - \frac{2}{x}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{-2}{x} - \left(x + x\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 10.1 |
|---|
| Cost | 712 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.65:\\
\;\;\;\;\frac{-1}{-1 - x} + \frac{-1}{x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{-2}{x} - \left(x + x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{x} - \frac{2}{x}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 0.3 |
|---|
| Cost | 704 |
|---|
\[\frac{2}{\left(x \cdot \left(-1 + x\right)\right) \cdot \left(1 + x\right)}
\]
| Alternative 8 |
|---|
| Error | 15.0 |
|---|
| Cost | 648 |
|---|
\[\begin{array}{l}
t_0 := \frac{-1}{x \cdot x}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\left(-x\right) + \frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 15.0 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
t_0 := \frac{-1}{x \cdot x}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.37:\\
\;\;\;\;\frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 30.5 |
|---|
| Cost | 192 |
|---|
\[\frac{-2}{x}
\]
| Alternative 11 |
|---|
| Error | 61.9 |
|---|
| Cost | 64 |
|---|
\[-1
\]