
(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 8 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 (/ (- 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}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -1.55e+41)
t_0
(if (<= y -9.5e-49)
-1.0
(if (<= y -2.9e-134) (* y -0.5) (if (<= y 58.0) -1.0 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -1.55e+41) {
tmp = t_0;
} else if (y <= -9.5e-49) {
tmp = -1.0;
} else if (y <= -2.9e-134) {
tmp = y * -0.5;
} else if (y <= 58.0) {
tmp = -1.0;
} else {
tmp = t_0;
}
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 = 1.0d0 - (x / y)
if (y <= (-1.55d+41)) then
tmp = t_0
else if (y <= (-9.5d-49)) then
tmp = -1.0d0
else if (y <= (-2.9d-134)) then
tmp = y * (-0.5d0)
else if (y <= 58.0d0) then
tmp = -1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -1.55e+41) {
tmp = t_0;
} else if (y <= -9.5e-49) {
tmp = -1.0;
} else if (y <= -2.9e-134) {
tmp = y * -0.5;
} else if (y <= 58.0) {
tmp = -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) tmp = 0 if y <= -1.55e+41: tmp = t_0 elif y <= -9.5e-49: tmp = -1.0 elif y <= -2.9e-134: tmp = y * -0.5 elif y <= 58.0: tmp = -1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -1.55e+41) tmp = t_0; elseif (y <= -9.5e-49) tmp = -1.0; elseif (y <= -2.9e-134) tmp = Float64(y * -0.5); elseif (y <= 58.0) tmp = -1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -1.55e+41) tmp = t_0; elseif (y <= -9.5e-49) tmp = -1.0; elseif (y <= -2.9e-134) tmp = y * -0.5; elseif (y <= 58.0) tmp = -1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.55e+41], t$95$0, If[LessEqual[y, -9.5e-49], -1.0, If[LessEqual[y, -2.9e-134], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 58.0], -1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -1.55 \cdot 10^{+41}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -9.5 \cdot 10^{-49}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -2.9 \cdot 10^{-134}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 58:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.55e41 or 58 < y 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%
clear-num99.9%
associate-/r/99.7%
+-commutative99.7%
associate-+l+99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 76.9%
Taylor expanded in y around 0 77.0%
neg-mul-177.0%
sub-neg77.0%
Simplified77.0%
if -1.55e41 < y < -9.50000000000000006e-49 or -2.89999999999999993e-134 < y < 58Initial 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 59.0%
if -9.50000000000000006e-49 < y < -2.89999999999999993e-134Initial 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 0 61.6%
Taylor expanded in y around 0 61.6%
*-commutative61.6%
Simplified61.6%
Final simplification66.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ x (- 2.0 x))))
(if (<= y -1.7e+42)
t_0
(if (<= y -1.6e-101)
t_1
(if (<= y -6.7e-134) (* y -0.5) (if (<= y 58.0) t_1 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -1.7e+42) {
tmp = t_0;
} else if (y <= -1.6e-101) {
tmp = t_1;
} else if (y <= -6.7e-134) {
tmp = y * -0.5;
} else if (y <= 58.0) {
tmp = t_1;
} else {
tmp = t_0;
}
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 = 1.0d0 - (x / y)
t_1 = x / (2.0d0 - x)
if (y <= (-1.7d+42)) then
tmp = t_0
else if (y <= (-1.6d-101)) then
tmp = t_1
else if (y <= (-6.7d-134)) then
tmp = y * (-0.5d0)
else if (y <= 58.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (2.0 - x);
double tmp;
if (y <= -1.7e+42) {
tmp = t_0;
} else if (y <= -1.6e-101) {
tmp = t_1;
} else if (y <= -6.7e-134) {
tmp = y * -0.5;
} else if (y <= 58.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) t_1 = x / (2.0 - x) tmp = 0 if y <= -1.7e+42: tmp = t_0 elif y <= -1.6e-101: tmp = t_1 elif y <= -6.7e-134: tmp = y * -0.5 elif y <= 58.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) t_1 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -1.7e+42) tmp = t_0; elseif (y <= -1.6e-101) tmp = t_1; elseif (y <= -6.7e-134) tmp = Float64(y * -0.5); elseif (y <= 58.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); t_1 = x / (2.0 - x); tmp = 0.0; if (y <= -1.7e+42) tmp = t_0; elseif (y <= -1.6e-101) tmp = t_1; elseif (y <= -6.7e-134) tmp = y * -0.5; elseif (y <= 58.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.7e+42], t$95$0, If[LessEqual[y, -1.6e-101], t$95$1, If[LessEqual[y, -6.7e-134], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 58.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
t_1 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -1.7 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.6 \cdot 10^{-101}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -6.7 \cdot 10^{-134}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 58:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.69999999999999988e42 or 58 < y 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%
clear-num99.9%
associate-/r/99.7%
+-commutative99.7%
associate-+l+99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 76.9%
Taylor expanded in y around 0 77.0%
neg-mul-177.0%
sub-neg77.0%
Simplified77.0%
if -1.69999999999999988e42 < y < -1.59999999999999989e-101 or -6.69999999999999996e-134 < y < 58Initial 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 81.9%
mul-1-neg81.9%
distribute-neg-frac281.9%
sub-neg81.9%
metadata-eval81.9%
distribute-neg-in81.9%
metadata-eval81.9%
+-commutative81.9%
unsub-neg81.9%
Simplified81.9%
if -1.59999999999999989e-101 < y < -6.69999999999999996e-134Initial 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 0 100.0%
Taylor expanded in y around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification80.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -3.1e+41)
(- 1.0 (/ x y))
(if (<= y -8.5e-102)
t_0
(if (<= y -6.7e-134)
(* y -0.5)
(if (<= y 1.15e-7) t_0 (/ y (- y 2.0))))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -3.1e+41) {
tmp = 1.0 - (x / y);
} else if (y <= -8.5e-102) {
tmp = t_0;
} else if (y <= -6.7e-134) {
tmp = y * -0.5;
} else if (y <= 1.15e-7) {
tmp = t_0;
} else {
tmp = y / (y - 2.0);
}
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 = x / (2.0d0 - x)
if (y <= (-3.1d+41)) then
tmp = 1.0d0 - (x / y)
else if (y <= (-8.5d-102)) then
tmp = t_0
else if (y <= (-6.7d-134)) then
tmp = y * (-0.5d0)
else if (y <= 1.15d-7) then
tmp = t_0
else
tmp = y / (y - 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -3.1e+41) {
tmp = 1.0 - (x / y);
} else if (y <= -8.5e-102) {
tmp = t_0;
} else if (y <= -6.7e-134) {
tmp = y * -0.5;
} else if (y <= 1.15e-7) {
tmp = t_0;
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -3.1e+41: tmp = 1.0 - (x / y) elif y <= -8.5e-102: tmp = t_0 elif y <= -6.7e-134: tmp = y * -0.5 elif y <= 1.15e-7: tmp = t_0 else: tmp = y / (y - 2.0) return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -3.1e+41) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= -8.5e-102) tmp = t_0; elseif (y <= -6.7e-134) tmp = Float64(y * -0.5); elseif (y <= 1.15e-7) tmp = t_0; else tmp = Float64(y / Float64(y - 2.0)); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); tmp = 0.0; if (y <= -3.1e+41) tmp = 1.0 - (x / y); elseif (y <= -8.5e-102) tmp = t_0; elseif (y <= -6.7e-134) tmp = y * -0.5; elseif (y <= 1.15e-7) tmp = t_0; else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.1e+41], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -8.5e-102], t$95$0, If[LessEqual[y, -6.7e-134], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.15e-7], t$95$0, N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -3.1 \cdot 10^{+41}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq -8.5 \cdot 10^{-102}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -6.7 \cdot 10^{-134}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if 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-num99.9%
associate-/r/99.7%
+-commutative99.7%
associate-+l+99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 86.4%
Taylor expanded in y around 0 86.6%
neg-mul-186.6%
sub-neg86.6%
Simplified86.6%
if -3.1e41 < y < -8.49999999999999973e-102 or -6.69999999999999996e-134 < y < 1.14999999999999997e-7Initial 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 81.9%
mul-1-neg81.9%
distribute-neg-frac281.9%
sub-neg81.9%
metadata-eval81.9%
distribute-neg-in81.9%
metadata-eval81.9%
+-commutative81.9%
unsub-neg81.9%
Simplified81.9%
if -8.49999999999999973e-102 < y < -6.69999999999999996e-134Initial 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 0 100.0%
Taylor expanded in y around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 1.14999999999999997e-7 < 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 x around 0 72.4%
Final simplification81.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -1e+41)
(+ 1.0 (/ (* x -2.0) y))
(if (<= y -4.5e-102)
t_0
(if (<= y -6.7e-134)
(* y -0.5)
(if (<= y 1.9e-9) t_0 (/ y (- y 2.0))))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -1e+41) {
tmp = 1.0 + ((x * -2.0) / y);
} else if (y <= -4.5e-102) {
tmp = t_0;
} else if (y <= -6.7e-134) {
tmp = y * -0.5;
} else if (y <= 1.9e-9) {
tmp = t_0;
} else {
tmp = y / (y - 2.0);
}
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 = x / (2.0d0 - x)
if (y <= (-1d+41)) then
tmp = 1.0d0 + ((x * (-2.0d0)) / y)
else if (y <= (-4.5d-102)) then
tmp = t_0
else if (y <= (-6.7d-134)) then
tmp = y * (-0.5d0)
else if (y <= 1.9d-9) then
tmp = t_0
else
tmp = y / (y - 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -1e+41) {
tmp = 1.0 + ((x * -2.0) / y);
} else if (y <= -4.5e-102) {
tmp = t_0;
} else if (y <= -6.7e-134) {
tmp = y * -0.5;
} else if (y <= 1.9e-9) {
tmp = t_0;
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -1e+41: tmp = 1.0 + ((x * -2.0) / y) elif y <= -4.5e-102: tmp = t_0 elif y <= -6.7e-134: tmp = y * -0.5 elif y <= 1.9e-9: tmp = t_0 else: tmp = y / (y - 2.0) return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -1e+41) tmp = Float64(1.0 + Float64(Float64(x * -2.0) / y)); elseif (y <= -4.5e-102) tmp = t_0; elseif (y <= -6.7e-134) tmp = Float64(y * -0.5); elseif (y <= 1.9e-9) tmp = t_0; else tmp = Float64(y / Float64(y - 2.0)); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); tmp = 0.0; if (y <= -1e+41) tmp = 1.0 + ((x * -2.0) / y); elseif (y <= -4.5e-102) tmp = t_0; elseif (y <= -6.7e-134) tmp = y * -0.5; elseif (y <= 1.9e-9) tmp = t_0; else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1e+41], N[(1.0 + N[(N[(x * -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -4.5e-102], t$95$0, If[LessEqual[y, -6.7e-134], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.9e-9], t$95$0, N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -1 \cdot 10^{+41}:\\
\;\;\;\;1 + \frac{x \cdot -2}{y}\\
\mathbf{elif}\;y \leq -4.5 \cdot 10^{-102}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -6.7 \cdot 10^{-134}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if y < -1.00000000000000001e41Initial 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-num99.9%
associate-/r/99.7%
+-commutative99.7%
associate-+l+99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 87.0%
associate--l+87.0%
+-commutative87.0%
mul-1-neg87.0%
unsub-neg87.0%
associate-*r/87.0%
metadata-eval87.0%
div-sub87.0%
div-sub87.0%
Simplified87.0%
Taylor expanded in x around inf 87.0%
*-commutative87.0%
Simplified87.0%
if -1.00000000000000001e41 < y < -4.49999999999999999e-102 or -6.69999999999999996e-134 < y < 1.90000000000000006e-9Initial 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 81.9%
mul-1-neg81.9%
distribute-neg-frac281.9%
sub-neg81.9%
metadata-eval81.9%
distribute-neg-in81.9%
metadata-eval81.9%
+-commutative81.9%
unsub-neg81.9%
Simplified81.9%
if -4.49999999999999999e-102 < y < -6.69999999999999996e-134Initial 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 0 100.0%
Taylor expanded in y around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 1.90000000000000006e-9 < 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 x around 0 72.4%
Final simplification81.2%
(FPCore (x y)
:precision binary64
(if (<= y -5e+41)
1.0
(if (<= y -3e-48)
-1.0
(if (<= y -3.5e-134) (* y -0.5) (if (<= y 58.0) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -5e+41) {
tmp = 1.0;
} else if (y <= -3e-48) {
tmp = -1.0;
} else if (y <= -3.5e-134) {
tmp = y * -0.5;
} else if (y <= 58.0) {
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 <= (-5d+41)) then
tmp = 1.0d0
else if (y <= (-3d-48)) then
tmp = -1.0d0
else if (y <= (-3.5d-134)) then
tmp = y * (-0.5d0)
else if (y <= 58.0d0) 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 <= -5e+41) {
tmp = 1.0;
} else if (y <= -3e-48) {
tmp = -1.0;
} else if (y <= -3.5e-134) {
tmp = y * -0.5;
} else if (y <= 58.0) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5e+41: tmp = 1.0 elif y <= -3e-48: tmp = -1.0 elif y <= -3.5e-134: tmp = y * -0.5 elif y <= 58.0: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5e+41) tmp = 1.0; elseif (y <= -3e-48) tmp = -1.0; elseif (y <= -3.5e-134) tmp = Float64(y * -0.5); elseif (y <= 58.0) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5e+41) tmp = 1.0; elseif (y <= -3e-48) tmp = -1.0; elseif (y <= -3.5e-134) tmp = y * -0.5; elseif (y <= 58.0) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5e+41], 1.0, If[LessEqual[y, -3e-48], -1.0, If[LessEqual[y, -3.5e-134], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 58.0], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+41}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -3 \cdot 10^{-48}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -3.5 \cdot 10^{-134}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 58:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.00000000000000022e41 or 58 < y 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 y around inf 76.4%
if -5.00000000000000022e41 < y < -2.9999999999999999e-48 or -3.4999999999999998e-134 < y < 58Initial 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 59.0%
if -2.9999999999999999e-48 < y < -3.4999999999999998e-134Initial 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 0 61.6%
Taylor expanded in y around 0 61.6%
*-commutative61.6%
Simplified61.6%
Final simplification66.6%
(FPCore (x y) :precision binary64 (if (<= y -1.5e+42) 1.0 (if (<= y 58.0) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.5e+42) {
tmp = 1.0;
} else if (y <= 58.0) {
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 <= (-1.5d+42)) then
tmp = 1.0d0
else if (y <= 58.0d0) 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 <= -1.5e+42) {
tmp = 1.0;
} else if (y <= 58.0) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.5e+42: tmp = 1.0 elif y <= 58.0: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.5e+42) tmp = 1.0; elseif (y <= 58.0) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.5e+42) tmp = 1.0; elseif (y <= 58.0) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.5e+42], 1.0, If[LessEqual[y, 58.0], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{+42}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 58:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.50000000000000014e42 or 58 < y 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 y around inf 76.4%
if -1.50000000000000014e42 < y < 58Initial 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.5%
Final simplification63.9%
(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 40.3%
Final simplification40.3%
(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 2024041
(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))))