
(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%
(FPCore (x y)
:precision binary64
(if (<= y -2950000000.0)
1.0
(if (<= y -6.3e-118)
(+ (/ y x) -1.0)
(if (<= y -1.35e-241)
(* x 0.5)
(if (<= y -3.7e-271)
-1.0
(if (<= y 4.05e-286) (* x 0.5) (if (<= y 5.6e+90) -1.0 1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -2950000000.0) {
tmp = 1.0;
} else if (y <= -6.3e-118) {
tmp = (y / x) + -1.0;
} else if (y <= -1.35e-241) {
tmp = x * 0.5;
} else if (y <= -3.7e-271) {
tmp = -1.0;
} else if (y <= 4.05e-286) {
tmp = x * 0.5;
} else if (y <= 5.6e+90) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2950000000.0d0)) then
tmp = 1.0d0
else if (y <= (-6.3d-118)) then
tmp = (y / x) + (-1.0d0)
else if (y <= (-1.35d-241)) then
tmp = x * 0.5d0
else if (y <= (-3.7d-271)) then
tmp = -1.0d0
else if (y <= 4.05d-286) then
tmp = x * 0.5d0
else if (y <= 5.6d+90) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2950000000.0) {
tmp = 1.0;
} else if (y <= -6.3e-118) {
tmp = (y / x) + -1.0;
} else if (y <= -1.35e-241) {
tmp = x * 0.5;
} else if (y <= -3.7e-271) {
tmp = -1.0;
} else if (y <= 4.05e-286) {
tmp = x * 0.5;
} else if (y <= 5.6e+90) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2950000000.0: tmp = 1.0 elif y <= -6.3e-118: tmp = (y / x) + -1.0 elif y <= -1.35e-241: tmp = x * 0.5 elif y <= -3.7e-271: tmp = -1.0 elif y <= 4.05e-286: tmp = x * 0.5 elif y <= 5.6e+90: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -2950000000.0) tmp = 1.0; elseif (y <= -6.3e-118) tmp = Float64(Float64(y / x) + -1.0); elseif (y <= -1.35e-241) tmp = Float64(x * 0.5); elseif (y <= -3.7e-271) tmp = -1.0; elseif (y <= 4.05e-286) tmp = Float64(x * 0.5); elseif (y <= 5.6e+90) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2950000000.0) tmp = 1.0; elseif (y <= -6.3e-118) tmp = (y / x) + -1.0; elseif (y <= -1.35e-241) tmp = x * 0.5; elseif (y <= -3.7e-271) tmp = -1.0; elseif (y <= 4.05e-286) tmp = x * 0.5; elseif (y <= 5.6e+90) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2950000000.0], 1.0, If[LessEqual[y, -6.3e-118], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[y, -1.35e-241], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, -3.7e-271], -1.0, If[LessEqual[y, 4.05e-286], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 5.6e+90], -1.0, 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2950000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -6.3 \cdot 10^{-118}:\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{elif}\;y \leq -1.35 \cdot 10^{-241}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq -3.7 \cdot 10^{-271}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 4.05 \cdot 10^{-286}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+90}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.95e9 or 5.6000000000000001e90 < 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 80.8%
if -2.95e9 < y < -6.2999999999999997e-118Initial 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%
clear-num99.9%
associate-/r/99.9%
+-commutative99.9%
associate-+l+99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 47.3%
Taylor expanded in x around inf 47.4%
if -6.2999999999999997e-118 < y < -1.35e-241 or -3.70000000000000022e-271 < y < 4.04999999999999986e-286Initial 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 85.7%
mul-1-neg85.7%
distribute-neg-frac285.7%
neg-sub085.7%
associate-+l-85.7%
neg-sub085.7%
+-commutative85.7%
unsub-neg85.7%
Simplified85.7%
Taylor expanded in x around 0 61.0%
*-commutative61.0%
Simplified61.0%
if -1.35e-241 < y < -3.70000000000000022e-271 or 4.04999999999999986e-286 < y < 5.6000000000000001e90Initial 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 66.4%
Final simplification70.3%
(FPCore (x y)
:precision binary64
(if (<= y -33000000000.0)
1.0
(if (<= y -6.3e-118)
-1.0
(if (<= y 1.85e-288) (* x 0.5) (if (<= y 1e+91) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -33000000000.0) {
tmp = 1.0;
} else if (y <= -6.3e-118) {
tmp = -1.0;
} else if (y <= 1.85e-288) {
tmp = x * 0.5;
} else if (y <= 1e+91) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-33000000000.0d0)) then
tmp = 1.0d0
else if (y <= (-6.3d-118)) then
tmp = -1.0d0
else if (y <= 1.85d-288) then
tmp = x * 0.5d0
else if (y <= 1d+91) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -33000000000.0) {
tmp = 1.0;
} else if (y <= -6.3e-118) {
tmp = -1.0;
} else if (y <= 1.85e-288) {
tmp = x * 0.5;
} else if (y <= 1e+91) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -33000000000.0: tmp = 1.0 elif y <= -6.3e-118: tmp = -1.0 elif y <= 1.85e-288: tmp = x * 0.5 elif y <= 1e+91: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -33000000000.0) tmp = 1.0; elseif (y <= -6.3e-118) tmp = -1.0; elseif (y <= 1.85e-288) tmp = Float64(x * 0.5); elseif (y <= 1e+91) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -33000000000.0) tmp = 1.0; elseif (y <= -6.3e-118) tmp = -1.0; elseif (y <= 1.85e-288) tmp = x * 0.5; elseif (y <= 1e+91) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -33000000000.0], 1.0, If[LessEqual[y, -6.3e-118], -1.0, If[LessEqual[y, 1.85e-288], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1e+91], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -33000000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -6.3 \cdot 10^{-118}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{-288}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 10^{+91}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.3e10 or 1.00000000000000008e91 < 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 80.8%
if -3.3e10 < y < -6.2999999999999997e-118 or 1.85e-288 < y < 1.00000000000000008e91Initial 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 60.7%
if -6.2999999999999997e-118 < y < 1.85e-288Initial 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 86.4%
mul-1-neg86.4%
distribute-neg-frac286.4%
neg-sub086.4%
associate-+l-86.4%
neg-sub086.4%
+-commutative86.4%
unsub-neg86.4%
Simplified86.4%
Taylor expanded in x around 0 51.8%
*-commutative51.8%
Simplified51.8%
(FPCore (x y) :precision binary64 (if (or (<= y -44000000000.0) (not (<= y 6.4e+90))) (+ 1.0 (/ (* -2.0 x) y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -44000000000.0) || !(y <= 6.4e+90)) {
tmp = 1.0 + ((-2.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 <= (-44000000000.0d0)) .or. (.not. (y <= 6.4d+90))) then
tmp = 1.0d0 + (((-2.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 <= -44000000000.0) || !(y <= 6.4e+90)) {
tmp = 1.0 + ((-2.0 * x) / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -44000000000.0) or not (y <= 6.4e+90): tmp = 1.0 + ((-2.0 * x) / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -44000000000.0) || !(y <= 6.4e+90)) tmp = Float64(1.0 + Float64(Float64(-2.0 * 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 <= -44000000000.0) || ~((y <= 6.4e+90))) tmp = 1.0 + ((-2.0 * x) / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -44000000000.0], N[Not[LessEqual[y, 6.4e+90]], $MachinePrecision]], N[(1.0 + N[(N[(-2.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -44000000000 \lor \neg \left(y \leq 6.4 \cdot 10^{+90}\right):\\
\;\;\;\;1 + \frac{-2 \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -4.4e10 or 6.39999999999999997e90 < 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 82.8%
associate--l+82.8%
+-commutative82.8%
mul-1-neg82.8%
unsub-neg82.8%
associate-*r/82.8%
metadata-eval82.8%
div-sub82.8%
unsub-neg82.8%
mul-1-neg82.8%
div-sub82.8%
mul-1-neg82.8%
associate--l+82.8%
sub-neg82.8%
mul-1-neg82.8%
mul-1-neg82.8%
distribute-rgt-out82.8%
metadata-eval82.8%
Simplified82.8%
Taylor expanded in x around inf 82.8%
associate-*r/82.8%
*-commutative82.8%
Simplified82.8%
if -4.4e10 < y < 6.39999999999999997e90Initial 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.3%
mul-1-neg75.3%
distribute-neg-frac275.3%
neg-sub075.3%
associate-+l-75.3%
neg-sub075.3%
+-commutative75.3%
unsub-neg75.3%
Simplified75.3%
Final simplification78.6%
(FPCore (x y) :precision binary64 (if (<= y -175000000.0) (+ 1.0 (/ (+ 2.0 (* -2.0 x)) y)) (if (<= y 9.5e+91) (/ x (- 2.0 x)) (+ 1.0 (/ (* -2.0 x) y)))))
double code(double x, double y) {
double tmp;
if (y <= -175000000.0) {
tmp = 1.0 + ((2.0 + (-2.0 * x)) / y);
} else if (y <= 9.5e+91) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0 + ((-2.0 * x) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-175000000.0d0)) then
tmp = 1.0d0 + ((2.0d0 + ((-2.0d0) * x)) / y)
else if (y <= 9.5d+91) then
tmp = x / (2.0d0 - x)
else
tmp = 1.0d0 + (((-2.0d0) * x) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -175000000.0) {
tmp = 1.0 + ((2.0 + (-2.0 * x)) / y);
} else if (y <= 9.5e+91) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0 + ((-2.0 * x) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -175000000.0: tmp = 1.0 + ((2.0 + (-2.0 * x)) / y) elif y <= 9.5e+91: tmp = x / (2.0 - x) else: tmp = 1.0 + ((-2.0 * x) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -175000000.0) tmp = Float64(1.0 + Float64(Float64(2.0 + Float64(-2.0 * x)) / y)); elseif (y <= 9.5e+91) tmp = Float64(x / Float64(2.0 - x)); else tmp = Float64(1.0 + Float64(Float64(-2.0 * x) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -175000000.0) tmp = 1.0 + ((2.0 + (-2.0 * x)) / y); elseif (y <= 9.5e+91) tmp = x / (2.0 - x); else tmp = 1.0 + ((-2.0 * x) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -175000000.0], N[(1.0 + N[(N[(2.0 + N[(-2.0 * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.5e+91], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(-2.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -175000000:\\
\;\;\;\;1 + \frac{2 + -2 \cdot x}{y}\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+91}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{-2 \cdot x}{y}\\
\end{array}
\end{array}
if y < -1.75e8Initial 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 83.8%
associate--l+83.8%
+-commutative83.8%
mul-1-neg83.8%
unsub-neg83.8%
associate-*r/83.8%
metadata-eval83.8%
div-sub83.8%
unsub-neg83.8%
mul-1-neg83.8%
div-sub83.8%
mul-1-neg83.8%
associate--l+83.8%
sub-neg83.8%
mul-1-neg83.8%
mul-1-neg83.8%
distribute-rgt-out83.8%
metadata-eval83.8%
Simplified83.8%
if -1.75e8 < y < 9.5000000000000001e91Initial 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.3%
mul-1-neg75.3%
distribute-neg-frac275.3%
neg-sub075.3%
associate-+l-75.3%
neg-sub075.3%
+-commutative75.3%
unsub-neg75.3%
Simplified75.3%
if 9.5000000000000001e91 < 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 81.8%
associate--l+81.8%
+-commutative81.8%
mul-1-neg81.8%
unsub-neg81.8%
associate-*r/81.8%
metadata-eval81.8%
div-sub81.8%
unsub-neg81.8%
mul-1-neg81.8%
div-sub81.8%
mul-1-neg81.8%
associate--l+81.8%
sub-neg81.8%
mul-1-neg81.8%
mul-1-neg81.8%
distribute-rgt-out81.8%
metadata-eval81.8%
Simplified81.8%
Taylor expanded in x around inf 81.8%
associate-*r/81.8%
*-commutative81.8%
Simplified81.8%
Final simplification78.6%
(FPCore (x y) :precision binary64 (if (<= y -5e-42) (/ y (- y 2.0)) (if (<= y 8.6e+107) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -5e-42) {
tmp = y / (y - 2.0);
} else if (y <= 8.6e+107) {
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 <= (-5d-42)) then
tmp = y / (y - 2.0d0)
else if (y <= 8.6d+107) 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 <= -5e-42) {
tmp = y / (y - 2.0);
} else if (y <= 8.6e+107) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5e-42: tmp = y / (y - 2.0) elif y <= 8.6e+107: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5e-42) tmp = Float64(y / Float64(y - 2.0)); elseif (y <= 8.6e+107) 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 <= -5e-42) tmp = y / (y - 2.0); elseif (y <= 8.6e+107) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5e-42], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.6e+107], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{elif}\;y \leq 8.6 \cdot 10^{+107}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.00000000000000003e-42Initial 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 79.0%
if -5.00000000000000003e-42 < y < 8.5999999999999999e107Initial 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.1%
mul-1-neg76.1%
distribute-neg-frac276.1%
neg-sub076.1%
associate-+l-76.1%
neg-sub076.1%
+-commutative76.1%
unsub-neg76.1%
Simplified76.1%
if 8.5999999999999999e107 < 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 82.3%
(FPCore (x y) :precision binary64 (if (<= y -5.4e+14) 1.0 (if (<= y 9.8e+107) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -5.4e+14) {
tmp = 1.0;
} else if (y <= 9.8e+107) {
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 <= (-5.4d+14)) then
tmp = 1.0d0
else if (y <= 9.8d+107) 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 <= -5.4e+14) {
tmp = 1.0;
} else if (y <= 9.8e+107) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5.4e+14: tmp = 1.0 elif y <= 9.8e+107: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5.4e+14) tmp = 1.0; elseif (y <= 9.8e+107) 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 <= -5.4e+14) tmp = 1.0; elseif (y <= 9.8e+107) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5.4e+14], 1.0, If[LessEqual[y, 9.8e+107], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+14}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 9.8 \cdot 10^{+107}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.4e14 or 9.8000000000000003e107 < 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 81.9%
if -5.4e14 < y < 9.8000000000000003e107Initial 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 74.7%
mul-1-neg74.7%
distribute-neg-frac274.7%
neg-sub074.7%
associate-+l-74.7%
neg-sub074.7%
+-commutative74.7%
unsub-neg74.7%
Simplified74.7%
(FPCore (x y) :precision binary64 (if (<= y -2.55e+14) 1.0 (if (<= y 1.4e+91) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -2.55e+14) {
tmp = 1.0;
} else if (y <= 1.4e+91) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2.55d+14)) then
tmp = 1.0d0
else if (y <= 1.4d+91) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.55e+14) {
tmp = 1.0;
} else if (y <= 1.4e+91) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.55e+14: tmp = 1.0 elif y <= 1.4e+91: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.55e+14) tmp = 1.0; elseif (y <= 1.4e+91) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.55e+14) tmp = 1.0; elseif (y <= 1.4e+91) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.55e+14], 1.0, If[LessEqual[y, 1.4e+91], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.55 \cdot 10^{+14}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+91}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.55e14 or 1.3999999999999999e91 < 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 80.8%
if -2.55e14 < y < 1.3999999999999999e91Initial 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 52.8%
(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 36.5%
(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 2024100
(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))))