
(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 (let* ((t_0 (+ y (+ -2.0 x)))) (- (/ y t_0) (/ x t_0))))
double code(double x, double y) {
double t_0 = y + (-2.0 + x);
return (y / t_0) - (x / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = y + ((-2.0d0) + x)
code = (y / t_0) - (x / t_0)
end function
public static double code(double x, double y) {
double t_0 = y + (-2.0 + x);
return (y / t_0) - (x / t_0);
}
def code(x, y): t_0 = y + (-2.0 + x) return (y / t_0) - (x / t_0)
function code(x, y) t_0 = Float64(y + Float64(-2.0 + x)) return Float64(Float64(y / t_0) - Float64(x / t_0)) end
function tmp = code(x, y) t_0 = y + (-2.0 + x); tmp = (y / t_0) - (x / t_0); end
code[x_, y_] := Block[{t$95$0 = N[(y + N[(-2.0 + x), $MachinePrecision]), $MachinePrecision]}, N[(N[(y / t$95$0), $MachinePrecision] - N[(x / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \left(-2 + x\right)\\
\frac{y}{t\_0} - \frac{x}{t\_0}
\end{array}
\end{array}
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%
div-sub100.0%
+-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
associate-+l+100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= x -5e+18)
-1.0
(if (<= x -8e-99)
1.0
(if (<= x -1.1e-221) (* y -0.5) (if (<= x 1e+17) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -5e+18) {
tmp = -1.0;
} else if (x <= -8e-99) {
tmp = 1.0;
} else if (x <= -1.1e-221) {
tmp = y * -0.5;
} else if (x <= 1e+17) {
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 <= (-5d+18)) then
tmp = -1.0d0
else if (x <= (-8d-99)) then
tmp = 1.0d0
else if (x <= (-1.1d-221)) then
tmp = y * (-0.5d0)
else if (x <= 1d+17) 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 <= -5e+18) {
tmp = -1.0;
} else if (x <= -8e-99) {
tmp = 1.0;
} else if (x <= -1.1e-221) {
tmp = y * -0.5;
} else if (x <= 1e+17) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5e+18: tmp = -1.0 elif x <= -8e-99: tmp = 1.0 elif x <= -1.1e-221: tmp = y * -0.5 elif x <= 1e+17: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -5e+18) tmp = -1.0; elseif (x <= -8e-99) tmp = 1.0; elseif (x <= -1.1e-221) tmp = Float64(y * -0.5); elseif (x <= 1e+17) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5e+18) tmp = -1.0; elseif (x <= -8e-99) tmp = 1.0; elseif (x <= -1.1e-221) tmp = y * -0.5; elseif (x <= 1e+17) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5e+18], -1.0, If[LessEqual[x, -8e-99], 1.0, If[LessEqual[x, -1.1e-221], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1e+17], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+18}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -8 \cdot 10^{-99}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{-221}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 10^{+17}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -5e18 or 1e17 < x 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 inf 80.6%
if -5e18 < x < -8.0000000000000002e-99 or -1.10000000000000001e-221 < x < 1e17Initial 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 inf 58.0%
if -8.0000000000000002e-99 < x < -1.10000000000000001e-221Initial 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 78.6%
Taylor expanded in y around 0 53.8%
*-commutative53.8%
Simplified53.8%
Final simplification69.2%
(FPCore (x y) :precision binary64 (if (or (<= x -3.3e+16) (not (<= x 9.5e+16))) (- -1.0 (/ (* y -2.0) x)) (/ (- y x) (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -3.3e+16) || !(x <= 9.5e+16)) {
tmp = -1.0 - ((y * -2.0) / x);
} else {
tmp = (y - x) / (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 <= (-3.3d+16)) .or. (.not. (x <= 9.5d+16))) then
tmp = (-1.0d0) - ((y * (-2.0d0)) / x)
else
tmp = (y - x) / (y - 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -3.3e+16) || !(x <= 9.5e+16)) {
tmp = -1.0 - ((y * -2.0) / x);
} else {
tmp = (y - x) / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -3.3e+16) or not (x <= 9.5e+16): tmp = -1.0 - ((y * -2.0) / x) else: tmp = (y - x) / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -3.3e+16) || !(x <= 9.5e+16)) tmp = Float64(-1.0 - Float64(Float64(y * -2.0) / x)); else tmp = Float64(Float64(y - x) / Float64(y - 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -3.3e+16) || ~((x <= 9.5e+16))) tmp = -1.0 - ((y * -2.0) / x); else tmp = (y - x) / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -3.3e+16], N[Not[LessEqual[x, 9.5e+16]], $MachinePrecision]], N[(-1.0 - N[(N[(y * -2.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.3 \cdot 10^{+16} \lor \neg \left(x \leq 9.5 \cdot 10^{+16}\right):\\
\;\;\;\;-1 - \frac{y \cdot -2}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y - 2}\\
\end{array}
\end{array}
if x < -3.3e16 or 9.5e16 < x 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 -inf 81.7%
sub-neg81.7%
metadata-eval81.7%
+-commutative81.7%
mul-1-neg81.7%
unsub-neg81.7%
mul-1-neg81.7%
unsub-neg81.7%
Simplified81.7%
Taylor expanded in y around inf 81.7%
*-commutative81.7%
Simplified81.7%
if -3.3e16 < x < 9.5e16Initial 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 98.3%
Final simplification89.8%
(FPCore (x y) :precision binary64 (if (<= y -3e+97) 1.0 (if (<= y 9e+25) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -3e+97) {
tmp = 1.0;
} else if (y <= 9e+25) {
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 <= (-3d+97)) then
tmp = 1.0d0
else if (y <= 9d+25) 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 <= -3e+97) {
tmp = 1.0;
} else if (y <= 9e+25) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3e+97: tmp = 1.0 elif y <= 9e+25: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -3e+97) tmp = 1.0; elseif (y <= 9e+25) 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 <= -3e+97) tmp = 1.0; elseif (y <= 9e+25) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3e+97], 1.0, If[LessEqual[y, 9e+25], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+97}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+25}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.9999999999999998e97 or 9.0000000000000006e25 < 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 y around inf 79.4%
if -2.9999999999999998e97 < y < 9.0000000000000006e25Initial 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 73.8%
mul-1-neg73.8%
sub-neg73.8%
metadata-eval73.8%
+-commutative73.8%
distribute-neg-frac273.8%
distribute-neg-in73.8%
metadata-eval73.8%
unsub-neg73.8%
Simplified73.8%
Final simplification75.9%
(FPCore (x y) :precision binary64 (if (<= x -1.75e+16) -1.0 (if (<= x 4.8e-94) (/ y (- y 2.0)) (/ x (- 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -1.75e+16) {
tmp = -1.0;
} else if (x <= 4.8e-94) {
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 <= (-1.75d+16)) then
tmp = -1.0d0
else if (x <= 4.8d-94) 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 <= -1.75e+16) {
tmp = -1.0;
} else if (x <= 4.8e-94) {
tmp = y / (y - 2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.75e+16: tmp = -1.0 elif x <= 4.8e-94: tmp = y / (y - 2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.75e+16) tmp = -1.0; elseif (x <= 4.8e-94) 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 <= -1.75e+16) tmp = -1.0; elseif (x <= 4.8e-94) tmp = y / (y - 2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.75e+16], -1.0, If[LessEqual[x, 4.8e-94], 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 -1.75 \cdot 10^{+16}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{-94}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -1.75e16Initial 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 79.5%
if -1.75e16 < x < 4.8e-94Initial 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 81.6%
if 4.8e-94 < x 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 y around 0 74.8%
mul-1-neg74.8%
sub-neg74.8%
metadata-eval74.8%
+-commutative74.8%
distribute-neg-frac274.8%
distribute-neg-in74.8%
metadata-eval74.8%
unsub-neg74.8%
Simplified74.8%
Final simplification78.7%
(FPCore (x y) :precision binary64 (if (<= x -2.9e+17) (/ (- y x) x) (if (<= x 3.95e-94) (/ y (- y 2.0)) (/ x (- 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -2.9e+17) {
tmp = (y - x) / x;
} else if (x <= 3.95e-94) {
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 <= (-2.9d+17)) then
tmp = (y - x) / x
else if (x <= 3.95d-94) 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 <= -2.9e+17) {
tmp = (y - x) / x;
} else if (x <= 3.95e-94) {
tmp = y / (y - 2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.9e+17: tmp = (y - x) / x elif x <= 3.95e-94: tmp = y / (y - 2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.9e+17) tmp = Float64(Float64(y - x) / x); elseif (x <= 3.95e-94) 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 <= -2.9e+17) tmp = (y - x) / x; elseif (x <= 3.95e-94) tmp = y / (y - 2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.9e+17], N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 3.95e-94], 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 -2.9 \cdot 10^{+17}:\\
\;\;\;\;\frac{y - x}{x}\\
\mathbf{elif}\;x \leq 3.95 \cdot 10^{-94}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -2.9e17Initial 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 80.1%
if -2.9e17 < x < 3.95e-94Initial 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 81.6%
if 3.95e-94 < x 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 y around 0 74.8%
mul-1-neg74.8%
sub-neg74.8%
metadata-eval74.8%
+-commutative74.8%
distribute-neg-frac274.8%
distribute-neg-in74.8%
metadata-eval74.8%
unsub-neg74.8%
Simplified74.8%
Final simplification78.8%
(FPCore (x y) :precision binary64 (if (<= x -3.7e+16) (- -1.0 (/ (* y -2.0) x)) (if (<= x 1.6e-95) (/ y (- y 2.0)) (/ x (- 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -3.7e+16) {
tmp = -1.0 - ((y * -2.0) / x);
} else if (x <= 1.6e-95) {
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 <= (-3.7d+16)) then
tmp = (-1.0d0) - ((y * (-2.0d0)) / x)
else if (x <= 1.6d-95) 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 <= -3.7e+16) {
tmp = -1.0 - ((y * -2.0) / x);
} else if (x <= 1.6e-95) {
tmp = y / (y - 2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.7e+16: tmp = -1.0 - ((y * -2.0) / x) elif x <= 1.6e-95: tmp = y / (y - 2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -3.7e+16) tmp = Float64(-1.0 - Float64(Float64(y * -2.0) / x)); elseif (x <= 1.6e-95) 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 <= -3.7e+16) tmp = -1.0 - ((y * -2.0) / x); elseif (x <= 1.6e-95) tmp = y / (y - 2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.7e+16], N[(-1.0 - N[(N[(y * -2.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e-95], 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 -3.7 \cdot 10^{+16}:\\
\;\;\;\;-1 - \frac{y \cdot -2}{x}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-95}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -3.7e16Initial 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 80.7%
sub-neg80.7%
metadata-eval80.7%
+-commutative80.7%
mul-1-neg80.7%
unsub-neg80.7%
mul-1-neg80.7%
unsub-neg80.7%
Simplified80.7%
Taylor expanded in y around inf 80.7%
*-commutative80.7%
Simplified80.7%
if -3.7e16 < x < 1.5999999999999999e-95Initial 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 81.6%
if 1.5999999999999999e-95 < x 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 y around 0 74.8%
mul-1-neg74.8%
sub-neg74.8%
metadata-eval74.8%
+-commutative74.8%
distribute-neg-frac274.8%
distribute-neg-in74.8%
metadata-eval74.8%
unsub-neg74.8%
Simplified74.8%
Final simplification79.0%
(FPCore (x y) :precision binary64 (if (<= x -9.2e+15) -1.0 (if (<= x 9.6e+16) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -9.2e+15) {
tmp = -1.0;
} else if (x <= 9.6e+16) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-9.2d+15)) then
tmp = -1.0d0
else if (x <= 9.6d+16) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -9.2e+15) {
tmp = -1.0;
} else if (x <= 9.6e+16) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9.2e+15: tmp = -1.0 elif x <= 9.6e+16: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -9.2e+15) tmp = -1.0; elseif (x <= 9.6e+16) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9.2e+15) tmp = -1.0; elseif (x <= 9.6e+16) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9.2e+15], -1.0, If[LessEqual[x, 9.6e+16], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+15}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 9.6 \cdot 10^{+16}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.2e15 or 9.6e16 < x 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 inf 80.6%
if -9.2e15 < x < 9.6e16Initial 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 inf 53.2%
Final simplification67.2%
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ y x))))
double code(double x, double y) {
return (x - y) / (2.0 - (y + x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (y + x))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (y + x));
}
def code(x, y): return (x - y) / (2.0 - (y + x))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(y + x))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (y + x)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(y + x\right)}
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 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 inf 42.7%
Final simplification42.7%
(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 2024039
(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))))