
(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 -5.5e+64)
t_0
(if (<= x -2.15e-40)
t_1
(if (<= x -1.15e-121)
(* x 0.5)
(if (<= x -3.1e-259)
t_1
(if (<= x 1.6e-265)
(* y -0.5)
(if (<= x 125000000.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 <= -5.5e+64) {
tmp = t_0;
} else if (x <= -2.15e-40) {
tmp = t_1;
} else if (x <= -1.15e-121) {
tmp = x * 0.5;
} else if (x <= -3.1e-259) {
tmp = t_1;
} else if (x <= 1.6e-265) {
tmp = y * -0.5;
} else if (x <= 125000000.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 <= (-5.5d+64)) then
tmp = t_0
else if (x <= (-2.15d-40)) then
tmp = t_1
else if (x <= (-1.15d-121)) then
tmp = x * 0.5d0
else if (x <= (-3.1d-259)) then
tmp = t_1
else if (x <= 1.6d-265) then
tmp = y * (-0.5d0)
else if (x <= 125000000.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 <= -5.5e+64) {
tmp = t_0;
} else if (x <= -2.15e-40) {
tmp = t_1;
} else if (x <= -1.15e-121) {
tmp = x * 0.5;
} else if (x <= -3.1e-259) {
tmp = t_1;
} else if (x <= 1.6e-265) {
tmp = y * -0.5;
} else if (x <= 125000000.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 <= -5.5e+64: tmp = t_0 elif x <= -2.15e-40: tmp = t_1 elif x <= -1.15e-121: tmp = x * 0.5 elif x <= -3.1e-259: tmp = t_1 elif x <= 1.6e-265: tmp = y * -0.5 elif x <= 125000000.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 <= -5.5e+64) tmp = t_0; elseif (x <= -2.15e-40) tmp = t_1; elseif (x <= -1.15e-121) tmp = Float64(x * 0.5); elseif (x <= -3.1e-259) tmp = t_1; elseif (x <= 1.6e-265) tmp = Float64(y * -0.5); elseif (x <= 125000000.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 <= -5.5e+64) tmp = t_0; elseif (x <= -2.15e-40) tmp = t_1; elseif (x <= -1.15e-121) tmp = x * 0.5; elseif (x <= -3.1e-259) tmp = t_1; elseif (x <= 1.6e-265) tmp = y * -0.5; elseif (x <= 125000000.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, -5.5e+64], t$95$0, If[LessEqual[x, -2.15e-40], t$95$1, If[LessEqual[x, -1.15e-121], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -3.1e-259], t$95$1, If[LessEqual[x, 1.6e-265], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 125000000.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 -5.5 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.15 \cdot 10^{-40}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.15 \cdot 10^{-121}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -3.1 \cdot 10^{-259}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-265}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 125000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.4999999999999996e64 or 1.25e8 < 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 -5.4999999999999996e64 < x < -2.1500000000000001e-40 or -1.15000000000000006e-121 < x < -3.0999999999999998e-259Initial 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.1500000000000001e-40 < x < -1.15000000000000006e-121Initial program 100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in y around 0 59.9%
*-commutative59.9%
Simplified59.9%
if -3.0999999999999998e-259 < x < 1.6e-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.6e-265 < x < 1.25e8Initial program 100.0%
Taylor expanded in y around inf 60.6%
Final simplification68.8%
(FPCore (x y)
:precision binary64
(if (<= x -2e+66)
-1.0
(if (<= x -7.9e-35)
1.0
(if (<= x -3.9e-119)
(* x 0.5)
(if (<= x -1.15e-256)
1.0
(if (<= x 3.2e-266) (* y -0.5) (if (<= x 85000000.0) 1.0 -1.0)))))))
double code(double x, double y) {
double tmp;
if (x <= -2e+66) {
tmp = -1.0;
} else if (x <= -7.9e-35) {
tmp = 1.0;
} else if (x <= -3.9e-119) {
tmp = x * 0.5;
} else if (x <= -1.15e-256) {
tmp = 1.0;
} else if (x <= 3.2e-266) {
tmp = y * -0.5;
} else if (x <= 85000000.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+66)) then
tmp = -1.0d0
else if (x <= (-7.9d-35)) then
tmp = 1.0d0
else if (x <= (-3.9d-119)) then
tmp = x * 0.5d0
else if (x <= (-1.15d-256)) then
tmp = 1.0d0
else if (x <= 3.2d-266) then
tmp = y * (-0.5d0)
else if (x <= 85000000.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+66) {
tmp = -1.0;
} else if (x <= -7.9e-35) {
tmp = 1.0;
} else if (x <= -3.9e-119) {
tmp = x * 0.5;
} else if (x <= -1.15e-256) {
tmp = 1.0;
} else if (x <= 3.2e-266) {
tmp = y * -0.5;
} else if (x <= 85000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2e+66: tmp = -1.0 elif x <= -7.9e-35: tmp = 1.0 elif x <= -3.9e-119: tmp = x * 0.5 elif x <= -1.15e-256: tmp = 1.0 elif x <= 3.2e-266: tmp = y * -0.5 elif x <= 85000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2e+66) tmp = -1.0; elseif (x <= -7.9e-35) tmp = 1.0; elseif (x <= -3.9e-119) tmp = Float64(x * 0.5); elseif (x <= -1.15e-256) tmp = 1.0; elseif (x <= 3.2e-266) tmp = Float64(y * -0.5); elseif (x <= 85000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2e+66) tmp = -1.0; elseif (x <= -7.9e-35) tmp = 1.0; elseif (x <= -3.9e-119) tmp = x * 0.5; elseif (x <= -1.15e-256) tmp = 1.0; elseif (x <= 3.2e-266) tmp = y * -0.5; elseif (x <= 85000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2e+66], -1.0, If[LessEqual[x, -7.9e-35], 1.0, If[LessEqual[x, -3.9e-119], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -1.15e-256], 1.0, If[LessEqual[x, 3.2e-266], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 85000000.0], 1.0, -1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+66}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -7.9 \cdot 10^{-35}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -3.9 \cdot 10^{-119}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -1.15 \cdot 10^{-256}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-266}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 85000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.99999999999999989e66 or 8.5e7 < x Initial program 100.0%
Taylor expanded in x around inf 82.0%
if -1.99999999999999989e66 < x < -7.89999999999999983e-35 or -3.8999999999999999e-119 < x < -1.15e-256 or 3.2e-266 < x < 8.5e7Initial program 100.0%
Taylor expanded in y around inf 55.3%
if -7.89999999999999983e-35 < x < -3.8999999999999999e-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.15e-256 < x < 3.2e-266Initial 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.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ 2.0 y))))
(if (<= x -1.3e+65)
-1.0
(if (<= x -2.25e-39)
t_0
(if (<= x -6e-119)
(* x 0.5)
(if (<= x -9.6e-259)
t_0
(if (<= x 1.2e-267) (* y -0.5) (if (<= x 1700000.0) 1.0 -1.0))))))))
double code(double x, double y) {
double t_0 = 1.0 + (2.0 / y);
double tmp;
if (x <= -1.3e+65) {
tmp = -1.0;
} else if (x <= -2.25e-39) {
tmp = t_0;
} else if (x <= -6e-119) {
tmp = x * 0.5;
} else if (x <= -9.6e-259) {
tmp = t_0;
} else if (x <= 1.2e-267) {
tmp = y * -0.5;
} else if (x <= 1700000.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 <= (-1.3d+65)) then
tmp = -1.0d0
else if (x <= (-2.25d-39)) then
tmp = t_0
else if (x <= (-6d-119)) then
tmp = x * 0.5d0
else if (x <= (-9.6d-259)) then
tmp = t_0
else if (x <= 1.2d-267) then
tmp = y * (-0.5d0)
else if (x <= 1700000.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 <= -1.3e+65) {
tmp = -1.0;
} else if (x <= -2.25e-39) {
tmp = t_0;
} else if (x <= -6e-119) {
tmp = x * 0.5;
} else if (x <= -9.6e-259) {
tmp = t_0;
} else if (x <= 1.2e-267) {
tmp = y * -0.5;
} else if (x <= 1700000.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 <= -1.3e+65: tmp = -1.0 elif x <= -2.25e-39: tmp = t_0 elif x <= -6e-119: tmp = x * 0.5 elif x <= -9.6e-259: tmp = t_0 elif x <= 1.2e-267: tmp = y * -0.5 elif x <= 1700000.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 <= -1.3e+65) tmp = -1.0; elseif (x <= -2.25e-39) tmp = t_0; elseif (x <= -6e-119) tmp = Float64(x * 0.5); elseif (x <= -9.6e-259) tmp = t_0; elseif (x <= 1.2e-267) tmp = Float64(y * -0.5); elseif (x <= 1700000.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 <= -1.3e+65) tmp = -1.0; elseif (x <= -2.25e-39) tmp = t_0; elseif (x <= -6e-119) tmp = x * 0.5; elseif (x <= -9.6e-259) tmp = t_0; elseif (x <= 1.2e-267) tmp = y * -0.5; elseif (x <= 1700000.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, -1.3e+65], -1.0, If[LessEqual[x, -2.25e-39], t$95$0, If[LessEqual[x, -6e-119], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -9.6e-259], t$95$0, If[LessEqual[x, 1.2e-267], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1700000.0], 1.0, -1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{2}{y}\\
\mathbf{if}\;x \leq -1.3 \cdot 10^{+65}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -2.25 \cdot 10^{-39}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-119}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -9.6 \cdot 10^{-259}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-267}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 1700000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.30000000000000001e65 or 1.7e6 < x Initial program 100.0%
Taylor expanded in x around inf 82.0%
if -1.30000000000000001e65 < x < -2.25e-39 or -6.0000000000000004e-119 < x < -9.6000000000000002e-259Initial 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.25e-39 < x < -6.0000000000000004e-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 -9.6000000000000002e-259 < x < 1.1999999999999999e-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%
if 1.1999999999999999e-267 < x < 1.7e6Initial program 100.0%
Taylor expanded in y around inf 60.6%
Final simplification68.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -1.1e+148)
1.0
(if (<= y -1.32e+110)
t_0
(if (<= y -3.2e+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 <= -1.32e+110) {
tmp = t_0;
} else if (y <= -3.2e+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 <= (-1.32d+110)) then
tmp = t_0
else if (y <= (-3.2d+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 <= -1.32e+110) {
tmp = t_0;
} else if (y <= -3.2e+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 <= -1.32e+110: tmp = t_0 elif y <= -3.2e+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 <= -1.32e+110) tmp = t_0; elseif (y <= -3.2e+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 <= -1.32e+110) tmp = t_0; elseif (y <= -3.2e+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, -1.32e+110], t$95$0, If[LessEqual[y, -3.2e+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 -1.32 \cdot 10^{+110}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -3.2 \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 -1.32e110 < y < -3.2000000000000001e41Initial program 100.0%
Taylor expanded in y around inf 83.1%
if -1.0999999999999999e148 < y < -1.32e110 or -3.2000000000000001e41 < y < 1020Initial program 100.0%
Taylor expanded in y around 0 73.2%
if 1020 < y Initial program 100.0%
Taylor expanded in y around inf 72.0%
sub-neg72.0%
mul-1-neg72.0%
unsub-neg72.0%
mul-1-neg72.0%
remove-double-neg72.0%
Simplified72.0%
Taylor expanded in x around 0 71.3%
associate-*r/71.3%
metadata-eval71.3%
Simplified71.3%
Final simplification74.3%
(FPCore (x y)
:precision binary64
(if (<= x -9.5e+64)
-1.0
(if (<= x -5e-34)
1.0
(if (<= x -5.5e-123) (* x 0.5) (if (<= x 85000000.0) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -9.5e+64) {
tmp = -1.0;
} else if (x <= -5e-34) {
tmp = 1.0;
} else if (x <= -5.5e-123) {
tmp = x * 0.5;
} else if (x <= 85000000.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.5d+64)) then
tmp = -1.0d0
else if (x <= (-5d-34)) then
tmp = 1.0d0
else if (x <= (-5.5d-123)) then
tmp = x * 0.5d0
else if (x <= 85000000.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.5e+64) {
tmp = -1.0;
} else if (x <= -5e-34) {
tmp = 1.0;
} else if (x <= -5.5e-123) {
tmp = x * 0.5;
} else if (x <= 85000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9.5e+64: tmp = -1.0 elif x <= -5e-34: tmp = 1.0 elif x <= -5.5e-123: tmp = x * 0.5 elif x <= 85000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -9.5e+64) tmp = -1.0; elseif (x <= -5e-34) tmp = 1.0; elseif (x <= -5.5e-123) tmp = Float64(x * 0.5); elseif (x <= 85000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9.5e+64) tmp = -1.0; elseif (x <= -5e-34) tmp = 1.0; elseif (x <= -5.5e-123) tmp = x * 0.5; elseif (x <= 85000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9.5e+64], -1.0, If[LessEqual[x, -5e-34], 1.0, If[LessEqual[x, -5.5e-123], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 85000000.0], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+64}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-34}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -5.5 \cdot 10^{-123}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 85000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.50000000000000028e64 or 8.5e7 < x Initial program 100.0%
Taylor expanded in x around inf 82.0%
if -9.50000000000000028e64 < x < -5.0000000000000003e-34 or -5.5e-123 < x < 8.5e7Initial program 100.0%
Taylor expanded in y around inf 50.3%
if -5.0000000000000003e-34 < x < -5.5e-123Initial 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.3%
(FPCore (x y) :precision binary64 (if (<= x -4.8e+64) (+ (/ y x) -1.0) (if (<= x 900000.0) (/ (- x y) (- 2.0 y)) (/ 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 <= 900000.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 <= (-4.8d+64)) then
tmp = (y / x) + (-1.0d0)
else if (x <= 900000.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 <= -4.8e+64) {
tmp = (y / x) + -1.0;
} else if (x <= 900000.0) {
tmp = (x - y) / (2.0 - y);
} 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 <= 900000.0: tmp = (x - y) / (2.0 - y) 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 <= 900000.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 <= -4.8e+64) tmp = (y / x) + -1.0; elseif (x <= 900000.0) tmp = (x - y) / (2.0 - y); 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, 900000.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 -4.8 \cdot 10^{+64}:\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{elif}\;x \leq 900000:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\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 < 9e5Initial program 100.0%
Taylor expanded in x around 0 94.5%
if 9e5 < x Initial program 100.0%
Taylor expanded in y around 0 84.7%
Final simplification89.2%
(FPCore (x y) :precision binary64 (if (<= x -7.2e+64) (+ (/ y x) -1.0) (if (<= x 62000.0) (/ y (+ y -2.0)) (/ x (- 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -7.2e+64) {
tmp = (y / x) + -1.0;
} else if (x <= 62000.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 <= (-7.2d+64)) then
tmp = (y / x) + (-1.0d0)
else if (x <= 62000.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 <= -7.2e+64) {
tmp = (y / x) + -1.0;
} else if (x <= 62000.0) {
tmp = y / (y + -2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -7.2e+64: tmp = (y / x) + -1.0 elif x <= 62000.0: tmp = y / (y + -2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -7.2e+64) tmp = Float64(Float64(y / x) + -1.0); elseif (x <= 62000.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 <= -7.2e+64) tmp = (y / x) + -1.0; elseif (x <= 62000.0) tmp = y / (y + -2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -7.2e+64], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, 62000.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 -7.2 \cdot 10^{+64}:\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{elif}\;x \leq 62000:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -7.20000000000000027e64Initial 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 -7.20000000000000027e64 < x < 62000Initial program 100.0%
Taylor expanded in x around 0 72.2%
associate-*r/72.2%
neg-mul-172.2%
Simplified72.2%
frac-2neg72.2%
div-inv72.1%
remove-double-neg72.1%
sub-neg72.1%
distribute-neg-in72.1%
metadata-eval72.1%
remove-double-neg72.1%
Applied egg-rr72.1%
associate-*r/72.2%
*-rgt-identity72.2%
+-commutative72.2%
Simplified72.2%
if 62000 < x Initial program 100.0%
Taylor expanded in y around 0 84.7%
Final simplification77.1%
(FPCore (x y) :precision binary64 (if (<= x -4.8e+64) -1.0 (if (<= x 130000000.0) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -4.8e+64) {
tmp = -1.0;
} else if (x <= 130000000.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 <= 130000000.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 <= 130000000.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 <= 130000000.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 <= 130000000.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 <= 130000000.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, 130000000.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 130000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -4.79999999999999999e64 or 1.3e8 < x Initial program 100.0%
Taylor expanded in x around inf 82.0%
if -4.79999999999999999e64 < x < 1.3e8Initial program 100.0%
Taylor expanded in y around inf 47.9%
Final simplification63.5%
(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))))