
(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%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= x -2e+50)
-1.0
(if (<= x -3.3e-276)
1.0
(if (<= x -1.95e-302)
(* y -0.5)
(if (<= x 2.2e-284)
1.0
(if (<= x 4.6e-181)
(* y -0.5)
(if (<= x 8.5e-132)
1.0
(if (<= x 1.6e-36) (* x 0.5) (if (<= x 3e+84) 1.0 -1.0)))))))))
double code(double x, double y) {
double tmp;
if (x <= -2e+50) {
tmp = -1.0;
} else if (x <= -3.3e-276) {
tmp = 1.0;
} else if (x <= -1.95e-302) {
tmp = y * -0.5;
} else if (x <= 2.2e-284) {
tmp = 1.0;
} else if (x <= 4.6e-181) {
tmp = y * -0.5;
} else if (x <= 8.5e-132) {
tmp = 1.0;
} else if (x <= 1.6e-36) {
tmp = x * 0.5;
} else if (x <= 3e+84) {
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+50)) then
tmp = -1.0d0
else if (x <= (-3.3d-276)) then
tmp = 1.0d0
else if (x <= (-1.95d-302)) then
tmp = y * (-0.5d0)
else if (x <= 2.2d-284) then
tmp = 1.0d0
else if (x <= 4.6d-181) then
tmp = y * (-0.5d0)
else if (x <= 8.5d-132) then
tmp = 1.0d0
else if (x <= 1.6d-36) then
tmp = x * 0.5d0
else if (x <= 3d+84) 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+50) {
tmp = -1.0;
} else if (x <= -3.3e-276) {
tmp = 1.0;
} else if (x <= -1.95e-302) {
tmp = y * -0.5;
} else if (x <= 2.2e-284) {
tmp = 1.0;
} else if (x <= 4.6e-181) {
tmp = y * -0.5;
} else if (x <= 8.5e-132) {
tmp = 1.0;
} else if (x <= 1.6e-36) {
tmp = x * 0.5;
} else if (x <= 3e+84) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2e+50: tmp = -1.0 elif x <= -3.3e-276: tmp = 1.0 elif x <= -1.95e-302: tmp = y * -0.5 elif x <= 2.2e-284: tmp = 1.0 elif x <= 4.6e-181: tmp = y * -0.5 elif x <= 8.5e-132: tmp = 1.0 elif x <= 1.6e-36: tmp = x * 0.5 elif x <= 3e+84: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2e+50) tmp = -1.0; elseif (x <= -3.3e-276) tmp = 1.0; elseif (x <= -1.95e-302) tmp = Float64(y * -0.5); elseif (x <= 2.2e-284) tmp = 1.0; elseif (x <= 4.6e-181) tmp = Float64(y * -0.5); elseif (x <= 8.5e-132) tmp = 1.0; elseif (x <= 1.6e-36) tmp = Float64(x * 0.5); elseif (x <= 3e+84) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2e+50) tmp = -1.0; elseif (x <= -3.3e-276) tmp = 1.0; elseif (x <= -1.95e-302) tmp = y * -0.5; elseif (x <= 2.2e-284) tmp = 1.0; elseif (x <= 4.6e-181) tmp = y * -0.5; elseif (x <= 8.5e-132) tmp = 1.0; elseif (x <= 1.6e-36) tmp = x * 0.5; elseif (x <= 3e+84) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2e+50], -1.0, If[LessEqual[x, -3.3e-276], 1.0, If[LessEqual[x, -1.95e-302], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 2.2e-284], 1.0, If[LessEqual[x, 4.6e-181], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 8.5e-132], 1.0, If[LessEqual[x, 1.6e-36], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 3e+84], 1.0, -1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+50}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -3.3 \cdot 10^{-276}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1.95 \cdot 10^{-302}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-284}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{-181}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-132}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-36}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+84}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.0000000000000002e50 or 2.99999999999999996e84 < 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 85.8%
if -2.0000000000000002e50 < x < -3.29999999999999991e-276 or -1.95e-302 < x < 2.2000000000000001e-284 or 4.59999999999999982e-181 < x < 8.49999999999999988e-132 or 1.60000000000000011e-36 < x < 2.99999999999999996e84Initial 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 58.9%
if -3.29999999999999991e-276 < x < -1.95e-302 or 2.2000000000000001e-284 < x < 4.59999999999999982e-181Initial 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 91.5%
Taylor expanded in y around 0 67.7%
Simplified67.7%
if 8.49999999999999988e-132 < x < 1.60000000000000011e-36Initial 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 68.3%
mul-1-neg68.3%
distribute-neg-frac268.3%
neg-sub068.3%
associate-+l-68.3%
neg-sub068.3%
+-commutative68.3%
unsub-neg68.3%
Simplified68.3%
Taylor expanded in x around 0 68.3%
*-commutative68.3%
Simplified68.3%
Final simplification70.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- -1.0 (* (/ y x) -2.0))))
(if (<= x -2.2e+49)
t_0
(if (<= x 4e-90)
(/ y (- y 2.0))
(if (<= x 1.6e-37) (* x 0.5) (if (<= x 4.3e+84) 1.0 t_0))))))
double code(double x, double y) {
double t_0 = -1.0 - ((y / x) * -2.0);
double tmp;
if (x <= -2.2e+49) {
tmp = t_0;
} else if (x <= 4e-90) {
tmp = y / (y - 2.0);
} else if (x <= 1.6e-37) {
tmp = x * 0.5;
} else if (x <= 4.3e+84) {
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) :: tmp
t_0 = (-1.0d0) - ((y / x) * (-2.0d0))
if (x <= (-2.2d+49)) then
tmp = t_0
else if (x <= 4d-90) then
tmp = y / (y - 2.0d0)
else if (x <= 1.6d-37) then
tmp = x * 0.5d0
else if (x <= 4.3d+84) 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 = -1.0 - ((y / x) * -2.0);
double tmp;
if (x <= -2.2e+49) {
tmp = t_0;
} else if (x <= 4e-90) {
tmp = y / (y - 2.0);
} else if (x <= 1.6e-37) {
tmp = x * 0.5;
} else if (x <= 4.3e+84) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = -1.0 - ((y / x) * -2.0) tmp = 0 if x <= -2.2e+49: tmp = t_0 elif x <= 4e-90: tmp = y / (y - 2.0) elif x <= 1.6e-37: tmp = x * 0.5 elif x <= 4.3e+84: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(-1.0 - Float64(Float64(y / x) * -2.0)) tmp = 0.0 if (x <= -2.2e+49) tmp = t_0; elseif (x <= 4e-90) tmp = Float64(y / Float64(y - 2.0)); elseif (x <= 1.6e-37) tmp = Float64(x * 0.5); elseif (x <= 4.3e+84) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = -1.0 - ((y / x) * -2.0); tmp = 0.0; if (x <= -2.2e+49) tmp = t_0; elseif (x <= 4e-90) tmp = y / (y - 2.0); elseif (x <= 1.6e-37) tmp = x * 0.5; elseif (x <= 4.3e+84) tmp = 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(-1.0 - N[(N[(y / x), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.2e+49], t$95$0, If[LessEqual[x, 4e-90], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e-37], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 4.3e+84], 1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 - \frac{y}{x} \cdot -2\\
\mathbf{if}\;x \leq -2.2 \cdot 10^{+49}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-90}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-37}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{+84}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.2000000000000001e49 or 4.2999999999999996e84 < 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 86.7%
+-commutative86.7%
associate--r+86.7%
associate-*r/86.7%
div-sub86.7%
sub-neg86.7%
Simplified86.7%
Taylor expanded in y around inf 86.7%
*-commutative86.7%
Simplified86.7%
if -2.2000000000000001e49 < x < 3.99999999999999998e-90Initial 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 79.3%
if 3.99999999999999998e-90 < x < 1.5999999999999999e-37Initial 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 83.1%
mul-1-neg83.1%
distribute-neg-frac283.1%
neg-sub083.1%
associate-+l-83.1%
neg-sub083.1%
+-commutative83.1%
unsub-neg83.1%
Simplified83.1%
Taylor expanded in x around 0 83.1%
*-commutative83.1%
Simplified83.1%
if 1.5999999999999999e-37 < x < 4.2999999999999996e84Initial 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 66.1%
Final simplification81.5%
(FPCore (x y)
:precision binary64
(if (<= x -1e+49)
-1.0
(if (<= x 1.05e-131)
1.0
(if (<= x 8.5e-37) (* x 0.5) (if (<= x 2e+85) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1e+49) {
tmp = -1.0;
} else if (x <= 1.05e-131) {
tmp = 1.0;
} else if (x <= 8.5e-37) {
tmp = x * 0.5;
} else if (x <= 2e+85) {
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 <= (-1d+49)) then
tmp = -1.0d0
else if (x <= 1.05d-131) then
tmp = 1.0d0
else if (x <= 8.5d-37) then
tmp = x * 0.5d0
else if (x <= 2d+85) 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 <= -1e+49) {
tmp = -1.0;
} else if (x <= 1.05e-131) {
tmp = 1.0;
} else if (x <= 8.5e-37) {
tmp = x * 0.5;
} else if (x <= 2e+85) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e+49: tmp = -1.0 elif x <= 1.05e-131: tmp = 1.0 elif x <= 8.5e-37: tmp = x * 0.5 elif x <= 2e+85: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1e+49) tmp = -1.0; elseif (x <= 1.05e-131) tmp = 1.0; elseif (x <= 8.5e-37) tmp = Float64(x * 0.5); elseif (x <= 2e+85) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e+49) tmp = -1.0; elseif (x <= 1.05e-131) tmp = 1.0; elseif (x <= 8.5e-37) tmp = x * 0.5; elseif (x <= 2e+85) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e+49], -1.0, If[LessEqual[x, 1.05e-131], 1.0, If[LessEqual[x, 8.5e-37], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 2e+85], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+49}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-131}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-37}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+85}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.99999999999999946e48 or 2e85 < 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 85.8%
if -9.99999999999999946e48 < x < 1.04999999999999999e-131 or 8.5000000000000007e-37 < x < 2e85Initial 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.0%
if 1.04999999999999999e-131 < x < 8.5000000000000007e-37Initial 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 68.3%
mul-1-neg68.3%
distribute-neg-frac268.3%
neg-sub068.3%
associate-+l-68.3%
neg-sub068.3%
+-commutative68.3%
unsub-neg68.3%
Simplified68.3%
Taylor expanded in x around 0 68.3%
*-commutative68.3%
Simplified68.3%
Final simplification66.8%
(FPCore (x y)
:precision binary64
(if (<= x -4e+49)
-1.0
(if (<= x 3.6e-90)
(/ y (- y 2.0))
(if (<= x 2e-37) (* x 0.5) (if (<= x 6.5e+83) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -4e+49) {
tmp = -1.0;
} else if (x <= 3.6e-90) {
tmp = y / (y - 2.0);
} else if (x <= 2e-37) {
tmp = x * 0.5;
} else if (x <= 6.5e+83) {
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 <= (-4d+49)) then
tmp = -1.0d0
else if (x <= 3.6d-90) then
tmp = y / (y - 2.0d0)
else if (x <= 2d-37) then
tmp = x * 0.5d0
else if (x <= 6.5d+83) 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 <= -4e+49) {
tmp = -1.0;
} else if (x <= 3.6e-90) {
tmp = y / (y - 2.0);
} else if (x <= 2e-37) {
tmp = x * 0.5;
} else if (x <= 6.5e+83) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4e+49: tmp = -1.0 elif x <= 3.6e-90: tmp = y / (y - 2.0) elif x <= 2e-37: tmp = x * 0.5 elif x <= 6.5e+83: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -4e+49) tmp = -1.0; elseif (x <= 3.6e-90) tmp = Float64(y / Float64(y - 2.0)); elseif (x <= 2e-37) tmp = Float64(x * 0.5); elseif (x <= 6.5e+83) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -4e+49) tmp = -1.0; elseif (x <= 3.6e-90) tmp = y / (y - 2.0); elseif (x <= 2e-37) tmp = x * 0.5; elseif (x <= 6.5e+83) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4e+49], -1.0, If[LessEqual[x, 3.6e-90], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2e-37], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 6.5e+83], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+49}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-90}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-37}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+83}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -3.99999999999999979e49 or 6.5000000000000003e83 < 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 85.8%
if -3.99999999999999979e49 < x < 3.59999999999999981e-90Initial 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 79.3%
if 3.59999999999999981e-90 < x < 2.00000000000000013e-37Initial 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 83.1%
mul-1-neg83.1%
distribute-neg-frac283.1%
neg-sub083.1%
associate-+l-83.1%
neg-sub083.1%
+-commutative83.1%
unsub-neg83.1%
Simplified83.1%
Taylor expanded in x around 0 83.1%
*-commutative83.1%
Simplified83.1%
if 2.00000000000000013e-37 < x < 6.5000000000000003e83Initial 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 66.1%
Final simplification81.2%
(FPCore (x y) :precision binary64 (if (<= y -23500000.0) 1.0 (if (<= y 1.06e+35) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -23500000.0) {
tmp = 1.0;
} else if (y <= 1.06e+35) {
tmp = x / (2.0 - x);
} 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 <= (-23500000.0d0)) then
tmp = 1.0d0
else if (y <= 1.06d+35) then
tmp = x / (2.0d0 - x)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -23500000.0) {
tmp = 1.0;
} else if (y <= 1.06e+35) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -23500000.0: tmp = 1.0 elif y <= 1.06e+35: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -23500000.0) tmp = 1.0; elseif (y <= 1.06e+35) tmp = Float64(x / Float64(2.0 - x)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -23500000.0) tmp = 1.0; elseif (y <= 1.06e+35) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -23500000.0], 1.0, If[LessEqual[y, 1.06e+35], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -23500000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.06 \cdot 10^{+35}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.35e7 or 1.0600000000000001e35 < 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 78.2%
if -2.35e7 < y < 1.0600000000000001e35Initial 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 73.7%
mul-1-neg73.7%
distribute-neg-frac273.7%
neg-sub073.7%
associate-+l-73.7%
neg-sub073.7%
+-commutative73.7%
unsub-neg73.7%
Simplified73.7%
Final simplification75.6%
(FPCore (x y) :precision binary64 (if (<= x -2e+49) -1.0 (if (<= x 9e+83) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -2e+49) {
tmp = -1.0;
} else if (x <= 9e+83) {
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+49)) then
tmp = -1.0d0
else if (x <= 9d+83) 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+49) {
tmp = -1.0;
} else if (x <= 9e+83) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2e+49: tmp = -1.0 elif x <= 9e+83: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2e+49) tmp = -1.0; elseif (x <= 9e+83) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2e+49) tmp = -1.0; elseif (x <= 9e+83) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2e+49], -1.0, If[LessEqual[x, 9e+83], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+49}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+83}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.99999999999999989e49 or 8.9999999999999999e83 < 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 85.8%
if -1.99999999999999989e49 < x < 8.9999999999999999e83Initial 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 50.2%
Final simplification64.3%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
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.1%
Final simplification38.1%
(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 2024044
(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))))