
(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 (/ (- 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 (* (- x y) 0.5)) (t_1 (+ -1.0 (/ y x))))
(if (<= x -1300000000.0)
t_1
(if (<= x -3.4e-118)
(- 1.0 (/ x y))
(if (<= x -3e-239)
t_0
(if (<= x -1.6e-280)
1.0
(if (<= x 2.05e-231) t_0 (if (<= x 8.6e+15) 1.0 t_1))))))))
double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double t_1 = -1.0 + (y / x);
double tmp;
if (x <= -1300000000.0) {
tmp = t_1;
} else if (x <= -3.4e-118) {
tmp = 1.0 - (x / y);
} else if (x <= -3e-239) {
tmp = t_0;
} else if (x <= -1.6e-280) {
tmp = 1.0;
} else if (x <= 2.05e-231) {
tmp = t_0;
} else if (x <= 8.6e+15) {
tmp = 1.0;
} else {
tmp = t_1;
}
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 = (x - y) * 0.5d0
t_1 = (-1.0d0) + (y / x)
if (x <= (-1300000000.0d0)) then
tmp = t_1
else if (x <= (-3.4d-118)) then
tmp = 1.0d0 - (x / y)
else if (x <= (-3d-239)) then
tmp = t_0
else if (x <= (-1.6d-280)) then
tmp = 1.0d0
else if (x <= 2.05d-231) then
tmp = t_0
else if (x <= 8.6d+15) then
tmp = 1.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double t_1 = -1.0 + (y / x);
double tmp;
if (x <= -1300000000.0) {
tmp = t_1;
} else if (x <= -3.4e-118) {
tmp = 1.0 - (x / y);
} else if (x <= -3e-239) {
tmp = t_0;
} else if (x <= -1.6e-280) {
tmp = 1.0;
} else if (x <= 2.05e-231) {
tmp = t_0;
} else if (x <= 8.6e+15) {
tmp = 1.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = (x - y) * 0.5 t_1 = -1.0 + (y / x) tmp = 0 if x <= -1300000000.0: tmp = t_1 elif x <= -3.4e-118: tmp = 1.0 - (x / y) elif x <= -3e-239: tmp = t_0 elif x <= -1.6e-280: tmp = 1.0 elif x <= 2.05e-231: tmp = t_0 elif x <= 8.6e+15: tmp = 1.0 else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) * 0.5) t_1 = Float64(-1.0 + Float64(y / x)) tmp = 0.0 if (x <= -1300000000.0) tmp = t_1; elseif (x <= -3.4e-118) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= -3e-239) tmp = t_0; elseif (x <= -1.6e-280) tmp = 1.0; elseif (x <= 2.05e-231) tmp = t_0; elseif (x <= 8.6e+15) tmp = 1.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) * 0.5; t_1 = -1.0 + (y / x); tmp = 0.0; if (x <= -1300000000.0) tmp = t_1; elseif (x <= -3.4e-118) tmp = 1.0 - (x / y); elseif (x <= -3e-239) tmp = t_0; elseif (x <= -1.6e-280) tmp = 1.0; elseif (x <= 2.05e-231) tmp = t_0; elseif (x <= 8.6e+15) tmp = 1.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1300000000.0], t$95$1, If[LessEqual[x, -3.4e-118], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3e-239], t$95$0, If[LessEqual[x, -1.6e-280], 1.0, If[LessEqual[x, 2.05e-231], t$95$0, If[LessEqual[x, 8.6e+15], 1.0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot 0.5\\
t_1 := -1 + \frac{y}{x}\\
\mathbf{if}\;x \leq -1300000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -3.4 \cdot 10^{-118}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-239}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.6 \cdot 10^{-280}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{-231}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 8.6 \cdot 10^{+15}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -1.3e9 or 8.6e15 < x Initial program 100.0%
clear-num99.9%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 83.5%
Taylor expanded in x around 0 83.7%
if -1.3e9 < x < -3.39999999999999991e-118Initial program 99.9%
div-sub99.9%
Applied egg-rr99.9%
Taylor expanded in y around inf 81.0%
associate-*r/81.0%
neg-mul-181.0%
Simplified81.0%
Taylor expanded in y around inf 70.9%
Taylor expanded in x around 0 70.9%
mul-1-neg70.9%
sub-neg70.9%
Simplified70.9%
if -3.39999999999999991e-118 < x < -2.9999999999999998e-239 or -1.6e-280 < x < 2.0500000000000001e-231Initial program 100.0%
clear-num99.9%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 99.9%
Taylor expanded in y around 0 66.7%
if -2.9999999999999998e-239 < x < -1.6e-280 or 2.0500000000000001e-231 < x < 8.6e15Initial program 100.0%
Taylor expanded in y around inf 63.2%
Final simplification73.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (- x y) 0.5)) (t_1 (- 1.0 (/ x y))) (t_2 (/ x (- 2.0 x))))
(if (<= y -3.8e+61)
t_1
(if (<= y -3.4e-14)
(+ -1.0 (/ y x))
(if (<= y -1.75e-140)
t_0
(if (<= y 4.5e-97)
t_2
(if (<= y 2.7e-12) t_0 (if (<= y 4.7e+116) t_2 t_1))))))))
double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double t_1 = 1.0 - (x / y);
double t_2 = x / (2.0 - x);
double tmp;
if (y <= -3.8e+61) {
tmp = t_1;
} else if (y <= -3.4e-14) {
tmp = -1.0 + (y / x);
} else if (y <= -1.75e-140) {
tmp = t_0;
} else if (y <= 4.5e-97) {
tmp = t_2;
} else if (y <= 2.7e-12) {
tmp = t_0;
} else if (y <= 4.7e+116) {
tmp = t_2;
} else {
tmp = t_1;
}
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) :: t_2
real(8) :: tmp
t_0 = (x - y) * 0.5d0
t_1 = 1.0d0 - (x / y)
t_2 = x / (2.0d0 - x)
if (y <= (-3.8d+61)) then
tmp = t_1
else if (y <= (-3.4d-14)) then
tmp = (-1.0d0) + (y / x)
else if (y <= (-1.75d-140)) then
tmp = t_0
else if (y <= 4.5d-97) then
tmp = t_2
else if (y <= 2.7d-12) then
tmp = t_0
else if (y <= 4.7d+116) then
tmp = t_2
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double t_1 = 1.0 - (x / y);
double t_2 = x / (2.0 - x);
double tmp;
if (y <= -3.8e+61) {
tmp = t_1;
} else if (y <= -3.4e-14) {
tmp = -1.0 + (y / x);
} else if (y <= -1.75e-140) {
tmp = t_0;
} else if (y <= 4.5e-97) {
tmp = t_2;
} else if (y <= 2.7e-12) {
tmp = t_0;
} else if (y <= 4.7e+116) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = (x - y) * 0.5 t_1 = 1.0 - (x / y) t_2 = x / (2.0 - x) tmp = 0 if y <= -3.8e+61: tmp = t_1 elif y <= -3.4e-14: tmp = -1.0 + (y / x) elif y <= -1.75e-140: tmp = t_0 elif y <= 4.5e-97: tmp = t_2 elif y <= 2.7e-12: tmp = t_0 elif y <= 4.7e+116: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) * 0.5) t_1 = Float64(1.0 - Float64(x / y)) t_2 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -3.8e+61) tmp = t_1; elseif (y <= -3.4e-14) tmp = Float64(-1.0 + Float64(y / x)); elseif (y <= -1.75e-140) tmp = t_0; elseif (y <= 4.5e-97) tmp = t_2; elseif (y <= 2.7e-12) tmp = t_0; elseif (y <= 4.7e+116) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) * 0.5; t_1 = 1.0 - (x / y); t_2 = x / (2.0 - x); tmp = 0.0; if (y <= -3.8e+61) tmp = t_1; elseif (y <= -3.4e-14) tmp = -1.0 + (y / x); elseif (y <= -1.75e-140) tmp = t_0; elseif (y <= 4.5e-97) tmp = t_2; elseif (y <= 2.7e-12) tmp = t_0; elseif (y <= 4.7e+116) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.8e+61], t$95$1, If[LessEqual[y, -3.4e-14], N[(-1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.75e-140], t$95$0, If[LessEqual[y, 4.5e-97], t$95$2, If[LessEqual[y, 2.7e-12], t$95$0, If[LessEqual[y, 4.7e+116], t$95$2, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot 0.5\\
t_1 := 1 - \frac{x}{y}\\
t_2 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -3.8 \cdot 10^{+61}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -3.4 \cdot 10^{-14}:\\
\;\;\;\;-1 + \frac{y}{x}\\
\mathbf{elif}\;y \leq -1.75 \cdot 10^{-140}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{-97}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-12}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.7 \cdot 10^{+116}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -3.79999999999999995e61 or 4.7000000000000003e116 < y Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 85.7%
associate-*r/85.7%
neg-mul-185.7%
Simplified85.7%
Taylor expanded in y around inf 85.3%
Taylor expanded in x around 0 85.3%
mul-1-neg85.3%
sub-neg85.3%
Simplified85.3%
if -3.79999999999999995e61 < y < -3.40000000000000003e-14Initial program 99.8%
clear-num99.8%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 70.6%
Taylor expanded in x around 0 70.6%
if -3.40000000000000003e-14 < y < -1.7499999999999999e-140 or 4.5000000000000001e-97 < y < 2.6999999999999998e-12Initial program 100.0%
clear-num99.7%
associate-/r/100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 72.3%
Taylor expanded in y around 0 71.6%
if -1.7499999999999999e-140 < y < 4.5000000000000001e-97 or 2.6999999999999998e-12 < y < 4.7000000000000003e116Initial program 100.0%
Taylor expanded in y around 0 74.3%
Final simplification77.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (- x y) 0.5)))
(if (<= x -530000000.0)
-1.0
(if (<= x -1.1e-117)
1.0
(if (<= x -6.5e-242)
t_0
(if (<= x -9.6e-285)
1.0
(if (<= x 1.7e-231) t_0 (if (<= x 3.2e+16) 1.0 -1.0))))))))
double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double tmp;
if (x <= -530000000.0) {
tmp = -1.0;
} else if (x <= -1.1e-117) {
tmp = 1.0;
} else if (x <= -6.5e-242) {
tmp = t_0;
} else if (x <= -9.6e-285) {
tmp = 1.0;
} else if (x <= 1.7e-231) {
tmp = t_0;
} else if (x <= 3.2e+16) {
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) :: t_0
real(8) :: tmp
t_0 = (x - y) * 0.5d0
if (x <= (-530000000.0d0)) then
tmp = -1.0d0
else if (x <= (-1.1d-117)) then
tmp = 1.0d0
else if (x <= (-6.5d-242)) then
tmp = t_0
else if (x <= (-9.6d-285)) then
tmp = 1.0d0
else if (x <= 1.7d-231) then
tmp = t_0
else if (x <= 3.2d+16) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double tmp;
if (x <= -530000000.0) {
tmp = -1.0;
} else if (x <= -1.1e-117) {
tmp = 1.0;
} else if (x <= -6.5e-242) {
tmp = t_0;
} else if (x <= -9.6e-285) {
tmp = 1.0;
} else if (x <= 1.7e-231) {
tmp = t_0;
} else if (x <= 3.2e+16) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = (x - y) * 0.5 tmp = 0 if x <= -530000000.0: tmp = -1.0 elif x <= -1.1e-117: tmp = 1.0 elif x <= -6.5e-242: tmp = t_0 elif x <= -9.6e-285: tmp = 1.0 elif x <= 1.7e-231: tmp = t_0 elif x <= 3.2e+16: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) * 0.5) tmp = 0.0 if (x <= -530000000.0) tmp = -1.0; elseif (x <= -1.1e-117) tmp = 1.0; elseif (x <= -6.5e-242) tmp = t_0; elseif (x <= -9.6e-285) tmp = 1.0; elseif (x <= 1.7e-231) tmp = t_0; elseif (x <= 3.2e+16) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) * 0.5; tmp = 0.0; if (x <= -530000000.0) tmp = -1.0; elseif (x <= -1.1e-117) tmp = 1.0; elseif (x <= -6.5e-242) tmp = t_0; elseif (x <= -9.6e-285) tmp = 1.0; elseif (x <= 1.7e-231) tmp = t_0; elseif (x <= 3.2e+16) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[x, -530000000.0], -1.0, If[LessEqual[x, -1.1e-117], 1.0, If[LessEqual[x, -6.5e-242], t$95$0, If[LessEqual[x, -9.6e-285], 1.0, If[LessEqual[x, 1.7e-231], t$95$0, If[LessEqual[x, 3.2e+16], 1.0, -1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot 0.5\\
\mathbf{if}\;x \leq -530000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{-117}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -6.5 \cdot 10^{-242}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -9.6 \cdot 10^{-285}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-231}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{+16}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -5.3e8 or 3.2e16 < x Initial program 100.0%
Taylor expanded in x around inf 83.4%
if -5.3e8 < x < -1.1000000000000001e-117 or -6.4999999999999998e-242 < x < -9.6000000000000001e-285 or 1.7e-231 < x < 3.2e16Initial program 100.0%
Taylor expanded in y around inf 65.7%
if -1.1000000000000001e-117 < x < -6.4999999999999998e-242 or -9.6000000000000001e-285 < x < 1.7e-231Initial program 100.0%
clear-num99.9%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 99.9%
Taylor expanded in y around 0 66.7%
Final simplification73.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (- x y) 0.5)))
(if (<= x -950000000.0)
-1.0
(if (<= x -3.6e-119)
(- 1.0 (/ x y))
(if (<= x -6.6e-239)
t_0
(if (<= x -9e-285)
1.0
(if (<= x 1.18e-231) t_0 (if (<= x 7.5e+16) 1.0 -1.0))))))))
double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double tmp;
if (x <= -950000000.0) {
tmp = -1.0;
} else if (x <= -3.6e-119) {
tmp = 1.0 - (x / y);
} else if (x <= -6.6e-239) {
tmp = t_0;
} else if (x <= -9e-285) {
tmp = 1.0;
} else if (x <= 1.18e-231) {
tmp = t_0;
} else if (x <= 7.5e+16) {
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) :: t_0
real(8) :: tmp
t_0 = (x - y) * 0.5d0
if (x <= (-950000000.0d0)) then
tmp = -1.0d0
else if (x <= (-3.6d-119)) then
tmp = 1.0d0 - (x / y)
else if (x <= (-6.6d-239)) then
tmp = t_0
else if (x <= (-9d-285)) then
tmp = 1.0d0
else if (x <= 1.18d-231) then
tmp = t_0
else if (x <= 7.5d+16) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x - y) * 0.5;
double tmp;
if (x <= -950000000.0) {
tmp = -1.0;
} else if (x <= -3.6e-119) {
tmp = 1.0 - (x / y);
} else if (x <= -6.6e-239) {
tmp = t_0;
} else if (x <= -9e-285) {
tmp = 1.0;
} else if (x <= 1.18e-231) {
tmp = t_0;
} else if (x <= 7.5e+16) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = (x - y) * 0.5 tmp = 0 if x <= -950000000.0: tmp = -1.0 elif x <= -3.6e-119: tmp = 1.0 - (x / y) elif x <= -6.6e-239: tmp = t_0 elif x <= -9e-285: tmp = 1.0 elif x <= 1.18e-231: tmp = t_0 elif x <= 7.5e+16: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(Float64(x - y) * 0.5) tmp = 0.0 if (x <= -950000000.0) tmp = -1.0; elseif (x <= -3.6e-119) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= -6.6e-239) tmp = t_0; elseif (x <= -9e-285) tmp = 1.0; elseif (x <= 1.18e-231) tmp = t_0; elseif (x <= 7.5e+16) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) * 0.5; tmp = 0.0; if (x <= -950000000.0) tmp = -1.0; elseif (x <= -3.6e-119) tmp = 1.0 - (x / y); elseif (x <= -6.6e-239) tmp = t_0; elseif (x <= -9e-285) tmp = 1.0; elseif (x <= 1.18e-231) tmp = t_0; elseif (x <= 7.5e+16) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[x, -950000000.0], -1.0, If[LessEqual[x, -3.6e-119], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -6.6e-239], t$95$0, If[LessEqual[x, -9e-285], 1.0, If[LessEqual[x, 1.18e-231], t$95$0, If[LessEqual[x, 7.5e+16], 1.0, -1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot 0.5\\
\mathbf{if}\;x \leq -950000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -3.6 \cdot 10^{-119}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq -6.6 \cdot 10^{-239}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -9 \cdot 10^{-285}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.18 \cdot 10^{-231}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+16}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.5e8 or 7.5e16 < x Initial program 100.0%
Taylor expanded in x around inf 83.4%
if -9.5e8 < x < -3.6e-119Initial program 99.9%
div-sub99.9%
Applied egg-rr99.9%
Taylor expanded in y around inf 81.0%
associate-*r/81.0%
neg-mul-181.0%
Simplified81.0%
Taylor expanded in y around inf 70.9%
Taylor expanded in x around 0 70.9%
mul-1-neg70.9%
sub-neg70.9%
Simplified70.9%
if -3.6e-119 < x < -6.5999999999999999e-239 or -9.0000000000000005e-285 < x < 1.18000000000000003e-231Initial program 100.0%
clear-num99.9%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 99.9%
Taylor expanded in y around 0 66.7%
if -6.5999999999999999e-239 < x < -9.0000000000000005e-285 or 1.18000000000000003e-231 < x < 7.5e16Initial program 100.0%
Taylor expanded in y around inf 63.2%
Final simplification73.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))) (t_1 (/ (- y) (- 2.0 y))))
(if (<= x -120000000.0)
t_0
(if (<= x 2.9e-58)
t_1
(if (<= x 3.05e+38)
t_0
(if (<= x 4.1e+89) t_1 (/ -1.0 (/ x (- x y)))))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double t_1 = -y / (2.0 - y);
double tmp;
if (x <= -120000000.0) {
tmp = t_0;
} else if (x <= 2.9e-58) {
tmp = t_1;
} else if (x <= 3.05e+38) {
tmp = t_0;
} else if (x <= 4.1e+89) {
tmp = t_1;
} else {
tmp = -1.0 / (x / (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 = x / (2.0d0 - x)
t_1 = -y / (2.0d0 - y)
if (x <= (-120000000.0d0)) then
tmp = t_0
else if (x <= 2.9d-58) then
tmp = t_1
else if (x <= 3.05d+38) then
tmp = t_0
else if (x <= 4.1d+89) then
tmp = t_1
else
tmp = (-1.0d0) / (x / (x - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (2.0 - x);
double t_1 = -y / (2.0 - y);
double tmp;
if (x <= -120000000.0) {
tmp = t_0;
} else if (x <= 2.9e-58) {
tmp = t_1;
} else if (x <= 3.05e+38) {
tmp = t_0;
} else if (x <= 4.1e+89) {
tmp = t_1;
} else {
tmp = -1.0 / (x / (x - y));
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) t_1 = -y / (2.0 - y) tmp = 0 if x <= -120000000.0: tmp = t_0 elif x <= 2.9e-58: tmp = t_1 elif x <= 3.05e+38: tmp = t_0 elif x <= 4.1e+89: tmp = t_1 else: tmp = -1.0 / (x / (x - y)) return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) t_1 = Float64(Float64(-y) / Float64(2.0 - y)) tmp = 0.0 if (x <= -120000000.0) tmp = t_0; elseif (x <= 2.9e-58) tmp = t_1; elseif (x <= 3.05e+38) tmp = t_0; elseif (x <= 4.1e+89) tmp = t_1; else tmp = Float64(-1.0 / Float64(x / Float64(x - y))); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); t_1 = -y / (2.0 - y); tmp = 0.0; if (x <= -120000000.0) tmp = t_0; elseif (x <= 2.9e-58) tmp = t_1; elseif (x <= 3.05e+38) tmp = t_0; elseif (x <= 4.1e+89) tmp = t_1; else tmp = -1.0 / (x / (x - y)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-y) / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -120000000.0], t$95$0, If[LessEqual[x, 2.9e-58], t$95$1, If[LessEqual[x, 3.05e+38], t$95$0, If[LessEqual[x, 4.1e+89], t$95$1, N[(-1.0 / N[(x / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
t_1 := \frac{-y}{2 - y}\\
\mathbf{if}\;x \leq -120000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{-58}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.05 \cdot 10^{+38}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{+89}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{x}{x - y}}\\
\end{array}
\end{array}
if x < -1.2e8 or 2.8999999999999999e-58 < x < 3.05e38Initial program 100.0%
Taylor expanded in y around 0 81.0%
if -1.2e8 < x < 2.8999999999999999e-58 or 3.05e38 < x < 4.09999999999999985e89Initial program 100.0%
Taylor expanded in x around 0 84.1%
mul-1-neg84.1%
distribute-neg-frac84.1%
Simplified84.1%
if 4.09999999999999985e89 < x Initial program 99.9%
clear-num99.9%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 88.5%
associate-*l/88.7%
associate-/l*88.7%
Applied egg-rr88.7%
Final simplification83.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))) (t_1 (/ (- y) (- 2.0 y))))
(if (<= x -530000000.0)
t_0
(if (<= x 1.55e-58)
t_1
(if (<= x 3.1e+39) t_0 (if (<= x 2.5e+88) t_1 (+ -1.0 (/ y x))))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double t_1 = -y / (2.0 - y);
double tmp;
if (x <= -530000000.0) {
tmp = t_0;
} else if (x <= 1.55e-58) {
tmp = t_1;
} else if (x <= 3.1e+39) {
tmp = t_0;
} else if (x <= 2.5e+88) {
tmp = t_1;
} else {
tmp = -1.0 + (y / x);
}
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 = x / (2.0d0 - x)
t_1 = -y / (2.0d0 - y)
if (x <= (-530000000.0d0)) then
tmp = t_0
else if (x <= 1.55d-58) then
tmp = t_1
else if (x <= 3.1d+39) then
tmp = t_0
else if (x <= 2.5d+88) then
tmp = t_1
else
tmp = (-1.0d0) + (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (2.0 - x);
double t_1 = -y / (2.0 - y);
double tmp;
if (x <= -530000000.0) {
tmp = t_0;
} else if (x <= 1.55e-58) {
tmp = t_1;
} else if (x <= 3.1e+39) {
tmp = t_0;
} else if (x <= 2.5e+88) {
tmp = t_1;
} else {
tmp = -1.0 + (y / x);
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) t_1 = -y / (2.0 - y) tmp = 0 if x <= -530000000.0: tmp = t_0 elif x <= 1.55e-58: tmp = t_1 elif x <= 3.1e+39: tmp = t_0 elif x <= 2.5e+88: tmp = t_1 else: tmp = -1.0 + (y / x) return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) t_1 = Float64(Float64(-y) / Float64(2.0 - y)) tmp = 0.0 if (x <= -530000000.0) tmp = t_0; elseif (x <= 1.55e-58) tmp = t_1; elseif (x <= 3.1e+39) tmp = t_0; elseif (x <= 2.5e+88) tmp = t_1; else tmp = Float64(-1.0 + Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); t_1 = -y / (2.0 - y); tmp = 0.0; if (x <= -530000000.0) tmp = t_0; elseif (x <= 1.55e-58) tmp = t_1; elseif (x <= 3.1e+39) tmp = t_0; elseif (x <= 2.5e+88) tmp = t_1; else tmp = -1.0 + (y / x); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-y) / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -530000000.0], t$95$0, If[LessEqual[x, 1.55e-58], t$95$1, If[LessEqual[x, 3.1e+39], t$95$0, If[LessEqual[x, 2.5e+88], t$95$1, N[(-1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
t_1 := \frac{-y}{2 - y}\\
\mathbf{if}\;x \leq -530000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-58}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+39}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+88}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{y}{x}\\
\end{array}
\end{array}
if x < -5.3e8 or 1.55e-58 < x < 3.1000000000000003e39Initial program 100.0%
Taylor expanded in y around 0 81.0%
if -5.3e8 < x < 1.55e-58 or 3.1000000000000003e39 < x < 2.49999999999999999e88Initial program 100.0%
Taylor expanded in x around 0 84.1%
mul-1-neg84.1%
distribute-neg-frac84.1%
Simplified84.1%
if 2.49999999999999999e88 < x Initial program 99.9%
clear-num99.9%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 88.5%
Taylor expanded in x around 0 88.7%
Final simplification83.9%
(FPCore (x y) :precision binary64 (if (<= x -32000000.0) (/ x (- 2.0 x)) (if (<= x 1.55e+16) (/ (- x y) (- 2.0 y)) (/ -1.0 (/ x (- x y))))))
double code(double x, double y) {
double tmp;
if (x <= -32000000.0) {
tmp = x / (2.0 - x);
} else if (x <= 1.55e+16) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = -1.0 / (x / (x - y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-32000000.0d0)) then
tmp = x / (2.0d0 - x)
else if (x <= 1.55d+16) then
tmp = (x - y) / (2.0d0 - y)
else
tmp = (-1.0d0) / (x / (x - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -32000000.0) {
tmp = x / (2.0 - x);
} else if (x <= 1.55e+16) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = -1.0 / (x / (x - y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -32000000.0: tmp = x / (2.0 - x) elif x <= 1.55e+16: tmp = (x - y) / (2.0 - y) else: tmp = -1.0 / (x / (x - y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -32000000.0) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 1.55e+16) tmp = Float64(Float64(x - y) / Float64(2.0 - y)); else tmp = Float64(-1.0 / Float64(x / Float64(x - y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -32000000.0) tmp = x / (2.0 - x); elseif (x <= 1.55e+16) tmp = (x - y) / (2.0 - y); else tmp = -1.0 / (x / (x - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -32000000.0], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.55e+16], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(x / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -32000000:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+16}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{x}{x - y}}\\
\end{array}
\end{array}
if x < -3.2e7Initial program 100.0%
Taylor expanded in y around 0 87.0%
if -3.2e7 < x < 1.55e16Initial program 100.0%
clear-num99.9%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 98.3%
Taylor expanded in x around 0 98.5%
+-commutative98.5%
mul-1-neg98.5%
sub-neg98.5%
div-sub98.5%
Simplified98.5%
if 1.55e16 < x Initial program 99.9%
clear-num99.9%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 80.8%
associate-*l/81.0%
associate-/l*81.0%
Applied egg-rr81.0%
Final simplification92.4%
(FPCore (x y) :precision binary64 (if (<= x -1650000000.0) -1.0 (if (<= x 3e+16) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1650000000.0) {
tmp = -1.0;
} else if (x <= 3e+16) {
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 (x <= (-1650000000.0d0)) then
tmp = -1.0d0
else if (x <= 3d+16) 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 (x <= -1650000000.0) {
tmp = -1.0;
} else if (x <= 3e+16) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1650000000.0: tmp = -1.0 elif x <= 3e+16: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1650000000.0) tmp = -1.0; elseif (x <= 3e+16) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1650000000.0) tmp = -1.0; elseif (x <= 3e+16) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1650000000.0], -1.0, If[LessEqual[x, 3e+16], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1650000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+16}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.65e9 or 3e16 < x Initial program 100.0%
Taylor expanded in x around inf 83.4%
if -1.65e9 < x < 3e16Initial program 100.0%
Taylor expanded in y around inf 54.9%
Final simplification67.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%
Taylor expanded in x around inf 36.9%
Final simplification36.9%
(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 2024018
(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))))