
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Initial program 100.0%
(FPCore (x y)
:precision binary64
(if (<= y -500000000.0)
1.0
(if (<= y -4.5e-16)
-1.0
(if (<= y -9e-55)
(* y -0.5)
(if (<= y -1.35e-289)
-1.0
(if (<= y 4e-193)
(* x 0.5)
(if (<= y 3.6e-43)
-1.0
(if (<= y 3.7e-10) (* y -0.5) (if (<= y 1e+81) -1.0 1.0)))))))))
double code(double x, double y) {
double tmp;
if (y <= -500000000.0) {
tmp = 1.0;
} else if (y <= -4.5e-16) {
tmp = -1.0;
} else if (y <= -9e-55) {
tmp = y * -0.5;
} else if (y <= -1.35e-289) {
tmp = -1.0;
} else if (y <= 4e-193) {
tmp = x * 0.5;
} else if (y <= 3.6e-43) {
tmp = -1.0;
} else if (y <= 3.7e-10) {
tmp = y * -0.5;
} else if (y <= 1e+81) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-500000000.0d0)) then
tmp = 1.0d0
else if (y <= (-4.5d-16)) then
tmp = -1.0d0
else if (y <= (-9d-55)) then
tmp = y * (-0.5d0)
else if (y <= (-1.35d-289)) then
tmp = -1.0d0
else if (y <= 4d-193) then
tmp = x * 0.5d0
else if (y <= 3.6d-43) then
tmp = -1.0d0
else if (y <= 3.7d-10) then
tmp = y * (-0.5d0)
else if (y <= 1d+81) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -500000000.0) {
tmp = 1.0;
} else if (y <= -4.5e-16) {
tmp = -1.0;
} else if (y <= -9e-55) {
tmp = y * -0.5;
} else if (y <= -1.35e-289) {
tmp = -1.0;
} else if (y <= 4e-193) {
tmp = x * 0.5;
} else if (y <= 3.6e-43) {
tmp = -1.0;
} else if (y <= 3.7e-10) {
tmp = y * -0.5;
} else if (y <= 1e+81) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -500000000.0: tmp = 1.0 elif y <= -4.5e-16: tmp = -1.0 elif y <= -9e-55: tmp = y * -0.5 elif y <= -1.35e-289: tmp = -1.0 elif y <= 4e-193: tmp = x * 0.5 elif y <= 3.6e-43: tmp = -1.0 elif y <= 3.7e-10: tmp = y * -0.5 elif y <= 1e+81: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -500000000.0) tmp = 1.0; elseif (y <= -4.5e-16) tmp = -1.0; elseif (y <= -9e-55) tmp = Float64(y * -0.5); elseif (y <= -1.35e-289) tmp = -1.0; elseif (y <= 4e-193) tmp = Float64(x * 0.5); elseif (y <= 3.6e-43) tmp = -1.0; elseif (y <= 3.7e-10) tmp = Float64(y * -0.5); elseif (y <= 1e+81) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -500000000.0) tmp = 1.0; elseif (y <= -4.5e-16) tmp = -1.0; elseif (y <= -9e-55) tmp = y * -0.5; elseif (y <= -1.35e-289) tmp = -1.0; elseif (y <= 4e-193) tmp = x * 0.5; elseif (y <= 3.6e-43) tmp = -1.0; elseif (y <= 3.7e-10) tmp = y * -0.5; elseif (y <= 1e+81) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -500000000.0], 1.0, If[LessEqual[y, -4.5e-16], -1.0, If[LessEqual[y, -9e-55], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -1.35e-289], -1.0, If[LessEqual[y, 4e-193], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 3.6e-43], -1.0, If[LessEqual[y, 3.7e-10], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1e+81], -1.0, 1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -500000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -4.5 \cdot 10^{-16}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -9 \cdot 10^{-55}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -1.35 \cdot 10^{-289}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-193}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-43}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{-10}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 10^{+81}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5e8 or 9.99999999999999921e80 < y Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 76.8%
if -5e8 < y < -4.5000000000000002e-16 or -8.99999999999999941e-55 < y < -1.35e-289 or 4.0000000000000002e-193 < y < 3.5999999999999999e-43 or 3.70000000000000015e-10 < y < 9.99999999999999921e80Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 64.1%
if -4.5000000000000002e-16 < y < -8.99999999999999941e-55 or 3.5999999999999999e-43 < y < 3.70000000000000015e-10Initial program 99.8%
remove-double-neg99.8%
+-commutative99.8%
distribute-neg-frac299.8%
distribute-frac-neg99.8%
sub-neg99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
neg-sub099.8%
associate--r-99.8%
metadata-eval99.8%
metadata-eval99.8%
+-commutative99.8%
+-commutative99.8%
associate-+r+99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 79.6%
Taylor expanded in y around 0 75.0%
*-commutative75.0%
Simplified75.0%
if -1.35e-289 < y < 4.0000000000000002e-193Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 90.5%
mul-1-neg90.5%
distribute-neg-frac290.5%
neg-sub090.5%
associate-+l-90.5%
neg-sub090.5%
+-commutative90.5%
unsub-neg90.5%
Simplified90.5%
Taylor expanded in x around 0 67.7%
*-commutative67.7%
Simplified67.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -460000.0)
1.0
(if (<= y 3.3e-42)
t_0
(if (<= y 7.2e-11) (* y -0.5) (if (<= y 2.1e+92) t_0 1.0))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -460000.0) {
tmp = 1.0;
} else if (y <= 3.3e-42) {
tmp = t_0;
} else if (y <= 7.2e-11) {
tmp = y * -0.5;
} else if (y <= 2.1e+92) {
tmp = t_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 / (2.0d0 - x)
if (y <= (-460000.0d0)) then
tmp = 1.0d0
else if (y <= 3.3d-42) then
tmp = t_0
else if (y <= 7.2d-11) then
tmp = y * (-0.5d0)
else if (y <= 2.1d+92) then
tmp = t_0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -460000.0) {
tmp = 1.0;
} else if (y <= 3.3e-42) {
tmp = t_0;
} else if (y <= 7.2e-11) {
tmp = y * -0.5;
} else if (y <= 2.1e+92) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -460000.0: tmp = 1.0 elif y <= 3.3e-42: tmp = t_0 elif y <= 7.2e-11: tmp = y * -0.5 elif y <= 2.1e+92: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (y <= -460000.0) tmp = 1.0; elseif (y <= 3.3e-42) tmp = t_0; elseif (y <= 7.2e-11) tmp = Float64(y * -0.5); elseif (y <= 2.1e+92) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); tmp = 0.0; if (y <= -460000.0) tmp = 1.0; elseif (y <= 3.3e-42) tmp = t_0; elseif (y <= 7.2e-11) tmp = y * -0.5; elseif (y <= 2.1e+92) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -460000.0], 1.0, If[LessEqual[y, 3.3e-42], t$95$0, If[LessEqual[y, 7.2e-11], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 2.1e+92], t$95$0, 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -460000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{-42}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{-11}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+92}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.6e5 or 2.09999999999999986e92 < y Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 76.8%
if -4.6e5 < y < 3.3000000000000002e-42 or 7.19999999999999969e-11 < y < 2.09999999999999986e92Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 77.5%
mul-1-neg77.5%
distribute-neg-frac277.5%
neg-sub077.5%
associate-+l-77.5%
neg-sub077.5%
+-commutative77.5%
unsub-neg77.5%
Simplified77.5%
if 3.3000000000000002e-42 < y < 7.19999999999999969e-11Initial program 99.8%
remove-double-neg99.8%
+-commutative99.8%
distribute-neg-frac299.8%
distribute-frac-neg99.8%
sub-neg99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
neg-sub099.8%
associate--r-99.8%
metadata-eval99.8%
metadata-eval99.8%
+-commutative99.8%
+-commutative99.8%
associate-+r+99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 90.7%
Taylor expanded in y around 0 82.0%
*-commutative82.0%
Simplified82.0%
(FPCore (x y)
:precision binary64
(if (<= y -7000000.0)
1.0
(if (<= y -1.85e-290)
-1.0
(if (<= y 1.5e-197) (* x 0.5) (if (<= y 4e+82) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -7000000.0) {
tmp = 1.0;
} else if (y <= -1.85e-290) {
tmp = -1.0;
} else if (y <= 1.5e-197) {
tmp = x * 0.5;
} else if (y <= 4e+82) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-7000000.0d0)) then
tmp = 1.0d0
else if (y <= (-1.85d-290)) then
tmp = -1.0d0
else if (y <= 1.5d-197) then
tmp = x * 0.5d0
else if (y <= 4d+82) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -7000000.0) {
tmp = 1.0;
} else if (y <= -1.85e-290) {
tmp = -1.0;
} else if (y <= 1.5e-197) {
tmp = x * 0.5;
} else if (y <= 4e+82) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7000000.0: tmp = 1.0 elif y <= -1.85e-290: tmp = -1.0 elif y <= 1.5e-197: tmp = x * 0.5 elif y <= 4e+82: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -7000000.0) tmp = 1.0; elseif (y <= -1.85e-290) tmp = -1.0; elseif (y <= 1.5e-197) tmp = Float64(x * 0.5); elseif (y <= 4e+82) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -7000000.0) tmp = 1.0; elseif (y <= -1.85e-290) tmp = -1.0; elseif (y <= 1.5e-197) tmp = x * 0.5; elseif (y <= 4e+82) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -7000000.0], 1.0, If[LessEqual[y, -1.85e-290], -1.0, If[LessEqual[y, 1.5e-197], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 4e+82], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.85 \cdot 10^{-290}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-197}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+82}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -7e6 or 3.9999999999999999e82 < y Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 76.8%
if -7e6 < y < -1.84999999999999989e-290 or 1.50000000000000013e-197 < y < 3.9999999999999999e82Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 57.0%
if -1.84999999999999989e-290 < y < 1.50000000000000013e-197Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 90.5%
mul-1-neg90.5%
distribute-neg-frac290.5%
neg-sub090.5%
associate-+l-90.5%
neg-sub090.5%
+-commutative90.5%
unsub-neg90.5%
Simplified90.5%
Taylor expanded in x around 0 67.7%
*-commutative67.7%
Simplified67.7%
(FPCore (x y) :precision binary64 (if (or (<= y -1.15) (not (<= y 2.55e-39))) (/ y (- y 2.0)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -1.15) || !(y <= 2.55e-39)) {
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 ((y <= (-1.15d0)) .or. (.not. (y <= 2.55d-39))) 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 ((y <= -1.15) || !(y <= 2.55e-39)) {
tmp = y / (y - 2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.15) or not (y <= 2.55e-39): tmp = y / (y - 2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.15) || !(y <= 2.55e-39)) 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 ((y <= -1.15) || ~((y <= 2.55e-39))) tmp = y / (y - 2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.15], N[Not[LessEqual[y, 2.55e-39]], $MachinePrecision]], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \lor \neg \left(y \leq 2.55 \cdot 10^{-39}\right):\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -1.1499999999999999 or 2.54999999999999994e-39 < y Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 72.5%
if -1.1499999999999999 < y < 2.54999999999999994e-39Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 81.3%
mul-1-neg81.3%
distribute-neg-frac281.3%
neg-sub081.3%
associate-+l-81.3%
neg-sub081.3%
+-commutative81.3%
unsub-neg81.3%
Simplified81.3%
Final simplification76.5%
(FPCore (x y) :precision binary64 (if (<= y -220000.0) (+ 1.0 (/ (+ 2.0 (* x -2.0)) y)) (if (<= y 3e-39) (/ x (- 2.0 x)) (/ y (- y 2.0)))))
double code(double x, double y) {
double tmp;
if (y <= -220000.0) {
tmp = 1.0 + ((2.0 + (x * -2.0)) / y);
} else if (y <= 3e-39) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-220000.0d0)) then
tmp = 1.0d0 + ((2.0d0 + (x * (-2.0d0))) / y)
else if (y <= 3d-39) then
tmp = x / (2.0d0 - x)
else
tmp = y / (y - 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -220000.0) {
tmp = 1.0 + ((2.0 + (x * -2.0)) / y);
} else if (y <= 3e-39) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -220000.0: tmp = 1.0 + ((2.0 + (x * -2.0)) / y) elif y <= 3e-39: tmp = x / (2.0 - x) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if (y <= -220000.0) tmp = Float64(1.0 + Float64(Float64(2.0 + Float64(x * -2.0)) / y)); elseif (y <= 3e-39) tmp = Float64(x / Float64(2.0 - x)); else tmp = Float64(y / Float64(y - 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -220000.0) tmp = 1.0 + ((2.0 + (x * -2.0)) / y); elseif (y <= 3e-39) tmp = x / (2.0 - x); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -220000.0], N[(1.0 + N[(N[(2.0 + N[(x * -2.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3e-39], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -220000:\\
\;\;\;\;1 + \frac{2 + x \cdot -2}{y}\\
\mathbf{elif}\;y \leq 3 \cdot 10^{-39}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if y < -2.2e5Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 76.8%
associate--l+76.8%
+-commutative76.8%
mul-1-neg76.8%
unsub-neg76.8%
associate-*r/76.8%
metadata-eval76.8%
div-sub76.8%
unsub-neg76.8%
mul-1-neg76.8%
div-sub76.8%
mul-1-neg76.8%
associate--l+76.8%
sub-neg76.8%
mul-1-neg76.8%
mul-1-neg76.8%
distribute-rgt-out76.8%
metadata-eval76.8%
Simplified76.8%
if -2.2e5 < y < 3.00000000000000028e-39Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 81.3%
mul-1-neg81.3%
distribute-neg-frac281.3%
neg-sub081.3%
associate-+l-81.3%
neg-sub081.3%
+-commutative81.3%
unsub-neg81.3%
Simplified81.3%
if 3.00000000000000028e-39 < y Initial program 99.9%
remove-double-neg99.9%
+-commutative99.9%
distribute-neg-frac299.9%
distribute-frac-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 69.9%
(FPCore (x y) :precision binary64 (if (<= y -1020000000.0) 1.0 (if (<= y 1e+81) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1020000000.0) {
tmp = 1.0;
} else if (y <= 1e+81) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1020000000.0d0)) then
tmp = 1.0d0
else if (y <= 1d+81) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1020000000.0) {
tmp = 1.0;
} else if (y <= 1e+81) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1020000000.0: tmp = 1.0 elif y <= 1e+81: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1020000000.0) tmp = 1.0; elseif (y <= 1e+81) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1020000000.0) tmp = 1.0; elseif (y <= 1e+81) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1020000000.0], 1.0, If[LessEqual[y, 1e+81], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1020000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 10^{+81}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.02e9 or 9.99999999999999921e80 < y Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 76.8%
if -1.02e9 < y < 9.99999999999999921e80Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 50.4%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 38.0%
(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 2024085
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:alt
(- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))
(/ (- x y) (- 2.0 (+ x y))))