
(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 11 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 (/ (+ (/ 1.0 x) 3.0) (* (/ (+ 1.0 x) x) (- 1.0 x))))
double code(double x) {
return ((1.0 / x) + 3.0) / (((1.0 + x) / x) * (1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / x) + 3.0d0) / (((1.0d0 + x) / x) * (1.0d0 - x))
end function
public static double code(double x) {
return ((1.0 / x) + 3.0) / (((1.0 + x) / x) * (1.0 - x));
}
def code(x): return ((1.0 / x) + 3.0) / (((1.0 + x) / x) * (1.0 - x))
function code(x) return Float64(Float64(Float64(1.0 / x) + 3.0) / Float64(Float64(Float64(1.0 + x) / x) * Float64(1.0 - x))) end
function tmp = code(x) tmp = ((1.0 / x) + 3.0) / (((1.0 + x) / x) * (1.0 - x)); end
code[x_] := N[(N[(N[(1.0 / x), $MachinePrecision] + 3.0), $MachinePrecision] / N[(N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x} + 3}{\frac{1 + x}{x} \cdot \left(1 - x\right)}
\end{array}
Initial program 56.6%
remove-double-neg56.6%
distribute-neg-frac56.6%
distribute-neg-in56.6%
sub-neg56.6%
distribute-frac-neg256.6%
sub-neg56.6%
+-commutative56.6%
unsub-neg56.6%
metadata-eval56.6%
neg-sub056.6%
associate-+l-56.6%
neg-sub056.6%
+-commutative56.6%
unsub-neg56.6%
Simplified56.6%
clear-num56.5%
frac-sub57.4%
*-un-lft-identity57.4%
Applied egg-rr57.4%
Taylor expanded in x around inf 100.0%
+-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (let* ((t_0 (+ (/ x (+ 1.0 x)) (/ (- -1.0 x) (+ x -1.0))))) (if (<= t_0 5e-6) (/ (- 3.0 (/ (+ 2.0 (/ -2.0 x)) x)) (- 1.0 x)) t_0)))
double code(double x) {
double t_0 = (x / (1.0 + x)) + ((-1.0 - x) / (x + -1.0));
double tmp;
if (t_0 <= 5e-6) {
tmp = (3.0 - ((2.0 + (-2.0 / x)) / 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 / (1.0d0 + x)) + (((-1.0d0) - x) / (x + (-1.0d0)))
if (t_0 <= 5d-6) then
tmp = (3.0d0 - ((2.0d0 + ((-2.0d0) / x)) / x)) / (1.0d0 - x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x / (1.0 + x)) + ((-1.0 - x) / (x + -1.0));
double tmp;
if (t_0 <= 5e-6) {
tmp = (3.0 - ((2.0 + (-2.0 / x)) / x)) / (1.0 - x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = (x / (1.0 + x)) + ((-1.0 - x) / (x + -1.0)) tmp = 0 if t_0 <= 5e-6: tmp = (3.0 - ((2.0 + (-2.0 / x)) / x)) / (1.0 - x) else: tmp = t_0 return tmp
function code(x) t_0 = Float64(Float64(x / Float64(1.0 + x)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) tmp = 0.0 if (t_0 <= 5e-6) tmp = Float64(Float64(3.0 - Float64(Float64(2.0 + Float64(-2.0 / x)) / x)) / Float64(1.0 - x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x) t_0 = (x / (1.0 + x)) + ((-1.0 - x) / (x + -1.0)); tmp = 0.0; if (t_0 <= 5e-6) tmp = (3.0 - ((2.0 + (-2.0 / x)) / x)) / (1.0 - x); else tmp = t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-6], N[(N[(3.0 - N[(N[(2.0 + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x} + \frac{-1 - x}{x + -1}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{3 - \frac{2 + \frac{-2}{x}}{x}}{1 - x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 5.00000000000000041e-6Initial program 8.9%
remove-double-neg8.9%
distribute-neg-frac8.9%
distribute-neg-in8.9%
sub-neg8.9%
distribute-frac-neg28.9%
sub-neg8.9%
+-commutative8.9%
unsub-neg8.9%
metadata-eval8.9%
neg-sub08.9%
associate-+l-8.9%
neg-sub08.9%
+-commutative8.9%
unsub-neg8.9%
Simplified8.9%
clear-num8.9%
frac-sub10.7%
*-un-lft-identity10.7%
Applied egg-rr10.7%
Taylor expanded in x around inf 100.0%
+-commutative100.0%
Simplified100.0%
pow1100.0%
*-un-lft-identity100.0%
pow1100.0%
div-inv99.6%
associate-/r*99.6%
clear-num99.6%
+-commutative99.6%
Applied egg-rr99.6%
*-lft-identity99.6%
associate-*r/99.9%
associate-*r/99.8%
*-commutative99.8%
+-commutative99.8%
distribute-rgt-in99.8%
fma-define99.8%
lft-mult-inverse99.8%
Simplified99.8%
Taylor expanded in x around -inf 98.9%
mul-1-neg98.9%
unsub-neg98.9%
sub-neg98.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
if 5.00000000000000041e-6 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
Final simplification99.4%
(FPCore (x) :precision binary64 (let* ((t_0 (+ (/ x (+ 1.0 x)) (/ (- -1.0 x) (+ x -1.0))))) (if (<= t_0 5e-6) (/ (+ -3.0 (/ (- -1.0 (/ 3.0 x)) x)) x) t_0)))
double code(double x) {
double t_0 = (x / (1.0 + x)) + ((-1.0 - x) / (x + -1.0));
double tmp;
if (t_0 <= 5e-6) {
tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / 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 / (1.0d0 + x)) + (((-1.0d0) - x) / (x + (-1.0d0)))
if (t_0 <= 5d-6) then
tmp = ((-3.0d0) + (((-1.0d0) - (3.0d0 / x)) / x)) / x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x / (1.0 + x)) + ((-1.0 - x) / (x + -1.0));
double tmp;
if (t_0 <= 5e-6) {
tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = (x / (1.0 + x)) + ((-1.0 - x) / (x + -1.0)) tmp = 0 if t_0 <= 5e-6: tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / x else: tmp = t_0 return tmp
function code(x) t_0 = Float64(Float64(x / Float64(1.0 + x)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) tmp = 0.0 if (t_0 <= 5e-6) tmp = Float64(Float64(-3.0 + Float64(Float64(-1.0 - Float64(3.0 / x)) / x)) / x); else tmp = t_0; end return tmp end
function tmp_2 = code(x) t_0 = (x / (1.0 + x)) + ((-1.0 - x) / (x + -1.0)); tmp = 0.0; if (t_0 <= 5e-6) tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / x; else tmp = t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-6], N[(N[(-3.0 + N[(N[(-1.0 - N[(3.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x} + \frac{-1 - x}{x + -1}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{-3 + \frac{-1 - \frac{3}{x}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 5.00000000000000041e-6Initial program 8.9%
remove-double-neg8.9%
distribute-neg-frac8.9%
distribute-neg-in8.9%
sub-neg8.9%
distribute-frac-neg28.9%
sub-neg8.9%
+-commutative8.9%
unsub-neg8.9%
metadata-eval8.9%
neg-sub08.9%
associate-+l-8.9%
neg-sub08.9%
+-commutative8.9%
unsub-neg8.9%
Simplified8.9%
Taylor expanded in x around inf 98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
mul-1-neg98.9%
unsub-neg98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
if 5.00000000000000041e-6 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ (+ -3.0 (/ (- -1.0 (/ 3.0 x)) x)) x) (+ 1.0 (* x (+ 3.0 (* x (+ 1.0 (* x 3.0))))))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / x;
} else {
tmp = 1.0 + (x * (3.0 + (x * (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) + (((-1.0d0) - (3.0d0 / x)) / x)) / x
else
tmp = 1.0d0 + (x * (3.0d0 + (x * (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 + ((-1.0 - (3.0 / x)) / x)) / x;
} else {
tmp = 1.0 + (x * (3.0 + (x * (1.0 + (x * 3.0)))));
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / x else: tmp = 1.0 + (x * (3.0 + (x * (1.0 + (x * 3.0))))) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(Float64(-3.0 + Float64(Float64(-1.0 - Float64(3.0 / x)) / x)) / x); else tmp = Float64(1.0 + Float64(x * Float64(3.0 + Float64(x * 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 + ((-1.0 - (3.0 / x)) / x)) / x; else tmp = 1.0 + (x * (3.0 + (x * (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[(N[(-3.0 + N[(N[(-1.0 - N[(3.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(1.0 + N[(x * N[(3.0 + N[(x * N[(1.0 + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-3 + \frac{-1 - \frac{3}{x}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(3 + x \cdot \left(1 + x \cdot 3\right)\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 8.2%
remove-double-neg8.2%
distribute-neg-frac8.2%
distribute-neg-in8.2%
sub-neg8.2%
distribute-frac-neg28.2%
sub-neg8.2%
+-commutative8.2%
unsub-neg8.2%
metadata-eval8.2%
neg-sub08.2%
associate-+l-8.2%
neg-sub08.2%
+-commutative8.2%
unsub-neg8.2%
Simplified8.2%
Taylor expanded in x around inf 99.7%
sub-neg99.7%
metadata-eval99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
if -1 < x < 1Initial program 99.9%
remove-double-neg99.9%
distribute-neg-frac99.9%
distribute-neg-in99.9%
sub-neg99.9%
distribute-frac-neg299.9%
sub-neg99.9%
+-commutative99.9%
unsub-neg99.9%
metadata-eval99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 98.9%
Final simplification99.3%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ (+ -3.0 (/ (- -1.0 (/ 3.0 x)) x)) x) (+ 1.0 (* x (+ x 3.0)))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / 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) + (((-1.0d0) - (3.0d0 / x)) / x)) / 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 + ((-1.0 - (3.0 / x)) / x)) / 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 + ((-1.0 - (3.0 / x)) / x)) / 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(Float64(-3.0 + Float64(Float64(-1.0 - Float64(3.0 / x)) / x)) / 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 + ((-1.0 - (3.0 / x)) / x)) / 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[(N[(-3.0 + N[(N[(-1.0 - N[(3.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / 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 + \frac{-1 - \frac{3}{x}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 8.2%
remove-double-neg8.2%
distribute-neg-frac8.2%
distribute-neg-in8.2%
sub-neg8.2%
distribute-frac-neg28.2%
sub-neg8.2%
+-commutative8.2%
unsub-neg8.2%
metadata-eval8.2%
neg-sub08.2%
associate-+l-8.2%
neg-sub08.2%
+-commutative8.2%
unsub-neg8.2%
Simplified8.2%
Taylor expanded in x around inf 99.7%
sub-neg99.7%
metadata-eval99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
if -1 < x < 1Initial program 99.9%
remove-double-neg99.9%
distribute-neg-frac99.9%
distribute-neg-in99.9%
sub-neg99.9%
distribute-frac-neg299.9%
sub-neg99.9%
+-commutative99.9%
unsub-neg99.9%
metadata-eval99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 98.4%
Final simplification99.0%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 0.85))) (/ (- 3.0 (/ 2.0 x)) (- 1.0 x)) (+ 1.0 (* x (+ x 3.0)))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 0.85)) {
tmp = (3.0 - (2.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 <= (-1.0d0)) .or. (.not. (x <= 0.85d0))) then
tmp = (3.0d0 - (2.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 <= -1.0) || !(x <= 0.85)) {
tmp = (3.0 - (2.0 / x)) / (1.0 - x);
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 0.85): tmp = (3.0 - (2.0 / x)) / (1.0 - x) else: tmp = 1.0 + (x * (x + 3.0)) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 0.85)) tmp = Float64(Float64(3.0 - Float64(2.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 <= -1.0) || ~((x <= 0.85))) tmp = (3.0 - (2.0 / x)) / (1.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, 0.85]], $MachinePrecision]], N[(N[(3.0 - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $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 0.85\right):\\
\;\;\;\;\frac{3 - \frac{2}{x}}{1 - x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\end{array}
\end{array}
if x < -1 or 0.849999999999999978 < x Initial program 8.2%
remove-double-neg8.2%
distribute-neg-frac8.2%
distribute-neg-in8.2%
sub-neg8.2%
distribute-frac-neg28.2%
sub-neg8.2%
+-commutative8.2%
unsub-neg8.2%
metadata-eval8.2%
neg-sub08.2%
associate-+l-8.2%
neg-sub08.2%
+-commutative8.2%
unsub-neg8.2%
Simplified8.2%
clear-num8.2%
frac-sub9.9%
*-un-lft-identity9.9%
Applied egg-rr9.9%
Taylor expanded in x around inf 100.0%
+-commutative100.0%
Simplified100.0%
pow1100.0%
*-un-lft-identity100.0%
pow1100.0%
div-inv99.6%
associate-/r*99.6%
clear-num99.6%
+-commutative99.6%
Applied egg-rr99.6%
*-lft-identity99.6%
associate-*r/100.0%
associate-*r/99.8%
*-commutative99.8%
+-commutative99.8%
distribute-rgt-in99.8%
fma-define99.8%
lft-mult-inverse99.8%
Simplified99.8%
Taylor expanded in x around inf 99.4%
associate-*r/99.4%
metadata-eval99.4%
Simplified99.4%
if -1 < x < 0.849999999999999978Initial program 99.9%
remove-double-neg99.9%
distribute-neg-frac99.9%
distribute-neg-in99.9%
sub-neg99.9%
distribute-frac-neg299.9%
sub-neg99.9%
+-commutative99.9%
unsub-neg99.9%
metadata-eval99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 98.4%
Final simplification98.9%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ (+ -3.0 (/ -1.0 x)) x) (+ 1.0 (* x (+ x 3.0)))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = (-3.0 + (-1.0 / x)) / 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) + ((-1.0d0) / x)) / 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 + (-1.0 / x)) / 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 + (-1.0 / x)) / 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(Float64(-3.0 + Float64(-1.0 / x)) / 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 + (-1.0 / x)) / 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[(N[(-3.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / 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 + \frac{-1}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 8.2%
remove-double-neg8.2%
distribute-neg-frac8.2%
distribute-neg-in8.2%
sub-neg8.2%
distribute-frac-neg28.2%
sub-neg8.2%
+-commutative8.2%
unsub-neg8.2%
metadata-eval8.2%
neg-sub08.2%
associate-+l-8.2%
neg-sub08.2%
+-commutative8.2%
unsub-neg8.2%
Simplified8.2%
Taylor expanded in x around inf 99.4%
associate-*r/99.4%
neg-mul-199.4%
distribute-neg-in99.4%
metadata-eval99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
Simplified99.4%
if -1 < x < 1Initial program 99.9%
remove-double-neg99.9%
distribute-neg-frac99.9%
distribute-neg-in99.9%
sub-neg99.9%
distribute-frac-neg299.9%
sub-neg99.9%
+-commutative99.9%
unsub-neg99.9%
metadata-eval99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 98.4%
Final simplification98.9%
(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%
remove-double-neg8.2%
distribute-neg-frac8.2%
distribute-neg-in8.2%
sub-neg8.2%
distribute-frac-neg28.2%
sub-neg8.2%
+-commutative8.2%
unsub-neg8.2%
metadata-eval8.2%
neg-sub08.2%
associate-+l-8.2%
neg-sub08.2%
+-commutative8.2%
unsub-neg8.2%
Simplified8.2%
Taylor expanded in x around inf 98.4%
if -1 < x < 1Initial program 99.9%
remove-double-neg99.9%
distribute-neg-frac99.9%
distribute-neg-in99.9%
sub-neg99.9%
distribute-frac-neg299.9%
sub-neg99.9%
+-commutative99.9%
unsub-neg99.9%
metadata-eval99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 98.4%
Final simplification98.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 8.2%
remove-double-neg8.2%
distribute-neg-frac8.2%
distribute-neg-in8.2%
sub-neg8.2%
distribute-frac-neg28.2%
sub-neg8.2%
+-commutative8.2%
unsub-neg8.2%
metadata-eval8.2%
neg-sub08.2%
associate-+l-8.2%
neg-sub08.2%
+-commutative8.2%
unsub-neg8.2%
Simplified8.2%
Taylor expanded in x around inf 98.4%
if -1 < x < 1Initial program 99.9%
remove-double-neg99.9%
distribute-neg-frac99.9%
distribute-neg-in99.9%
sub-neg99.9%
distribute-frac-neg299.9%
sub-neg99.9%
+-commutative99.9%
unsub-neg99.9%
metadata-eval99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 97.7%
Final simplification98.0%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ -3.0 x) (- x -1.0)))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = x - -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 = x - (-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 = x - -1.0;
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -3.0 / x else: tmp = x - -1.0 return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(-3.0 / x); else tmp = Float64(x - -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 = x - -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], N[(x - -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;x - -1\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 8.2%
remove-double-neg8.2%
distribute-neg-frac8.2%
distribute-neg-in8.2%
sub-neg8.2%
distribute-frac-neg28.2%
sub-neg8.2%
+-commutative8.2%
unsub-neg8.2%
metadata-eval8.2%
neg-sub08.2%
associate-+l-8.2%
neg-sub08.2%
+-commutative8.2%
unsub-neg8.2%
Simplified8.2%
Taylor expanded in x around inf 98.4%
if -1 < x < 1Initial program 99.9%
remove-double-neg99.9%
distribute-neg-frac99.9%
distribute-neg-in99.9%
sub-neg99.9%
distribute-frac-neg299.9%
sub-neg99.9%
+-commutative99.9%
unsub-neg99.9%
metadata-eval99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 95.6%
Taylor expanded in x around 0 95.4%
Final simplification96.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 56.6%
remove-double-neg56.6%
distribute-neg-frac56.6%
distribute-neg-in56.6%
sub-neg56.6%
distribute-frac-neg256.6%
sub-neg56.6%
+-commutative56.6%
unsub-neg56.6%
metadata-eval56.6%
neg-sub056.6%
associate-+l-56.6%
neg-sub056.6%
+-commutative56.6%
unsub-neg56.6%
Simplified56.6%
Taylor expanded in x around 0 52.1%
herbie shell --seed 2024085
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))