
(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 (/ (- y x) (+ y (+ x -2.0))))
double code(double x, double y) {
return (y - x) / (y + (x + -2.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y - x) / (y + (x + (-2.0d0)))
end function
public static double code(double x, double y) {
return (y - x) / (y + (x + -2.0));
}
def code(x, y): return (y - x) / (y + (x + -2.0))
function code(x, y) return Float64(Float64(y - x) / Float64(y + Float64(x + -2.0))) end
function tmp = code(x, y) tmp = (y - x) / (y + (x + -2.0)); end
code[x_, y_] := N[(N[(y - x), $MachinePrecision] / N[(y + N[(x + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y - x}{y + \left(x + -2\right)}
\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 0 100.0%
associate--l+100.0%
sub-neg100.0%
metadata-eval100.0%
+-commutative100.0%
associate-+r+100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ -1.0 (* 2.0 (/ y x)))))
(if (<= x -1.14e+33)
t_0
(if (<= x 3e-56)
(/ y (- y 2.0))
(if (<= x 4.9e+101) (/ x (- 2.0 x)) (if (<= x 5.3e+104) 1.0 t_0))))))
double code(double x, double y) {
double t_0 = -1.0 + (2.0 * (y / x));
double tmp;
if (x <= -1.14e+33) {
tmp = t_0;
} else if (x <= 3e-56) {
tmp = y / (y - 2.0);
} else if (x <= 4.9e+101) {
tmp = x / (2.0 - x);
} else if (x <= 5.3e+104) {
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) + (2.0d0 * (y / x))
if (x <= (-1.14d+33)) then
tmp = t_0
else if (x <= 3d-56) then
tmp = y / (y - 2.0d0)
else if (x <= 4.9d+101) then
tmp = x / (2.0d0 - x)
else if (x <= 5.3d+104) 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 + (2.0 * (y / x));
double tmp;
if (x <= -1.14e+33) {
tmp = t_0;
} else if (x <= 3e-56) {
tmp = y / (y - 2.0);
} else if (x <= 4.9e+101) {
tmp = x / (2.0 - x);
} else if (x <= 5.3e+104) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = -1.0 + (2.0 * (y / x)) tmp = 0 if x <= -1.14e+33: tmp = t_0 elif x <= 3e-56: tmp = y / (y - 2.0) elif x <= 4.9e+101: tmp = x / (2.0 - x) elif x <= 5.3e+104: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(-1.0 + Float64(2.0 * Float64(y / x))) tmp = 0.0 if (x <= -1.14e+33) tmp = t_0; elseif (x <= 3e-56) tmp = Float64(y / Float64(y - 2.0)); elseif (x <= 4.9e+101) tmp = Float64(x / Float64(2.0 - x)); elseif (x <= 5.3e+104) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = -1.0 + (2.0 * (y / x)); tmp = 0.0; if (x <= -1.14e+33) tmp = t_0; elseif (x <= 3e-56) tmp = y / (y - 2.0); elseif (x <= 4.9e+101) tmp = x / (2.0 - x); elseif (x <= 5.3e+104) tmp = 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(-1.0 + N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.14e+33], t$95$0, If[LessEqual[x, 3e-56], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.9e+101], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.3e+104], 1.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + 2 \cdot \frac{y}{x}\\
\mathbf{if}\;x \leq -1.14 \cdot 10^{+33}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-56}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{elif}\;x \leq 4.9 \cdot 10^{+101}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;x \leq 5.3 \cdot 10^{+104}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.14e33 or 5.2999999999999999e104 < 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 87.0%
Simplified87.0%
Taylor expanded in y around inf 87.0%
if -1.14e33 < x < 2.99999999999999989e-56Initial program 100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-neg-frac2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
metadata-eval100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 78.8%
if 2.99999999999999989e-56 < x < 4.89999999999999983e101Initial 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 63.4%
mul-1-neg63.4%
distribute-neg-frac263.4%
neg-sub063.4%
associate-+l-63.4%
neg-sub063.4%
+-commutative63.4%
unsub-neg63.4%
Simplified63.4%
if 4.89999999999999983e101 < x < 5.2999999999999999e104Initial 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 100.0%
Final simplification80.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- 2.0 x))))
(if (<= x -1e-20)
t_0
(if (<= x 3.8e-57)
(/ y (- y 2.0))
(if (<= x 2.5e+101) t_0 (if (<= x 9e+104) 1.0 (/ (- y x) x)))))))
double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (x <= -1e-20) {
tmp = t_0;
} else if (x <= 3.8e-57) {
tmp = y / (y - 2.0);
} else if (x <= 2.5e+101) {
tmp = t_0;
} else if (x <= 9e+104) {
tmp = 1.0;
} else {
tmp = (y - x) / 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 = x / (2.0d0 - x)
if (x <= (-1d-20)) then
tmp = t_0
else if (x <= 3.8d-57) then
tmp = y / (y - 2.0d0)
else if (x <= 2.5d+101) then
tmp = t_0
else if (x <= 9d+104) then
tmp = 1.0d0
else
tmp = (y - x) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / (2.0 - x);
double tmp;
if (x <= -1e-20) {
tmp = t_0;
} else if (x <= 3.8e-57) {
tmp = y / (y - 2.0);
} else if (x <= 2.5e+101) {
tmp = t_0;
} else if (x <= 9e+104) {
tmp = 1.0;
} else {
tmp = (y - x) / x;
}
return tmp;
}
def code(x, y): t_0 = x / (2.0 - x) tmp = 0 if x <= -1e-20: tmp = t_0 elif x <= 3.8e-57: tmp = y / (y - 2.0) elif x <= 2.5e+101: tmp = t_0 elif x <= 9e+104: tmp = 1.0 else: tmp = (y - x) / x return tmp
function code(x, y) t_0 = Float64(x / Float64(2.0 - x)) tmp = 0.0 if (x <= -1e-20) tmp = t_0; elseif (x <= 3.8e-57) tmp = Float64(y / Float64(y - 2.0)); elseif (x <= 2.5e+101) tmp = t_0; elseif (x <= 9e+104) tmp = 1.0; else tmp = Float64(Float64(y - x) / x); end return tmp end
function tmp_2 = code(x, y) t_0 = x / (2.0 - x); tmp = 0.0; if (x <= -1e-20) tmp = t_0; elseif (x <= 3.8e-57) tmp = y / (y - 2.0); elseif (x <= 2.5e+101) tmp = t_0; elseif (x <= 9e+104) tmp = 1.0; else tmp = (y - x) / x; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1e-20], t$95$0, If[LessEqual[x, 3.8e-57], N[(y / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.5e+101], t$95$0, If[LessEqual[x, 9e+104], 1.0, N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2 - x}\\
\mathbf{if}\;x \leq -1 \cdot 10^{-20}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-57}:\\
\;\;\;\;\frac{y}{y - 2}\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+101}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+104}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{x}\\
\end{array}
\end{array}
if x < -9.99999999999999945e-21 or 3.7999999999999997e-57 < x < 2.49999999999999994e101Initial 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 73.9%
mul-1-neg73.9%
distribute-neg-frac273.9%
neg-sub073.9%
associate-+l-73.9%
neg-sub073.9%
+-commutative73.9%
unsub-neg73.9%
Simplified73.9%
if -9.99999999999999945e-21 < x < 3.7999999999999997e-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 81.1%
if 2.49999999999999994e101 < x < 8.9999999999999997e104Initial 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 100.0%
if 8.9999999999999997e104 < 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 91.8%
Final simplification80.3%
(FPCore (x y)
:precision binary64
(if (<= x -1.35e+33)
-1.0
(if (<= x -1.7e-124)
1.0
(if (<= x 3.1e-305) (* y -0.5) (if (<= x 1.65e+17) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1.35e+33) {
tmp = -1.0;
} else if (x <= -1.7e-124) {
tmp = 1.0;
} else if (x <= 3.1e-305) {
tmp = y * -0.5;
} else if (x <= 1.65e+17) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.35d+33)) then
tmp = -1.0d0
else if (x <= (-1.7d-124)) then
tmp = 1.0d0
else if (x <= 3.1d-305) then
tmp = y * (-0.5d0)
else if (x <= 1.65d+17) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.35e+33) {
tmp = -1.0;
} else if (x <= -1.7e-124) {
tmp = 1.0;
} else if (x <= 3.1e-305) {
tmp = y * -0.5;
} else if (x <= 1.65e+17) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.35e+33: tmp = -1.0 elif x <= -1.7e-124: tmp = 1.0 elif x <= 3.1e-305: tmp = y * -0.5 elif x <= 1.65e+17: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.35e+33) tmp = -1.0; elseif (x <= -1.7e-124) tmp = 1.0; elseif (x <= 3.1e-305) tmp = Float64(y * -0.5); elseif (x <= 1.65e+17) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.35e+33) tmp = -1.0; elseif (x <= -1.7e-124) tmp = 1.0; elseif (x <= 3.1e-305) tmp = y * -0.5; elseif (x <= 1.65e+17) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.35e+33], -1.0, If[LessEqual[x, -1.7e-124], 1.0, If[LessEqual[x, 3.1e-305], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 1.65e+17], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+33}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.7 \cdot 10^{-124}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-305}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+17}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.34999999999999996e33 or 1.65e17 < 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 81.1%
if -1.34999999999999996e33 < x < -1.7e-124 or 3.0999999999999998e-305 < x < 1.65e17Initial 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 58.2%
if -1.7e-124 < x < 3.0999999999999998e-305Initial 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.6%
Taylor expanded in y around 0 47.4%
*-commutative47.4%
Simplified47.4%
Final simplification68.7%
(FPCore (x y)
:precision binary64
(if (<= y -4e+75)
1.0
(if (<= y 5e-44)
(/ x (- 2.0 x))
(if (<= y 9.5e-12) (* y -0.5) (if (<= y 1.45e+59) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -4e+75) {
tmp = 1.0;
} else if (y <= 5e-44) {
tmp = x / (2.0 - x);
} else if (y <= 9.5e-12) {
tmp = y * -0.5;
} else if (y <= 1.45e+59) {
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 <= (-4d+75)) then
tmp = 1.0d0
else if (y <= 5d-44) then
tmp = x / (2.0d0 - x)
else if (y <= 9.5d-12) then
tmp = y * (-0.5d0)
else if (y <= 1.45d+59) 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 <= -4e+75) {
tmp = 1.0;
} else if (y <= 5e-44) {
tmp = x / (2.0 - x);
} else if (y <= 9.5e-12) {
tmp = y * -0.5;
} else if (y <= 1.45e+59) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4e+75: tmp = 1.0 elif y <= 5e-44: tmp = x / (2.0 - x) elif y <= 9.5e-12: tmp = y * -0.5 elif y <= 1.45e+59: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -4e+75) tmp = 1.0; elseif (y <= 5e-44) tmp = Float64(x / Float64(2.0 - x)); elseif (y <= 9.5e-12) tmp = Float64(y * -0.5); elseif (y <= 1.45e+59) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -4e+75) tmp = 1.0; elseif (y <= 5e-44) tmp = x / (2.0 - x); elseif (y <= 9.5e-12) tmp = y * -0.5; elseif (y <= 1.45e+59) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -4e+75], 1.0, If[LessEqual[y, 5e-44], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.5e-12], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.45e+59], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+75}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-44}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{-12}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+59}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.99999999999999971e75 or 1.44999999999999995e59 < 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 81.8%
if -3.99999999999999971e75 < y < 5.00000000000000039e-44Initial 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.8%
mul-1-neg79.8%
distribute-neg-frac279.8%
neg-sub079.8%
associate-+l-79.8%
neg-sub079.8%
+-commutative79.8%
unsub-neg79.8%
Simplified79.8%
if 5.00000000000000039e-44 < y < 9.4999999999999995e-12Initial 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.9%
Taylor expanded in y around 0 83.8%
*-commutative83.8%
Simplified83.8%
if 9.4999999999999995e-12 < y < 1.44999999999999995e59Initial 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 57.7%
Final simplification78.9%
(FPCore (x y) :precision binary64 (if (<= y -3.8e+76) 1.0 (if (<= y 1.5e+47) (/ (- y x) (- x 2.0)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -3.8e+76) {
tmp = 1.0;
} else if (y <= 1.5e+47) {
tmp = (y - x) / (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 (y <= (-3.8d+76)) then
tmp = 1.0d0
else if (y <= 1.5d+47) then
tmp = (y - x) / (x - 2.0d0)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -3.8e+76) {
tmp = 1.0;
} else if (y <= 1.5e+47) {
tmp = (y - x) / (x - 2.0);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.8e+76: tmp = 1.0 elif y <= 1.5e+47: tmp = (y - x) / (x - 2.0) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -3.8e+76) tmp = 1.0; elseif (y <= 1.5e+47) tmp = Float64(Float64(y - x) / Float64(x - 2.0)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -3.8e+76) tmp = 1.0; elseif (y <= 1.5e+47) tmp = (y - x) / (x - 2.0); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.8e+76], 1.0, If[LessEqual[y, 1.5e+47], N[(N[(y - x), $MachinePrecision] / N[(x - 2.0), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{+76}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+47}:\\
\;\;\;\;\frac{y - x}{x - 2}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.80000000000000024e76 or 1.5000000000000001e47 < 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 81.2%
if -3.80000000000000024e76 < y < 1.5000000000000001e47Initial 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 91.3%
Final simplification87.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.45e-18) (not (<= x 4.2e-60))) (/ x (- 2.0 x)) (/ y (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.45e-18) || !(x <= 4.2e-60)) {
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.45d-18)) .or. (.not. (x <= 4.2d-60))) 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.45e-18) || !(x <= 4.2e-60)) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.45e-18) or not (x <= 4.2e-60): tmp = x / (2.0 - x) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.45e-18) || !(x <= 4.2e-60)) 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.45e-18) || ~((x <= 4.2e-60))) tmp = x / (2.0 - x); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.45e-18], N[Not[LessEqual[x, 4.2e-60]], $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.45 \cdot 10^{-18} \lor \neg \left(x \leq 4.2 \cdot 10^{-60}\right):\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if x < -1.45e-18 or 4.19999999999999982e-60 < 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 77.0%
mul-1-neg77.0%
distribute-neg-frac277.0%
neg-sub077.0%
associate-+l-77.0%
neg-sub077.0%
+-commutative77.0%
unsub-neg77.0%
Simplified77.0%
if -1.45e-18 < x < 4.19999999999999982e-60Initial 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.1%
Final simplification78.6%
(FPCore (x y) :precision binary64 (if (<= x -1.14e+33) -1.0 (if (<= x 1.85e+15) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.14e+33) {
tmp = -1.0;
} else if (x <= 1.85e+15) {
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.14d+33)) then
tmp = -1.0d0
else if (x <= 1.85d+15) 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.14e+33) {
tmp = -1.0;
} else if (x <= 1.85e+15) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.14e+33: tmp = -1.0 elif x <= 1.85e+15: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.14e+33) tmp = -1.0; elseif (x <= 1.85e+15) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.14e+33) tmp = -1.0; elseif (x <= 1.85e+15) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.14e+33], -1.0, If[LessEqual[x, 1.85e+15], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.14 \cdot 10^{+33}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{+15}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.14e33 or 1.85e15 < 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 81.1%
if -1.14e33 < x < 1.85e15Initial 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 52.4%
Final simplification67.1%
(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 100.0%
Final simplification100.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 43.6%
Final simplification43.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 2024078
(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))))