
(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 9 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
(if (<= x -2e+39)
-1.0
(if (<= x 9.5e-237)
1.0
(if (<= x 2.1e-196)
(* y -0.5)
(if (<= x 8.8e-72)
1.0
(if (<= x 1.1e-22) (* x 0.5) (if (<= x 3850000000.0) 1.0 -1.0)))))))
double code(double x, double y) {
double tmp;
if (x <= -2e+39) {
tmp = -1.0;
} else if (x <= 9.5e-237) {
tmp = 1.0;
} else if (x <= 2.1e-196) {
tmp = y * -0.5;
} else if (x <= 8.8e-72) {
tmp = 1.0;
} else if (x <= 1.1e-22) {
tmp = x * 0.5;
} else if (x <= 3850000000.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+39)) then
tmp = -1.0d0
else if (x <= 9.5d-237) then
tmp = 1.0d0
else if (x <= 2.1d-196) then
tmp = y * (-0.5d0)
else if (x <= 8.8d-72) then
tmp = 1.0d0
else if (x <= 1.1d-22) then
tmp = x * 0.5d0
else if (x <= 3850000000.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+39) {
tmp = -1.0;
} else if (x <= 9.5e-237) {
tmp = 1.0;
} else if (x <= 2.1e-196) {
tmp = y * -0.5;
} else if (x <= 8.8e-72) {
tmp = 1.0;
} else if (x <= 1.1e-22) {
tmp = x * 0.5;
} else if (x <= 3850000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2e+39: tmp = -1.0 elif x <= 9.5e-237: tmp = 1.0 elif x <= 2.1e-196: tmp = y * -0.5 elif x <= 8.8e-72: tmp = 1.0 elif x <= 1.1e-22: tmp = x * 0.5 elif x <= 3850000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2e+39) tmp = -1.0; elseif (x <= 9.5e-237) tmp = 1.0; elseif (x <= 2.1e-196) tmp = Float64(y * -0.5); elseif (x <= 8.8e-72) tmp = 1.0; elseif (x <= 1.1e-22) tmp = Float64(x * 0.5); elseif (x <= 3850000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2e+39) tmp = -1.0; elseif (x <= 9.5e-237) tmp = 1.0; elseif (x <= 2.1e-196) tmp = y * -0.5; elseif (x <= 8.8e-72) tmp = 1.0; elseif (x <= 1.1e-22) tmp = x * 0.5; elseif (x <= 3850000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2e+39], -1.0, If[LessEqual[x, 9.5e-237], 1.0, If[LessEqual[x, 2.1e-196], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 8.8e-72], 1.0, If[LessEqual[x, 1.1e-22], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 3850000000.0], 1.0, -1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+39}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-237}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-196}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{-72}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-22}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 3850000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.99999999999999988e39 or 3.85e9 < x 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 81.3%
if -1.99999999999999988e39 < x < 9.4999999999999998e-237 or 2.09999999999999988e-196 < x < 8.8000000000000001e-72 or 1.1e-22 < x < 3.85e9Initial 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 57.0%
if 9.4999999999999998e-237 < x < 2.09999999999999988e-196Initial 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 93.3%
Taylor expanded in y around 0 79.7%
*-commutative79.7%
Simplified79.7%
if 8.8000000000000001e-72 < x < 1.1e-22Initial 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 100.0%
Taylor expanded in y around 0 79.4%
*-commutative79.4%
Simplified79.4%
Final simplification69.6%
(FPCore (x y)
:precision binary64
(if (<= x -1.95e+37)
-1.0
(if (<= x 7.4e-242)
(- 1.0 (/ x y))
(if (<= x 1.45e-196)
(* y -0.5)
(if (<= x 7.5e-71)
1.0
(if (<= x 1.16e-14) (* x 0.5) (if (<= x 980000000.0) 1.0 -1.0)))))))
double code(double x, double y) {
double tmp;
if (x <= -1.95e+37) {
tmp = -1.0;
} else if (x <= 7.4e-242) {
tmp = 1.0 - (x / y);
} else if (x <= 1.45e-196) {
tmp = y * -0.5;
} else if (x <= 7.5e-71) {
tmp = 1.0;
} else if (x <= 1.16e-14) {
tmp = x * 0.5;
} else if (x <= 980000000.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.95d+37)) then
tmp = -1.0d0
else if (x <= 7.4d-242) then
tmp = 1.0d0 - (x / y)
else if (x <= 1.45d-196) then
tmp = y * (-0.5d0)
else if (x <= 7.5d-71) then
tmp = 1.0d0
else if (x <= 1.16d-14) then
tmp = x * 0.5d0
else if (x <= 980000000.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.95e+37) {
tmp = -1.0;
} else if (x <= 7.4e-242) {
tmp = 1.0 - (x / y);
} else if (x <= 1.45e-196) {
tmp = y * -0.5;
} else if (x <= 7.5e-71) {
tmp = 1.0;
} else if (x <= 1.16e-14) {
tmp = x * 0.5;
} else if (x <= 980000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.95e+37: tmp = -1.0 elif x <= 7.4e-242: tmp = 1.0 - (x / y) elif x <= 1.45e-196: tmp = y * -0.5 elif x <= 7.5e-71: tmp = 1.0 elif x <= 1.16e-14: tmp = x * 0.5 elif x <= 980000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.95e+37) tmp = -1.0; elseif (x <= 7.4e-242) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= 1.45e-196) tmp = Float64(y * -0.5); elseif (x <= 7.5e-71) tmp = 1.0; elseif (x <= 1.16e-14) tmp = Float64(x * 0.5); elseif (x <= 980000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.95e+37) tmp = -1.0; elseif (x <= 7.4e-242) tmp = 1.0 - (x / y); elseif (x <= 1.45e-196) tmp = y * -0.5; elseif (x <= 7.5e-71) tmp = 1.0; elseif (x <= 1.16e-14) tmp = x * 0.5; elseif (x <= 980000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.95e+37], -1.0, If[LessEqual[x, 7.4e-242], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-196], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 7.5e-71], 1.0, If[LessEqual[x, 1.16e-14], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 980000000.0], 1.0, -1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.95 \cdot 10^{+37}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{-242}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-196}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-71}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.16 \cdot 10^{-14}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 980000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.9499999999999999e37 or 9.8e8 < x 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 81.3%
if -1.9499999999999999e37 < x < 7.39999999999999994e-242Initial 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 55.7%
Taylor expanded in y around 0 55.7%
neg-mul-155.7%
sub-neg55.7%
div-sub55.7%
*-inverses55.7%
Simplified55.7%
if 7.39999999999999994e-242 < x < 1.44999999999999994e-196Initial 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 93.3%
Taylor expanded in y around 0 79.7%
*-commutative79.7%
Simplified79.7%
if 1.44999999999999994e-196 < x < 7.5000000000000004e-71 or 1.16000000000000007e-14 < x < 9.8e8Initial 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 64.0%
if 7.5000000000000004e-71 < x < 1.16000000000000007e-14Initial 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 100.0%
Taylor expanded in y around 0 79.4%
*-commutative79.4%
Simplified79.4%
Final simplification69.6%
(FPCore (x y)
:precision binary64
(if (<= x -1.2e+37)
-1.0
(if (<= x 2.2e-71)
1.0
(if (<= x 1.26e-17) (* x 0.5) (if (<= x 3400000000.0) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1.2e+37) {
tmp = -1.0;
} else if (x <= 2.2e-71) {
tmp = 1.0;
} else if (x <= 1.26e-17) {
tmp = x * 0.5;
} else if (x <= 3400000000.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.2d+37)) then
tmp = -1.0d0
else if (x <= 2.2d-71) then
tmp = 1.0d0
else if (x <= 1.26d-17) then
tmp = x * 0.5d0
else if (x <= 3400000000.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.2e+37) {
tmp = -1.0;
} else if (x <= 2.2e-71) {
tmp = 1.0;
} else if (x <= 1.26e-17) {
tmp = x * 0.5;
} else if (x <= 3400000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.2e+37: tmp = -1.0 elif x <= 2.2e-71: tmp = 1.0 elif x <= 1.26e-17: tmp = x * 0.5 elif x <= 3400000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.2e+37) tmp = -1.0; elseif (x <= 2.2e-71) tmp = 1.0; elseif (x <= 1.26e-17) tmp = Float64(x * 0.5); elseif (x <= 3400000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.2e+37) tmp = -1.0; elseif (x <= 2.2e-71) tmp = 1.0; elseif (x <= 1.26e-17) tmp = x * 0.5; elseif (x <= 3400000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.2e+37], -1.0, If[LessEqual[x, 2.2e-71], 1.0, If[LessEqual[x, 1.26e-17], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 3400000000.0], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+37}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-71}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.26 \cdot 10^{-17}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 3400000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.2e37 or 3.4e9 < x 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 81.3%
if -1.2e37 < x < 2.19999999999999997e-71 or 1.2600000000000001e-17 < x < 3.4e9Initial 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 54.9%
if 2.19999999999999997e-71 < x < 1.2600000000000001e-17Initial 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 100.0%
Taylor expanded in y around 0 79.4%
*-commutative79.4%
Simplified79.4%
Final simplification67.8%
(FPCore (x y) :precision binary64 (if (<= x -1.05e+39) (/ (- y x) x) (if (<= x 3400000000.0) (/ (- y x) (- y 2.0)) (/ x (- 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -1.05e+39) {
tmp = (y - x) / x;
} else if (x <= 3400000000.0) {
tmp = (y - x) / (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 <= (-1.05d+39)) then
tmp = (y - x) / x
else if (x <= 3400000000.0d0) then
tmp = (y - x) / (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 <= -1.05e+39) {
tmp = (y - x) / x;
} else if (x <= 3400000000.0) {
tmp = (y - x) / (y - 2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.05e+39: tmp = (y - x) / x elif x <= 3400000000.0: tmp = (y - x) / (y - 2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.05e+39) tmp = Float64(Float64(y - x) / x); elseif (x <= 3400000000.0) tmp = Float64(Float64(y - x) / 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 <= -1.05e+39) tmp = (y - x) / x; elseif (x <= 3400000000.0) tmp = (y - x) / (y - 2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.05e+39], N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 3400000000.0], N[(N[(y - x), $MachinePrecision] / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+39}:\\
\;\;\;\;\frac{y - x}{x}\\
\mathbf{elif}\;x \leq 3400000000:\\
\;\;\;\;\frac{y - x}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -1.0499999999999999e39Initial 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 84.5%
if -1.0499999999999999e39 < x < 3.4e9Initial 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 95.8%
if 3.4e9 < x 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 0 80.3%
mul-1-neg80.3%
distribute-neg-frac280.3%
neg-sub080.3%
associate-+l-80.3%
neg-sub080.3%
+-commutative80.3%
unsub-neg80.3%
Simplified80.3%
Final simplification89.6%
(FPCore (x y) :precision binary64 (if (or (<= y -8.2e+27) (not (<= y 4.7e+67))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -8.2e+27) || !(y <= 4.7e+67)) {
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 <= (-8.2d+27)) .or. (.not. (y <= 4.7d+67))) 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 <= -8.2e+27) || !(y <= 4.7e+67)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -8.2e+27) or not (y <= 4.7e+67): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -8.2e+27) || !(y <= 4.7e+67)) 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 <= -8.2e+27) || ~((y <= 4.7e+67))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -8.2e+27], N[Not[LessEqual[y, 4.7e+67]], $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 -8.2 \cdot 10^{+27} \lor \neg \left(y \leq 4.7 \cdot 10^{+67}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -8.2000000000000005e27 or 4.70000000000000017e67 < 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 77.6%
Taylor expanded in y around 0 77.6%
neg-mul-177.6%
sub-neg77.6%
div-sub77.6%
*-inverses77.6%
Simplified77.6%
if -8.2000000000000005e27 < y < 4.70000000000000017e67Initial 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 75.0%
mul-1-neg75.0%
distribute-neg-frac275.0%
neg-sub075.0%
associate-+l-75.0%
neg-sub075.0%
+-commutative75.0%
unsub-neg75.0%
Simplified75.0%
Final simplification76.1%
(FPCore (x y) :precision binary64 (if (or (<= x -7e-36) (not (<= x 6.6e-71))) (/ x (- 2.0 x)) (/ y (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -7e-36) || !(x <= 6.6e-71)) {
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 ((x <= (-7d-36)) .or. (.not. (x <= 6.6d-71))) 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 ((x <= -7e-36) || !(x <= 6.6e-71)) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -7e-36) or not (x <= 6.6e-71): tmp = x / (2.0 - x) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -7e-36) || !(x <= 6.6e-71)) 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 ((x <= -7e-36) || ~((x <= 6.6e-71))) tmp = x / (2.0 - x); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -7e-36], N[Not[LessEqual[x, 6.6e-71]], $MachinePrecision]], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{-36} \lor \neg \left(x \leq 6.6 \cdot 10^{-71}\right):\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if x < -6.9999999999999999e-36 or 6.6000000000000003e-71 < x 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 0 77.4%
mul-1-neg77.4%
distribute-neg-frac277.4%
neg-sub077.4%
associate-+l-77.4%
neg-sub077.4%
+-commutative77.4%
unsub-neg77.4%
Simplified77.4%
if -6.9999999999999999e-36 < x < 6.6000000000000003e-71Initial 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 82.8%
Final simplification79.6%
(FPCore (x y) :precision binary64 (if (<= x -2.45e+36) -1.0 (if (<= x 3350000000.0) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -2.45e+36) {
tmp = -1.0;
} else if (x <= 3350000000.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 <= (-2.45d+36)) then
tmp = -1.0d0
else if (x <= 3350000000.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 <= -2.45e+36) {
tmp = -1.0;
} else if (x <= 3350000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.45e+36: tmp = -1.0 elif x <= 3350000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.45e+36) tmp = -1.0; elseif (x <= 3350000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.45e+36) tmp = -1.0; elseif (x <= 3350000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.45e+36], -1.0, If[LessEqual[x, 3350000000.0], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.45 \cdot 10^{+36}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 3350000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.4499999999999999e36 or 3.35e9 < x 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 81.3%
if -2.4499999999999999e36 < x < 3.35e9Initial 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 53.2%
Final simplification66.0%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
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 39.9%
Final simplification39.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 2024080
(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))))