
(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 -1.0) (+ x 1.0))))
(if (<= (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))) 0.0)
(-
(- (+ (/ -1.0 (pow x 2.0)) (/ -1.0 (pow x 4.0))) (/ 3.0 (pow x 3.0)))
(/ 3.0 x))
(/ (+ t_0 (/ (- -1.0 x) x)) (* t_0 (/ (+ x 1.0) x))))))
double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = (((-1.0 / pow(x, 2.0)) + (-1.0 / pow(x, 4.0))) - (3.0 / pow(x, 3.0))) - (3.0 / x);
} else {
tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (x + (-1.0d0)) / (x + 1.0d0)
if (((x / (x + 1.0d0)) + (((-1.0d0) - x) / (x + (-1.0d0)))) <= 0.0d0) then
tmp = ((((-1.0d0) / (x ** 2.0d0)) + ((-1.0d0) / (x ** 4.0d0))) - (3.0d0 / (x ** 3.0d0))) - (3.0d0 / x)
else
tmp = (t_0 + (((-1.0d0) - x) / x)) / (t_0 * ((x + 1.0d0) / x))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = (((-1.0 / Math.pow(x, 2.0)) + (-1.0 / Math.pow(x, 4.0))) - (3.0 / Math.pow(x, 3.0))) - (3.0 / x);
} else {
tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x));
}
return tmp;
}
def code(x): t_0 = (x + -1.0) / (x + 1.0) tmp = 0 if ((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0: tmp = (((-1.0 / math.pow(x, 2.0)) + (-1.0 / math.pow(x, 4.0))) - (3.0 / math.pow(x, 3.0))) - (3.0 / x) else: tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x)) return tmp
function code(x) t_0 = Float64(Float64(x + -1.0) / Float64(x + 1.0)) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) <= 0.0) tmp = Float64(Float64(Float64(Float64(-1.0 / (x ^ 2.0)) + Float64(-1.0 / (x ^ 4.0))) - Float64(3.0 / (x ^ 3.0))) - Float64(3.0 / x)); else tmp = Float64(Float64(t_0 + Float64(Float64(-1.0 - x) / x)) / Float64(t_0 * Float64(Float64(x + 1.0) / x))); end return tmp end
function tmp_2 = code(x) t_0 = (x + -1.0) / (x + 1.0); tmp = 0.0; if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) tmp = (((-1.0 / (x ^ 2.0)) + (-1.0 / (x ^ 4.0))) - (3.0 / (x ^ 3.0))) - (3.0 / x); else tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(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 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(3.0 / x), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 + N[(N[(-1.0 - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + -1}{x + 1}\\
\mathbf{if}\;\frac{x}{x + 1} + \frac{-1 - x}{x + -1} \leq 0:\\
\;\;\;\;\left(\left(\frac{-1}{{x}^{2}} + \frac{-1}{{x}^{4}}\right) - \frac{3}{{x}^{3}}\right) - \frac{3}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 + \frac{-1 - x}{x}}{t_0 \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 8.2%
Taylor expanded in x around inf 99.4%
distribute-neg-in99.4%
unsub-neg99.4%
associate-*r/99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 99.4%
associate-*r/99.8%
metadata-eval99.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 100.0%
clear-num100.0%
clear-num99.9%
frac-sub100.0%
*-un-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (+ x -1.0) (+ x 1.0))))
(if (<= (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))) 0.0)
(+
(/ -3.0 (pow x 3.0))
(- (+ (* (/ 1.0 x) (/ -1.0 x)) (/ -1.0 (pow x 4.0))) (/ 3.0 x)))
(/ (+ t_0 (/ (- -1.0 x) x)) (* t_0 (/ (+ x 1.0) x))))))
double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = (-3.0 / pow(x, 3.0)) + ((((1.0 / x) * (-1.0 / x)) + (-1.0 / pow(x, 4.0))) - (3.0 / x));
} else {
tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (x + (-1.0d0)) / (x + 1.0d0)
if (((x / (x + 1.0d0)) + (((-1.0d0) - x) / (x + (-1.0d0)))) <= 0.0d0) then
tmp = ((-3.0d0) / (x ** 3.0d0)) + ((((1.0d0 / x) * ((-1.0d0) / x)) + ((-1.0d0) / (x ** 4.0d0))) - (3.0d0 / x))
else
tmp = (t_0 + (((-1.0d0) - x) / x)) / (t_0 * ((x + 1.0d0) / x))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = (-3.0 / Math.pow(x, 3.0)) + ((((1.0 / x) * (-1.0 / x)) + (-1.0 / Math.pow(x, 4.0))) - (3.0 / x));
} else {
tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x));
}
return tmp;
}
def code(x): t_0 = (x + -1.0) / (x + 1.0) tmp = 0 if ((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0: tmp = (-3.0 / math.pow(x, 3.0)) + ((((1.0 / x) * (-1.0 / x)) + (-1.0 / math.pow(x, 4.0))) - (3.0 / x)) else: tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x)) return tmp
function code(x) t_0 = Float64(Float64(x + -1.0) / Float64(x + 1.0)) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) <= 0.0) tmp = Float64(Float64(-3.0 / (x ^ 3.0)) + Float64(Float64(Float64(Float64(1.0 / x) * Float64(-1.0 / x)) + Float64(-1.0 / (x ^ 4.0))) - Float64(3.0 / x))); else tmp = Float64(Float64(t_0 + Float64(Float64(-1.0 - x) / x)) / Float64(t_0 * Float64(Float64(x + 1.0) / x))); end return tmp end
function tmp_2 = code(x) t_0 = (x + -1.0) / (x + 1.0); tmp = 0.0; if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) tmp = (-3.0 / (x ^ 3.0)) + ((((1.0 / x) * (-1.0 / x)) + (-1.0 / (x ^ 4.0))) - (3.0 / x)); else tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(-3.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(3.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 + N[(N[(-1.0 - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + -1}{x + 1}\\
\mathbf{if}\;\frac{x}{x + 1} + \frac{-1 - x}{x + -1} \leq 0:\\
\;\;\;\;\frac{-3}{{x}^{3}} + \left(\left(\frac{1}{x} \cdot \frac{-1}{x} + \frac{-1}{{x}^{4}}\right) - \frac{3}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 + \frac{-1 - x}{x}}{t_0 \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 8.2%
Taylor expanded in x around inf 99.4%
distribute-neg-in99.4%
unsub-neg99.4%
associate-*r/99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
metadata-eval98.9%
unpow298.9%
frac-times98.9%
Applied egg-rr99.8%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 100.0%
clear-num100.0%
clear-num99.9%
frac-sub100.0%
*-un-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (+ x -1.0) (+ x 1.0))))
(if (<= (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))) 0.0)
(- (* -3.0 (pow x -3.0)) (+ (/ 3.0 x) (pow x -2.0)))
(/ (+ t_0 (/ (- -1.0 x) x)) (* t_0 (/ (+ x 1.0) x))))))
double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = (-3.0 * pow(x, -3.0)) - ((3.0 / x) + pow(x, -2.0));
} else {
tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (x + (-1.0d0)) / (x + 1.0d0)
if (((x / (x + 1.0d0)) + (((-1.0d0) - x) / (x + (-1.0d0)))) <= 0.0d0) then
tmp = ((-3.0d0) * (x ** (-3.0d0))) - ((3.0d0 / x) + (x ** (-2.0d0)))
else
tmp = (t_0 + (((-1.0d0) - x) / x)) / (t_0 * ((x + 1.0d0) / x))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = (-3.0 * Math.pow(x, -3.0)) - ((3.0 / x) + Math.pow(x, -2.0));
} else {
tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x));
}
return tmp;
}
def code(x): t_0 = (x + -1.0) / (x + 1.0) tmp = 0 if ((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0: tmp = (-3.0 * math.pow(x, -3.0)) - ((3.0 / x) + math.pow(x, -2.0)) else: tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x)) return tmp
function code(x) t_0 = Float64(Float64(x + -1.0) / Float64(x + 1.0)) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) <= 0.0) tmp = Float64(Float64(-3.0 * (x ^ -3.0)) - Float64(Float64(3.0 / x) + (x ^ -2.0))); else tmp = Float64(Float64(t_0 + Float64(Float64(-1.0 - x) / x)) / Float64(t_0 * Float64(Float64(x + 1.0) / x))); end return tmp end
function tmp_2 = code(x) t_0 = (x + -1.0) / (x + 1.0); tmp = 0.0; if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) tmp = (-3.0 * (x ^ -3.0)) - ((3.0 / x) + (x ^ -2.0)); else tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(-3.0 * N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision] - N[(N[(3.0 / x), $MachinePrecision] + N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 + N[(N[(-1.0 - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + -1}{x + 1}\\
\mathbf{if}\;\frac{x}{x + 1} + \frac{-1 - x}{x + -1} \leq 0:\\
\;\;\;\;-3 \cdot {x}^{-3} - \left(\frac{3}{x} + {x}^{-2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 + \frac{-1 - x}{x}}{t_0 \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 8.2%
Taylor expanded in x around inf 99.4%
distribute-neg-in99.4%
unsub-neg99.4%
associate-*r/99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 99.3%
distribute-neg-in99.3%
unsub-neg99.3%
distribute-lft-neg-in99.3%
metadata-eval99.3%
exp-to-pow55.8%
*-commutative55.8%
exp-neg55.8%
distribute-lft-neg-in55.8%
metadata-eval55.8%
*-commutative55.8%
exp-to-pow99.3%
unpow299.3%
associate-/l/99.3%
*-rgt-identity99.3%
associate-*r/99.3%
unpow-199.3%
unpow-199.3%
pow-sqr99.3%
metadata-eval99.3%
Simplified99.7%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 100.0%
clear-num100.0%
clear-num99.9%
frac-sub100.0%
*-un-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (+ x -1.0) (+ x 1.0))) (t_1 (* t_0 (/ (+ x 1.0) x))))
(if (<= (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))) 0.0)
(/ (- (/ 2.0 (pow x 2.0)) (/ 3.0 x)) t_1)
(/ (+ t_0 (/ (- -1.0 x) x)) t_1))))
double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double t_1 = t_0 * ((x + 1.0) / x);
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = ((2.0 / pow(x, 2.0)) - (3.0 / x)) / t_1;
} else {
tmp = (t_0 + ((-1.0 - x) / x)) / 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 + (-1.0d0)) / (x + 1.0d0)
t_1 = t_0 * ((x + 1.0d0) / x)
if (((x / (x + 1.0d0)) + (((-1.0d0) - x) / (x + (-1.0d0)))) <= 0.0d0) then
tmp = ((2.0d0 / (x ** 2.0d0)) - (3.0d0 / x)) / t_1
else
tmp = (t_0 + (((-1.0d0) - x) / x)) / t_1
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double t_1 = t_0 * ((x + 1.0) / x);
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = ((2.0 / Math.pow(x, 2.0)) - (3.0 / x)) / t_1;
} else {
tmp = (t_0 + ((-1.0 - x) / x)) / t_1;
}
return tmp;
}
def code(x): t_0 = (x + -1.0) / (x + 1.0) t_1 = t_0 * ((x + 1.0) / x) tmp = 0 if ((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0: tmp = ((2.0 / math.pow(x, 2.0)) - (3.0 / x)) / t_1 else: tmp = (t_0 + ((-1.0 - x) / x)) / t_1 return tmp
function code(x) t_0 = Float64(Float64(x + -1.0) / Float64(x + 1.0)) t_1 = Float64(t_0 * Float64(Float64(x + 1.0) / x)) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) <= 0.0) tmp = Float64(Float64(Float64(2.0 / (x ^ 2.0)) - Float64(3.0 / x)) / t_1); else tmp = Float64(Float64(t_0 + Float64(Float64(-1.0 - x) / x)) / t_1); end return tmp end
function tmp_2 = code(x) t_0 = (x + -1.0) / (x + 1.0); t_1 = t_0 * ((x + 1.0) / x); tmp = 0.0; if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) tmp = ((2.0 / (x ^ 2.0)) - (3.0 / x)) / t_1; else tmp = (t_0 + ((-1.0 - x) / x)) / t_1; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(N[(2.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] - N[(3.0 / x), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(t$95$0 + N[(N[(-1.0 - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + -1}{x + 1}\\
t_1 := t_0 \cdot \frac{x + 1}{x}\\
\mathbf{if}\;\frac{x}{x + 1} + \frac{-1 - x}{x + -1} \leq 0:\\
\;\;\;\;\frac{\frac{2}{{x}^{2}} - \frac{3}{x}}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 + \frac{-1 - x}{x}}{t_1}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 0.0Initial program 8.2%
clear-num8.2%
clear-num8.2%
frac-sub8.1%
*-un-lft-identity8.1%
sub-neg8.1%
metadata-eval8.1%
sub-neg8.1%
metadata-eval8.1%
Applied egg-rr8.1%
Taylor expanded in x around inf 98.9%
associate-*r/98.9%
metadata-eval98.9%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 100.0%
clear-num100.0%
clear-num99.9%
frac-sub100.0%
*-un-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification99.6%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (+ x -1.0) (+ x 1.0))))
(if (<= (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))) 0.0)
(- (/ -3.0 x) (/ 1.0 (pow x 2.0)))
(/ (+ t_0 (/ (- -1.0 x) x)) (* t_0 (/ (+ x 1.0) x))))))
double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = (-3.0 / x) - (1.0 / pow(x, 2.0));
} else {
tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (x + (-1.0d0)) / (x + 1.0d0)
if (((x / (x + 1.0d0)) + (((-1.0d0) - x) / (x + (-1.0d0)))) <= 0.0d0) then
tmp = ((-3.0d0) / x) - (1.0d0 / (x ** 2.0d0))
else
tmp = (t_0 + (((-1.0d0) - x) / x)) / (t_0 * ((x + 1.0d0) / x))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = (-3.0 / x) - (1.0 / Math.pow(x, 2.0));
} else {
tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x));
}
return tmp;
}
def code(x): t_0 = (x + -1.0) / (x + 1.0) tmp = 0 if ((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0: tmp = (-3.0 / x) - (1.0 / math.pow(x, 2.0)) else: tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x)) return tmp
function code(x) t_0 = Float64(Float64(x + -1.0) / Float64(x + 1.0)) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) <= 0.0) tmp = Float64(Float64(-3.0 / x) - Float64(1.0 / (x ^ 2.0))); else tmp = Float64(Float64(t_0 + Float64(Float64(-1.0 - x) / x)) / Float64(t_0 * Float64(Float64(x + 1.0) / x))); end return tmp end
function tmp_2 = code(x) t_0 = (x + -1.0) / (x + 1.0); tmp = 0.0; if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) tmp = (-3.0 / x) - (1.0 / (x ^ 2.0)); else tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(-3.0 / x), $MachinePrecision] - N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 + N[(N[(-1.0 - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + -1}{x + 1}\\
\mathbf{if}\;\frac{x}{x + 1} + \frac{-1 - x}{x + -1} \leq 0:\\
\;\;\;\;\frac{-3}{x} - \frac{1}{{x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 + \frac{-1 - x}{x}}{t_0 \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 8.2%
Taylor expanded in x around inf 98.9%
distribute-neg-in98.9%
associate-*r/99.3%
metadata-eval99.3%
distribute-neg-frac99.3%
metadata-eval99.3%
distribute-neg-frac99.3%
metadata-eval99.3%
Simplified99.3%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 100.0%
clear-num100.0%
clear-num99.9%
frac-sub100.0%
*-un-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification99.6%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (+ x -1.0) (+ x 1.0))))
(if (<= (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))) 0.0)
(+ (* 3.0 (/ -1.0 x)) (* (/ 1.0 x) (/ -1.0 x)))
(/ (+ t_0 (/ (- -1.0 x) x)) (* t_0 (/ (+ x 1.0) x))))))
double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = (3.0 * (-1.0 / x)) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (x + (-1.0d0)) / (x + 1.0d0)
if (((x / (x + 1.0d0)) + (((-1.0d0) - x) / (x + (-1.0d0)))) <= 0.0d0) then
tmp = (3.0d0 * ((-1.0d0) / x)) + ((1.0d0 / x) * ((-1.0d0) / x))
else
tmp = (t_0 + (((-1.0d0) - x) / x)) / (t_0 * ((x + 1.0d0) / x))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x + -1.0) / (x + 1.0);
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = (3.0 * (-1.0 / x)) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x));
}
return tmp;
}
def code(x): t_0 = (x + -1.0) / (x + 1.0) tmp = 0 if ((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0: tmp = (3.0 * (-1.0 / x)) + ((1.0 / x) * (-1.0 / x)) else: tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x)) return tmp
function code(x) t_0 = Float64(Float64(x + -1.0) / Float64(x + 1.0)) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) <= 0.0) tmp = Float64(Float64(3.0 * Float64(-1.0 / x)) + Float64(Float64(1.0 / x) * Float64(-1.0 / x))); else tmp = Float64(Float64(t_0 + Float64(Float64(-1.0 - x) / x)) / Float64(t_0 * Float64(Float64(x + 1.0) / x))); end return tmp end
function tmp_2 = code(x) t_0 = (x + -1.0) / (x + 1.0); tmp = 0.0; if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) tmp = (3.0 * (-1.0 / x)) + ((1.0 / x) * (-1.0 / x)); else tmp = (t_0 + ((-1.0 - x) / x)) / (t_0 * ((x + 1.0) / x)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(3.0 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 + N[(N[(-1.0 - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + -1}{x + 1}\\
\mathbf{if}\;\frac{x}{x + 1} + \frac{-1 - x}{x + -1} \leq 0:\\
\;\;\;\;3 \cdot \frac{-1}{x} + \frac{1}{x} \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 + \frac{-1 - x}{x}}{t_0 \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 8.2%
Taylor expanded in x around inf 98.9%
metadata-eval98.9%
unpow298.9%
frac-times98.9%
Applied egg-rr98.9%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 100.0%
clear-num100.0%
clear-num99.9%
frac-sub100.0%
*-un-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (<= (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))) 0.0) (+ (* 3.0 (/ -1.0 x)) (* (/ 1.0 x) (/ -1.0 x))) (/ (+ (/ (+ x -1.0) (+ x 1.0)) (/ (- -1.0 x) x)) (+ 1.0 (/ -1.0 x)))))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = (3.0 * (-1.0 / x)) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = (((x + -1.0) / (x + 1.0)) + ((-1.0 - x) / x)) / (1.0 + (-1.0 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((x / (x + 1.0d0)) + (((-1.0d0) - x) / (x + (-1.0d0)))) <= 0.0d0) then
tmp = (3.0d0 * ((-1.0d0) / x)) + ((1.0d0 / x) * ((-1.0d0) / x))
else
tmp = (((x + (-1.0d0)) / (x + 1.0d0)) + (((-1.0d0) - x) / x)) / (1.0d0 + ((-1.0d0) / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) {
tmp = (3.0 * (-1.0 / x)) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = (((x + -1.0) / (x + 1.0)) + ((-1.0 - x) / x)) / (1.0 + (-1.0 / x));
}
return tmp;
}
def code(x): tmp = 0 if ((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0: tmp = (3.0 * (-1.0 / x)) + ((1.0 / x) * (-1.0 / x)) else: tmp = (((x + -1.0) / (x + 1.0)) + ((-1.0 - x) / x)) / (1.0 + (-1.0 / x)) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) <= 0.0) tmp = Float64(Float64(3.0 * Float64(-1.0 / x)) + Float64(Float64(1.0 / x) * Float64(-1.0 / x))); else tmp = Float64(Float64(Float64(Float64(x + -1.0) / Float64(x + 1.0)) + Float64(Float64(-1.0 - x) / x)) / Float64(1.0 + Float64(-1.0 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0) tmp = (3.0 * (-1.0 / x)) + ((1.0 / x) * (-1.0 / x)); else tmp = (((x + -1.0) / (x + 1.0)) + ((-1.0 - x) / x)) / (1.0 + (-1.0 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(3.0 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} + \frac{-1 - x}{x + -1} \leq 0:\\
\;\;\;\;3 \cdot \frac{-1}{x} + \frac{1}{x} \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + -1}{x + 1} + \frac{-1 - x}{x}}{1 + \frac{-1}{x}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 0.0Initial program 8.2%
Taylor expanded in x around inf 98.9%
metadata-eval98.9%
unpow298.9%
frac-times98.9%
Applied egg-rr98.9%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 100.0%
clear-num100.0%
clear-num99.9%
frac-sub100.0%
*-un-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
sub-neg100.0%
+-commutative100.0%
*-rgt-identity100.0%
+-commutative100.0%
Applied egg-rr100.0%
sub-neg100.0%
Simplified100.0%
Final simplification99.4%
(FPCore (x) :precision binary64 (let* ((t_0 (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))))) (if (<= t_0 0.0) (* (+ 3.0 (/ 1.0 x)) (/ -1.0 x)) t_0)))
double code(double x) {
double t_0 = (x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = (3.0 + (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)) + (((-1.0d0) - x) / (x + (-1.0d0)))
if (t_0 <= 0.0d0) then
tmp = (3.0d0 + (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)) + ((-1.0 - x) / (x + -1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = (3.0 + (1.0 / x)) * (-1.0 / x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = (x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0)) tmp = 0 if t_0 <= 0.0: tmp = (3.0 + (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(-1.0 - x) / Float64(x + -1.0))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(3.0 + 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)) + ((-1.0 - x) / (x + -1.0)); tmp = 0.0; if (t_0 <= 0.0) tmp = (3.0 + (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[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(3.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1} + \frac{-1 - x}{x + -1}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\left(3 + \frac{1}{x}\right) \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 8.2%
Taylor expanded in x around inf 98.9%
metadata-eval98.9%
unpow298.9%
frac-times98.9%
Applied egg-rr98.9%
distribute-rgt-out98.8%
Applied egg-rr98.8%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 100.0%
Final simplification99.4%
(FPCore (x) :precision binary64 (let* ((t_0 (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))))) (if (<= t_0 0.0) (+ (* 3.0 (/ -1.0 x)) (* (/ 1.0 x) (/ -1.0 x))) t_0)))
double code(double x) {
double t_0 = (x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = (3.0 * (-1.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)) + (((-1.0d0) - x) / (x + (-1.0d0)))
if (t_0 <= 0.0d0) then
tmp = (3.0d0 * ((-1.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)) + ((-1.0 - x) / (x + -1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = (3.0 * (-1.0 / x)) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = (x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0)) tmp = 0 if t_0 <= 0.0: tmp = (3.0 * (-1.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(-1.0 - x) / Float64(x + -1.0))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(3.0 * Float64(-1.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)) + ((-1.0 - x) / (x + -1.0)); tmp = 0.0; if (t_0 <= 0.0) tmp = (3.0 * (-1.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[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(3.0 * N[(-1.0 / x), $MachinePrecision]), $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{-1 - x}{x + -1}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;3 \cdot \frac{-1}{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 8.2%
Taylor expanded in x around inf 98.9%
metadata-eval98.9%
unpow298.9%
frac-times98.9%
Applied egg-rr98.9%
if 0.0 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 100.0%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (<= x -1.0) (/ -3.0 x) (if (<= x 1.0) (+ 1.0 (* x (+ x 3.0))) (* (+ 3.0 (/ 1.0 x)) (/ -1.0 x)))))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = -3.0 / x;
} else if (x <= 1.0) {
tmp = 1.0 + (x * (x + 3.0));
} else {
tmp = (3.0 + (1.0 / x)) * (-1.0 / x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = (-3.0d0) / x
else if (x <= 1.0d0) then
tmp = 1.0d0 + (x * (x + 3.0d0))
else
tmp = (3.0d0 + (1.0d0 / x)) * ((-1.0d0) / x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = -3.0 / x;
} else if (x <= 1.0) {
tmp = 1.0 + (x * (x + 3.0));
} else {
tmp = (3.0 + (1.0 / x)) * (-1.0 / x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = -3.0 / x elif x <= 1.0: tmp = 1.0 + (x * (x + 3.0)) else: tmp = (3.0 + (1.0 / x)) * (-1.0 / x) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = Float64(-3.0 / x); elseif (x <= 1.0) tmp = Float64(1.0 + Float64(x * Float64(x + 3.0))); else tmp = Float64(Float64(3.0 + Float64(1.0 / x)) * Float64(-1.0 / x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.0) tmp = -3.0 / x; elseif (x <= 1.0) tmp = 1.0 + (x * (x + 3.0)); else tmp = (3.0 + (1.0 / x)) * (-1.0 / x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.0], N[(-3.0 / x), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 + N[(x * N[(x + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(3.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\mathbf{else}:\\
\;\;\;\;\left(3 + \frac{1}{x}\right) \cdot \frac{-1}{x}\\
\end{array}
\end{array}
if x < -1Initial program 5.7%
Taylor expanded in x around inf 100.0%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.6%
unpow299.6%
distribute-rgt-out99.6%
Simplified99.6%
if 1 < x Initial program 10.1%
Taylor expanded in x around inf 98.4%
metadata-eval98.4%
unpow298.4%
frac-times98.4%
Applied egg-rr98.4%
distribute-rgt-out98.4%
Applied egg-rr98.4%
Final simplification99.3%
(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 8.2%
Taylor expanded in x around inf 98.4%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.6%
unpow299.6%
distribute-rgt-out99.6%
Simplified99.6%
Final simplification98.9%
(FPCore (x)
:precision binary64
(if (<= x -1.0)
(/ -3.0 x)
(if (<= x 1.0)
(+ 1.0 (* x (+ x 3.0)))
(/ 1.0 (+ (* x -0.3333333333333333) 0.1111111111111111)))))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = -3.0 / x;
} else if (x <= 1.0) {
tmp = 1.0 + (x * (x + 3.0));
} else {
tmp = 1.0 / ((x * -0.3333333333333333) + 0.1111111111111111);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = (-3.0d0) / x
else if (x <= 1.0d0) then
tmp = 1.0d0 + (x * (x + 3.0d0))
else
tmp = 1.0d0 / ((x * (-0.3333333333333333d0)) + 0.1111111111111111d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = -3.0 / x;
} else if (x <= 1.0) {
tmp = 1.0 + (x * (x + 3.0));
} else {
tmp = 1.0 / ((x * -0.3333333333333333) + 0.1111111111111111);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = -3.0 / x elif x <= 1.0: tmp = 1.0 + (x * (x + 3.0)) else: tmp = 1.0 / ((x * -0.3333333333333333) + 0.1111111111111111) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = Float64(-3.0 / x); elseif (x <= 1.0) tmp = Float64(1.0 + Float64(x * Float64(x + 3.0))); else tmp = Float64(1.0 / Float64(Float64(x * -0.3333333333333333) + 0.1111111111111111)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.0) tmp = -3.0 / x; elseif (x <= 1.0) tmp = 1.0 + (x * (x + 3.0)); else tmp = 1.0 / ((x * -0.3333333333333333) + 0.1111111111111111); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.0], N[(-3.0 / x), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 + N[(x * N[(x + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(x * -0.3333333333333333), $MachinePrecision] + 0.1111111111111111), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot -0.3333333333333333 + 0.1111111111111111}\\
\end{array}
\end{array}
if x < -1Initial program 5.7%
Taylor expanded in x around inf 100.0%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.6%
unpow299.6%
distribute-rgt-out99.6%
Simplified99.6%
if 1 < x Initial program 10.1%
clear-num10.1%
clear-num10.1%
frac-sub10.0%
*-un-lft-identity10.0%
sub-neg10.0%
metadata-eval10.0%
sub-neg10.0%
metadata-eval10.0%
Applied egg-rr10.0%
Taylor expanded in x around inf 98.4%
associate-*r/98.4%
metadata-eval98.4%
associate-*r/98.8%
metadata-eval98.8%
Simplified98.8%
div-sub98.8%
div-inv98.8%
div-inv98.4%
div-sub98.4%
clear-num98.2%
inv-pow98.2%
Applied egg-rr98.5%
unpow-198.5%
associate-/l*98.5%
sub-neg98.5%
distribute-neg-frac98.5%
metadata-eval98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in x around inf 98.1%
+-commutative98.1%
*-commutative98.1%
Simplified98.1%
Final simplification99.2%
(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 8.2%
Taylor expanded in x around inf 98.4%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.3%
Final simplification98.8%
(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 8.2%
Taylor expanded in x around inf 98.4%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 98.8%
Final simplification98.6%
(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 51.6%
Taylor expanded in x around 0 48.5%
Final simplification48.5%
herbie shell --seed 2023318
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))