
(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 11 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 (<= x -950.0) (- -1.0 (/ 2.0 x)) (if (<= x 5.4e-103) 1.0 (if (<= x 3.9) (/ x 2.0) (+ -1.0 (/ y x))))))
double code(double x, double y) {
double tmp;
if (x <= -950.0) {
tmp = -1.0 - (2.0 / x);
} else if (x <= 5.4e-103) {
tmp = 1.0;
} else if (x <= 3.9) {
tmp = x / 2.0;
} else {
tmp = -1.0 + (y / x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-950.0d0)) then
tmp = (-1.0d0) - (2.0d0 / x)
else if (x <= 5.4d-103) then
tmp = 1.0d0
else if (x <= 3.9d0) then
tmp = x / 2.0d0
else
tmp = (-1.0d0) + (y / x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -950.0) {
tmp = -1.0 - (2.0 / x);
} else if (x <= 5.4e-103) {
tmp = 1.0;
} else if (x <= 3.9) {
tmp = x / 2.0;
} else {
tmp = -1.0 + (y / x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -950.0: tmp = -1.0 - (2.0 / x) elif x <= 5.4e-103: tmp = 1.0 elif x <= 3.9: tmp = x / 2.0 else: tmp = -1.0 + (y / x) return tmp
function code(x, y) tmp = 0.0 if (x <= -950.0) tmp = Float64(-1.0 - Float64(2.0 / x)); elseif (x <= 5.4e-103) tmp = 1.0; elseif (x <= 3.9) tmp = Float64(x / 2.0); else tmp = Float64(-1.0 + Float64(y / x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -950.0) tmp = -1.0 - (2.0 / x); elseif (x <= 5.4e-103) tmp = 1.0; elseif (x <= 3.9) tmp = x / 2.0; else tmp = -1.0 + (y / x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -950.0], N[(-1.0 - N[(2.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.4e-103], 1.0, If[LessEqual[x, 3.9], N[(x / 2.0), $MachinePrecision], N[(-1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -950:\\
\;\;\;\;-1 - \frac{2}{x}\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{-103}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.9:\\
\;\;\;\;\frac{x}{2}\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{y}{x}\\
\end{array}
\end{array}
if x < -950Initial 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 78.8%
sub-neg78.8%
metadata-eval78.8%
+-commutative78.8%
mul-1-neg78.8%
unsub-neg78.8%
mul-1-neg78.8%
unsub-neg78.8%
Simplified78.8%
Taylor expanded in y around 0 77.2%
if -950 < x < 5.40000000000000019e-103Initial 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 47.8%
if 5.40000000000000019e-103 < x < 3.89999999999999991Initial 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 51.8%
mul-1-neg51.8%
distribute-neg-frac251.8%
neg-sub051.8%
associate-+l-51.8%
neg-sub051.8%
+-commutative51.8%
unsub-neg51.8%
Simplified51.8%
Taylor expanded in x around 0 50.3%
if 3.89999999999999991 < 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 78.5%
sub-neg78.5%
metadata-eval78.5%
+-commutative78.5%
mul-1-neg78.5%
unsub-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Taylor expanded in y around 0 77.3%
Taylor expanded in y around inf 77.1%
neg-mul-177.1%
Simplified77.1%
Taylor expanded in y around 0 77.1%
Final simplification62.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- -1.0 (/ 2.0 x))))
(if (<= x -950.0)
t_0
(if (<= x 3.9e-104) 1.0 (if (<= x 2.6) (/ x 2.0) t_0)))))
double code(double x, double y) {
double t_0 = -1.0 - (2.0 / x);
double tmp;
if (x <= -950.0) {
tmp = t_0;
} else if (x <= 3.9e-104) {
tmp = 1.0;
} else if (x <= 2.6) {
tmp = x / 2.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) - (2.0d0 / x)
if (x <= (-950.0d0)) then
tmp = t_0
else if (x <= 3.9d-104) then
tmp = 1.0d0
else if (x <= 2.6d0) then
tmp = x / 2.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = -1.0 - (2.0 / x);
double tmp;
if (x <= -950.0) {
tmp = t_0;
} else if (x <= 3.9e-104) {
tmp = 1.0;
} else if (x <= 2.6) {
tmp = x / 2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = -1.0 - (2.0 / x) tmp = 0 if x <= -950.0: tmp = t_0 elif x <= 3.9e-104: tmp = 1.0 elif x <= 2.6: tmp = x / 2.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(-1.0 - Float64(2.0 / x)) tmp = 0.0 if (x <= -950.0) tmp = t_0; elseif (x <= 3.9e-104) tmp = 1.0; elseif (x <= 2.6) tmp = Float64(x / 2.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = -1.0 - (2.0 / x); tmp = 0.0; if (x <= -950.0) tmp = t_0; elseif (x <= 3.9e-104) tmp = 1.0; elseif (x <= 2.6) tmp = x / 2.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(-1.0 - N[(2.0 / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -950.0], t$95$0, If[LessEqual[x, 3.9e-104], 1.0, If[LessEqual[x, 2.6], N[(x / 2.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 - \frac{2}{x}\\
\mathbf{if}\;x \leq -950:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{-104}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.6:\\
\;\;\;\;\frac{x}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -950 or 2.60000000000000009 < 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 78.6%
sub-neg78.6%
metadata-eval78.6%
+-commutative78.6%
mul-1-neg78.6%
unsub-neg78.6%
mul-1-neg78.6%
unsub-neg78.6%
Simplified78.6%
Taylor expanded in y around 0 77.0%
if -950 < x < 3.9000000000000002e-104Initial 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 47.8%
if 3.9000000000000002e-104 < x < 2.60000000000000009Initial 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 51.8%
mul-1-neg51.8%
distribute-neg-frac251.8%
neg-sub051.8%
associate-+l-51.8%
neg-sub051.8%
+-commutative51.8%
unsub-neg51.8%
Simplified51.8%
Taylor expanded in x around 0 50.3%
(FPCore (x y) :precision binary64 (if (or (<= y -8e+51) (not (<= y 13600000.0))) (+ 1.0 (/ (- (- 2.0 x) x) y)) (/ (- y x) (- x 2.0))))
double code(double x, double y) {
double tmp;
if ((y <= -8e+51) || !(y <= 13600000.0)) {
tmp = 1.0 + (((2.0 - x) - x) / y);
} else {
tmp = (y - x) / (x - 2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-8d+51)) .or. (.not. (y <= 13600000.0d0))) then
tmp = 1.0d0 + (((2.0d0 - x) - x) / y)
else
tmp = (y - x) / (x - 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -8e+51) || !(y <= 13600000.0)) {
tmp = 1.0 + (((2.0 - x) - x) / y);
} else {
tmp = (y - x) / (x - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -8e+51) or not (y <= 13600000.0): tmp = 1.0 + (((2.0 - x) - x) / y) else: tmp = (y - x) / (x - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((y <= -8e+51) || !(y <= 13600000.0)) tmp = Float64(1.0 + Float64(Float64(Float64(2.0 - x) - x) / y)); else tmp = Float64(Float64(y - x) / Float64(x - 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -8e+51) || ~((y <= 13600000.0))) tmp = 1.0 + (((2.0 - x) - x) / y); else tmp = (y - x) / (x - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -8e+51], N[Not[LessEqual[y, 13600000.0]], $MachinePrecision]], N[(1.0 + N[(N[(N[(2.0 - x), $MachinePrecision] - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / N[(x - 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{+51} \lor \neg \left(y \leq 13600000\right):\\
\;\;\;\;1 + \frac{\left(2 - x\right) - x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{x - 2}\\
\end{array}
\end{array}
if y < -8e51 or 1.36e7 < 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 72.9%
associate--l+72.9%
+-commutative72.9%
mul-1-neg72.9%
unsub-neg72.9%
associate-*r/72.9%
metadata-eval72.9%
div-sub72.9%
unsub-neg72.9%
+-commutative72.9%
neg-sub072.9%
associate-+l-72.9%
neg-sub072.9%
mul-1-neg72.9%
+-rgt-identity72.9%
div-sub72.9%
+-rgt-identity72.9%
mul-1-neg72.9%
neg-sub072.9%
associate-+l-72.9%
neg-sub072.9%
+-commutative72.9%
unsub-neg72.9%
Simplified72.9%
if -8e51 < y < 1.36e7Initial 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 97.3%
Final simplification86.7%
(FPCore (x y) :precision binary64 (if (<= y -8e+51) 1.0 (if (<= y 1.9e-65) (/ x (- 2.0 x)) (if (<= y 800000.0) (* y -0.5) 1.0))))
double code(double x, double y) {
double tmp;
if (y <= -8e+51) {
tmp = 1.0;
} else if (y <= 1.9e-65) {
tmp = x / (2.0 - x);
} else if (y <= 800000.0) {
tmp = y * -0.5;
} 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 <= (-8d+51)) then
tmp = 1.0d0
else if (y <= 1.9d-65) then
tmp = x / (2.0d0 - x)
else if (y <= 800000.0d0) then
tmp = y * (-0.5d0)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -8e+51) {
tmp = 1.0;
} else if (y <= 1.9e-65) {
tmp = x / (2.0 - x);
} else if (y <= 800000.0) {
tmp = y * -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8e+51: tmp = 1.0 elif y <= 1.9e-65: tmp = x / (2.0 - x) elif y <= 800000.0: tmp = y * -0.5 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -8e+51) tmp = 1.0; elseif (y <= 1.9e-65) tmp = Float64(x / Float64(2.0 - x)); elseif (y <= 800000.0) tmp = Float64(y * -0.5); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -8e+51) tmp = 1.0; elseif (y <= 1.9e-65) tmp = x / (2.0 - x); elseif (y <= 800000.0) tmp = y * -0.5; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -8e+51], 1.0, If[LessEqual[y, 1.9e-65], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 800000.0], N[(y * -0.5), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{+51}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-65}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;y \leq 800000:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -8e51 or 8e5 < 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 71.2%
if -8e51 < y < 1.9000000000000001e-65Initial 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 79.3%
mul-1-neg79.3%
distribute-neg-frac279.3%
neg-sub079.3%
associate-+l-79.3%
neg-sub079.3%
+-commutative79.3%
unsub-neg79.3%
Simplified79.3%
if 1.9000000000000001e-65 < y < 8e5Initial 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 63.7%
Taylor expanded in y around 0 62.9%
*-commutative62.9%
Simplified62.9%
(FPCore (x y) :precision binary64 (if (<= x -2.8e+33) -1.0 (if (<= x 1.04e-103) 1.0 (if (<= x 3.4) (/ x 2.0) -1.0))))
double code(double x, double y) {
double tmp;
if (x <= -2.8e+33) {
tmp = -1.0;
} else if (x <= 1.04e-103) {
tmp = 1.0;
} else if (x <= 3.4) {
tmp = x / 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.8d+33)) then
tmp = -1.0d0
else if (x <= 1.04d-103) then
tmp = 1.0d0
else if (x <= 3.4d0) then
tmp = x / 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.8e+33) {
tmp = -1.0;
} else if (x <= 1.04e-103) {
tmp = 1.0;
} else if (x <= 3.4) {
tmp = x / 2.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.8e+33: tmp = -1.0 elif x <= 1.04e-103: tmp = 1.0 elif x <= 3.4: tmp = x / 2.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.8e+33) tmp = -1.0; elseif (x <= 1.04e-103) tmp = 1.0; elseif (x <= 3.4) tmp = Float64(x / 2.0); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.8e+33) tmp = -1.0; elseif (x <= 1.04e-103) tmp = 1.0; elseif (x <= 3.4) tmp = x / 2.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.8e+33], -1.0, If[LessEqual[x, 1.04e-103], 1.0, If[LessEqual[x, 3.4], N[(x / 2.0), $MachinePrecision], -1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{+33}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.04 \cdot 10^{-103}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.4:\\
\;\;\;\;\frac{x}{2}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -2.8000000000000001e33 or 3.39999999999999991 < 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 78.1%
if -2.8000000000000001e33 < x < 1.04000000000000001e-103Initial 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 47.5%
if 1.04000000000000001e-103 < x < 3.39999999999999991Initial 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 51.8%
mul-1-neg51.8%
distribute-neg-frac251.8%
neg-sub051.8%
associate-+l-51.8%
neg-sub051.8%
+-commutative51.8%
unsub-neg51.8%
Simplified51.8%
Taylor expanded in x around 0 50.3%
(FPCore (x y) :precision binary64 (if (or (<= y -4.2e+51) (not (<= y 13600000.0))) (/ y (+ x (+ y -2.0))) (/ (- y x) (- x 2.0))))
double code(double x, double y) {
double tmp;
if ((y <= -4.2e+51) || !(y <= 13600000.0)) {
tmp = y / (x + (y + -2.0));
} else {
tmp = (y - x) / (x - 2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-4.2d+51)) .or. (.not. (y <= 13600000.0d0))) then
tmp = y / (x + (y + (-2.0d0)))
else
tmp = (y - x) / (x - 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -4.2e+51) || !(y <= 13600000.0)) {
tmp = y / (x + (y + -2.0));
} else {
tmp = (y - x) / (x - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -4.2e+51) or not (y <= 13600000.0): tmp = y / (x + (y + -2.0)) else: tmp = (y - x) / (x - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((y <= -4.2e+51) || !(y <= 13600000.0)) tmp = Float64(y / Float64(x + Float64(y + -2.0))); else tmp = Float64(Float64(y - x) / Float64(x - 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -4.2e+51) || ~((y <= 13600000.0))) tmp = y / (x + (y + -2.0)); else tmp = (y - x) / (x - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -4.2e+51], N[Not[LessEqual[y, 13600000.0]], $MachinePrecision]], N[(y / N[(x + N[(y + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / N[(x - 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+51} \lor \neg \left(y \leq 13600000\right):\\
\;\;\;\;\frac{y}{x + \left(y + -2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{x - 2}\\
\end{array}
\end{array}
if y < -4.2000000000000002e51 or 1.36e7 < 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 72.5%
if -4.2000000000000002e51 < y < 1.36e7Initial 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 97.3%
Final simplification86.5%
(FPCore (x y) :precision binary64 (if (or (<= x -2.25e-17) (not (<= x 1.95e-84))) (/ x (- 2.0 x)) (/ y (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -2.25e-17) || !(x <= 1.95e-84)) {
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 <= (-2.25d-17)) .or. (.not. (x <= 1.95d-84))) 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 <= -2.25e-17) || !(x <= 1.95e-84)) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -2.25e-17) or not (x <= 1.95e-84): tmp = x / (2.0 - x) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -2.25e-17) || !(x <= 1.95e-84)) 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 <= -2.25e-17) || ~((x <= 1.95e-84))) tmp = x / (2.0 - x); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -2.25e-17], N[Not[LessEqual[x, 1.95e-84]], $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 -2.25 \cdot 10^{-17} \lor \neg \left(x \leq 1.95 \cdot 10^{-84}\right):\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if x < -2.24999999999999989e-17 or 1.95000000000000011e-84 < 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 75.2%
mul-1-neg75.2%
distribute-neg-frac275.2%
neg-sub075.2%
associate-+l-75.2%
neg-sub075.2%
+-commutative75.2%
unsub-neg75.2%
Simplified75.2%
if -2.24999999999999989e-17 < x < 1.95000000000000011e-84Initial 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 77.0%
Final simplification76.0%
(FPCore (x y) :precision binary64 (if (<= x -1e+34) -1.0 (if (<= x 650000.0) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1e+34) {
tmp = -1.0;
} else if (x <= 650000.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 <= (-1d+34)) then
tmp = -1.0d0
else if (x <= 650000.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 <= -1e+34) {
tmp = -1.0;
} else if (x <= 650000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e+34: tmp = -1.0 elif x <= 650000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1e+34) tmp = -1.0; elseif (x <= 650000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e+34) tmp = -1.0; elseif (x <= 650000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e+34], -1.0, If[LessEqual[x, 650000.0], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+34}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 650000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.99999999999999946e33 or 6.5e5 < 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 78.1%
if -9.99999999999999946e33 < x < 6.5e5Initial 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 44.9%
(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 38.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 2024165
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:alt
(! :herbie-platform default (- (/ x (- 2 (+ x y))) (/ y (- 2 (+ x y)))))
(/ (- x y) (- 2.0 (+ x y))))