
(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
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= y -1.9e+129)
1.0
(if (<= y -1.75e+94)
t_0
(if (<= y -6.5e+15)
1.0
(if (<= y 1.46e-86)
t_0
(if (<= y 9.4e-57) (* y -0.5) (if (<= y 9.4e+55) t_0 1.0))))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (y <= -1.9e+129) {
tmp = 1.0;
} else if (y <= -1.75e+94) {
tmp = t_0;
} else if (y <= -6.5e+15) {
tmp = 1.0;
} else if (y <= 1.46e-86) {
tmp = t_0;
} else if (y <= 9.4e-57) {
tmp = y * -0.5;
} else if (y <= 9.4e+55) {
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 <= (-1.9d+129)) then
tmp = 1.0d0
else if (y <= (-1.75d+94)) then
tmp = t_0
else if (y <= (-6.5d+15)) then
tmp = 1.0d0
else if (y <= 1.46d-86) then
tmp = t_0
else if (y <= 9.4d-57) then
tmp = y * (-0.5d0)
else if (y <= 9.4d+55) 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 <= -1.9e+129) {
tmp = 1.0;
} else if (y <= -1.75e+94) {
tmp = t_0;
} else if (y <= -6.5e+15) {
tmp = 1.0;
} else if (y <= 1.46e-86) {
tmp = t_0;
} else if (y <= 9.4e-57) {
tmp = y * -0.5;
} else if (y <= 9.4e+55) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if y <= -1.9e+129: tmp = 1.0 elif y <= -1.75e+94: tmp = t_0 elif y <= -6.5e+15: tmp = 1.0 elif y <= 1.46e-86: tmp = t_0 elif y <= 9.4e-57: tmp = y * -0.5 elif y <= 9.4e+55: 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 <= -1.9e+129) tmp = 1.0; elseif (y <= -1.75e+94) tmp = t_0; elseif (y <= -6.5e+15) tmp = 1.0; elseif (y <= 1.46e-86) tmp = t_0; elseif (y <= 9.4e-57) tmp = Float64(y * -0.5); elseif (y <= 9.4e+55) 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 <= -1.9e+129) tmp = 1.0; elseif (y <= -1.75e+94) tmp = t_0; elseif (y <= -6.5e+15) tmp = 1.0; elseif (y <= 1.46e-86) tmp = t_0; elseif (y <= 9.4e-57) tmp = y * -0.5; elseif (y <= 9.4e+55) 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, -1.9e+129], 1.0, If[LessEqual[y, -1.75e+94], t$95$0, If[LessEqual[y, -6.5e+15], 1.0, If[LessEqual[y, 1.46e-86], t$95$0, If[LessEqual[y, 9.4e-57], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 9.4e+55], t$95$0, 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;y \leq -1.9 \cdot 10^{+129}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.75 \cdot 10^{+94}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{+15}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.46 \cdot 10^{-86}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 9.4 \cdot 10^{-57}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 9.4 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.90000000000000003e129 or -1.7499999999999999e94 < y < -6.5e15 or 9.4000000000000001e55 < 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.8%
if -1.90000000000000003e129 < y < -1.7499999999999999e94 or -6.5e15 < y < 1.45999999999999993e-86 or 9.3999999999999996e-57 < y < 9.4000000000000001e55Initial 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 76.8%
mul-1-neg76.8%
distribute-neg-frac276.8%
neg-sub076.8%
associate-+l-76.8%
neg-sub076.8%
+-commutative76.8%
unsub-neg76.8%
Simplified76.8%
if 1.45999999999999993e-86 < y < 9.3999999999999996e-57Initial 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 86.7%
Taylor expanded in y around 0 86.7%
*-commutative86.7%
Simplified86.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (/ 1.0 (- y 2.0)) (- y x))))
(if (<= x -1.12e+118)
(- -1.0 (/ (* y -2.0) x))
(if (<= x -4.2e+55)
t_0
(if (<= x -5.5e+37) -1.0 (if (<= x 1.9e-7) t_0 (/ x (- 2.0 x))))))))
double code(double x, double y) {
double t_0 = (1.0 / (y - 2.0)) * (y - x);
double tmp;
if (x <= -1.12e+118) {
tmp = -1.0 - ((y * -2.0) / x);
} else if (x <= -4.2e+55) {
tmp = t_0;
} else if (x <= -5.5e+37) {
tmp = -1.0;
} else if (x <= 1.9e-7) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / (y - 2.0d0)) * (y - x)
if (x <= (-1.12d+118)) then
tmp = (-1.0d0) - ((y * (-2.0d0)) / x)
else if (x <= (-4.2d+55)) then
tmp = t_0
else if (x <= (-5.5d+37)) then
tmp = -1.0d0
else if (x <= 1.9d-7) then
tmp = t_0
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (1.0 / (y - 2.0)) * (y - x);
double tmp;
if (x <= -1.12e+118) {
tmp = -1.0 - ((y * -2.0) / x);
} else if (x <= -4.2e+55) {
tmp = t_0;
} else if (x <= -5.5e+37) {
tmp = -1.0;
} else if (x <= 1.9e-7) {
tmp = t_0;
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): t_0 = (1.0 / (y - 2.0)) * (y - x) tmp = 0 if x <= -1.12e+118: tmp = -1.0 - ((y * -2.0) / x) elif x <= -4.2e+55: tmp = t_0 elif x <= -5.5e+37: tmp = -1.0 elif x <= 1.9e-7: tmp = t_0 else: tmp = x / (2.0 - x) return tmp
function code(x, y) t_0 = Float64(Float64(1.0 / Float64(y - 2.0)) * Float64(y - x)) tmp = 0.0 if (x <= -1.12e+118) tmp = Float64(-1.0 - Float64(Float64(y * -2.0) / x)); elseif (x <= -4.2e+55) tmp = t_0; elseif (x <= -5.5e+37) tmp = -1.0; elseif (x <= 1.9e-7) tmp = t_0; else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) t_0 = (1.0 / (y - 2.0)) * (y - x); tmp = 0.0; if (x <= -1.12e+118) tmp = -1.0 - ((y * -2.0) / x); elseif (x <= -4.2e+55) tmp = t_0; elseif (x <= -5.5e+37) tmp = -1.0; elseif (x <= 1.9e-7) tmp = t_0; else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 / N[(y - 2.0), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.12e+118], N[(-1.0 - N[(N[(y * -2.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4.2e+55], t$95$0, If[LessEqual[x, -5.5e+37], -1.0, If[LessEqual[x, 1.9e-7], t$95$0, N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{y - 2} \cdot \left(y - x\right)\\
\mathbf{if}\;x \leq -1.12 \cdot 10^{+118}:\\
\;\;\;\;-1 - \frac{y \cdot -2}{x}\\
\mathbf{elif}\;x \leq -4.2 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.5 \cdot 10^{+37}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -1.11999999999999999e118Initial 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 90.1%
sub-neg90.1%
+-commutative90.1%
distribute-neg-in90.1%
metadata-eval90.1%
mul-1-neg90.1%
remove-double-neg90.1%
associate-+l+90.1%
remove-double-neg90.1%
mul-1-neg90.1%
neg-sub090.1%
associate--r-90.1%
associate-*r/90.1%
sub-neg90.1%
metadata-eval90.1%
+-commutative90.1%
distribute-lft-in90.1%
metadata-eval90.1%
div-sub90.1%
Simplified90.1%
Taylor expanded in y around inf 90.1%
associate-*r/90.1%
*-commutative90.1%
Simplified90.1%
if -1.11999999999999999e118 < x < -4.2000000000000001e55 or -5.50000000000000016e37 < x < 1.90000000000000007e-7Initial 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%
clear-num99.8%
associate-/r/99.8%
+-commutative99.8%
associate-+l+99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 95.8%
if -4.2000000000000001e55 < x < -5.50000000000000016e37Initial 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 100.0%
if 1.90000000000000007e-7 < 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 83.7%
mul-1-neg83.7%
distribute-neg-frac283.7%
neg-sub083.7%
associate-+l-83.7%
neg-sub083.7%
+-commutative83.7%
unsub-neg83.7%
Simplified83.7%
(FPCore (x y)
:precision binary64
(if (<= x -1.12e+118)
(- -1.0 (/ (* y -2.0) x))
(if (<= x -3.4e+55)
(+ 1.0 (/ (* x -2.0) y))
(if (or (<= x -3.8e-17) (not (<= x 1.1e-29)))
(/ x (- 2.0 x))
(/ y (- y 2.0))))))
double code(double x, double y) {
double tmp;
if (x <= -1.12e+118) {
tmp = -1.0 - ((y * -2.0) / x);
} else if (x <= -3.4e+55) {
tmp = 1.0 + ((x * -2.0) / y);
} else if ((x <= -3.8e-17) || !(x <= 1.1e-29)) {
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 <= (-1.12d+118)) then
tmp = (-1.0d0) - ((y * (-2.0d0)) / x)
else if (x <= (-3.4d+55)) then
tmp = 1.0d0 + ((x * (-2.0d0)) / y)
else if ((x <= (-3.8d-17)) .or. (.not. (x <= 1.1d-29))) 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 <= -1.12e+118) {
tmp = -1.0 - ((y * -2.0) / x);
} else if (x <= -3.4e+55) {
tmp = 1.0 + ((x * -2.0) / y);
} else if ((x <= -3.8e-17) || !(x <= 1.1e-29)) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.12e+118: tmp = -1.0 - ((y * -2.0) / x) elif x <= -3.4e+55: tmp = 1.0 + ((x * -2.0) / y) elif (x <= -3.8e-17) or not (x <= 1.1e-29): tmp = x / (2.0 - x) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.12e+118) tmp = Float64(-1.0 - Float64(Float64(y * -2.0) / x)); elseif (x <= -3.4e+55) tmp = Float64(1.0 + Float64(Float64(x * -2.0) / y)); elseif ((x <= -3.8e-17) || !(x <= 1.1e-29)) 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 <= -1.12e+118) tmp = -1.0 - ((y * -2.0) / x); elseif (x <= -3.4e+55) tmp = 1.0 + ((x * -2.0) / y); elseif ((x <= -3.8e-17) || ~((x <= 1.1e-29))) tmp = x / (2.0 - x); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.12e+118], N[(-1.0 - N[(N[(y * -2.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.4e+55], N[(1.0 + N[(N[(x * -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -3.8e-17], N[Not[LessEqual[x, 1.1e-29]], $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 -1.12 \cdot 10^{+118}:\\
\;\;\;\;-1 - \frac{y \cdot -2}{x}\\
\mathbf{elif}\;x \leq -3.4 \cdot 10^{+55}:\\
\;\;\;\;1 + \frac{x \cdot -2}{y}\\
\mathbf{elif}\;x \leq -3.8 \cdot 10^{-17} \lor \neg \left(x \leq 1.1 \cdot 10^{-29}\right):\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if x < -1.11999999999999999e118Initial 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 90.1%
sub-neg90.1%
+-commutative90.1%
distribute-neg-in90.1%
metadata-eval90.1%
mul-1-neg90.1%
remove-double-neg90.1%
associate-+l+90.1%
remove-double-neg90.1%
mul-1-neg90.1%
neg-sub090.1%
associate--r-90.1%
associate-*r/90.1%
sub-neg90.1%
metadata-eval90.1%
+-commutative90.1%
distribute-lft-in90.1%
metadata-eval90.1%
div-sub90.1%
Simplified90.1%
Taylor expanded in y around inf 90.1%
associate-*r/90.1%
*-commutative90.1%
Simplified90.1%
if -1.11999999999999999e118 < x < -3.3999999999999998e55Initial 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 83.7%
associate--l+83.7%
+-commutative83.7%
mul-1-neg83.7%
unsub-neg83.7%
associate-*r/83.7%
metadata-eval83.7%
div-sub83.7%
unsub-neg83.7%
mul-1-neg83.7%
div-sub83.7%
mul-1-neg83.7%
associate--l+83.7%
sub-neg83.7%
mul-1-neg83.7%
mul-1-neg83.7%
distribute-rgt-out83.7%
metadata-eval83.7%
Simplified83.7%
Taylor expanded in x around inf 83.7%
associate-*r/83.7%
*-commutative83.7%
Simplified83.7%
if -3.3999999999999998e55 < x < -3.8000000000000001e-17 or 1.09999999999999995e-29 < 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 81.0%
mul-1-neg81.0%
distribute-neg-frac281.0%
neg-sub081.0%
associate-+l-81.0%
neg-sub081.0%
+-commutative81.0%
unsub-neg81.0%
Simplified81.0%
if -3.8000000000000001e-17 < x < 1.09999999999999995e-29Initial 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.7%
Final simplification83.2%
(FPCore (x y)
:precision binary64
(if (<= x -1.12e+118)
-1.0
(if (<= x -3.4e+55)
(+ 1.0 (/ (* x -2.0) y))
(if (or (<= x -2e-24) (not (<= x 2.5e-29)))
(/ x (- 2.0 x))
(/ y (- y 2.0))))))
double code(double x, double y) {
double tmp;
if (x <= -1.12e+118) {
tmp = -1.0;
} else if (x <= -3.4e+55) {
tmp = 1.0 + ((x * -2.0) / y);
} else if ((x <= -2e-24) || !(x <= 2.5e-29)) {
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 <= (-1.12d+118)) then
tmp = -1.0d0
else if (x <= (-3.4d+55)) then
tmp = 1.0d0 + ((x * (-2.0d0)) / y)
else if ((x <= (-2d-24)) .or. (.not. (x <= 2.5d-29))) 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 <= -1.12e+118) {
tmp = -1.0;
} else if (x <= -3.4e+55) {
tmp = 1.0 + ((x * -2.0) / y);
} else if ((x <= -2e-24) || !(x <= 2.5e-29)) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.12e+118: tmp = -1.0 elif x <= -3.4e+55: tmp = 1.0 + ((x * -2.0) / y) elif (x <= -2e-24) or not (x <= 2.5e-29): tmp = x / (2.0 - x) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.12e+118) tmp = -1.0; elseif (x <= -3.4e+55) tmp = Float64(1.0 + Float64(Float64(x * -2.0) / y)); elseif ((x <= -2e-24) || !(x <= 2.5e-29)) 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 <= -1.12e+118) tmp = -1.0; elseif (x <= -3.4e+55) tmp = 1.0 + ((x * -2.0) / y); elseif ((x <= -2e-24) || ~((x <= 2.5e-29))) tmp = x / (2.0 - x); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.12e+118], -1.0, If[LessEqual[x, -3.4e+55], N[(1.0 + N[(N[(x * -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -2e-24], N[Not[LessEqual[x, 2.5e-29]], $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 -1.12 \cdot 10^{+118}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -3.4 \cdot 10^{+55}:\\
\;\;\;\;1 + \frac{x \cdot -2}{y}\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-24} \lor \neg \left(x \leq 2.5 \cdot 10^{-29}\right):\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if x < -1.11999999999999999e118Initial 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 89.2%
if -1.11999999999999999e118 < x < -3.3999999999999998e55Initial 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 83.7%
associate--l+83.7%
+-commutative83.7%
mul-1-neg83.7%
unsub-neg83.7%
associate-*r/83.7%
metadata-eval83.7%
div-sub83.7%
unsub-neg83.7%
mul-1-neg83.7%
div-sub83.7%
mul-1-neg83.7%
associate--l+83.7%
sub-neg83.7%
mul-1-neg83.7%
mul-1-neg83.7%
distribute-rgt-out83.7%
metadata-eval83.7%
Simplified83.7%
Taylor expanded in x around inf 83.7%
associate-*r/83.7%
*-commutative83.7%
Simplified83.7%
if -3.3999999999999998e55 < x < -1.99999999999999985e-24 or 2.49999999999999993e-29 < 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 81.0%
mul-1-neg81.0%
distribute-neg-frac281.0%
neg-sub081.0%
associate-+l-81.0%
neg-sub081.0%
+-commutative81.0%
unsub-neg81.0%
Simplified81.0%
if -1.99999999999999985e-24 < x < 2.49999999999999993e-29Initial 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.7%
Final simplification83.0%
(FPCore (x y)
:precision binary64
(if (<= x -1.12e+118)
-1.0
(if (or (<= x -4.2e+55) (and (not (<= x -6e-25)) (<= x 2.8e-29)))
(/ y (- y 2.0))
(/ x (- 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= -1.12e+118) {
tmp = -1.0;
} else if ((x <= -4.2e+55) || (!(x <= -6e-25) && (x <= 2.8e-29))) {
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.12d+118)) then
tmp = -1.0d0
else if ((x <= (-4.2d+55)) .or. (.not. (x <= (-6d-25))) .and. (x <= 2.8d-29)) 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.12e+118) {
tmp = -1.0;
} else if ((x <= -4.2e+55) || (!(x <= -6e-25) && (x <= 2.8e-29))) {
tmp = y / (y - 2.0);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.12e+118: tmp = -1.0 elif (x <= -4.2e+55) or (not (x <= -6e-25) and (x <= 2.8e-29)): tmp = y / (y - 2.0) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.12e+118) tmp = -1.0; elseif ((x <= -4.2e+55) || (!(x <= -6e-25) && (x <= 2.8e-29))) 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.12e+118) tmp = -1.0; elseif ((x <= -4.2e+55) || (~((x <= -6e-25)) && (x <= 2.8e-29))) tmp = y / (y - 2.0); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.12e+118], -1.0, If[Or[LessEqual[x, -4.2e+55], And[N[Not[LessEqual[x, -6e-25]], $MachinePrecision], LessEqual[x, 2.8e-29]]], 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.12 \cdot 10^{+118}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -4.2 \cdot 10^{+55} \lor \neg \left(x \leq -6 \cdot 10^{-25}\right) \land x \leq 2.8 \cdot 10^{-29}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if x < -1.11999999999999999e118Initial 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 89.2%
if -1.11999999999999999e118 < x < -4.2000000000000001e55 or -5.9999999999999995e-25 < x < 2.8000000000000002e-29Initial 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.9%
if -4.2000000000000001e55 < x < -5.9999999999999995e-25 or 2.8000000000000002e-29 < 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 81.0%
mul-1-neg81.0%
distribute-neg-frac281.0%
neg-sub081.0%
associate-+l-81.0%
neg-sub081.0%
+-commutative81.0%
unsub-neg81.0%
Simplified81.0%
Final simplification83.0%
(FPCore (x y)
:precision binary64
(if (<= x -1.12e+118)
-1.0
(if (<= x -4.2e+55)
1.0
(if (<= x -4.8e+37) -1.0 (if (<= x 8600000000000.0) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1.12e+118) {
tmp = -1.0;
} else if (x <= -4.2e+55) {
tmp = 1.0;
} else if (x <= -4.8e+37) {
tmp = -1.0;
} else if (x <= 8600000000000.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.12d+118)) then
tmp = -1.0d0
else if (x <= (-4.2d+55)) then
tmp = 1.0d0
else if (x <= (-4.8d+37)) then
tmp = -1.0d0
else if (x <= 8600000000000.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.12e+118) {
tmp = -1.0;
} else if (x <= -4.2e+55) {
tmp = 1.0;
} else if (x <= -4.8e+37) {
tmp = -1.0;
} else if (x <= 8600000000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.12e+118: tmp = -1.0 elif x <= -4.2e+55: tmp = 1.0 elif x <= -4.8e+37: tmp = -1.0 elif x <= 8600000000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.12e+118) tmp = -1.0; elseif (x <= -4.2e+55) tmp = 1.0; elseif (x <= -4.8e+37) tmp = -1.0; elseif (x <= 8600000000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.12e+118) tmp = -1.0; elseif (x <= -4.2e+55) tmp = 1.0; elseif (x <= -4.8e+37) tmp = -1.0; elseif (x <= 8600000000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.12e+118], -1.0, If[LessEqual[x, -4.2e+55], 1.0, If[LessEqual[x, -4.8e+37], -1.0, If[LessEqual[x, 8600000000000.0], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.12 \cdot 10^{+118}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -4.2 \cdot 10^{+55}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -4.8 \cdot 10^{+37}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 8600000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.11999999999999999e118 or -4.2000000000000001e55 < x < -4.8e37 or 8.6e12 < 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 88.0%
if -1.11999999999999999e118 < x < -4.2000000000000001e55 or -4.8e37 < x < 8.6e12Initial 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 51.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 44.4%
(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 2024106
(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))))