
(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 (+ (/ y x) -1.0)) (t_1 (+ 1.0 (/ 2.0 y))))
(if (<= x -4.8e+64)
t_0
(if (<= x -1.2e-43)
t_1
(if (<= x -2.3e-119)
(* x 0.5)
(if (<= x -1.95e-258)
t_1
(if (<= x 1.5e-265)
(* y -0.5)
(if (<= x 140000000.0) 1.0 t_0))))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double t_1 = 1.0 + (2.0 / y);
double tmp;
if (x <= -4.8e+64) {
tmp = t_0;
} else if (x <= -1.2e-43) {
tmp = t_1;
} else if (x <= -2.3e-119) {
tmp = x * 0.5;
} else if (x <= -1.95e-258) {
tmp = t_1;
} else if (x <= 1.5e-265) {
tmp = y * -0.5;
} else if (x <= 140000000.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 + (2.0d0 / y)
if (x <= (-4.8d+64)) then
tmp = t_0
else if (x <= (-1.2d-43)) then
tmp = t_1
else if (x <= (-2.3d-119)) then
tmp = x * 0.5d0
else if (x <= (-1.95d-258)) then
tmp = t_1
else if (x <= 1.5d-265) then
tmp = y * (-0.5d0)
else if (x <= 140000000.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 + (2.0 / y);
double tmp;
if (x <= -4.8e+64) {
tmp = t_0;
} else if (x <= -1.2e-43) {
tmp = t_1;
} else if (x <= -2.3e-119) {
tmp = x * 0.5;
} else if (x <= -1.95e-258) {
tmp = t_1;
} else if (x <= 1.5e-265) {
tmp = y * -0.5;
} else if (x <= 140000000.0) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 t_1 = 1.0 + (2.0 / y) tmp = 0 if x <= -4.8e+64: tmp = t_0 elif x <= -1.2e-43: tmp = t_1 elif x <= -2.3e-119: tmp = x * 0.5 elif x <= -1.95e-258: tmp = t_1 elif x <= 1.5e-265: tmp = y * -0.5 elif x <= 140000000.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(2.0 / y)) tmp = 0.0 if (x <= -4.8e+64) tmp = t_0; elseif (x <= -1.2e-43) tmp = t_1; elseif (x <= -2.3e-119) tmp = Float64(x * 0.5); elseif (x <= -1.95e-258) tmp = t_1; elseif (x <= 1.5e-265) tmp = Float64(y * -0.5); elseif (x <= 140000000.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 + (2.0 / y); tmp = 0.0; if (x <= -4.8e+64) tmp = t_0; elseif (x <= -1.2e-43) tmp = t_1; elseif (x <= -2.3e-119) tmp = x * 0.5; elseif (x <= -1.95e-258) tmp = t_1; elseif (x <= 1.5e-265) tmp = y * -0.5; elseif (x <= 140000000.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[(2.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.8e+64], t$95$0, If[LessEqual[x, -1.2e-43], t$95$1, If[LessEqual[x, -2.3e-119], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -1.95e-258], t$95$1, If[LessEqual[x, 1.5e-265], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 140000000.0], 1.0, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
t_1 := 1 + \frac{2}{y}\\
\mathbf{if}\;x \leq -4.8 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.2 \cdot 10^{-43}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-119}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -1.95 \cdot 10^{-258}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-265}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 140000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.79999999999999999e64 or 1.4e8 < x Initial program 100.0%
Taylor expanded in x around inf 82.4%
mul-1-neg82.4%
Simplified82.4%
Taylor expanded in x around 0 82.4%
if -4.79999999999999999e64 < x < -1.2000000000000001e-43 or -2.29999999999999993e-119 < x < -1.95000000000000002e-258Initial program 100.0%
Taylor expanded in y around inf 50.1%
sub-neg50.1%
mul-1-neg50.1%
unsub-neg50.1%
mul-1-neg50.1%
remove-double-neg50.1%
Simplified50.1%
Taylor expanded in x around 0 50.2%
associate-*r/50.2%
metadata-eval50.2%
Simplified50.2%
if -1.2000000000000001e-43 < x < -2.29999999999999993e-119Initial program 100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 59.9%
*-commutative59.9%
Simplified59.9%
if -1.95000000000000002e-258 < x < 1.4999999999999999e-265Initial program 100.0%
Taylor expanded in x around 0 81.3%
associate-*r/81.3%
neg-mul-181.3%
Simplified81.3%
Taylor expanded in y around 0 64.9%
*-commutative64.9%
Simplified64.9%
if 1.4999999999999999e-265 < x < 1.4e8Initial program 100.0%
Taylor expanded in y around inf 62.3%
Final simplification69.1%
(FPCore (x y)
:precision binary64
(if (<= x -9.2e+64)
-1.0
(if (<= x -1.26e-36)
1.0
(if (<= x -4.5e-122)
(* x 0.5)
(if (<= x -1.82e-258)
1.0
(if (<= x 5.2e-267) (* y -0.5) (if (<= x 125000000.0) 1.0 -1.0)))))))
double code(double x, double y) {
double tmp;
if (x <= -9.2e+64) {
tmp = -1.0;
} else if (x <= -1.26e-36) {
tmp = 1.0;
} else if (x <= -4.5e-122) {
tmp = x * 0.5;
} else if (x <= -1.82e-258) {
tmp = 1.0;
} else if (x <= 5.2e-267) {
tmp = y * -0.5;
} else if (x <= 125000000.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 <= (-9.2d+64)) then
tmp = -1.0d0
else if (x <= (-1.26d-36)) then
tmp = 1.0d0
else if (x <= (-4.5d-122)) then
tmp = x * 0.5d0
else if (x <= (-1.82d-258)) then
tmp = 1.0d0
else if (x <= 5.2d-267) then
tmp = y * (-0.5d0)
else if (x <= 125000000.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 <= -9.2e+64) {
tmp = -1.0;
} else if (x <= -1.26e-36) {
tmp = 1.0;
} else if (x <= -4.5e-122) {
tmp = x * 0.5;
} else if (x <= -1.82e-258) {
tmp = 1.0;
} else if (x <= 5.2e-267) {
tmp = y * -0.5;
} else if (x <= 125000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9.2e+64: tmp = -1.0 elif x <= -1.26e-36: tmp = 1.0 elif x <= -4.5e-122: tmp = x * 0.5 elif x <= -1.82e-258: tmp = 1.0 elif x <= 5.2e-267: tmp = y * -0.5 elif x <= 125000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -9.2e+64) tmp = -1.0; elseif (x <= -1.26e-36) tmp = 1.0; elseif (x <= -4.5e-122) tmp = Float64(x * 0.5); elseif (x <= -1.82e-258) tmp = 1.0; elseif (x <= 5.2e-267) tmp = Float64(y * -0.5); elseif (x <= 125000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9.2e+64) tmp = -1.0; elseif (x <= -1.26e-36) tmp = 1.0; elseif (x <= -4.5e-122) tmp = x * 0.5; elseif (x <= -1.82e-258) tmp = 1.0; elseif (x <= 5.2e-267) tmp = y * -0.5; elseif (x <= 125000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9.2e+64], -1.0, If[LessEqual[x, -1.26e-36], 1.0, If[LessEqual[x, -4.5e-122], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -1.82e-258], 1.0, If[LessEqual[x, 5.2e-267], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 125000000.0], 1.0, -1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+64}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.26 \cdot 10^{-36}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -4.5 \cdot 10^{-122}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -1.82 \cdot 10^{-258}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-267}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 125000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.2e64 or 1.25e8 < x Initial program 100.0%
Taylor expanded in x around inf 82.0%
if -9.2e64 < x < -1.26000000000000005e-36 or -4.4999999999999998e-122 < x < -1.82000000000000003e-258 or 5.2000000000000003e-267 < x < 1.25e8Initial program 100.0%
Taylor expanded in y around inf 56.2%
if -1.26000000000000005e-36 < x < -4.4999999999999998e-122Initial program 100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 59.9%
*-commutative59.9%
Simplified59.9%
if -1.82000000000000003e-258 < x < 5.2000000000000003e-267Initial program 100.0%
Taylor expanded in x around 0 81.3%
associate-*r/81.3%
neg-mul-181.3%
Simplified81.3%
Taylor expanded in y around 0 64.9%
*-commutative64.9%
Simplified64.9%
Final simplification68.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ 2.0 y))))
(if (<= x -6.6e+65)
-1.0
(if (<= x -2.1e-43)
t_0
(if (<= x -2.3e-119)
(* x 0.5)
(if (<= x -4.5e-257)
t_0
(if (<= x 1.75e-268)
(* y -0.5)
(if (<= x 140000000.0) 1.0 -1.0))))))))
double code(double x, double y) {
double t_0 = 1.0 + (2.0 / y);
double tmp;
if (x <= -6.6e+65) {
tmp = -1.0;
} else if (x <= -2.1e-43) {
tmp = t_0;
} else if (x <= -2.3e-119) {
tmp = x * 0.5;
} else if (x <= -4.5e-257) {
tmp = t_0;
} else if (x <= 1.75e-268) {
tmp = y * -0.5;
} else if (x <= 140000000.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 + (2.0d0 / y)
if (x <= (-6.6d+65)) then
tmp = -1.0d0
else if (x <= (-2.1d-43)) then
tmp = t_0
else if (x <= (-2.3d-119)) then
tmp = x * 0.5d0
else if (x <= (-4.5d-257)) then
tmp = t_0
else if (x <= 1.75d-268) then
tmp = y * (-0.5d0)
else if (x <= 140000000.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 + (2.0 / y);
double tmp;
if (x <= -6.6e+65) {
tmp = -1.0;
} else if (x <= -2.1e-43) {
tmp = t_0;
} else if (x <= -2.3e-119) {
tmp = x * 0.5;
} else if (x <= -4.5e-257) {
tmp = t_0;
} else if (x <= 1.75e-268) {
tmp = y * -0.5;
} else if (x <= 140000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (2.0 / y) tmp = 0 if x <= -6.6e+65: tmp = -1.0 elif x <= -2.1e-43: tmp = t_0 elif x <= -2.3e-119: tmp = x * 0.5 elif x <= -4.5e-257: tmp = t_0 elif x <= 1.75e-268: tmp = y * -0.5 elif x <= 140000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(2.0 / y)) tmp = 0.0 if (x <= -6.6e+65) tmp = -1.0; elseif (x <= -2.1e-43) tmp = t_0; elseif (x <= -2.3e-119) tmp = Float64(x * 0.5); elseif (x <= -4.5e-257) tmp = t_0; elseif (x <= 1.75e-268) tmp = Float64(y * -0.5); elseif (x <= 140000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (2.0 / y); tmp = 0.0; if (x <= -6.6e+65) tmp = -1.0; elseif (x <= -2.1e-43) tmp = t_0; elseif (x <= -2.3e-119) tmp = x * 0.5; elseif (x <= -4.5e-257) tmp = t_0; elseif (x <= 1.75e-268) tmp = y * -0.5; elseif (x <= 140000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.6e+65], -1.0, If[LessEqual[x, -2.1e-43], t$95$0, If[LessEqual[x, -2.3e-119], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -4.5e-257], t$95$0, If[LessEqual[x, 1.75e-268], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 140000000.0], 1.0, -1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{2}{y}\\
\mathbf{if}\;x \leq -6.6 \cdot 10^{+65}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -2.1 \cdot 10^{-43}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-119}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -4.5 \cdot 10^{-257}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-268}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 140000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -6.60000000000000046e65 or 1.4e8 < x Initial program 100.0%
Taylor expanded in x around inf 82.0%
if -6.60000000000000046e65 < x < -2.1000000000000001e-43 or -2.29999999999999993e-119 < x < -4.5000000000000003e-257Initial program 100.0%
Taylor expanded in y around inf 50.1%
sub-neg50.1%
mul-1-neg50.1%
unsub-neg50.1%
mul-1-neg50.1%
remove-double-neg50.1%
Simplified50.1%
Taylor expanded in x around 0 50.2%
associate-*r/50.2%
metadata-eval50.2%
Simplified50.2%
if -2.1000000000000001e-43 < x < -2.29999999999999993e-119Initial program 100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 59.9%
*-commutative59.9%
Simplified59.9%
if -4.5000000000000003e-257 < x < 1.75000000000000003e-268Initial program 100.0%
Taylor expanded in x around 0 81.3%
associate-*r/81.3%
neg-mul-181.3%
Simplified81.3%
Taylor expanded in y around 0 64.9%
*-commutative64.9%
Simplified64.9%
if 1.75000000000000003e-268 < x < 1.4e8Initial program 100.0%
Taylor expanded in y around inf 62.3%
Final simplification68.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -1.1e+148)
1.0
(if (<= y -6e+109)
t_0
(if (<= y -4e+41) 1.0 (if (<= y 1020.0) t_0 (+ 1.0 (/ 2.0 y))))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -1.1e+148) {
tmp = 1.0;
} else if (y <= -6e+109) {
tmp = t_0;
} else if (y <= -4e+41) {
tmp = 1.0;
} else if (y <= 1020.0) {
tmp = t_0;
} else {
tmp = 1.0 + (2.0 / 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 = x / (2.0d0 - x)
if (y <= (-1.1d+148)) then
tmp = 1.0d0
else if (y <= (-6d+109)) then
tmp = t_0
else if (y <= (-4d+41)) then
tmp = 1.0d0
else if (y <= 1020.0d0) then
tmp = t_0
else
tmp = 1.0d0 + (2.0d0 / y)
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 <= -1.1e+148) {
tmp = 1.0;
} else if (y <= -6e+109) {
tmp = t_0;
} else if (y <= -4e+41) {
tmp = 1.0;
} else if (y <= 1020.0) {
tmp = t_0;
} else {
tmp = 1.0 + (2.0 / y);
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -1.1e+148: tmp = 1.0 elif y <= -6e+109: tmp = t_0 elif y <= -4e+41: tmp = 1.0 elif y <= 1020.0: tmp = t_0 else: tmp = 1.0 + (2.0 / y) return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -1.1e+148) tmp = 1.0; elseif (y <= -6e+109) tmp = t_0; elseif (y <= -4e+41) tmp = 1.0; elseif (y <= 1020.0) tmp = t_0; else tmp = Float64(1.0 + Float64(2.0 / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); tmp = 0.0; if (y <= -1.1e+148) tmp = 1.0; elseif (y <= -6e+109) tmp = t_0; elseif (y <= -4e+41) tmp = 1.0; elseif (y <= 1020.0) tmp = t_0; else tmp = 1.0 + (2.0 / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.1e+148], 1.0, If[LessEqual[y, -6e+109], t$95$0, If[LessEqual[y, -4e+41], 1.0, If[LessEqual[y, 1020.0], t$95$0, N[(1.0 + N[(2.0 / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -1.1 \cdot 10^{+148}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -6 \cdot 10^{+109}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -4 \cdot 10^{+41}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1020:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{2}{y}\\
\end{array}
\end{array}
if y < -1.0999999999999999e148 or -6.00000000000000031e109 < y < -4.00000000000000002e41Initial program 100.0%
Taylor expanded in y around inf 83.1%
if -1.0999999999999999e148 < y < -6.00000000000000031e109 or -4.00000000000000002e41 < y < 1020Initial program 100.0%
Taylor expanded in y around 0 73.0%
if 1020 < y Initial program 100.0%
Taylor expanded in y around inf 72.5%
sub-neg72.5%
mul-1-neg72.5%
unsub-neg72.5%
mul-1-neg72.5%
remove-double-neg72.5%
Simplified72.5%
Taylor expanded in x around 0 71.8%
associate-*r/71.8%
metadata-eval71.8%
Simplified71.8%
Final simplification74.3%
(FPCore (x y)
:precision binary64
(if (<= x -6.6e+65)
-1.0
(if (<= x -4.8e-40)
1.0
(if (<= x -6.6e-119) (* x 0.5) (if (<= x 1900000.0) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -6.6e+65) {
tmp = -1.0;
} else if (x <= -4.8e-40) {
tmp = 1.0;
} else if (x <= -6.6e-119) {
tmp = x * 0.5;
} else if (x <= 1900000.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 <= (-6.6d+65)) then
tmp = -1.0d0
else if (x <= (-4.8d-40)) then
tmp = 1.0d0
else if (x <= (-6.6d-119)) then
tmp = x * 0.5d0
else if (x <= 1900000.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 <= -6.6e+65) {
tmp = -1.0;
} else if (x <= -4.8e-40) {
tmp = 1.0;
} else if (x <= -6.6e-119) {
tmp = x * 0.5;
} else if (x <= 1900000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -6.6e+65: tmp = -1.0 elif x <= -4.8e-40: tmp = 1.0 elif x <= -6.6e-119: tmp = x * 0.5 elif x <= 1900000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -6.6e+65) tmp = -1.0; elseif (x <= -4.8e-40) tmp = 1.0; elseif (x <= -6.6e-119) tmp = Float64(x * 0.5); elseif (x <= 1900000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -6.6e+65) tmp = -1.0; elseif (x <= -4.8e-40) tmp = 1.0; elseif (x <= -6.6e-119) tmp = x * 0.5; elseif (x <= 1900000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -6.6e+65], -1.0, If[LessEqual[x, -4.8e-40], 1.0, If[LessEqual[x, -6.6e-119], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1900000.0], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.6 \cdot 10^{+65}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -4.8 \cdot 10^{-40}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -6.6 \cdot 10^{-119}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1900000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -6.60000000000000046e65 or 1.9e6 < x Initial program 100.0%
Taylor expanded in x around inf 82.0%
if -6.60000000000000046e65 < x < -4.79999999999999982e-40 or -6.60000000000000017e-119 < x < 1.9e6Initial program 100.0%
Taylor expanded in y around inf 51.1%
if -4.79999999999999982e-40 < x < -6.60000000000000017e-119Initial program 100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 59.9%
*-commutative59.9%
Simplified59.9%
Final simplification65.7%
(FPCore (x y) :precision binary64 (if (<= x -6.6e+64) (+ (/ y x) -1.0) (if (<= x 650000.0) (/ (- x y) (- 2.0 y)) (/ x (- 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -6.6e+64) {
tmp = (y / x) + -1.0;
} else if (x <= 650000.0) {
tmp = (x - y) / (2.0 - 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 (x <= (-6.6d+64)) then
tmp = (y / x) + (-1.0d0)
else if (x <= 650000.0d0) then
tmp = (x - y) / (2.0d0 - y)
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -6.6e+64) {
tmp = (y / x) + -1.0;
} else if (x <= 650000.0) {
tmp = (x - y) / (2.0 - y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -6.6e+64: tmp = (y / x) + -1.0 elif x <= 650000.0: tmp = (x - y) / (2.0 - y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -6.6e+64) tmp = Float64(Float64(y / x) + -1.0); elseif (x <= 650000.0) tmp = Float64(Float64(x - y) / Float64(2.0 - y)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -6.6e+64) tmp = (y / x) + -1.0; elseif (x <= 650000.0) tmp = (x - y) / (2.0 - y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -6.6e+64], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, 650000.0], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.6 \cdot 10^{+64}:\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{elif}\;x \leq 650000:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -6.59999999999999976e64Initial program 100.0%
Taylor expanded in x around inf 81.2%
mul-1-neg81.2%
Simplified81.2%
Taylor expanded in x around 0 81.2%
if -6.59999999999999976e64 < x < 6.5e5Initial program 100.0%
Taylor expanded in x around 0 94.5%
if 6.5e5 < x Initial program 100.0%
Taylor expanded in y around 0 84.7%
Final simplification89.2%
(FPCore (x y) :precision binary64 (if (<= x -4.8e+64) (+ (/ y x) -1.0) (if (<= x 52000.0) (/ y (+ y -2.0)) (/ x (- 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -4.8e+64) {
tmp = (y / x) + -1.0;
} else if (x <= 52000.0) {
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 <= (-4.8d+64)) then
tmp = (y / x) + (-1.0d0)
else if (x <= 52000.0d0) 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 <= -4.8e+64) {
tmp = (y / x) + -1.0;
} else if (x <= 52000.0) {
tmp = y / (y + -2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4.8e+64: tmp = (y / x) + -1.0 elif x <= 52000.0: tmp = y / (y + -2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -4.8e+64) tmp = Float64(Float64(y / x) + -1.0); elseif (x <= 52000.0) 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 <= -4.8e+64) tmp = (y / x) + -1.0; elseif (x <= 52000.0) tmp = y / (y + -2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4.8e+64], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, 52000.0], 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 -4.8 \cdot 10^{+64}:\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{elif}\;x \leq 52000:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -4.79999999999999999e64Initial program 100.0%
Taylor expanded in x around inf 81.2%
mul-1-neg81.2%
Simplified81.2%
Taylor expanded in x around 0 81.2%
if -4.79999999999999999e64 < x < 52000Initial program 100.0%
Taylor expanded in x around 0 72.9%
associate-*r/72.9%
neg-mul-172.9%
Simplified72.9%
frac-2neg72.9%
div-inv72.8%
remove-double-neg72.8%
sub-neg72.8%
distribute-neg-in72.8%
metadata-eval72.8%
remove-double-neg72.8%
Applied egg-rr72.8%
associate-*r/72.9%
*-rgt-identity72.9%
+-commutative72.9%
Simplified72.9%
if 52000 < x Initial program 100.0%
Taylor expanded in y around 0 84.7%
Final simplification77.5%
(FPCore (x y) :precision binary64 (if (<= x -4.8e+64) -1.0 (if (<= x 140000000.0) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -4.8e+64) {
tmp = -1.0;
} else if (x <= 140000000.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 <= (-4.8d+64)) then
tmp = -1.0d0
else if (x <= 140000000.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 <= -4.8e+64) {
tmp = -1.0;
} else if (x <= 140000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4.8e+64: tmp = -1.0 elif x <= 140000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -4.8e+64) tmp = -1.0; elseif (x <= 140000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -4.8e+64) tmp = -1.0; elseif (x <= 140000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4.8e+64], -1.0, If[LessEqual[x, 140000000.0], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{+64}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 140000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -4.79999999999999999e64 or 1.4e8 < x Initial program 100.0%
Taylor expanded in x around inf 82.0%
if -4.79999999999999999e64 < x < 1.4e8Initial program 100.0%
Taylor expanded in y around inf 48.6%
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%
Taylor expanded in x around inf 40.8%
Final simplification40.8%
(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 2024031
(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))))