
(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 (/ (- 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 99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -1.06e+17)
t_0
(if (<= y -2.65e-283)
-1.0
(if (<= y 5.5e-178) (* x 0.5) (if (<= y 1000000000000.0) -1.0 t_0))))))
double code(double x, double y) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -1.06e+17) {
tmp = t_0;
} else if (y <= -2.65e-283) {
tmp = -1.0;
} else if (y <= 5.5e-178) {
tmp = x * 0.5;
} else if (y <= 1000000000000.0) {
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 - (x / y)
if (y <= (-1.06d+17)) then
tmp = t_0
else if (y <= (-2.65d-283)) then
tmp = -1.0d0
else if (y <= 5.5d-178) then
tmp = x * 0.5d0
else if (y <= 1000000000000.0d0) 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 - (x / y);
double tmp;
if (y <= -1.06e+17) {
tmp = t_0;
} else if (y <= -2.65e-283) {
tmp = -1.0;
} else if (y <= 5.5e-178) {
tmp = x * 0.5;
} else if (y <= 1000000000000.0) {
tmp = -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x / y) tmp = 0 if y <= -1.06e+17: tmp = t_0 elif y <= -2.65e-283: tmp = -1.0 elif y <= 5.5e-178: tmp = x * 0.5 elif y <= 1000000000000.0: tmp = -1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -1.06e+17) tmp = t_0; elseif (y <= -2.65e-283) tmp = -1.0; elseif (y <= 5.5e-178) tmp = Float64(x * 0.5); elseif (y <= 1000000000000.0) tmp = -1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -1.06e+17) tmp = t_0; elseif (y <= -2.65e-283) tmp = -1.0; elseif (y <= 5.5e-178) tmp = x * 0.5; elseif (y <= 1000000000000.0) tmp = -1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.06e+17], t$95$0, If[LessEqual[y, -2.65e-283], -1.0, If[LessEqual[y, 5.5e-178], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1000000000000.0], -1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -1.06 \cdot 10^{+17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -2.65 \cdot 10^{-283}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-178}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 1000000000000:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.06e17 or 1e12 < 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 78.5%
Taylor expanded in y around 0 78.5%
neg-mul-178.5%
sub-neg78.5%
div-sub78.5%
*-inverses78.5%
Simplified78.5%
if -1.06e17 < y < -2.6500000000000002e-283 or 5.50000000000000028e-178 < y < 1e12Initial 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 52.7%
if -2.6500000000000002e-283 < y < 5.50000000000000028e-178Initial 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 68.6%
Taylor expanded in y around 0 51.1%
*-commutative51.1%
Simplified51.1%
(FPCore (x y)
:precision binary64
(if (<= y -2.8e+17)
1.0
(if (<= y -2e-285)
-1.0
(if (<= y 3.4e-178) (* x 0.5) (if (<= y 2200000000000.0) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -2.8e+17) {
tmp = 1.0;
} else if (y <= -2e-285) {
tmp = -1.0;
} else if (y <= 3.4e-178) {
tmp = x * 0.5;
} else if (y <= 2200000000000.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 (y <= (-2.8d+17)) then
tmp = 1.0d0
else if (y <= (-2d-285)) then
tmp = -1.0d0
else if (y <= 3.4d-178) then
tmp = x * 0.5d0
else if (y <= 2200000000000.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 (y <= -2.8e+17) {
tmp = 1.0;
} else if (y <= -2e-285) {
tmp = -1.0;
} else if (y <= 3.4e-178) {
tmp = x * 0.5;
} else if (y <= 2200000000000.0) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.8e+17: tmp = 1.0 elif y <= -2e-285: tmp = -1.0 elif y <= 3.4e-178: tmp = x * 0.5 elif y <= 2200000000000.0: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.8e+17) tmp = 1.0; elseif (y <= -2e-285) tmp = -1.0; elseif (y <= 3.4e-178) tmp = Float64(x * 0.5); elseif (y <= 2200000000000.0) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.8e+17) tmp = 1.0; elseif (y <= -2e-285) tmp = -1.0; elseif (y <= 3.4e-178) tmp = x * 0.5; elseif (y <= 2200000000000.0) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.8e+17], 1.0, If[LessEqual[y, -2e-285], -1.0, If[LessEqual[y, 3.4e-178], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 2200000000000.0], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+17}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2 \cdot 10^{-285}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-178}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 2200000000000:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.8e17 or 2.2e12 < 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 77.9%
if -2.8e17 < y < -2.00000000000000015e-285 or 3.39999999999999973e-178 < y < 2.2e12Initial 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 52.7%
if -2.00000000000000015e-285 < y < 3.39999999999999973e-178Initial 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 68.6%
Taylor expanded in y around 0 51.1%
*-commutative51.1%
Simplified51.1%
(FPCore (x y) :precision binary64 (if (or (<= x -4.2e+14) (not (<= x 140000000.0))) (+ -1.0 (/ (+ -2.0 (* y 2.0)) x)) (/ (- y x) (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -4.2e+14) || !(x <= 140000000.0)) {
tmp = -1.0 + ((-2.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 <= (-4.2d+14)) .or. (.not. (x <= 140000000.0d0))) then
tmp = (-1.0d0) + (((-2.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 <= -4.2e+14) || !(x <= 140000000.0)) {
tmp = -1.0 + ((-2.0 + (y * 2.0)) / x);
} else {
tmp = (y - x) / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -4.2e+14) or not (x <= 140000000.0): tmp = -1.0 + ((-2.0 + (y * 2.0)) / x) else: tmp = (y - x) / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -4.2e+14) || !(x <= 140000000.0)) tmp = Float64(-1.0 + Float64(Float64(-2.0 + 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 <= -4.2e+14) || ~((x <= 140000000.0))) tmp = -1.0 + ((-2.0 + (y * 2.0)) / x); else tmp = (y - x) / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -4.2e+14], N[Not[LessEqual[x, 140000000.0]], $MachinePrecision]], N[(-1.0 + N[(N[(-2.0 + N[(y * 2.0), $MachinePrecision]), $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 -4.2 \cdot 10^{+14} \lor \neg \left(x \leq 140000000\right):\\
\;\;\;\;-1 + \frac{-2 + y \cdot 2}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y - 2}\\
\end{array}
\end{array}
if x < -4.2e14 or 1.4e8 < 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 75.4%
Simplified75.4%
if -4.2e14 < x < 1.4e8Initial 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 simplification87.7%
(FPCore (x y) :precision binary64 (if (or (<= x -4.2e+14) (not (<= x 3.8e+27))) (/ (- y x) x) (/ (- y x) (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -4.2e+14) || !(x <= 3.8e+27)) {
tmp = (y - x) / 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 <= (-4.2d+14)) .or. (.not. (x <= 3.8d+27))) then
tmp = (y - x) / 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 <= -4.2e+14) || !(x <= 3.8e+27)) {
tmp = (y - x) / x;
} else {
tmp = (y - x) / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -4.2e+14) or not (x <= 3.8e+27): tmp = (y - x) / x else: tmp = (y - x) / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -4.2e+14) || !(x <= 3.8e+27)) tmp = Float64(Float64(y - x) / 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 <= -4.2e+14) || ~((x <= 3.8e+27))) tmp = (y - x) / x; else tmp = (y - x) / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -4.2e+14], N[Not[LessEqual[x, 3.8e+27]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{+14} \lor \neg \left(x \leq 3.8 \cdot 10^{+27}\right):\\
\;\;\;\;\frac{y - x}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y - 2}\\
\end{array}
\end{array}
if x < -4.2e14 or 3.80000000000000022e27 < 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 75.5%
if -4.2e14 < x < 3.80000000000000022e27Initial 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 96.9%
Final simplification87.3%
(FPCore (x y) :precision binary64 (if (or (<= x -4.5e+14) (not (<= x 4e+27))) (/ (- y x) x) (/ y (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -4.5e+14) || !(x <= 4e+27)) {
tmp = (y - x) / 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 <= (-4.5d+14)) .or. (.not. (x <= 4d+27))) then
tmp = (y - x) / 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 <= -4.5e+14) || !(x <= 4e+27)) {
tmp = (y - x) / x;
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -4.5e+14) or not (x <= 4e+27): tmp = (y - x) / x else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -4.5e+14) || !(x <= 4e+27)) tmp = Float64(Float64(y - x) / x); else tmp = Float64(y / Float64(y - 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -4.5e+14) || ~((x <= 4e+27))) tmp = (y - x) / x; else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -4.5e+14], N[Not[LessEqual[x, 4e+27]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.5 \cdot 10^{+14} \lor \neg \left(x \leq 4 \cdot 10^{+27}\right):\\
\;\;\;\;\frac{y - x}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if x < -4.5e14 or 4.0000000000000001e27 < 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 75.5%
if -4.5e14 < x < 4.0000000000000001e27Initial 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 75.7%
Final simplification75.6%
(FPCore (x y) :precision binary64 (if (or (<= y -7.2e+18) (not (<= y 1100000000000.0))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -7.2e+18) || !(y <= 1100000000000.0)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-7.2d+18)) .or. (.not. (y <= 1100000000000.0d0))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -7.2e+18) || !(y <= 1100000000000.0)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -7.2e+18) or not (y <= 1100000000000.0): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -7.2e+18) || !(y <= 1100000000000.0)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -7.2e+18) || ~((y <= 1100000000000.0))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -7.2e+18], N[Not[LessEqual[y, 1100000000000.0]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+18} \lor \neg \left(y \leq 1100000000000\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -7.2e18 or 1.1e12 < 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 78.5%
Taylor expanded in y around 0 78.5%
neg-mul-178.5%
sub-neg78.5%
div-sub78.5%
*-inverses78.5%
Simplified78.5%
if -7.2e18 < y < 1.1e12Initial 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 68.0%
mul-1-neg68.0%
distribute-neg-frac268.0%
neg-sub068.0%
associate-+l-68.0%
neg-sub068.0%
+-commutative68.0%
unsub-neg68.0%
Simplified68.0%
Final simplification72.8%
(FPCore (x y) :precision binary64 (if (<= x -2.5e+14) -1.0 (if (<= x 4.1e+27) (/ y (- y 2.0)) -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -2.5e+14) {
tmp = -1.0;
} else if (x <= 4.1e+27) {
tmp = y / (y - 2.0);
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-2.5d+14)) then
tmp = -1.0d0
else if (x <= 4.1d+27) then
tmp = y / (y - 2.0d0)
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.5e+14) {
tmp = -1.0;
} else if (x <= 4.1e+27) {
tmp = y / (y - 2.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.5e+14: tmp = -1.0 elif x <= 4.1e+27: tmp = y / (y - 2.0) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.5e+14) tmp = -1.0; elseif (x <= 4.1e+27) tmp = Float64(y / Float64(y - 2.0)); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.5e+14) tmp = -1.0; elseif (x <= 4.1e+27) tmp = y / (y - 2.0); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.5e+14], -1.0, If[LessEqual[x, 4.1e+27], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{+14}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{+27}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.5e14 or 4.1000000000000002e27 < 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 74.6%
if -2.5e14 < x < 4.1000000000000002e27Initial 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 75.7%
(FPCore (x y) :precision binary64 (if (<= y -1.32e+17) 1.0 (if (<= y 1150000000000.0) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.32e+17) {
tmp = 1.0;
} else if (y <= 1150000000000.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 (y <= (-1.32d+17)) then
tmp = 1.0d0
else if (y <= 1150000000000.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 (y <= -1.32e+17) {
tmp = 1.0;
} else if (y <= 1150000000000.0) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.32e+17: tmp = 1.0 elif y <= 1150000000000.0: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.32e+17) tmp = 1.0; elseif (y <= 1150000000000.0) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.32e+17) tmp = 1.0; elseif (y <= 1150000000000.0) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.32e+17], 1.0, If[LessEqual[y, 1150000000000.0], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.32 \cdot 10^{+17}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1150000000000:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.32e17 or 1.15e12 < 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 77.9%
if -1.32e17 < y < 1.15e12Initial 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 47.5%
(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 35.6%
(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 2024098
(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))))