
(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x / (x + 1.0d0)) - ((x + 1.0d0) / (x - 1.0d0))
end function
public static double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
def code(x): return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))
function code(x) return Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) end
function tmp = code(x) tmp = (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0)); 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]
\begin{array}{l}
\\
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x / (x + 1.0d0)) - ((x + 1.0d0) / (x - 1.0d0))
end function
public static double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
def code(x): return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))
function code(x) return Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) end
function tmp = code(x) tmp = (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0)); 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]
\begin{array}{l}
\\
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))) (t_1 (/ (+ x 1.0) (+ x -1.0))))
(if (<= (- t_0 t_1) 0.0001)
(+
(/ -3.0 (pow x 3.0))
(- (+ (/ -1.0 (pow x 2.0)) (/ -1.0 (pow x 4.0))) (/ 3.0 x)))
(fma
(- (pow t_0 2.0) (pow t_1 2.0))
(/ 1.0 (+ t_0 t_1))
(fma (/ -1.0 (+ x -1.0)) (+ x 1.0) t_1)))))
double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / (x + -1.0);
double tmp;
if ((t_0 - t_1) <= 0.0001) {
tmp = (-3.0 / pow(x, 3.0)) + (((-1.0 / pow(x, 2.0)) + (-1.0 / pow(x, 4.0))) - (3.0 / x));
} else {
tmp = fma((pow(t_0, 2.0) - pow(t_1, 2.0)), (1.0 / (t_0 + t_1)), fma((-1.0 / (x + -1.0)), (x + 1.0), t_1));
}
return tmp;
}
function code(x) t_0 = Float64(x / Float64(x + 1.0)) t_1 = Float64(Float64(x + 1.0) / Float64(x + -1.0)) tmp = 0.0 if (Float64(t_0 - t_1) <= 0.0001) tmp = Float64(Float64(-3.0 / (x ^ 3.0)) + Float64(Float64(Float64(-1.0 / (x ^ 2.0)) + Float64(-1.0 / (x ^ 4.0))) - Float64(3.0 / x))); else tmp = fma(Float64((t_0 ^ 2.0) - (t_1 ^ 2.0)), Float64(1.0 / Float64(t_0 + t_1)), fma(Float64(-1.0 / Float64(x + -1.0)), Float64(x + 1.0), t_1)); end return tmp end
code[x_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], 0.0001], N[(N[(-3.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(3.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(t$95$0 + t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] * N[(x + 1.0), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := \frac{x + 1}{x + -1}\\
\mathbf{if}\;t\_0 - t\_1 \leq 0.0001:\\
\;\;\;\;\frac{-3}{{x}^{3}} + \left(\left(\frac{-1}{{x}^{2}} + \frac{-1}{{x}^{4}}\right) - \frac{3}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({t\_0}^{2} - {t\_1}^{2}, \frac{1}{t\_0 + t\_1}, \mathsf{fma}\left(\frac{-1}{x + -1}, x + 1, t\_1\right)\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 1.00000000000000005e-4Initial program 6.2%
Taylor expanded in x around inf 99.5%
distribute-neg-in99.5%
unsub-neg99.5%
associate-*r/99.5%
metadata-eval99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
if 1.00000000000000005e-4 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 99.9%
div-inv99.9%
div-inv99.9%
prod-diff99.9%
associate-/r/99.9%
clear-num99.9%
fma-neg99.9%
div-inv99.9%
flip--100.0%
div-inv99.9%
fma-define99.9%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))) (t_1 (/ (+ x 1.0) (+ x -1.0))))
(if (<= (- t_0 t_1) 0.0001)
(+
(/ -3.0 (pow x 3.0))
(- (+ (/ -1.0 (pow x 2.0)) (/ -1.0 (pow x 4.0))) (/ 3.0 x)))
(/ (- (pow t_0 2.0) (pow t_1 2.0)) (+ t_1 (* x (/ 1.0 (+ x 1.0))))))))
double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / (x + -1.0);
double tmp;
if ((t_0 - t_1) <= 0.0001) {
tmp = (-3.0 / pow(x, 3.0)) + (((-1.0 / pow(x, 2.0)) + (-1.0 / pow(x, 4.0))) - (3.0 / x));
} else {
tmp = (pow(t_0, 2.0) - pow(t_1, 2.0)) / (t_1 + (x * (1.0 / (x + 1.0))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x / (x + 1.0d0)
t_1 = (x + 1.0d0) / (x + (-1.0d0))
if ((t_0 - t_1) <= 0.0001d0) then
tmp = ((-3.0d0) / (x ** 3.0d0)) + ((((-1.0d0) / (x ** 2.0d0)) + ((-1.0d0) / (x ** 4.0d0))) - (3.0d0 / x))
else
tmp = ((t_0 ** 2.0d0) - (t_1 ** 2.0d0)) / (t_1 + (x * (1.0d0 / (x + 1.0d0))))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / (x + -1.0);
double tmp;
if ((t_0 - t_1) <= 0.0001) {
tmp = (-3.0 / Math.pow(x, 3.0)) + (((-1.0 / Math.pow(x, 2.0)) + (-1.0 / Math.pow(x, 4.0))) - (3.0 / x));
} else {
tmp = (Math.pow(t_0, 2.0) - Math.pow(t_1, 2.0)) / (t_1 + (x * (1.0 / (x + 1.0))));
}
return tmp;
}
def code(x): t_0 = x / (x + 1.0) t_1 = (x + 1.0) / (x + -1.0) tmp = 0 if (t_0 - t_1) <= 0.0001: tmp = (-3.0 / math.pow(x, 3.0)) + (((-1.0 / math.pow(x, 2.0)) + (-1.0 / math.pow(x, 4.0))) - (3.0 / x)) else: tmp = (math.pow(t_0, 2.0) - math.pow(t_1, 2.0)) / (t_1 + (x * (1.0 / (x + 1.0)))) return tmp
function code(x) t_0 = Float64(x / Float64(x + 1.0)) t_1 = Float64(Float64(x + 1.0) / Float64(x + -1.0)) tmp = 0.0 if (Float64(t_0 - t_1) <= 0.0001) tmp = Float64(Float64(-3.0 / (x ^ 3.0)) + Float64(Float64(Float64(-1.0 / (x ^ 2.0)) + Float64(-1.0 / (x ^ 4.0))) - Float64(3.0 / x))); else tmp = Float64(Float64((t_0 ^ 2.0) - (t_1 ^ 2.0)) / Float64(t_1 + Float64(x * Float64(1.0 / Float64(x + 1.0))))); end return tmp end
function tmp_2 = code(x) t_0 = x / (x + 1.0); t_1 = (x + 1.0) / (x + -1.0); tmp = 0.0; if ((t_0 - t_1) <= 0.0001) tmp = (-3.0 / (x ^ 3.0)) + (((-1.0 / (x ^ 2.0)) + (-1.0 / (x ^ 4.0))) - (3.0 / x)); else tmp = ((t_0 ^ 2.0) - (t_1 ^ 2.0)) / (t_1 + (x * (1.0 / (x + 1.0)))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], 0.0001], N[(N[(-3.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(3.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 + N[(x * N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := \frac{x + 1}{x + -1}\\
\mathbf{if}\;t\_0 - t\_1 \leq 0.0001:\\
\;\;\;\;\frac{-3}{{x}^{3}} + \left(\left(\frac{-1}{{x}^{2}} + \frac{-1}{{x}^{4}}\right) - \frac{3}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{t\_0}^{2} - {t\_1}^{2}}{t\_1 + x \cdot \frac{1}{x + 1}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 1.00000000000000005e-4Initial program 6.2%
Taylor expanded in x around inf 99.5%
distribute-neg-in99.5%
unsub-neg99.5%
associate-*r/99.5%
metadata-eval99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
if 1.00000000000000005e-4 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 99.9%
flip--99.9%
pow299.9%
pow299.9%
sub-neg99.9%
metadata-eval99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
clear-num99.9%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))) (t_1 (/ (+ x 1.0) (+ x -1.0))))
(if (<= (- t_0 t_1) 0.0001)
(+ (/ -3.0 (pow x 3.0)) (+ (/ -3.0 x) (/ -1.0 (pow x 2.0))))
(/ (- (pow t_0 2.0) (pow t_1 2.0)) (+ t_1 (* x (/ 1.0 (+ x 1.0))))))))
double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / (x + -1.0);
double tmp;
if ((t_0 - t_1) <= 0.0001) {
tmp = (-3.0 / pow(x, 3.0)) + ((-3.0 / x) + (-1.0 / pow(x, 2.0)));
} else {
tmp = (pow(t_0, 2.0) - pow(t_1, 2.0)) / (t_1 + (x * (1.0 / (x + 1.0))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x / (x + 1.0d0)
t_1 = (x + 1.0d0) / (x + (-1.0d0))
if ((t_0 - t_1) <= 0.0001d0) then
tmp = ((-3.0d0) / (x ** 3.0d0)) + (((-3.0d0) / x) + ((-1.0d0) / (x ** 2.0d0)))
else
tmp = ((t_0 ** 2.0d0) - (t_1 ** 2.0d0)) / (t_1 + (x * (1.0d0 / (x + 1.0d0))))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / (x + -1.0);
double tmp;
if ((t_0 - t_1) <= 0.0001) {
tmp = (-3.0 / Math.pow(x, 3.0)) + ((-3.0 / x) + (-1.0 / Math.pow(x, 2.0)));
} else {
tmp = (Math.pow(t_0, 2.0) - Math.pow(t_1, 2.0)) / (t_1 + (x * (1.0 / (x + 1.0))));
}
return tmp;
}
def code(x): t_0 = x / (x + 1.0) t_1 = (x + 1.0) / (x + -1.0) tmp = 0 if (t_0 - t_1) <= 0.0001: tmp = (-3.0 / math.pow(x, 3.0)) + ((-3.0 / x) + (-1.0 / math.pow(x, 2.0))) else: tmp = (math.pow(t_0, 2.0) - math.pow(t_1, 2.0)) / (t_1 + (x * (1.0 / (x + 1.0)))) return tmp
function code(x) t_0 = Float64(x / Float64(x + 1.0)) t_1 = Float64(Float64(x + 1.0) / Float64(x + -1.0)) tmp = 0.0 if (Float64(t_0 - t_1) <= 0.0001) tmp = Float64(Float64(-3.0 / (x ^ 3.0)) + Float64(Float64(-3.0 / x) + Float64(-1.0 / (x ^ 2.0)))); else tmp = Float64(Float64((t_0 ^ 2.0) - (t_1 ^ 2.0)) / Float64(t_1 + Float64(x * Float64(1.0 / Float64(x + 1.0))))); end return tmp end
function tmp_2 = code(x) t_0 = x / (x + 1.0); t_1 = (x + 1.0) / (x + -1.0); tmp = 0.0; if ((t_0 - t_1) <= 0.0001) tmp = (-3.0 / (x ^ 3.0)) + ((-3.0 / x) + (-1.0 / (x ^ 2.0))); else tmp = ((t_0 ^ 2.0) - (t_1 ^ 2.0)) / (t_1 + (x * (1.0 / (x + 1.0)))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], 0.0001], N[(N[(-3.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-3.0 / x), $MachinePrecision] + N[(-1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 + N[(x * N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := \frac{x + 1}{x + -1}\\
\mathbf{if}\;t\_0 - t\_1 \leq 0.0001:\\
\;\;\;\;\frac{-3}{{x}^{3}} + \left(\frac{-3}{x} + \frac{-1}{{x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{t\_0}^{2} - {t\_1}^{2}}{t\_1 + x \cdot \frac{1}{x + 1}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 1.00000000000000005e-4Initial program 6.2%
Taylor expanded in x around inf 99.5%
+-commutative99.5%
distribute-neg-in99.5%
distribute-neg-in99.5%
associate-*r/99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
associate-*r/99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
Simplified99.9%
if 1.00000000000000005e-4 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 99.9%
flip--99.9%
pow299.9%
pow299.9%
sub-neg99.9%
metadata-eval99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
clear-num99.9%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))) (t_1 (/ (+ x 1.0) (+ x -1.0))))
(if (<= (- t_0 t_1) 0.0001)
(+ (/ -3.0 (pow x 3.0)) (+ (/ -3.0 x) (/ -1.0 (pow x 2.0))))
(/ (- (/ t_0 (/ (+ x 1.0) x)) (pow t_1 2.0)) (+ t_0 t_1)))))
double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / (x + -1.0);
double tmp;
if ((t_0 - t_1) <= 0.0001) {
tmp = (-3.0 / pow(x, 3.0)) + ((-3.0 / x) + (-1.0 / pow(x, 2.0)));
} else {
tmp = ((t_0 / ((x + 1.0) / x)) - pow(t_1, 2.0)) / (t_0 + t_1);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x / (x + 1.0d0)
t_1 = (x + 1.0d0) / (x + (-1.0d0))
if ((t_0 - t_1) <= 0.0001d0) then
tmp = ((-3.0d0) / (x ** 3.0d0)) + (((-3.0d0) / x) + ((-1.0d0) / (x ** 2.0d0)))
else
tmp = ((t_0 / ((x + 1.0d0) / x)) - (t_1 ** 2.0d0)) / (t_0 + t_1)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / (x + -1.0);
double tmp;
if ((t_0 - t_1) <= 0.0001) {
tmp = (-3.0 / Math.pow(x, 3.0)) + ((-3.0 / x) + (-1.0 / Math.pow(x, 2.0)));
} else {
tmp = ((t_0 / ((x + 1.0) / x)) - Math.pow(t_1, 2.0)) / (t_0 + t_1);
}
return tmp;
}
def code(x): t_0 = x / (x + 1.0) t_1 = (x + 1.0) / (x + -1.0) tmp = 0 if (t_0 - t_1) <= 0.0001: tmp = (-3.0 / math.pow(x, 3.0)) + ((-3.0 / x) + (-1.0 / math.pow(x, 2.0))) else: tmp = ((t_0 / ((x + 1.0) / x)) - math.pow(t_1, 2.0)) / (t_0 + t_1) return tmp
function code(x) t_0 = Float64(x / Float64(x + 1.0)) t_1 = Float64(Float64(x + 1.0) / Float64(x + -1.0)) tmp = 0.0 if (Float64(t_0 - t_1) <= 0.0001) tmp = Float64(Float64(-3.0 / (x ^ 3.0)) + Float64(Float64(-3.0 / x) + Float64(-1.0 / (x ^ 2.0)))); else tmp = Float64(Float64(Float64(t_0 / Float64(Float64(x + 1.0) / x)) - (t_1 ^ 2.0)) / Float64(t_0 + t_1)); end return tmp end
function tmp_2 = code(x) t_0 = x / (x + 1.0); t_1 = (x + 1.0) / (x + -1.0); tmp = 0.0; if ((t_0 - t_1) <= 0.0001) tmp = (-3.0 / (x ^ 3.0)) + ((-3.0 / x) + (-1.0 / (x ^ 2.0))); else tmp = ((t_0 / ((x + 1.0) / x)) - (t_1 ^ 2.0)) / (t_0 + t_1); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], 0.0001], N[(N[(-3.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-3.0 / x), $MachinePrecision] + N[(-1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$0 / N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] - N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := \frac{x + 1}{x + -1}\\
\mathbf{if}\;t\_0 - t\_1 \leq 0.0001:\\
\;\;\;\;\frac{-3}{{x}^{3}} + \left(\frac{-3}{x} + \frac{-1}{{x}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{\frac{x + 1}{x}} - {t\_1}^{2}}{t\_0 + t\_1}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 1.00000000000000005e-4Initial program 6.2%
Taylor expanded in x around inf 99.5%
+-commutative99.5%
distribute-neg-in99.5%
distribute-neg-in99.5%
associate-*r/99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
associate-*r/99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
Simplified99.9%
if 1.00000000000000005e-4 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 99.9%
flip--99.9%
pow299.9%
pow299.9%
sub-neg99.9%
metadata-eval99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
unpow299.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))) (t_1 (/ (+ x 1.0) (+ x -1.0))))
(if (<= (- t_0 t_1) 0.0)
(+ (/ -3.0 x) (* (/ 1.0 x) (/ -1.0 x)))
(/ (- (/ t_0 (/ (+ x 1.0) x)) (pow t_1 2.0)) (+ t_0 t_1)))))
double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / (x + -1.0);
double tmp;
if ((t_0 - t_1) <= 0.0) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = ((t_0 / ((x + 1.0) / x)) - pow(t_1, 2.0)) / (t_0 + t_1);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x / (x + 1.0d0)
t_1 = (x + 1.0d0) / (x + (-1.0d0))
if ((t_0 - t_1) <= 0.0d0) then
tmp = ((-3.0d0) / x) + ((1.0d0 / x) * ((-1.0d0) / x))
else
tmp = ((t_0 / ((x + 1.0d0) / x)) - (t_1 ** 2.0d0)) / (t_0 + t_1)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / (x + -1.0);
double tmp;
if ((t_0 - t_1) <= 0.0) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = ((t_0 / ((x + 1.0) / x)) - Math.pow(t_1, 2.0)) / (t_0 + t_1);
}
return tmp;
}
def code(x): t_0 = x / (x + 1.0) t_1 = (x + 1.0) / (x + -1.0) tmp = 0 if (t_0 - t_1) <= 0.0: tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)) else: tmp = ((t_0 / ((x + 1.0) / x)) - math.pow(t_1, 2.0)) / (t_0 + t_1) return tmp
function code(x) t_0 = Float64(x / Float64(x + 1.0)) t_1 = Float64(Float64(x + 1.0) / Float64(x + -1.0)) tmp = 0.0 if (Float64(t_0 - t_1) <= 0.0) tmp = Float64(Float64(-3.0 / x) + Float64(Float64(1.0 / x) * Float64(-1.0 / x))); else tmp = Float64(Float64(Float64(t_0 / Float64(Float64(x + 1.0) / x)) - (t_1 ^ 2.0)) / Float64(t_0 + t_1)); end return tmp end
function tmp_2 = code(x) t_0 = x / (x + 1.0); t_1 = (x + 1.0) / (x + -1.0); tmp = 0.0; if ((t_0 - t_1) <= 0.0) tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)); else tmp = ((t_0 / ((x + 1.0) / x)) - (t_1 ^ 2.0)) / (t_0 + t_1); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], 0.0], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$0 / N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] - N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := \frac{x + 1}{x + -1}\\
\mathbf{if}\;t\_0 - t\_1 \leq 0:\\
\;\;\;\;\frac{-3}{x} + \frac{1}{x} \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{\frac{x + 1}{x}} - {t\_1}^{2}}{t\_0 + t\_1}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 0.0Initial program 5.6%
sub-neg5.6%
+-commutative5.6%
div-inv5.3%
distribute-rgt-neg-in5.3%
fma-define4.0%
sub-neg4.0%
metadata-eval4.0%
Applied egg-rr4.0%
Taylor expanded in x around inf 99.5%
distribute-neg-in99.5%
unsub-neg99.5%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
inv-pow100.0%
unpow2100.0%
unpow-prod-down100.0%
inv-pow100.0%
inv-pow100.0%
Applied egg-rr100.0%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 99.8%
flip--99.8%
pow299.8%
pow299.8%
sub-neg99.8%
metadata-eval99.8%
sub-neg99.8%
metadata-eval99.8%
Applied egg-rr99.8%
unpow299.8%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))) (t_1 (/ (+ x 1.0) x)))
(if (<= (- t_0 (/ (+ x 1.0) (+ x -1.0))) 0.0)
(+ (/ -3.0 x) (* (/ 1.0 x) (/ -1.0 x)))
(/
(+ (/ t_0 t_1) (/ (/ (- -1.0 x) (+ x -1.0)) (/ (+ x -1.0) (+ x 1.0))))
(/ (+ (+ x -1.0) (* (+ x 1.0) t_1)) (* (+ x -1.0) t_1))))))
double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / x;
double tmp;
if ((t_0 - ((x + 1.0) / (x + -1.0))) <= 0.0) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = ((t_0 / t_1) + (((-1.0 - x) / (x + -1.0)) / ((x + -1.0) / (x + 1.0)))) / (((x + -1.0) + ((x + 1.0) * t_1)) / ((x + -1.0) * t_1));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x / (x + 1.0d0)
t_1 = (x + 1.0d0) / x
if ((t_0 - ((x + 1.0d0) / (x + (-1.0d0)))) <= 0.0d0) then
tmp = ((-3.0d0) / x) + ((1.0d0 / x) * ((-1.0d0) / x))
else
tmp = ((t_0 / t_1) + ((((-1.0d0) - x) / (x + (-1.0d0))) / ((x + (-1.0d0)) / (x + 1.0d0)))) / (((x + (-1.0d0)) + ((x + 1.0d0) * t_1)) / ((x + (-1.0d0)) * t_1))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / x;
double tmp;
if ((t_0 - ((x + 1.0) / (x + -1.0))) <= 0.0) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = ((t_0 / t_1) + (((-1.0 - x) / (x + -1.0)) / ((x + -1.0) / (x + 1.0)))) / (((x + -1.0) + ((x + 1.0) * t_1)) / ((x + -1.0) * t_1));
}
return tmp;
}
def code(x): t_0 = x / (x + 1.0) t_1 = (x + 1.0) / x tmp = 0 if (t_0 - ((x + 1.0) / (x + -1.0))) <= 0.0: tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)) else: tmp = ((t_0 / t_1) + (((-1.0 - x) / (x + -1.0)) / ((x + -1.0) / (x + 1.0)))) / (((x + -1.0) + ((x + 1.0) * t_1)) / ((x + -1.0) * t_1)) return tmp
function code(x) t_0 = Float64(x / Float64(x + 1.0)) t_1 = Float64(Float64(x + 1.0) / x) tmp = 0.0 if (Float64(t_0 - Float64(Float64(x + 1.0) / Float64(x + -1.0))) <= 0.0) tmp = Float64(Float64(-3.0 / x) + Float64(Float64(1.0 / x) * Float64(-1.0 / x))); else tmp = Float64(Float64(Float64(t_0 / t_1) + Float64(Float64(Float64(-1.0 - x) / Float64(x + -1.0)) / Float64(Float64(x + -1.0) / Float64(x + 1.0)))) / Float64(Float64(Float64(x + -1.0) + Float64(Float64(x + 1.0) * t_1)) / Float64(Float64(x + -1.0) * t_1))); end return tmp end
function tmp_2 = code(x) t_0 = x / (x + 1.0); t_1 = (x + 1.0) / x; tmp = 0.0; if ((t_0 - ((x + 1.0) / (x + -1.0))) <= 0.0) tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)); else tmp = ((t_0 / t_1) + (((-1.0 - x) / (x + -1.0)) / ((x + -1.0) / (x + 1.0)))) / (((x + -1.0) + ((x + 1.0) * t_1)) / ((x + -1.0) * t_1)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$0 / t$95$1), $MachinePrecision] + N[(N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(x + -1.0), $MachinePrecision] + N[(N[(x + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := \frac{x + 1}{x}\\
\mathbf{if}\;t\_0 - \frac{x + 1}{x + -1} \leq 0:\\
\;\;\;\;\frac{-3}{x} + \frac{1}{x} \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{t\_1} + \frac{\frac{-1 - x}{x + -1}}{\frac{x + -1}{x + 1}}}{\frac{\left(x + -1\right) + \left(x + 1\right) \cdot t\_1}{\left(x + -1\right) \cdot t\_1}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 0.0Initial program 5.6%
sub-neg5.6%
+-commutative5.6%
div-inv5.3%
distribute-rgt-neg-in5.3%
fma-define4.0%
sub-neg4.0%
metadata-eval4.0%
Applied egg-rr4.0%
Taylor expanded in x around inf 99.5%
distribute-neg-in99.5%
unsub-neg99.5%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
inv-pow100.0%
unpow2100.0%
unpow-prod-down100.0%
inv-pow100.0%
inv-pow100.0%
Applied egg-rr100.0%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 99.8%
flip--99.8%
pow299.8%
pow299.8%
sub-neg99.8%
metadata-eval99.8%
sub-neg99.8%
metadata-eval99.8%
Applied egg-rr99.8%
unpow299.8%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
clear-num99.8%
frac-add99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
unpow299.8%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ x (+ x 1.0))) (t_1 (/ (+ x 1.0) (+ x -1.0))))
(if (<= (- t_0 t_1) 0.0)
(+ (/ -3.0 x) (* (/ 1.0 x) (/ -1.0 x)))
(/
(+
(/ t_0 (/ (+ x 1.0) x))
(/ (/ (- -1.0 x) (+ x -1.0)) (/ (+ x -1.0) (+ x 1.0))))
(+ t_0 t_1)))))
double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / (x + -1.0);
double tmp;
if ((t_0 - t_1) <= 0.0) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = ((t_0 / ((x + 1.0) / x)) + (((-1.0 - x) / (x + -1.0)) / ((x + -1.0) / (x + 1.0)))) / (t_0 + t_1);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x / (x + 1.0d0)
t_1 = (x + 1.0d0) / (x + (-1.0d0))
if ((t_0 - t_1) <= 0.0d0) then
tmp = ((-3.0d0) / x) + ((1.0d0 / x) * ((-1.0d0) / x))
else
tmp = ((t_0 / ((x + 1.0d0) / x)) + ((((-1.0d0) - x) / (x + (-1.0d0))) / ((x + (-1.0d0)) / (x + 1.0d0)))) / (t_0 + t_1)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x / (x + 1.0);
double t_1 = (x + 1.0) / (x + -1.0);
double tmp;
if ((t_0 - t_1) <= 0.0) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = ((t_0 / ((x + 1.0) / x)) + (((-1.0 - x) / (x + -1.0)) / ((x + -1.0) / (x + 1.0)))) / (t_0 + t_1);
}
return tmp;
}
def code(x): t_0 = x / (x + 1.0) t_1 = (x + 1.0) / (x + -1.0) tmp = 0 if (t_0 - t_1) <= 0.0: tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)) else: tmp = ((t_0 / ((x + 1.0) / x)) + (((-1.0 - x) / (x + -1.0)) / ((x + -1.0) / (x + 1.0)))) / (t_0 + t_1) return tmp
function code(x) t_0 = Float64(x / Float64(x + 1.0)) t_1 = Float64(Float64(x + 1.0) / Float64(x + -1.0)) tmp = 0.0 if (Float64(t_0 - t_1) <= 0.0) tmp = Float64(Float64(-3.0 / x) + Float64(Float64(1.0 / x) * Float64(-1.0 / x))); else tmp = Float64(Float64(Float64(t_0 / Float64(Float64(x + 1.0) / x)) + Float64(Float64(Float64(-1.0 - x) / Float64(x + -1.0)) / Float64(Float64(x + -1.0) / Float64(x + 1.0)))) / Float64(t_0 + t_1)); end return tmp end
function tmp_2 = code(x) t_0 = x / (x + 1.0); t_1 = (x + 1.0) / (x + -1.0); tmp = 0.0; if ((t_0 - t_1) <= 0.0) tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)); else tmp = ((t_0 / ((x + 1.0) / x)) + (((-1.0 - x) / (x + -1.0)) / ((x + -1.0) / (x + 1.0)))) / (t_0 + t_1); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], 0.0], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$0 / N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := \frac{x + 1}{x + -1}\\
\mathbf{if}\;t\_0 - t\_1 \leq 0:\\
\;\;\;\;\frac{-3}{x} + \frac{1}{x} \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_0}{\frac{x + 1}{x}} + \frac{\frac{-1 - x}{x + -1}}{\frac{x + -1}{x + 1}}}{t\_0 + t\_1}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 0.0Initial program 5.6%
sub-neg5.6%
+-commutative5.6%
div-inv5.3%
distribute-rgt-neg-in5.3%
fma-define4.0%
sub-neg4.0%
metadata-eval4.0%
Applied egg-rr4.0%
Taylor expanded in x around inf 99.5%
distribute-neg-in99.5%
unsub-neg99.5%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
inv-pow100.0%
unpow2100.0%
unpow-prod-down100.0%
inv-pow100.0%
inv-pow100.0%
Applied egg-rr100.0%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 99.8%
flip--99.8%
pow299.8%
pow299.8%
sub-neg99.8%
metadata-eval99.8%
sub-neg99.8%
metadata-eval99.8%
Applied egg-rr99.8%
unpow299.8%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
unpow299.8%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
Final simplification99.9%
(FPCore (x)
:precision binary64
(if (<= (- (/ x (+ x 1.0)) (/ (+ x 1.0) (+ x -1.0))) 0.0)
(+ (/ -3.0 x) (* (/ 1.0 x) (/ -1.0 x)))
(/
(+ (+ x -1.0) (* (+ x 1.0) (/ (- -1.0 x) x)))
(* (+ x -1.0) (/ (+ x 1.0) x)))))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) - ((x + 1.0) / (x + -1.0))) <= 0.0) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = ((x + -1.0) + ((x + 1.0) * ((-1.0 - x) / x))) / ((x + -1.0) * ((x + 1.0) / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((x / (x + 1.0d0)) - ((x + 1.0d0) / (x + (-1.0d0)))) <= 0.0d0) then
tmp = ((-3.0d0) / x) + ((1.0d0 / x) * ((-1.0d0) / x))
else
tmp = ((x + (-1.0d0)) + ((x + 1.0d0) * (((-1.0d0) - x) / x))) / ((x + (-1.0d0)) * ((x + 1.0d0) / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((x / (x + 1.0)) - ((x + 1.0) / (x + -1.0))) <= 0.0) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = ((x + -1.0) + ((x + 1.0) * ((-1.0 - x) / x))) / ((x + -1.0) * ((x + 1.0) / x));
}
return tmp;
}
def code(x): tmp = 0 if ((x / (x + 1.0)) - ((x + 1.0) / (x + -1.0))) <= 0.0: tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)) else: tmp = ((x + -1.0) + ((x + 1.0) * ((-1.0 - x) / x))) / ((x + -1.0) * ((x + 1.0) / x)) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x + -1.0))) <= 0.0) tmp = Float64(Float64(-3.0 / x) + Float64(Float64(1.0 / x) * Float64(-1.0 / x))); else tmp = Float64(Float64(Float64(x + -1.0) + Float64(Float64(x + 1.0) * Float64(Float64(-1.0 - x) / x))) / Float64(Float64(x + -1.0) * Float64(Float64(x + 1.0) / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((x / (x + 1.0)) - ((x + 1.0) / (x + -1.0))) <= 0.0) tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)); else tmp = ((x + -1.0) + ((x + 1.0) * ((-1.0 - x) / x))) / ((x + -1.0) * ((x + 1.0) / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + -1.0), $MachinePrecision] + N[(N[(x + 1.0), $MachinePrecision] * N[(N[(-1.0 - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] * N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} - \frac{x + 1}{x + -1} \leq 0:\\
\;\;\;\;\frac{-3}{x} + \frac{1}{x} \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x + -1\right) + \left(x + 1\right) \cdot \frac{-1 - x}{x}}{\left(x + -1\right) \cdot \frac{x + 1}{x}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 0.0Initial program 5.6%
sub-neg5.6%
+-commutative5.6%
div-inv5.3%
distribute-rgt-neg-in5.3%
fma-define4.0%
sub-neg4.0%
metadata-eval4.0%
Applied egg-rr4.0%
Taylor expanded in x around inf 99.5%
distribute-neg-in99.5%
unsub-neg99.5%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
inv-pow100.0%
unpow2100.0%
unpow-prod-down100.0%
inv-pow100.0%
inv-pow100.0%
Applied egg-rr100.0%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 99.8%
clear-num99.8%
frac-sub99.8%
*-un-lft-identity99.8%
sub-neg99.8%
metadata-eval99.8%
sub-neg99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.9%
(FPCore (x) :precision binary64 (let* ((t_0 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (+ x -1.0))))) (if (<= t_0 0.0) (+ (/ -3.0 x) (* (/ 1.0 x) (/ -1.0 x))) t_0)))
double code(double x) {
double t_0 = (x / (x + 1.0)) - ((x + 1.0) / (x + -1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (x / (x + 1.0d0)) - ((x + 1.0d0) / (x + (-1.0d0)))
if (t_0 <= 0.0d0) then
tmp = ((-3.0d0) / x) + ((1.0d0 / x) * ((-1.0d0) / x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x / (x + 1.0)) - ((x + 1.0) / (x + -1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = (x / (x + 1.0)) - ((x + 1.0) / (x + -1.0)) tmp = 0 if t_0 <= 0.0: tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)) else: tmp = t_0 return tmp
function code(x) t_0 = Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x + -1.0))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(-3.0 / x) + Float64(Float64(1.0 / x) * Float64(-1.0 / x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x) t_0 = (x / (x + 1.0)) - ((x + 1.0) / (x + -1.0)); tmp = 0.0; if (t_0 <= 0.0) tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1} - \frac{x + 1}{x + -1}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{-3}{x} + \frac{1}{x} \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 0.0Initial program 5.6%
sub-neg5.6%
+-commutative5.6%
div-inv5.3%
distribute-rgt-neg-in5.3%
fma-define4.0%
sub-neg4.0%
metadata-eval4.0%
Applied egg-rr4.0%
Taylor expanded in x around inf 99.5%
distribute-neg-in99.5%
unsub-neg99.5%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
inv-pow100.0%
unpow2100.0%
unpow-prod-down100.0%
inv-pow100.0%
inv-pow100.0%
Applied egg-rr100.0%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 99.8%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (or (<= x -3.0) (not (<= x 1.0))) (+ (/ -3.0 x) (* (/ 1.0 x) (/ -1.0 x))) (+ 1.0 (* x (+ x 3.0)))))
double code(double x) {
double tmp;
if ((x <= -3.0) || !(x <= 1.0)) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-3.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = ((-3.0d0) / x) + ((1.0d0 / x) * ((-1.0d0) / x))
else
tmp = 1.0d0 + (x * (x + 3.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -3.0) || !(x <= 1.0)) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
def code(x): tmp = 0 if (x <= -3.0) or not (x <= 1.0): tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)) else: tmp = 1.0 + (x * (x + 3.0)) return tmp
function code(x) tmp = 0.0 if ((x <= -3.0) || !(x <= 1.0)) tmp = Float64(Float64(-3.0 / x) + Float64(Float64(1.0 / x) * Float64(-1.0 / x))); else tmp = Float64(1.0 + Float64(x * Float64(x + 3.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -3.0) || ~((x <= 1.0))) tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)); else tmp = 1.0 + (x * (x + 3.0)); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -3.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x * N[(x + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-3}{x} + \frac{1}{x} \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\end{array}
\end{array}
if x < -3 or 1 < x Initial program 6.9%
sub-neg6.9%
+-commutative6.9%
div-inv6.6%
distribute-rgt-neg-in6.6%
fma-define5.4%
sub-neg5.4%
metadata-eval5.4%
Applied egg-rr5.4%
Taylor expanded in x around inf 98.8%
distribute-neg-in98.8%
unsub-neg98.8%
associate-*r/99.3%
metadata-eval99.3%
distribute-neg-frac99.3%
metadata-eval99.3%
Simplified99.3%
inv-pow99.3%
unpow299.3%
unpow-prod-down99.3%
inv-pow99.3%
inv-pow99.3%
Applied egg-rr99.3%
if -3 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.8%
unpow299.8%
distribute-rgt-out99.8%
Simplified99.8%
Final simplification99.6%
(FPCore (x)
:precision binary64
(if (<= x -0.33)
(/
1.0
(+
0.1111111111111111
(+ (* x -0.3333333333333333) (/ 0.2962962962962963 x))))
(if (<= x 1.0)
(+ 1.0 (* x (+ x 3.0)))
(+ (/ -3.0 x) (* (/ 1.0 x) (/ -1.0 x))))))
double code(double x) {
double tmp;
if (x <= -0.33) {
tmp = 1.0 / (0.1111111111111111 + ((x * -0.3333333333333333) + (0.2962962962962963 / x)));
} else if (x <= 1.0) {
tmp = 1.0 + (x * (x + 3.0));
} else {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-0.33d0)) then
tmp = 1.0d0 / (0.1111111111111111d0 + ((x * (-0.3333333333333333d0)) + (0.2962962962962963d0 / x)))
else if (x <= 1.0d0) then
tmp = 1.0d0 + (x * (x + 3.0d0))
else
tmp = ((-3.0d0) / x) + ((1.0d0 / x) * ((-1.0d0) / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -0.33) {
tmp = 1.0 / (0.1111111111111111 + ((x * -0.3333333333333333) + (0.2962962962962963 / x)));
} else if (x <= 1.0) {
tmp = 1.0 + (x * (x + 3.0));
} else {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.33: tmp = 1.0 / (0.1111111111111111 + ((x * -0.3333333333333333) + (0.2962962962962963 / x))) elif x <= 1.0: tmp = 1.0 + (x * (x + 3.0)) else: tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)) return tmp
function code(x) tmp = 0.0 if (x <= -0.33) tmp = Float64(1.0 / Float64(0.1111111111111111 + Float64(Float64(x * -0.3333333333333333) + Float64(0.2962962962962963 / x)))); elseif (x <= 1.0) tmp = Float64(1.0 + Float64(x * Float64(x + 3.0))); else tmp = Float64(Float64(-3.0 / x) + Float64(Float64(1.0 / x) * Float64(-1.0 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -0.33) tmp = 1.0 / (0.1111111111111111 + ((x * -0.3333333333333333) + (0.2962962962962963 / x))); elseif (x <= 1.0) tmp = 1.0 + (x * (x + 3.0)); else tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -0.33], N[(1.0 / N[(0.1111111111111111 + N[(N[(x * -0.3333333333333333), $MachinePrecision] + N[(0.2962962962962963 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 + N[(x * N[(x + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.33:\\
\;\;\;\;\frac{1}{0.1111111111111111 + \left(x \cdot -0.3333333333333333 + \frac{0.2962962962962963}{x}\right)}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-3}{x} + \frac{1}{x} \cdot \frac{-1}{x}\\
\end{array}
\end{array}
if x < -0.330000000000000016Initial program 7.8%
flip--8.0%
clear-num8.0%
sub-neg8.0%
metadata-eval8.0%
pow28.0%
pow28.0%
sub-neg8.0%
metadata-eval8.0%
Applied egg-rr8.0%
Taylor expanded in x around inf 98.8%
Taylor expanded in x around 0 98.8%
if -0.330000000000000016 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.8%
unpow299.8%
distribute-rgt-out99.8%
Simplified99.8%
if 1 < x Initial program 5.8%
sub-neg5.8%
+-commutative5.8%
div-inv5.5%
distribute-rgt-neg-in5.5%
fma-define4.4%
sub-neg4.4%
metadata-eval4.4%
Applied egg-rr4.4%
Taylor expanded in x around inf 99.6%
distribute-neg-in99.6%
unsub-neg99.6%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
inv-pow100.0%
unpow2100.0%
unpow-prod-down100.0%
inv-pow100.0%
inv-pow100.0%
Applied egg-rr100.0%
Final simplification99.6%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ -3.0 x) (+ 1.0 (* x (+ x 3.0)))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (-3.0d0) / x
else
tmp = 1.0d0 + (x * (x + 3.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -3.0 / x else: tmp = 1.0 + (x * (x + 3.0)) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(-3.0 / x); else tmp = Float64(1.0 + Float64(x * Float64(x + 3.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = -3.0 / x; else tmp = 1.0 + (x * (x + 3.0)); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(-3.0 / x), $MachinePrecision], N[(1.0 + N[(x * N[(x + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 6.9%
Taylor expanded in x around inf 98.9%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.8%
unpow299.8%
distribute-rgt-out99.8%
Simplified99.8%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ -3.0 x) (+ 1.0 (* x 3.0))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0 + (x * 3.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (-3.0d0) / x
else
tmp = 1.0d0 + (x * 3.0d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0 + (x * 3.0);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -3.0 / x else: tmp = 1.0 + (x * 3.0) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(-3.0 / x); else tmp = Float64(1.0 + Float64(x * 3.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = -3.0 / x; else tmp = 1.0 + (x * 3.0); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(-3.0 / x), $MachinePrecision], N[(1.0 + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot 3\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 6.9%
Taylor expanded in x around inf 98.9%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.6%
Final simplification99.3%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ -3.0 x) 1.0))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (-3.0d0) / x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -3.0 / x else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(-3.0 / x); else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = -3.0 / x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(-3.0 / x), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 6.9%
Taylor expanded in x around inf 98.9%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 98.8%
Final simplification98.8%
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 57.1%
Taylor expanded in x around 0 55.1%
Final simplification55.1%
herbie shell --seed 2024036
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))