
(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 -10200.0) (not (<= x 2.0))) (/ (- x y) (- (- x) y)) (/ (- x y) (- 2.0 y))))
double code(double x, double y) {
double tmp;
if ((x <= -10200.0) || !(x <= 2.0)) {
tmp = (x - y) / (-x - y);
} else {
tmp = (x - y) / (2.0 - y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-10200.0d0)) .or. (.not. (x <= 2.0d0))) then
tmp = (x - y) / (-x - y)
else
tmp = (x - y) / (2.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -10200.0) || !(x <= 2.0)) {
tmp = (x - y) / (-x - y);
} else {
tmp = (x - y) / (2.0 - y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -10200.0) or not (x <= 2.0): tmp = (x - y) / (-x - y) else: tmp = (x - y) / (2.0 - y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -10200.0) || !(x <= 2.0)) tmp = Float64(Float64(x - y) / Float64(Float64(-x) - y)); else tmp = Float64(Float64(x - y) / Float64(2.0 - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -10200.0) || ~((x <= 2.0))) tmp = (x - y) / (-x - y); else tmp = (x - y) / (2.0 - y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -10200.0], N[Not[LessEqual[x, 2.0]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] / N[((-x) - y), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10200 \lor \neg \left(x \leq 2\right):\\
\;\;\;\;\frac{x - y}{\left(-x\right) - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\end{array}
\end{array}
if x < -10200 or 2 < x Initial program 100.0%
associate--r+100.0%
Simplified100.0%
flip--46.7%
div-inv46.5%
fma-neg46.5%
metadata-eval46.5%
+-commutative46.5%
Applied egg-rr46.5%
fma-neg46.5%
associate-*r/46.7%
*-rgt-identity46.7%
+-commutative46.7%
Simplified46.7%
Taylor expanded in x around inf 98.9%
neg-mul-198.9%
Simplified98.9%
if -10200 < x < 2Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 98.7%
Final simplification98.8%
(FPCore (x y) :precision binary64 (if (or (<= x -5.4e+67) (not (<= x 1.16e+58))) (+ (* 2.0 (/ y x)) -1.0) (/ y (+ y -2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -5.4e+67) || !(x <= 1.16e+58)) {
tmp = (2.0 * (y / x)) + -1.0;
} 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 <= (-5.4d+67)) .or. (.not. (x <= 1.16d+58))) then
tmp = (2.0d0 * (y / x)) + (-1.0d0)
else
tmp = y / (y + (-2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -5.4e+67) || !(x <= 1.16e+58)) {
tmp = (2.0 * (y / x)) + -1.0;
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -5.4e+67) or not (x <= 1.16e+58): tmp = (2.0 * (y / x)) + -1.0 else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -5.4e+67) || !(x <= 1.16e+58)) tmp = Float64(Float64(2.0 * Float64(y / x)) + -1.0); else tmp = Float64(y / Float64(y + -2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -5.4e+67) || ~((x <= 1.16e+58))) tmp = (2.0 * (y / x)) + -1.0; else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -5.4e+67], N[Not[LessEqual[x, 1.16e+58]], $MachinePrecision]], N[(N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.4 \cdot 10^{+67} \lor \neg \left(x \leq 1.16 \cdot 10^{+58}\right):\\
\;\;\;\;2 \cdot \frac{y}{x} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if x < -5.3999999999999998e67 or 1.1600000000000001e58 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
flip--36.3%
div-inv36.2%
fma-neg36.2%
metadata-eval36.2%
+-commutative36.2%
Applied egg-rr36.2%
fma-neg36.2%
associate-*r/36.3%
*-rgt-identity36.3%
+-commutative36.3%
Simplified36.3%
Taylor expanded in x around inf 99.9%
neg-mul-199.9%
Simplified99.9%
Taylor expanded in y around 0 84.9%
if -5.3999999999999998e67 < x < 1.1600000000000001e58Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 79.4%
associate-*r/79.4%
neg-mul-179.4%
Simplified79.4%
frac-2neg79.4%
div-inv79.2%
remove-double-neg79.2%
sub-neg79.2%
distribute-neg-in79.2%
metadata-eval79.2%
remove-double-neg79.2%
Applied egg-rr79.2%
associate-*r/79.4%
*-rgt-identity79.4%
Simplified79.4%
Final simplification81.7%
(FPCore (x y) :precision binary64 (if (or (<= x -5.8e+68) (not (<= x 2.35e+59))) (+ (* 2.0 (/ y x)) -1.0) (/ (- x y) (- 2.0 y))))
double code(double x, double y) {
double tmp;
if ((x <= -5.8e+68) || !(x <= 2.35e+59)) {
tmp = (2.0 * (y / x)) + -1.0;
} else {
tmp = (x - y) / (2.0 - y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-5.8d+68)) .or. (.not. (x <= 2.35d+59))) then
tmp = (2.0d0 * (y / x)) + (-1.0d0)
else
tmp = (x - y) / (2.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -5.8e+68) || !(x <= 2.35e+59)) {
tmp = (2.0 * (y / x)) + -1.0;
} else {
tmp = (x - y) / (2.0 - y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -5.8e+68) or not (x <= 2.35e+59): tmp = (2.0 * (y / x)) + -1.0 else: tmp = (x - y) / (2.0 - y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -5.8e+68) || !(x <= 2.35e+59)) tmp = Float64(Float64(2.0 * Float64(y / x)) + -1.0); else tmp = Float64(Float64(x - y) / Float64(2.0 - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -5.8e+68) || ~((x <= 2.35e+59))) tmp = (2.0 * (y / x)) + -1.0; else tmp = (x - y) / (2.0 - y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -5.8e+68], N[Not[LessEqual[x, 2.35e+59]], $MachinePrecision]], N[(N[(2.0 * N[(y / x), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(2.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{+68} \lor \neg \left(x \leq 2.35 \cdot 10^{+59}\right):\\
\;\;\;\;2 \cdot \frac{y}{x} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{2 - y}\\
\end{array}
\end{array}
if x < -5.80000000000000023e68 or 2.35e59 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
flip--36.3%
div-inv36.2%
fma-neg36.2%
metadata-eval36.2%
+-commutative36.2%
Applied egg-rr36.2%
fma-neg36.2%
associate-*r/36.3%
*-rgt-identity36.3%
+-commutative36.3%
Simplified36.3%
Taylor expanded in x around inf 99.9%
neg-mul-199.9%
Simplified99.9%
Taylor expanded in y around 0 84.9%
if -5.80000000000000023e68 < x < 2.35e59Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 93.4%
Final simplification89.8%
(FPCore (x y) :precision binary64 (if (<= x -3.7e+68) (+ (/ y x) -1.0) (if (<= x 1e+58) (/ y (+ y -2.0)) (/ (- x y) (- x)))))
double code(double x, double y) {
double tmp;
if (x <= -3.7e+68) {
tmp = (y / x) + -1.0;
} else if (x <= 1e+58) {
tmp = y / (y + -2.0);
} else {
tmp = (x - 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 <= (-3.7d+68)) then
tmp = (y / x) + (-1.0d0)
else if (x <= 1d+58) then
tmp = y / (y + (-2.0d0))
else
tmp = (x - y) / -x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.7e+68) {
tmp = (y / x) + -1.0;
} else if (x <= 1e+58) {
tmp = y / (y + -2.0);
} else {
tmp = (x - y) / -x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.7e+68: tmp = (y / x) + -1.0 elif x <= 1e+58: tmp = y / (y + -2.0) else: tmp = (x - y) / -x return tmp
function code(x, y) tmp = 0.0 if (x <= -3.7e+68) tmp = Float64(Float64(y / x) + -1.0); elseif (x <= 1e+58) tmp = Float64(y / Float64(y + -2.0)); else tmp = Float64(Float64(x - y) / Float64(-x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.7e+68) tmp = (y / x) + -1.0; elseif (x <= 1e+58) tmp = y / (y + -2.0); else tmp = (x - y) / -x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.7e+68], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, 1e+58], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / (-x)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.7 \cdot 10^{+68}:\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{elif}\;x \leq 10^{+58}:\\
\;\;\;\;\frac{y}{y + -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{-x}\\
\end{array}
\end{array}
if x < -3.69999999999999998e68Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 85.6%
neg-mul-185.6%
Simplified85.6%
Taylor expanded in x around 0 85.6%
if -3.69999999999999998e68 < x < 9.99999999999999944e57Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 79.4%
associate-*r/79.4%
neg-mul-179.4%
Simplified79.4%
frac-2neg79.4%
div-inv79.2%
remove-double-neg79.2%
sub-neg79.2%
distribute-neg-in79.2%
metadata-eval79.2%
remove-double-neg79.2%
Applied egg-rr79.2%
associate-*r/79.4%
*-rgt-identity79.4%
Simplified79.4%
if 9.99999999999999944e57 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 82.4%
neg-mul-182.4%
Simplified82.4%
Final simplification81.3%
(FPCore (x y) :precision binary64 (if (or (<= x -5.2e+67) (not (<= x 2.75e+60))) (+ (/ y x) -1.0) 1.0))
double code(double x, double y) {
double tmp;
if ((x <= -5.2e+67) || !(x <= 2.75e+60)) {
tmp = (y / x) + -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 <= (-5.2d+67)) .or. (.not. (x <= 2.75d+60))) then
tmp = (y / x) + (-1.0d0)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -5.2e+67) || !(x <= 2.75e+60)) {
tmp = (y / x) + -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -5.2e+67) or not (x <= 2.75e+60): tmp = (y / x) + -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if ((x <= -5.2e+67) || !(x <= 2.75e+60)) tmp = Float64(Float64(y / x) + -1.0); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -5.2e+67) || ~((x <= 2.75e+60))) tmp = (y / x) + -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -5.2e+67], N[Not[LessEqual[x, 2.75e+60]], $MachinePrecision]], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{+67} \lor \neg \left(x \leq 2.75 \cdot 10^{+60}\right):\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -5.2000000000000001e67 or 2.75e60 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 84.0%
neg-mul-184.0%
Simplified84.0%
Taylor expanded in x around 0 84.0%
if -5.2000000000000001e67 < x < 2.75e60Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 57.4%
Final simplification68.6%
(FPCore (x y) :precision binary64 (if (or (<= y -8.2e+37) (not (<= y 6200000000000.0))) (- 1.0 (/ x y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -8.2e+37) || !(y <= 6200000000000.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 <= (-8.2d+37)) .or. (.not. (y <= 6200000000000.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 <= -8.2e+37) || !(y <= 6200000000000.0)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -8.2e+37) or not (y <= 6200000000000.0): tmp = 1.0 - (x / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -8.2e+37) || !(y <= 6200000000000.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 <= -8.2e+37) || ~((y <= 6200000000000.0))) tmp = 1.0 - (x / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -8.2e+37], N[Not[LessEqual[y, 6200000000000.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 -8.2 \cdot 10^{+37} \lor \neg \left(y \leq 6200000000000\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -8.1999999999999996e37 or 6.2e12 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 76.3%
neg-mul-176.3%
Simplified76.3%
Taylor expanded in x around 0 76.3%
neg-mul-176.3%
unsub-neg76.3%
Simplified76.3%
if -8.1999999999999996e37 < y < 6.2e12Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 72.7%
Final simplification74.4%
(FPCore (x y) :precision binary64 (if (or (<= x -1.6e+68) (not (<= x 1.4e+58))) (+ (/ y x) -1.0) (/ y (+ y -2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.6e+68) || !(x <= 1.4e+58)) {
tmp = (y / x) + -1.0;
} 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.6d+68)) .or. (.not. (x <= 1.4d+58))) then
tmp = (y / x) + (-1.0d0)
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.6e+68) || !(x <= 1.4e+58)) {
tmp = (y / x) + -1.0;
} else {
tmp = y / (y + -2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.6e+68) or not (x <= 1.4e+58): tmp = (y / x) + -1.0 else: tmp = y / (y + -2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.6e+68) || !(x <= 1.4e+58)) tmp = Float64(Float64(y / x) + -1.0); else tmp = Float64(y / Float64(y + -2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.6e+68) || ~((x <= 1.4e+58))) tmp = (y / x) + -1.0; else tmp = y / (y + -2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.6e+68], N[Not[LessEqual[x, 1.4e+58]], $MachinePrecision]], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], N[(y / N[(y + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+68} \lor \neg \left(x \leq 1.4 \cdot 10^{+58}\right):\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y + -2}\\
\end{array}
\end{array}
if x < -1.59999999999999997e68 or 1.3999999999999999e58 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 84.0%
neg-mul-184.0%
Simplified84.0%
Taylor expanded in x around 0 84.0%
if -1.59999999999999997e68 < x < 1.3999999999999999e58Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 79.4%
associate-*r/79.4%
neg-mul-179.4%
Simplified79.4%
frac-2neg79.4%
div-inv79.2%
remove-double-neg79.2%
sub-neg79.2%
distribute-neg-in79.2%
metadata-eval79.2%
remove-double-neg79.2%
Applied egg-rr79.2%
associate-*r/79.4%
*-rgt-identity79.4%
Simplified79.4%
Final simplification81.3%
(FPCore (x y) :precision binary64 (if (<= x -9.2e+61) -1.0 (if (<= x 5e+58) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -9.2e+61) {
tmp = -1.0;
} else if (x <= 5e+58) {
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 <= (-9.2d+61)) then
tmp = -1.0d0
else if (x <= 5d+58) 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 <= -9.2e+61) {
tmp = -1.0;
} else if (x <= 5e+58) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -9.2e+61: tmp = -1.0 elif x <= 5e+58: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -9.2e+61) tmp = -1.0; elseif (x <= 5e+58) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -9.2e+61) tmp = -1.0; elseif (x <= 5e+58) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -9.2e+61], -1.0, If[LessEqual[x, 5e+58], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+61}:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+58}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -9.1999999999999998e61 or 4.99999999999999986e58 < x Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in x around inf 82.8%
if -9.1999999999999998e61 < x < 4.99999999999999986e58Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around inf 57.5%
Final simplification68.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%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 39.2%
Final simplification39.2%
(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 2023293
(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))))