
(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 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (or (<= x -1.95e+142) (not (<= x 3.6e+26))) (/ 1.0 (/ x (- y x))) (/ y (+ y -2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.95e+142) || !(x <= 3.6e+26)) {
tmp = 1.0 / (x / (y - 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.95d+142)) .or. (.not. (x <= 3.6d+26))) then
tmp = 1.0d0 / (x / (y - 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.95e+142) || !(x <= 3.6e+26)) {
tmp = 1.0 / (x / (y - x));
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.95e+142) or not (x <= 3.6e+26): tmp = 1.0 / (x / (y - x)) else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.95e+142) || !(x <= 3.6e+26)) tmp = Float64(1.0 / Float64(x / Float64(y - 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.95e+142) || ~((x <= 3.6e+26))) tmp = 1.0 / (x / (y - x)); else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.95e+142], N[Not[LessEqual[x, 3.6e+26]], $MachinePrecision]], N[(1.0 / N[(x / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.95 \cdot 10^{+142} \lor \neg \left(x \leq 3.6 \cdot 10^{+26}\right):\\
\;\;\;\;\frac{1}{\frac{x}{y - x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if x < -1.95e142 or 3.60000000000000024e26 < x Initial program 100.0%
clear-num100.0%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 89.6%
associate-*l/89.9%
clear-num89.9%
neg-mul-189.9%
sub-neg89.9%
distribute-neg-in89.9%
remove-double-neg89.9%
Applied egg-rr89.9%
if -1.95e142 < x < 3.60000000000000024e26Initial program 100.0%
Taylor expanded in x around 0 69.6%
mul-1-neg69.6%
distribute-neg-frac69.6%
Simplified69.6%
frac-2neg69.6%
div-inv69.5%
remove-double-neg69.5%
sub-neg69.5%
distribute-neg-in69.5%
metadata-eval69.5%
remove-double-neg69.5%
Applied egg-rr69.5%
associate-*r/69.6%
*-rgt-identity69.6%
+-commutative69.6%
Simplified69.6%
Final simplification78.0%
(FPCore (x y)
:precision binary64
(if (<= x -1.7e+142)
-1.0
(if (<= x 1.05e-225)
1.0
(if (<= x 1.1e-6) (* x 0.5) (if (<= x 1.65e+22) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1.7e+142) {
tmp = -1.0;
} else if (x <= 1.05e-225) {
tmp = 1.0;
} else if (x <= 1.1e-6) {
tmp = x * 0.5;
} else if (x <= 1.65e+22) {
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.7d+142)) then
tmp = -1.0d0
else if (x <= 1.05d-225) then
tmp = 1.0d0
else if (x <= 1.1d-6) then
tmp = x * 0.5d0
else if (x <= 1.65d+22) 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.7e+142) {
tmp = -1.0;
} else if (x <= 1.05e-225) {
tmp = 1.0;
} else if (x <= 1.1e-6) {
tmp = x * 0.5;
} else if (x <= 1.65e+22) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.7e+142: tmp = -1.0 elif x <= 1.05e-225: tmp = 1.0 elif x <= 1.1e-6: tmp = x * 0.5 elif x <= 1.65e+22: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.7e+142) tmp = -1.0; elseif (x <= 1.05e-225) tmp = 1.0; elseif (x <= 1.1e-6) tmp = Float64(x * 0.5); elseif (x <= 1.65e+22) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.7e+142) tmp = -1.0; elseif (x <= 1.05e-225) tmp = 1.0; elseif (x <= 1.1e-6) tmp = x * 0.5; elseif (x <= 1.65e+22) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.7e+142], -1.0, If[LessEqual[x, 1.05e-225], 1.0, If[LessEqual[x, 1.1e-6], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.65e+22], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+142}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-225}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-6}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+22}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.6999999999999999e142 or 1.6499999999999999e22 < x Initial program 100.0%
Taylor expanded in x around inf 89.8%
if -1.6999999999999999e142 < x < 1.05e-225 or 1.1000000000000001e-6 < x < 1.6499999999999999e22Initial program 100.0%
Taylor expanded in y around inf 56.1%
if 1.05e-225 < x < 1.1000000000000001e-6Initial program 100.0%
Taylor expanded in y around 0 51.0%
Taylor expanded in x around 0 49.8%
*-commutative49.8%
Simplified49.8%
Final simplification69.2%
(FPCore (x y)
:precision binary64
(if (<= x -1.7e+142)
-1.0
(if (<= x -1.8e-264)
1.0
(if (<= x 1.25e-176) (* y -0.5) (if (<= x 8.8e+17) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1.7e+142) {
tmp = -1.0;
} else if (x <= -1.8e-264) {
tmp = 1.0;
} else if (x <= 1.25e-176) {
tmp = y * -0.5;
} else if (x <= 8.8e+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.7d+142)) then
tmp = -1.0d0
else if (x <= (-1.8d-264)) then
tmp = 1.0d0
else if (x <= 1.25d-176) then
tmp = y * (-0.5d0)
else if (x <= 8.8d+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.7e+142) {
tmp = -1.0;
} else if (x <= -1.8e-264) {
tmp = 1.0;
} else if (x <= 1.25e-176) {
tmp = y * -0.5;
} else if (x <= 8.8e+17) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.7e+142: tmp = -1.0 elif x <= -1.8e-264: tmp = 1.0 elif x <= 1.25e-176: tmp = y * -0.5 elif x <= 8.8e+17: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.7e+142) tmp = -1.0; elseif (x <= -1.8e-264) tmp = 1.0; elseif (x <= 1.25e-176) tmp = Float64(y * -0.5); elseif (x <= 8.8e+17) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.7e+142) tmp = -1.0; elseif (x <= -1.8e-264) tmp = 1.0; elseif (x <= 1.25e-176) tmp = y * -0.5; elseif (x <= 8.8e+17) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.7e+142], -1.0, If[LessEqual[x, -1.8e-264], 1.0, If[LessEqual[x, 1.25e-176], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 8.8e+17], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+142}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-264}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-176}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{+17}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.6999999999999999e142 or 8.8e17 < x Initial program 100.0%
Taylor expanded in x around inf 89.8%
if -1.6999999999999999e142 < x < -1.8000000000000001e-264 or 1.25e-176 < x < 8.8e17Initial program 100.0%
Taylor expanded in y around inf 57.2%
if -1.8000000000000001e-264 < x < 1.25e-176Initial program 99.9%
Taylor expanded in x around 0 85.6%
mul-1-neg85.6%
distribute-neg-frac85.6%
Simplified85.6%
Taylor expanded in y around 0 56.5%
*-commutative56.5%
Simplified56.5%
Final simplification70.7%
(FPCore (x y)
:precision binary64
(if (<= x -1.55e+141)
-1.0
(if (<= x -1.8e-256)
(- 1.0 (/ x y))
(if (<= x 1.3e-176) (* y -0.5) (if (<= x 4e+35) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -1.55e+141) {
tmp = -1.0;
} else if (x <= -1.8e-256) {
tmp = 1.0 - (x / y);
} else if (x <= 1.3e-176) {
tmp = y * -0.5;
} else if (x <= 4e+35) {
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.55d+141)) then
tmp = -1.0d0
else if (x <= (-1.8d-256)) then
tmp = 1.0d0 - (x / y)
else if (x <= 1.3d-176) then
tmp = y * (-0.5d0)
else if (x <= 4d+35) 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.55e+141) {
tmp = -1.0;
} else if (x <= -1.8e-256) {
tmp = 1.0 - (x / y);
} else if (x <= 1.3e-176) {
tmp = y * -0.5;
} else if (x <= 4e+35) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.55e+141: tmp = -1.0 elif x <= -1.8e-256: tmp = 1.0 - (x / y) elif x <= 1.3e-176: tmp = y * -0.5 elif x <= 4e+35: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.55e+141) tmp = -1.0; elseif (x <= -1.8e-256) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= 1.3e-176) tmp = Float64(y * -0.5); elseif (x <= 4e+35) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.55e+141) tmp = -1.0; elseif (x <= -1.8e-256) tmp = 1.0 - (x / y); elseif (x <= 1.3e-176) tmp = y * -0.5; elseif (x <= 4e+35) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.55e+141], -1.0, If[LessEqual[x, -1.8e-256], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.3e-176], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 4e+35], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{+141}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-256}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{-176}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+35}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.55000000000000002e141 or 3.9999999999999999e35 < x Initial program 100.0%
Taylor expanded in x around inf 89.1%
if -1.55000000000000002e141 < x < -1.8000000000000001e-256Initial program 100.0%
clear-num99.9%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 61.3%
Taylor expanded in y around 0 61.4%
mul-1-neg61.4%
unsub-neg61.4%
Simplified61.4%
if -1.8000000000000001e-256 < x < 1.29999999999999996e-176Initial program 99.9%
Taylor expanded in x around 0 85.6%
mul-1-neg85.6%
distribute-neg-frac85.6%
Simplified85.6%
Taylor expanded in y around 0 56.5%
*-commutative56.5%
Simplified56.5%
if 1.29999999999999996e-176 < x < 3.9999999999999999e35Initial program 100.0%
Taylor expanded in y around inf 51.8%
Final simplification70.8%
(FPCore (x y) :precision binary64 (if (or (<= y -6.5e+14) (not (<= y 5.2e+82))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -6.5e+14) || !(y <= 5.2e+82)) {
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 <= (-6.5d+14)) .or. (.not. (y <= 5.2d+82))) 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 <= -6.5e+14) || !(y <= 5.2e+82)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -6.5e+14) or not (y <= 5.2e+82): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -6.5e+14) || !(y <= 5.2e+82)) 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 <= -6.5e+14) || ~((y <= 5.2e+82))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -6.5e+14], N[Not[LessEqual[y, 5.2e+82]], $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 -6.5 \cdot 10^{+14} \lor \neg \left(y \leq 5.2 \cdot 10^{+82}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -6.5e14 or 5.1999999999999997e82 < y Initial program 100.0%
clear-num100.0%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 75.3%
Taylor expanded in y around 0 75.4%
mul-1-neg75.4%
unsub-neg75.4%
Simplified75.4%
if -6.5e14 < y < 5.1999999999999997e82Initial program 100.0%
Taylor expanded in y around 0 78.2%
Final simplification77.1%
(FPCore (x y) :precision binary64 (if (or (<= x -1.7e+142) (not (<= x 1.8e+22))) (/ (- y x) x) (/ y (+ y -2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.7e+142) || !(x <= 1.8e+22)) {
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 <= (-1.7d+142)) .or. (.not. (x <= 1.8d+22))) 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 <= -1.7e+142) || !(x <= 1.8e+22)) {
tmp = (y - x) / x;
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.7e+142) or not (x <= 1.8e+22): tmp = (y - x) / x else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.7e+142) || !(x <= 1.8e+22)) 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 <= -1.7e+142) || ~((x <= 1.8e+22))) tmp = (y - x) / x; else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.7e+142], N[Not[LessEqual[x, 1.8e+22]], $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 -1.7 \cdot 10^{+142} \lor \neg \left(x \leq 1.8 \cdot 10^{+22}\right):\\
\;\;\;\;\frac{y - x}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if x < -1.6999999999999999e142 or 1.8e22 < x Initial program 100.0%
clear-num100.0%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 89.6%
associate-*l/89.9%
neg-mul-189.9%
sub-neg89.9%
distribute-neg-in89.9%
remove-double-neg89.9%
Applied egg-rr89.9%
+-commutative89.9%
unsub-neg89.9%
Simplified89.9%
if -1.6999999999999999e142 < x < 1.8e22Initial program 100.0%
Taylor expanded in x around 0 69.6%
mul-1-neg69.6%
distribute-neg-frac69.6%
Simplified69.6%
frac-2neg69.6%
div-inv69.5%
remove-double-neg69.5%
sub-neg69.5%
distribute-neg-in69.5%
metadata-eval69.5%
remove-double-neg69.5%
Applied egg-rr69.5%
associate-*r/69.6%
*-rgt-identity69.6%
+-commutative69.6%
Simplified69.6%
Final simplification78.0%
(FPCore (x y) :precision binary64 (if (<= x -1.7e+142) -1.0 (if (<= x 3.9e+19) (/ y (+ y -2.0)) -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.7e+142) {
tmp = -1.0;
} else if (x <= 3.9e+19) {
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 <= (-1.7d+142)) then
tmp = -1.0d0
else if (x <= 3.9d+19) 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 <= -1.7e+142) {
tmp = -1.0;
} else if (x <= 3.9e+19) {
tmp = y / (y + -2.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.7e+142: tmp = -1.0 elif x <= 3.9e+19: tmp = y / (y + -2.0) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.7e+142) tmp = -1.0; elseif (x <= 3.9e+19) 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 <= -1.7e+142) tmp = -1.0; elseif (x <= 3.9e+19) tmp = y / (y + -2.0); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.7e+142], -1.0, If[LessEqual[x, 3.9e+19], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+142}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{+19}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.6999999999999999e142 or 3.9e19 < x Initial program 100.0%
Taylor expanded in x around inf 89.8%
if -1.6999999999999999e142 < x < 3.9e19Initial program 100.0%
Taylor expanded in x around 0 69.6%
mul-1-neg69.6%
distribute-neg-frac69.6%
Simplified69.6%
frac-2neg69.6%
div-inv69.5%
remove-double-neg69.5%
sub-neg69.5%
distribute-neg-in69.5%
metadata-eval69.5%
remove-double-neg69.5%
Applied egg-rr69.5%
associate-*r/69.6%
*-rgt-identity69.6%
+-commutative69.6%
Simplified69.6%
Final simplification78.0%
(FPCore (x y) :precision binary64 (if (<= x -1.65e+141) -1.0 (if (<= x 6e+18) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.65e+141) {
tmp = -1.0;
} else if (x <= 6e+18) {
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.65d+141)) then
tmp = -1.0d0
else if (x <= 6d+18) 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.65e+141) {
tmp = -1.0;
} else if (x <= 6e+18) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.65e+141: tmp = -1.0 elif x <= 6e+18: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.65e+141) tmp = -1.0; elseif (x <= 6e+18) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.65e+141) tmp = -1.0; elseif (x <= 6e+18) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.65e+141], -1.0, If[LessEqual[x, 6e+18], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.65 \cdot 10^{+141}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+18}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -1.6499999999999998e141 or 6e18 < x Initial program 100.0%
Taylor expanded in x around inf 89.1%
if -1.6499999999999998e141 < x < 6e18Initial program 100.0%
Taylor expanded in y around inf 51.4%
Final simplification67.4%
(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%
Taylor expanded in x around inf 41.8%
Final simplification41.8%
(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 2023332
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:herbie-target
(- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))
(/ (- x y) (- 2.0 (+ x y))))