
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
(FPCore (x y) :precision binary64 (let* ((t_0 (+ y (+ -2.0 x)))) (- (/ y t_0) (/ x t_0))))
double code(double x, double y) {
double t_0 = y + (-2.0 + x);
return (y / t_0) - (x / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = y + ((-2.0d0) + x)
code = (y / t_0) - (x / t_0)
end function
public static double code(double x, double y) {
double t_0 = y + (-2.0 + x);
return (y / t_0) - (x / t_0);
}
def code(x, y): t_0 = y + (-2.0 + x) return (y / t_0) - (x / t_0)
function code(x, y) t_0 = Float64(y + Float64(-2.0 + x)) return Float64(Float64(y / t_0) - Float64(x / t_0)) end
function tmp = code(x, y) t_0 = y + (-2.0 + x); tmp = (y / t_0) - (x / t_0); end
code[x_, y_] := Block[{t$95$0 = N[(y + N[(-2.0 + x), $MachinePrecision]), $MachinePrecision]}, N[(N[(y / t$95$0), $MachinePrecision] - N[(x / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \left(-2 + x\right)\\
\frac{y}{t\_0} - \frac{x}{t\_0}
\end{array}
\end{array}
Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
div-sub100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
associate-+l+100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (- y 2.0))))
(if (<= y -3.3e-40)
t_0
(if (<= y 1.65e-36)
(/ x (- 2.0 x))
(if (<= y 26000000.0)
t_0
(if (<= y 1.25e+49) (/ (- y x) x) (- 1.0 (/ (+ x (+ -2.0 x)) y))))))))
double code(double x, double y) {
double t_0 = y / (y - 2.0);
double tmp;
if (y <= -3.3e-40) {
tmp = t_0;
} else if (y <= 1.65e-36) {
tmp = x / (2.0 - x);
} else if (y <= 26000000.0) {
tmp = t_0;
} else if (y <= 1.25e+49) {
tmp = (y - x) / x;
} else {
tmp = 1.0 - ((x + (-2.0 + x)) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y / (y - 2.0d0)
if (y <= (-3.3d-40)) then
tmp = t_0
else if (y <= 1.65d-36) then
tmp = x / (2.0d0 - x)
else if (y <= 26000000.0d0) then
tmp = t_0
else if (y <= 1.25d+49) then
tmp = (y - x) / x
else
tmp = 1.0d0 - ((x + ((-2.0d0) + x)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (y - 2.0);
double tmp;
if (y <= -3.3e-40) {
tmp = t_0;
} else if (y <= 1.65e-36) {
tmp = x / (2.0 - x);
} else if (y <= 26000000.0) {
tmp = t_0;
} else if (y <= 1.25e+49) {
tmp = (y - x) / x;
} else {
tmp = 1.0 - ((x + (-2.0 + x)) / y);
}
return tmp;
}
def code(x, y): t_0 = y / (y - 2.0) tmp = 0 if y <= -3.3e-40: tmp = t_0 elif y <= 1.65e-36: tmp = x / (2.0 - x) elif y <= 26000000.0: tmp = t_0 elif y <= 1.25e+49: tmp = (y - x) / x else: tmp = 1.0 - ((x + (-2.0 + x)) / y) return tmp
function code(x, y) t_0 = Float64(y / Float64(y - 2.0)) tmp = 0.0 if (y <= -3.3e-40) tmp = t_0; elseif (y <= 1.65e-36) tmp = Float64(x / Float64(2.0 - x)); elseif (y <= 26000000.0) tmp = t_0; elseif (y <= 1.25e+49) tmp = Float64(Float64(y - x) / x); else tmp = Float64(1.0 - Float64(Float64(x + Float64(-2.0 + x)) / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y - 2.0); tmp = 0.0; if (y <= -3.3e-40) tmp = t_0; elseif (y <= 1.65e-36) tmp = x / (2.0 - x); elseif (y <= 26000000.0) tmp = t_0; elseif (y <= 1.25e+49) tmp = (y - x) / x; else tmp = 1.0 - ((x + (-2.0 + x)) / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.3e-40], t$95$0, If[LessEqual[y, 1.65e-36], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 26000000.0], t$95$0, If[LessEqual[y, 1.25e+49], N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - N[(N[(x + N[(-2.0 + x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - 2}\\
\mathbf{if}\;y \leq -3.3 \cdot 10^{-40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{-36}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;y \leq 26000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{+49}:\\
\;\;\;\;\frac{y - x}{x}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x + \left(-2 + x\right)}{y}\\
\end{array}
\end{array}
if y < -3.29999999999999993e-40 or 1.64999999999999995e-36 < y < 2.6e7Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 71.6%
if -3.29999999999999993e-40 < y < 1.64999999999999995e-36Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 82.6%
mul-1-neg82.6%
distribute-neg-frac282.6%
sub-neg82.6%
metadata-eval82.6%
distribute-neg-in82.6%
metadata-eval82.6%
+-commutative82.6%
unsub-neg82.6%
Simplified82.6%
if 2.6e7 < y < 1.2500000000000001e49Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.8%
+-commutative99.8%
associate-+l+99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 87.2%
associate-*l/87.2%
*-un-lft-identity87.2%
Applied egg-rr87.2%
if 1.2500000000000001e49 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
div-sub100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
associate-+l+100.0%
Applied egg-rr100.0%
Taylor expanded in y around -inf 78.5%
mul-1-neg78.5%
unsub-neg78.5%
sub-neg78.5%
neg-mul-178.5%
distribute-neg-in78.5%
metadata-eval78.5%
remove-double-neg78.5%
+-commutative78.5%
Simplified78.5%
Final simplification78.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (- y 2.0))) (t_1 (/ x (- 2.0 x))))
(if (<= y -2e-40)
t_0
(if (<= y 5.5e-37)
t_1
(if (<= y 14000000.0) t_0 (if (<= y 1.15e+49) t_1 (- 1.0 (/ x y))))))))
double code(double x, double y) {
double t_0 = y / (y - 2.0);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -2e-40) {
tmp = t_0;
} else if (y <= 5.5e-37) {
tmp = t_1;
} else if (y <= 14000000.0) {
tmp = t_0;
} else if (y <= 1.15e+49) {
tmp = t_1;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y / (y - 2.0d0)
t_1 = x / (2.0d0 - x)
if (y <= (-2d-40)) then
tmp = t_0
else if (y <= 5.5d-37) then
tmp = t_1
else if (y <= 14000000.0d0) then
tmp = t_0
else if (y <= 1.15d+49) then
tmp = t_1
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (y - 2.0);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -2e-40) {
tmp = t_0;
} else if (y <= 5.5e-37) {
tmp = t_1;
} else if (y <= 14000000.0) {
tmp = t_0;
} else if (y <= 1.15e+49) {
tmp = t_1;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y): t_0 = y / (y - 2.0) t_1 = x / (2.0 - x) tmp = 0 if y <= -2e-40: tmp = t_0 elif y <= 5.5e-37: tmp = t_1 elif y <= 14000000.0: tmp = t_0 elif y <= 1.15e+49: tmp = t_1 else: tmp = 1.0 - (x / y) return tmp
function code(x, y) t_0 = Float64(y / Float64(y - 2.0)) t_1 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -2e-40) tmp = t_0; elseif (y <= 5.5e-37) tmp = t_1; elseif (y <= 14000000.0) tmp = t_0; elseif (y <= 1.15e+49) tmp = t_1; else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y - 2.0); t_1 = x / (2.0 - x); tmp = 0.0; if (y <= -2e-40) tmp = t_0; elseif (y <= 5.5e-37) tmp = t_1; elseif (y <= 14000000.0) tmp = t_0; elseif (y <= 1.15e+49) tmp = t_1; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2e-40], t$95$0, If[LessEqual[y, 5.5e-37], t$95$1, If[LessEqual[y, 14000000.0], t$95$0, If[LessEqual[y, 1.15e+49], t$95$1, N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - 2}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -2 \cdot 10^{-40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-37}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 14000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{+49}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -1.9999999999999999e-40 or 5.4999999999999998e-37 < y < 1.4e7Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 71.6%
if -1.9999999999999999e-40 < y < 5.4999999999999998e-37 or 1.4e7 < y < 1.15000000000000001e49Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 82.9%
mul-1-neg82.9%
distribute-neg-frac282.9%
sub-neg82.9%
metadata-eval82.9%
distribute-neg-in82.9%
metadata-eval82.9%
+-commutative82.9%
unsub-neg82.9%
Simplified82.9%
if 1.15000000000000001e49 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.7%
+-commutative99.7%
associate-+l+99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 77.1%
Taylor expanded in y around 0 77.3%
mul-1-neg77.3%
sub-neg77.3%
Simplified77.3%
Final simplification78.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (- y 2.0))))
(if (<= y -3.3e-40)
t_0
(if (<= y 1.3e-37)
(/ x (- 2.0 x))
(if (<= y 1300000000.0)
t_0
(if (<= y 1.86e+49) (/ (- y x) x) (- 1.0 (/ x y))))))))
double code(double x, double y) {
double t_0 = y / (y - 2.0);
double tmp;
if (y <= -3.3e-40) {
tmp = t_0;
} else if (y <= 1.3e-37) {
tmp = x / (2.0 - x);
} else if (y <= 1300000000.0) {
tmp = t_0;
} else if (y <= 1.86e+49) {
tmp = (y - x) / x;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y / (y - 2.0d0)
if (y <= (-3.3d-40)) then
tmp = t_0
else if (y <= 1.3d-37) then
tmp = x / (2.0d0 - x)
else if (y <= 1300000000.0d0) then
tmp = t_0
else if (y <= 1.86d+49) then
tmp = (y - x) / x
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (y - 2.0);
double tmp;
if (y <= -3.3e-40) {
tmp = t_0;
} else if (y <= 1.3e-37) {
tmp = x / (2.0 - x);
} else if (y <= 1300000000.0) {
tmp = t_0;
} else if (y <= 1.86e+49) {
tmp = (y - x) / x;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y): t_0 = y / (y - 2.0) tmp = 0 if y <= -3.3e-40: tmp = t_0 elif y <= 1.3e-37: tmp = x / (2.0 - x) elif y <= 1300000000.0: tmp = t_0 elif y <= 1.86e+49: tmp = (y - x) / x else: tmp = 1.0 - (x / y) return tmp
function code(x, y) t_0 = Float64(y / Float64(y - 2.0)) tmp = 0.0 if (y <= -3.3e-40) tmp = t_0; elseif (y <= 1.3e-37) tmp = Float64(x / Float64(2.0 - x)); elseif (y <= 1300000000.0) tmp = t_0; elseif (y <= 1.86e+49) tmp = Float64(Float64(y - x) / x); else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y - 2.0); tmp = 0.0; if (y <= -3.3e-40) tmp = t_0; elseif (y <= 1.3e-37) tmp = x / (2.0 - x); elseif (y <= 1300000000.0) tmp = t_0; elseif (y <= 1.86e+49) tmp = (y - x) / x; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.3e-40], t$95$0, If[LessEqual[y, 1.3e-37], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1300000000.0], t$95$0, If[LessEqual[y, 1.86e+49], N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - 2}\\
\mathbf{if}\;y \leq -3.3 \cdot 10^{-40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-37}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;y \leq 1300000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.86 \cdot 10^{+49}:\\
\;\;\;\;\frac{y - x}{x}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -3.29999999999999993e-40 or 1.2999999999999999e-37 < y < 1.3e9Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 71.6%
if -3.29999999999999993e-40 < y < 1.2999999999999999e-37Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 82.6%
mul-1-neg82.6%
distribute-neg-frac282.6%
sub-neg82.6%
metadata-eval82.6%
distribute-neg-in82.6%
metadata-eval82.6%
+-commutative82.6%
unsub-neg82.6%
Simplified82.6%
if 1.3e9 < y < 1.8599999999999999e49Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.8%
+-commutative99.8%
associate-+l+99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 87.2%
associate-*l/87.2%
*-un-lft-identity87.2%
Applied egg-rr87.2%
if 1.8599999999999999e49 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.7%
+-commutative99.7%
associate-+l+99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 77.1%
Taylor expanded in y around 0 77.3%
mul-1-neg77.3%
sub-neg77.3%
Simplified77.3%
Final simplification78.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (- y 2.0))))
(if (<= y -3e-40)
t_0
(if (<= y 2.8e-37)
(/ x (- 2.0 x))
(if (<= y 24000000.0)
t_0
(if (<= y 3.1e+41) (/ (- y x) x) (/ (- y x) y)))))))
double code(double x, double y) {
double t_0 = y / (y - 2.0);
double tmp;
if (y <= -3e-40) {
tmp = t_0;
} else if (y <= 2.8e-37) {
tmp = x / (2.0 - x);
} else if (y <= 24000000.0) {
tmp = t_0;
} else if (y <= 3.1e+41) {
tmp = (y - x) / x;
} else {
tmp = (y - x) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y / (y - 2.0d0)
if (y <= (-3d-40)) then
tmp = t_0
else if (y <= 2.8d-37) then
tmp = x / (2.0d0 - x)
else if (y <= 24000000.0d0) then
tmp = t_0
else if (y <= 3.1d+41) then
tmp = (y - x) / x
else
tmp = (y - x) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (y - 2.0);
double tmp;
if (y <= -3e-40) {
tmp = t_0;
} else if (y <= 2.8e-37) {
tmp = x / (2.0 - x);
} else if (y <= 24000000.0) {
tmp = t_0;
} else if (y <= 3.1e+41) {
tmp = (y - x) / x;
} else {
tmp = (y - x) / y;
}
return tmp;
}
def code(x, y): t_0 = y / (y - 2.0) tmp = 0 if y <= -3e-40: tmp = t_0 elif y <= 2.8e-37: tmp = x / (2.0 - x) elif y <= 24000000.0: tmp = t_0 elif y <= 3.1e+41: tmp = (y - x) / x else: tmp = (y - x) / y return tmp
function code(x, y) t_0 = Float64(y / Float64(y - 2.0)) tmp = 0.0 if (y <= -3e-40) tmp = t_0; elseif (y <= 2.8e-37) tmp = Float64(x / Float64(2.0 - x)); elseif (y <= 24000000.0) tmp = t_0; elseif (y <= 3.1e+41) tmp = Float64(Float64(y - x) / x); else tmp = Float64(Float64(y - x) / y); end return tmp end
function tmp_2 = code(x, y) t_0 = y / (y - 2.0); tmp = 0.0; if (y <= -3e-40) tmp = t_0; elseif (y <= 2.8e-37) tmp = x / (2.0 - x); elseif (y <= 24000000.0) tmp = t_0; elseif (y <= 3.1e+41) tmp = (y - x) / x; else tmp = (y - x) / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3e-40], t$95$0, If[LessEqual[y, 2.8e-37], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 24000000.0], t$95$0, If[LessEqual[y, 3.1e+41], N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - 2}\\
\mathbf{if}\;y \leq -3 \cdot 10^{-40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-37}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;y \leq 24000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{+41}:\\
\;\;\;\;\frac{y - x}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y}\\
\end{array}
\end{array}
if y < -3.0000000000000002e-40 or 2.8000000000000001e-37 < y < 2.4e7Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 71.6%
if -3.0000000000000002e-40 < y < 2.8000000000000001e-37Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 82.6%
mul-1-neg82.6%
distribute-neg-frac282.6%
sub-neg82.6%
metadata-eval82.6%
distribute-neg-in82.6%
metadata-eval82.6%
+-commutative82.6%
unsub-neg82.6%
Simplified82.6%
if 2.4e7 < y < 3.1e41Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
clear-num100.0%
associate-/r/99.8%
+-commutative99.8%
associate-+l+99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 87.2%
associate-*l/87.2%
*-un-lft-identity87.2%
Applied egg-rr87.2%
if 3.1e41 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.7%
+-commutative99.7%
associate-+l+99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 77.1%
associate-*l/77.3%
*-un-lft-identity77.3%
Applied egg-rr77.3%
Final simplification78.4%
(FPCore (x y) :precision binary64 (if (or (<= y -3.3e+24) (not (<= y 1.15e+49))) (- 1.0 (/ x y)) -1.0))
double code(double x, double y) {
double tmp;
if ((y <= -3.3e+24) || !(y <= 1.15e+49)) {
tmp = 1.0 - (x / y);
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-3.3d+24)) .or. (.not. (y <= 1.15d+49))) then
tmp = 1.0d0 - (x / y)
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -3.3e+24) || !(y <= 1.15e+49)) {
tmp = 1.0 - (x / y);
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -3.3e+24) or not (y <= 1.15e+49): tmp = 1.0 - (x / y) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -3.3e+24) || !(y <= 1.15e+49)) tmp = Float64(1.0 - Float64(x / y)); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -3.3e+24) || ~((y <= 1.15e+49))) tmp = 1.0 - (x / y); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -3.3e+24], N[Not[LessEqual[y, 1.15e+49]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{+24} \lor \neg \left(y \leq 1.15 \cdot 10^{+49}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < -3.2999999999999999e24 or 1.15000000000000001e49 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.7%
+-commutative99.7%
associate-+l+99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 76.8%
Taylor expanded in y around 0 77.0%
mul-1-neg77.0%
sub-neg77.0%
Simplified77.0%
if -3.2999999999999999e24 < y < 1.15000000000000001e49Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 54.8%
Final simplification64.0%
(FPCore (x y) :precision binary64 (if (or (<= y -5.4e+24) (not (<= y 4.2e+45))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -5.4e+24) || !(y <= 4.2e+45)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-5.4d+24)) .or. (.not. (y <= 4.2d+45))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -5.4e+24) || !(y <= 4.2e+45)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -5.4e+24) or not (y <= 4.2e+45): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -5.4e+24) || !(y <= 4.2e+45)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -5.4e+24) || ~((y <= 4.2e+45))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -5.4e+24], N[Not[LessEqual[y, 4.2e+45]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+24} \lor \neg \left(y \leq 4.2 \cdot 10^{+45}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -5.4e24 or 4.1999999999999999e45 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.7%
+-commutative99.7%
associate-+l+99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 76.8%
Taylor expanded in y around 0 77.0%
mul-1-neg77.0%
sub-neg77.0%
Simplified77.0%
if -5.4e24 < y < 4.1999999999999999e45Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 75.7%
mul-1-neg75.7%
distribute-neg-frac275.7%
sub-neg75.7%
metadata-eval75.7%
distribute-neg-in75.7%
metadata-eval75.7%
+-commutative75.7%
unsub-neg75.7%
Simplified75.7%
Final simplification76.2%
(FPCore (x y) :precision binary64 (if (<= y -5.5e+22) 1.0 (if (<= y 3.5e+33) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -5.5e+22) {
tmp = 1.0;
} else if (y <= 3.5e+33) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-5.5d+22)) then
tmp = 1.0d0
else if (y <= 3.5d+33) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -5.5e+22) {
tmp = 1.0;
} else if (y <= 3.5e+33) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5.5e+22: tmp = 1.0 elif y <= 3.5e+33: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5.5e+22) tmp = 1.0; elseif (y <= 3.5e+33) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5.5e+22) tmp = 1.0; elseif (y <= 3.5e+33) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5.5e+22], 1.0, If[LessEqual[y, 3.5e+33], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+22}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+33}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.50000000000000021e22 or 3.5000000000000001e33 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 76.6%
if -5.50000000000000021e22 < y < 3.5000000000000001e33Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 54.8%
Final simplification63.8%
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ y x))))
double code(double x, double y) {
return (x - y) / (2.0 - (y + x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (y + x))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (y + x));
}
def code(x, y): return (x - y) / (2.0 - (y + x))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(y + x))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (y + x)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(y + x\right)}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 41.1%
Final simplification41.1%
(FPCore (x y) :precision binary64 (let* ((t_0 (- 2.0 (+ x y)))) (- (/ x t_0) (/ y t_0))))
double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = 2.0d0 - (x + y)
code = (x / t_0) - (y / t_0)
end function
public static double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
def code(x, y): t_0 = 2.0 - (x + y) return (x / t_0) - (y / t_0)
function code(x, y) t_0 = Float64(2.0 - Float64(x + y)) return Float64(Float64(x / t_0) - Float64(y / t_0)) end
function tmp = code(x, y) t_0 = 2.0 - (x + y); tmp = (x / t_0) - (y / t_0); end
code[x_, y_] := Block[{t$95$0 = N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]}, N[(N[(x / t$95$0), $MachinePrecision] - N[(y / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 - \left(x + y\right)\\
\frac{x}{t\_0} - \frac{y}{t\_0}
\end{array}
\end{array}
herbie shell --seed 2024040
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:herbie-target
(- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))
(/ (- x y) (- 2.0 (+ x y))))