
(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 11 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 (- 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}
Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ y x) -1.0)) (t_1 (- 1.0 (/ x y))))
(if (<= x -6.2e+50)
t_0
(if (<= x -1.45e-13)
t_1
(if (<= x -4.6e-125)
(* x 0.5)
(if (<= x 2.45e-269)
t_1
(if (<= x 1.1e-168) (* y -0.5) (if (<= x 480000.0) 1.0 t_0))))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double t_1 = 1.0 - (x / y);
double tmp;
if (x <= -6.2e+50) {
tmp = t_0;
} else if (x <= -1.45e-13) {
tmp = t_1;
} else if (x <= -4.6e-125) {
tmp = x * 0.5;
} else if (x <= 2.45e-269) {
tmp = t_1;
} else if (x <= 1.1e-168) {
tmp = y * -0.5;
} else if (x <= 480000.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) :: t_1
real(8) :: tmp
t_0 = (y / x) + (-1.0d0)
t_1 = 1.0d0 - (x / y)
if (x <= (-6.2d+50)) then
tmp = t_0
else if (x <= (-1.45d-13)) then
tmp = t_1
else if (x <= (-4.6d-125)) then
tmp = x * 0.5d0
else if (x <= 2.45d-269) then
tmp = t_1
else if (x <= 1.1d-168) then
tmp = y * (-0.5d0)
else if (x <= 480000.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 = (y / x) + -1.0;
double t_1 = 1.0 - (x / y);
double tmp;
if (x <= -6.2e+50) {
tmp = t_0;
} else if (x <= -1.45e-13) {
tmp = t_1;
} else if (x <= -4.6e-125) {
tmp = x * 0.5;
} else if (x <= 2.45e-269) {
tmp = t_1;
} else if (x <= 1.1e-168) {
tmp = y * -0.5;
} else if (x <= 480000.0) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 t_1 = 1.0 - (x / y) tmp = 0 if x <= -6.2e+50: tmp = t_0 elif x <= -1.45e-13: tmp = t_1 elif x <= -4.6e-125: tmp = x * 0.5 elif x <= 2.45e-269: tmp = t_1 elif x <= 1.1e-168: tmp = y * -0.5 elif x <= 480000.0: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(y / x) + -1.0) t_1 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (x <= -6.2e+50) tmp = t_0; elseif (x <= -1.45e-13) tmp = t_1; elseif (x <= -4.6e-125) tmp = Float64(x * 0.5); elseif (x <= 2.45e-269) tmp = t_1; elseif (x <= 1.1e-168) tmp = Float64(y * -0.5); elseif (x <= 480000.0) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (y / x) + -1.0; t_1 = 1.0 - (x / y); tmp = 0.0; if (x <= -6.2e+50) tmp = t_0; elseif (x <= -1.45e-13) tmp = t_1; elseif (x <= -4.6e-125) tmp = x * 0.5; elseif (x <= 2.45e-269) tmp = t_1; elseif (x <= 1.1e-168) tmp = y * -0.5; elseif (x <= 480000.0) tmp = 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.2e+50], t$95$0, If[LessEqual[x, -1.45e-13], t$95$1, If[LessEqual[x, -4.6e-125], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 2.45e-269], t$95$1, If[LessEqual[x, 1.1e-168], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 480000.0], 1.0, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
t_1 := 1 - \frac{x}{y}\\
\mathbf{if}\;x \leq -6.2 \cdot 10^{+50}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.45 \cdot 10^{-13}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -4.6 \cdot 10^{-125}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 2.45 \cdot 10^{-269}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-168}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 480000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -6.20000000000000006e50 or 4.8e5 < x Initial program 100.0%
clear-num99.9%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 75.7%
Taylor expanded in x around 0 75.9%
if -6.20000000000000006e50 < x < -1.4499999999999999e-13 or -4.5999999999999998e-125 < x < 2.45e-269Initial program 99.9%
clear-num99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 57.1%
Taylor expanded in y around 0 57.3%
mul-1-neg57.3%
unsub-neg57.3%
Simplified57.3%
if -1.4499999999999999e-13 < x < -4.5999999999999998e-125Initial program 100.0%
Taylor expanded in y around 0 57.9%
Taylor expanded in x around 0 57.9%
*-commutative57.9%
Simplified57.9%
if 2.45e-269 < x < 1.0999999999999999e-168Initial program 100.0%
Taylor expanded in x around 0 82.9%
mul-1-neg82.9%
distribute-neg-frac82.9%
Simplified82.9%
Taylor expanded in y around 0 57.8%
*-commutative57.8%
Simplified57.8%
if 1.0999999999999999e-168 < x < 4.8e5Initial program 100.0%
Taylor expanded in y around inf 78.6%
Final simplification67.2%
(FPCore (x y)
:precision binary64
(if (<= x -9e+52)
-1.0
(if (<= x -2.3e-14)
1.0
(if (<= x -1.8e-125)
(* x 0.5)
(if (<= x 3.4e-269)
1.0
(if (<= x 1.1e-168) (* y -0.5) (if (<= x 600000.0) 1.0 -1.0)))))))
double code(double x, double y) {
double tmp;
if (x <= -9e+52) {
tmp = -1.0;
} else if (x <= -2.3e-14) {
tmp = 1.0;
} else if (x <= -1.8e-125) {
tmp = x * 0.5;
} else if (x <= 3.4e-269) {
tmp = 1.0;
} else if (x <= 1.1e-168) {
tmp = y * -0.5;
} else if (x <= 600000.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 (x <= (-9d+52)) then
tmp = -1.0d0
else if (x <= (-2.3d-14)) then
tmp = 1.0d0
else if (x <= (-1.8d-125)) then
tmp = x * 0.5d0
else if (x <= 3.4d-269) then
tmp = 1.0d0
else if (x <= 1.1d-168) then
tmp = y * (-0.5d0)
else if (x <= 600000.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 (x <= -9e+52) {
tmp = -1.0;
} else if (x <= -2.3e-14) {
tmp = 1.0;
} else if (x <= -1.8e-125) {
tmp = x * 0.5;
} else if (x <= 3.4e-269) {
tmp = 1.0;
} else if (x <= 1.1e-168) {
tmp = y * -0.5;
} else if (x <= 600000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9e+52: tmp = -1.0 elif x <= -2.3e-14: tmp = 1.0 elif x <= -1.8e-125: tmp = x * 0.5 elif x <= 3.4e-269: tmp = 1.0 elif x <= 1.1e-168: tmp = y * -0.5 elif x <= 600000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -9e+52) tmp = -1.0; elseif (x <= -2.3e-14) tmp = 1.0; elseif (x <= -1.8e-125) tmp = Float64(x * 0.5); elseif (x <= 3.4e-269) tmp = 1.0; elseif (x <= 1.1e-168) tmp = Float64(y * -0.5); elseif (x <= 600000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9e+52) tmp = -1.0; elseif (x <= -2.3e-14) tmp = 1.0; elseif (x <= -1.8e-125) tmp = x * 0.5; elseif (x <= 3.4e-269) tmp = 1.0; elseif (x <= 1.1e-168) tmp = y * -0.5; elseif (x <= 600000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9e+52], -1.0, If[LessEqual[x, -2.3e-14], 1.0, If[LessEqual[x, -1.8e-125], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 3.4e-269], 1.0, If[LessEqual[x, 1.1e-168], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 600000.0], 1.0, -1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+52}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-14}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-125}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-269}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-168}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 600000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -8.9999999999999999e52 or 6e5 < x Initial program 100.0%
Taylor expanded in x around inf 75.2%
if -8.9999999999999999e52 < x < -2.29999999999999998e-14 or -1.8000000000000001e-125 < x < 3.3999999999999997e-269 or 1.0999999999999999e-168 < x < 6e5Initial program 100.0%
Taylor expanded in y around inf 61.7%
if -2.29999999999999998e-14 < x < -1.8000000000000001e-125Initial program 100.0%
Taylor expanded in y around 0 57.9%
Taylor expanded in x around 0 57.9%
*-commutative57.9%
Simplified57.9%
if 3.3999999999999997e-269 < x < 1.0999999999999999e-168Initial program 100.0%
Taylor expanded in x around 0 82.9%
mul-1-neg82.9%
distribute-neg-frac82.9%
Simplified82.9%
Taylor expanded in y around 0 57.8%
*-commutative57.8%
Simplified57.8%
Final simplification66.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= x -2.2e+48)
-1.0
(if (<= x -4.5e-16)
t_0
(if (<= x -4.8e-128)
(* x 0.5)
(if (<= x 1.4e-269)
t_0
(if (<= x 1.7e-165) (* y -0.5) (if (<= x 550000.0) 1.0 -1.0))))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (x <= -2.2e+48) {
tmp = -1.0;
} else if (x <= -4.5e-16) {
tmp = t_0;
} else if (x <= -4.8e-128) {
tmp = x * 0.5;
} else if (x <= 1.4e-269) {
tmp = t_0;
} else if (x <= 1.7e-165) {
tmp = y * -0.5;
} else if (x <= 550000.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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (x <= (-2.2d+48)) then
tmp = -1.0d0
else if (x <= (-4.5d-16)) then
tmp = t_0
else if (x <= (-4.8d-128)) then
tmp = x * 0.5d0
else if (x <= 1.4d-269) then
tmp = t_0
else if (x <= 1.7d-165) then
tmp = y * (-0.5d0)
else if (x <= 550000.0d0) 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 = 1.0 - (x / y);
double tmp;
if (x <= -2.2e+48) {
tmp = -1.0;
} else if (x <= -4.5e-16) {
tmp = t_0;
} else if (x <= -4.8e-128) {
tmp = x * 0.5;
} else if (x <= 1.4e-269) {
tmp = t_0;
} else if (x <= 1.7e-165) {
tmp = y * -0.5;
} else if (x <= 550000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) tmp = 0 if x <= -2.2e+48: tmp = -1.0 elif x <= -4.5e-16: tmp = t_0 elif x <= -4.8e-128: tmp = x * 0.5 elif x <= 1.4e-269: tmp = t_0 elif x <= 1.7e-165: tmp = y * -0.5 elif x <= 550000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (x <= -2.2e+48) tmp = -1.0; elseif (x <= -4.5e-16) tmp = t_0; elseif (x <= -4.8e-128) tmp = Float64(x * 0.5); elseif (x <= 1.4e-269) tmp = t_0; elseif (x <= 1.7e-165) tmp = Float64(y * -0.5); elseif (x <= 550000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); tmp = 0.0; if (x <= -2.2e+48) tmp = -1.0; elseif (x <= -4.5e-16) tmp = t_0; elseif (x <= -4.8e-128) tmp = x * 0.5; elseif (x <= 1.4e-269) tmp = t_0; elseif (x <= 1.7e-165) tmp = y * -0.5; elseif (x <= 550000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.2e+48], -1.0, If[LessEqual[x, -4.5e-16], t$95$0, If[LessEqual[x, -4.8e-128], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.4e-269], t$95$0, If[LessEqual[x, 1.7e-165], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 550000.0], 1.0, -1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;x \leq -2.2 \cdot 10^{+48}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -4.5 \cdot 10^{-16}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -4.8 \cdot 10^{-128}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-269}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-165}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 550000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.1999999999999999e48 or 5.5e5 < x Initial program 100.0%
Taylor expanded in x around inf 75.2%
if -2.1999999999999999e48 < x < -4.5000000000000002e-16 or -4.7999999999999996e-128 < x < 1.39999999999999997e-269Initial program 99.9%
clear-num99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 57.1%
Taylor expanded in y around 0 57.3%
mul-1-neg57.3%
unsub-neg57.3%
Simplified57.3%
if -4.5000000000000002e-16 < x < -4.7999999999999996e-128Initial program 100.0%
Taylor expanded in y around 0 57.9%
Taylor expanded in x around 0 57.9%
*-commutative57.9%
Simplified57.9%
if 1.39999999999999997e-269 < x < 1.7e-165Initial program 100.0%
Taylor expanded in x around 0 82.9%
mul-1-neg82.9%
distribute-neg-frac82.9%
Simplified82.9%
Taylor expanded in y around 0 57.8%
*-commutative57.8%
Simplified57.8%
if 1.7e-165 < x < 5.5e5Initial program 100.0%
Taylor expanded in y around inf 78.6%
Final simplification66.9%
(FPCore (x y)
:precision binary64
(if (<= x -2.1e+48)
(+ (/ y x) -1.0)
(if (<= x -8.6e-17)
(- 1.0 (/ x y))
(if (<= x -1.9e-31)
(* x 0.5)
(if (<= x 4.3e-10) (/ y (+ y -2.0)) (/ x (- 2.0 x)))))))
double code(double x, double y) {
double tmp;
if (x <= -2.1e+48) {
tmp = (y / x) + -1.0;
} else if (x <= -8.6e-17) {
tmp = 1.0 - (x / y);
} else if (x <= -1.9e-31) {
tmp = x * 0.5;
} else if (x <= 4.3e-10) {
tmp = y / (y + -2.0);
} 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 (x <= (-2.1d+48)) then
tmp = (y / x) + (-1.0d0)
else if (x <= (-8.6d-17)) then
tmp = 1.0d0 - (x / y)
else if (x <= (-1.9d-31)) then
tmp = x * 0.5d0
else if (x <= 4.3d-10) then
tmp = y / (y + (-2.0d0))
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.1e+48) {
tmp = (y / x) + -1.0;
} else if (x <= -8.6e-17) {
tmp = 1.0 - (x / y);
} else if (x <= -1.9e-31) {
tmp = x * 0.5;
} else if (x <= 4.3e-10) {
tmp = y / (y + -2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.1e+48: tmp = (y / x) + -1.0 elif x <= -8.6e-17: tmp = 1.0 - (x / y) elif x <= -1.9e-31: tmp = x * 0.5 elif x <= 4.3e-10: tmp = y / (y + -2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.1e+48) tmp = Float64(Float64(y / x) + -1.0); elseif (x <= -8.6e-17) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= -1.9e-31) tmp = Float64(x * 0.5); elseif (x <= 4.3e-10) tmp = Float64(y / Float64(y + -2.0)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.1e+48) tmp = (y / x) + -1.0; elseif (x <= -8.6e-17) tmp = 1.0 - (x / y); elseif (x <= -1.9e-31) tmp = x * 0.5; elseif (x <= 4.3e-10) tmp = y / (y + -2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.1e+48], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, -8.6e-17], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.9e-31], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 4.3e-10], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+48}:\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{elif}\;x \leq -8.6 \cdot 10^{-17}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq -1.9 \cdot 10^{-31}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{-10}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -2.0999999999999998e48Initial program 100.0%
clear-num100.0%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 81.2%
Taylor expanded in x around 0 81.5%
if -2.0999999999999998e48 < x < -8.60000000000000046e-17Initial program 99.8%
clear-num99.9%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 63.3%
Taylor expanded in y around 0 63.5%
mul-1-neg63.5%
unsub-neg63.5%
Simplified63.5%
if -8.60000000000000046e-17 < x < -1.9e-31Initial program 100.0%
Taylor expanded in y around 0 79.6%
Taylor expanded in x around 0 79.6%
*-commutative79.6%
Simplified79.6%
if -1.9e-31 < x < 4.30000000000000014e-10Initial program 100.0%
Taylor expanded in x around 0 82.2%
mul-1-neg82.2%
distribute-neg-frac82.2%
Simplified82.2%
frac-2neg82.2%
div-inv82.1%
remove-double-neg82.1%
sub-neg82.1%
distribute-neg-in82.1%
metadata-eval82.1%
remove-double-neg82.1%
Applied egg-rr82.1%
associate-*r/82.2%
*-rgt-identity82.2%
+-commutative82.2%
Simplified82.2%
if 4.30000000000000014e-10 < x Initial program 99.9%
Taylor expanded in y around 0 71.1%
Final simplification78.4%
(FPCore (x y)
:precision binary64
(if (<= x -2.1e+48)
(/ (- x y) (- x))
(if (<= x -3.3e-16)
(- 1.0 (/ x y))
(if (<= x -1.1e-31)
(* x 0.5)
(if (<= x 3e-10) (/ y (+ y -2.0)) (/ x (- 2.0 x)))))))
double code(double x, double y) {
double tmp;
if (x <= -2.1e+48) {
tmp = (x - y) / -x;
} else if (x <= -3.3e-16) {
tmp = 1.0 - (x / y);
} else if (x <= -1.1e-31) {
tmp = x * 0.5;
} else if (x <= 3e-10) {
tmp = y / (y + -2.0);
} 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 (x <= (-2.1d+48)) then
tmp = (x - y) / -x
else if (x <= (-3.3d-16)) then
tmp = 1.0d0 - (x / y)
else if (x <= (-1.1d-31)) then
tmp = x * 0.5d0
else if (x <= 3d-10) then
tmp = y / (y + (-2.0d0))
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.1e+48) {
tmp = (x - y) / -x;
} else if (x <= -3.3e-16) {
tmp = 1.0 - (x / y);
} else if (x <= -1.1e-31) {
tmp = x * 0.5;
} else if (x <= 3e-10) {
tmp = y / (y + -2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.1e+48: tmp = (x - y) / -x elif x <= -3.3e-16: tmp = 1.0 - (x / y) elif x <= -1.1e-31: tmp = x * 0.5 elif x <= 3e-10: tmp = y / (y + -2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.1e+48) tmp = Float64(Float64(x - y) / Float64(-x)); elseif (x <= -3.3e-16) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= -1.1e-31) tmp = Float64(x * 0.5); elseif (x <= 3e-10) tmp = Float64(y / Float64(y + -2.0)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.1e+48) tmp = (x - y) / -x; elseif (x <= -3.3e-16) tmp = 1.0 - (x / y); elseif (x <= -1.1e-31) tmp = x * 0.5; elseif (x <= 3e-10) tmp = y / (y + -2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.1e+48], N[(N[(x - y), $MachinePrecision] / (-x)), $MachinePrecision], If[LessEqual[x, -3.3e-16], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.1e-31], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 3e-10], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+48}:\\
\;\;\;\;\frac{x - y}{-x}\\
\mathbf{elif}\;x \leq -3.3 \cdot 10^{-16}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{-31}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-10}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -2.0999999999999998e48Initial program 100.0%
clear-num100.0%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 81.2%
sub-neg81.2%
distribute-lft-in81.2%
Applied egg-rr81.2%
distribute-lft-out81.2%
sub-neg81.2%
associate-*l/81.5%
remove-double-neg81.5%
neg-mul-181.5%
associate-*r*81.5%
metadata-eval81.5%
associate-*l/81.2%
*-rgt-identity81.2%
*-commutative81.2%
associate-*l*81.2%
metadata-eval81.2%
associate-*l/81.5%
metadata-eval81.5%
distribute-lft-neg-in81.5%
neg-mul-181.5%
remove-double-neg81.5%
times-frac81.5%
neg-mul-181.5%
remove-double-neg81.5%
neg-mul-181.5%
Simplified81.5%
if -2.0999999999999998e48 < x < -3.29999999999999988e-16Initial program 99.8%
clear-num99.9%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 63.3%
Taylor expanded in y around 0 63.5%
mul-1-neg63.5%
unsub-neg63.5%
Simplified63.5%
if -3.29999999999999988e-16 < x < -1.10000000000000005e-31Initial program 100.0%
Taylor expanded in y around 0 79.6%
Taylor expanded in x around 0 79.6%
*-commutative79.6%
Simplified79.6%
if -1.10000000000000005e-31 < x < 3e-10Initial program 100.0%
Taylor expanded in x around 0 82.2%
mul-1-neg82.2%
distribute-neg-frac82.2%
Simplified82.2%
frac-2neg82.2%
div-inv82.1%
remove-double-neg82.1%
sub-neg82.1%
distribute-neg-in82.1%
metadata-eval82.1%
remove-double-neg82.1%
Applied egg-rr82.1%
associate-*r/82.2%
*-rgt-identity82.2%
+-commutative82.2%
Simplified82.2%
if 3e-10 < x Initial program 99.9%
Taylor expanded in y around 0 71.1%
Final simplification78.4%
(FPCore (x y)
:precision binary64
(if (<= x -2e+59)
-1.0
(if (<= x -2e-16)
1.0
(if (<= x -7e-127) (* x 0.5) (if (<= x 600000.0) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -2e+59) {
tmp = -1.0;
} else if (x <= -2e-16) {
tmp = 1.0;
} else if (x <= -7e-127) {
tmp = x * 0.5;
} else if (x <= 600000.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 (x <= (-2d+59)) then
tmp = -1.0d0
else if (x <= (-2d-16)) then
tmp = 1.0d0
else if (x <= (-7d-127)) then
tmp = x * 0.5d0
else if (x <= 600000.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 (x <= -2e+59) {
tmp = -1.0;
} else if (x <= -2e-16) {
tmp = 1.0;
} else if (x <= -7e-127) {
tmp = x * 0.5;
} else if (x <= 600000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2e+59: tmp = -1.0 elif x <= -2e-16: tmp = 1.0 elif x <= -7e-127: tmp = x * 0.5 elif x <= 600000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2e+59) tmp = -1.0; elseif (x <= -2e-16) tmp = 1.0; elseif (x <= -7e-127) tmp = Float64(x * 0.5); elseif (x <= 600000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2e+59) tmp = -1.0; elseif (x <= -2e-16) tmp = 1.0; elseif (x <= -7e-127) tmp = x * 0.5; elseif (x <= 600000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2e+59], -1.0, If[LessEqual[x, -2e-16], 1.0, If[LessEqual[x, -7e-127], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 600000.0], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+59}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-16}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-127}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 600000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.99999999999999994e59 or 6e5 < x Initial program 100.0%
Taylor expanded in x around inf 75.2%
if -1.99999999999999994e59 < x < -2e-16 or -6.99999999999999979e-127 < x < 6e5Initial program 100.0%
Taylor expanded in y around inf 56.9%
if -2e-16 < x < -6.99999999999999979e-127Initial program 100.0%
Taylor expanded in y around 0 57.9%
Taylor expanded in x around 0 57.9%
*-commutative57.9%
Simplified57.9%
Final simplification64.7%
(FPCore (x y) :precision binary64 (if (or (<= y -5.1e+17) (not (<= y 1.65e+30))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -5.1e+17) || !(y <= 1.65e+30)) {
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.1d+17)) .or. (.not. (y <= 1.65d+30))) 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.1e+17) || !(y <= 1.65e+30)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -5.1e+17) or not (y <= 1.65e+30): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -5.1e+17) || !(y <= 1.65e+30)) 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.1e+17) || ~((y <= 1.65e+30))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -5.1e+17], N[Not[LessEqual[y, 1.65e+30]], $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.1 \cdot 10^{+17} \lor \neg \left(y \leq 1.65 \cdot 10^{+30}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -5.1e17 or 1.65000000000000013e30 < y Initial program 100.0%
clear-num99.9%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 78.4%
Taylor expanded in y around 0 78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
if -5.1e17 < y < 1.65000000000000013e30Initial program 100.0%
Taylor expanded in y around 0 69.5%
Final simplification73.8%
(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 (if (<= x -1.12e+49) -1.0 (if (<= x 600000.0) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.12e+49) {
tmp = -1.0;
} else if (x <= 600000.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 (x <= (-1.12d+49)) then
tmp = -1.0d0
else if (x <= 600000.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 (x <= -1.12e+49) {
tmp = -1.0;
} else if (x <= 600000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.12e+49: tmp = -1.0 elif x <= 600000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.12e+49) tmp = -1.0; elseif (x <= 600000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.12e+49) tmp = -1.0; elseif (x <= 600000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.12e+49], -1.0, If[LessEqual[x, 600000.0], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.12 \cdot 10^{+49}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 600000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.12000000000000005e49 or 6e5 < x Initial program 100.0%
Taylor expanded in x around inf 75.2%
if -1.12000000000000005e49 < x < 6e5Initial program 100.0%
Taylor expanded in y around inf 52.8%
Final simplification62.3%
(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 34.9%
Final simplification34.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 2023322
(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))))