
(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 (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 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%
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 -3100000.0) (/ (- y x) (- x 2.0)) (if (<= x 120.0) (/ (- y x) (- y 2.0)) (/ x (- (- x) (+ y -2.0))))))
double code(double x, double y) {
double tmp;
if (x <= -3100000.0) {
tmp = (y - x) / (x - 2.0);
} else if (x <= 120.0) {
tmp = (y - x) / (y - 2.0);
} else {
tmp = x / (-x - (y + -2.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-3100000.0d0)) then
tmp = (y - x) / (x - 2.0d0)
else if (x <= 120.0d0) then
tmp = (y - x) / (y - 2.0d0)
else
tmp = x / (-x - (y + (-2.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3100000.0) {
tmp = (y - x) / (x - 2.0);
} else if (x <= 120.0) {
tmp = (y - x) / (y - 2.0);
} else {
tmp = x / (-x - (y + -2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3100000.0: tmp = (y - x) / (x - 2.0) elif x <= 120.0: tmp = (y - x) / (y - 2.0) else: tmp = x / (-x - (y + -2.0)) return tmp
function code(x, y) tmp = 0.0 if (x <= -3100000.0) tmp = Float64(Float64(y - x) / Float64(x - 2.0)); elseif (x <= 120.0) tmp = Float64(Float64(y - x) / Float64(y - 2.0)); else tmp = Float64(x / Float64(Float64(-x) - Float64(y + -2.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3100000.0) tmp = (y - x) / (x - 2.0); elseif (x <= 120.0) tmp = (y - x) / (y - 2.0); else tmp = x / (-x - (y + -2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3100000.0], N[(N[(y - x), $MachinePrecision] / N[(x - 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 120.0], N[(N[(y - x), $MachinePrecision] / N[(y - 2.0), $MachinePrecision]), $MachinePrecision], N[(x / N[((-x) - N[(y + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3100000:\\
\;\;\;\;\frac{y - x}{x - 2}\\
\mathbf{elif}\;x \leq 120:\\
\;\;\;\;\frac{y - x}{y - 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(-x\right) - \left(y + -2\right)}\\
\end{array}
\end{array}
if x < -3.1e6Initial 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 81.7%
if -3.1e6 < x < 120Initial 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 98.4%
if 120 < 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 84.7%
neg-mul-184.7%
Simplified84.7%
Final simplification91.4%
(FPCore (x y) :precision binary64 (if (or (<= x -16000000.0) (not (<= x 21000000.0))) (/ (- y x) (- x 2.0)) (/ (- y x) (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -16000000.0) || !(x <= 21000000.0)) {
tmp = (y - x) / (x - 2.0);
} else {
tmp = (y - x) / (y - 2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-16000000.0d0)) .or. (.not. (x <= 21000000.0d0))) then
tmp = (y - x) / (x - 2.0d0)
else
tmp = (y - x) / (y - 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -16000000.0) || !(x <= 21000000.0)) {
tmp = (y - x) / (x - 2.0);
} else {
tmp = (y - x) / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -16000000.0) or not (x <= 21000000.0): tmp = (y - x) / (x - 2.0) else: tmp = (y - x) / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -16000000.0) || !(x <= 21000000.0)) tmp = Float64(Float64(y - x) / Float64(x - 2.0)); else tmp = Float64(Float64(y - x) / Float64(y - 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -16000000.0) || ~((x <= 21000000.0))) tmp = (y - x) / (x - 2.0); else tmp = (y - x) / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -16000000.0], N[Not[LessEqual[x, 21000000.0]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] / N[(x - 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / N[(y - 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -16000000 \lor \neg \left(x \leq 21000000\right):\\
\;\;\;\;\frac{y - x}{x - 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y - 2}\\
\end{array}
\end{array}
if x < -1.6e7 or 2.1e7 < 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 84.1%
if -1.6e7 < x < 2.1e7Initial 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 97.7%
Final simplification91.4%
(FPCore (x y) :precision binary64 (if (or (<= y -3900000000.0) (not (<= y 1.25e-8))) (/ y (+ x (+ y -2.0))) (/ (- y x) (- x 2.0))))
double code(double x, double y) {
double tmp;
if ((y <= -3900000000.0) || !(y <= 1.25e-8)) {
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 <= (-3900000000.0d0)) .or. (.not. (y <= 1.25d-8))) 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 <= -3900000000.0) || !(y <= 1.25e-8)) {
tmp = y / (x + (y + -2.0));
} else {
tmp = (y - x) / (x - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -3900000000.0) or not (y <= 1.25e-8): tmp = y / (x + (y + -2.0)) else: tmp = (y - x) / (x - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((y <= -3900000000.0) || !(y <= 1.25e-8)) 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 <= -3900000000.0) || ~((y <= 1.25e-8))) 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, -3900000000.0], N[Not[LessEqual[y, 1.25e-8]], $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 -3900000000 \lor \neg \left(y \leq 1.25 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{y}{x + \left(y + -2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{x - 2}\\
\end{array}
\end{array}
if y < -3.9e9 or 1.2499999999999999e-8 < 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 76.8%
if -3.9e9 < y < 1.2499999999999999e-8Initial 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 99.0%
Final simplification88.2%
(FPCore (x y) :precision binary64 (if (or (<= x -1.55e-21) (not (<= x 1.12e-16))) (/ x (- 2.0 x)) (/ y (- y 2.0))))
double code(double x, double y) {
double tmp;
if ((x <= -1.55e-21) || !(x <= 1.12e-16)) {
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.55d-21)) .or. (.not. (x <= 1.12d-16))) 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.55e-21) || !(x <= 1.12e-16)) {
tmp = x / (2.0 - x);
} else {
tmp = y / (y - 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.55e-21) or not (x <= 1.12e-16): tmp = x / (2.0 - x) else: tmp = y / (y - 2.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.55e-21) || !(x <= 1.12e-16)) 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.55e-21) || ~((x <= 1.12e-16))) tmp = x / (2.0 - x); else tmp = y / (y - 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.55e-21], N[Not[LessEqual[x, 1.12e-16]], $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.55 \cdot 10^{-21} \lor \neg \left(x \leq 1.12 \cdot 10^{-16}\right):\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - 2}\\
\end{array}
\end{array}
if x < -1.5499999999999999e-21 or 1.12e-16 < 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 80.1%
mul-1-neg80.1%
distribute-neg-frac280.1%
neg-sub080.1%
associate-+l-80.1%
neg-sub080.1%
+-commutative80.1%
unsub-neg80.1%
Simplified80.1%
if -1.5499999999999999e-21 < x < 1.12e-16Initial 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 79.4%
Final simplification79.8%
(FPCore (x y) :precision binary64 (if (or (<= x -16500000.0) (not (<= x 55000000.0))) (+ (/ y x) -1.0) 1.0))
double code(double x, double y) {
double tmp;
if ((x <= -16500000.0) || !(x <= 55000000.0)) {
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 <= (-16500000.0d0)) .or. (.not. (x <= 55000000.0d0))) 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 <= -16500000.0) || !(x <= 55000000.0)) {
tmp = (y / x) + -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -16500000.0) or not (x <= 55000000.0): tmp = (y / x) + -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if ((x <= -16500000.0) || !(x <= 55000000.0)) 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 <= -16500000.0) || ~((x <= 55000000.0))) tmp = (y / x) + -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -16500000.0], N[Not[LessEqual[x, 55000000.0]], $MachinePrecision]], N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -16500000 \lor \neg \left(x \leq 55000000\right):\\
\;\;\;\;\frac{y}{x} + -1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1.65e7 or 5.5e7 < 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 82.5%
Taylor expanded in y around 0 82.5%
if -1.65e7 < x < 5.5e7Initial 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 55.7%
Final simplification68.1%
(FPCore (x y) :precision binary64 (if (<= y -5200000000.0) 1.0 (if (<= y 7.5e+41) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -5200000000.0) {
tmp = 1.0;
} else if (y <= 7.5e+41) {
tmp = x / (2.0 - x);
} 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 <= (-5200000000.0d0)) then
tmp = 1.0d0
else if (y <= 7.5d+41) then
tmp = x / (2.0d0 - x)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -5200000000.0) {
tmp = 1.0;
} else if (y <= 7.5e+41) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5200000000.0: tmp = 1.0 elif y <= 7.5e+41: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -5200000000.0) tmp = 1.0; elseif (y <= 7.5e+41) tmp = Float64(x / Float64(2.0 - x)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5200000000.0) tmp = 1.0; elseif (y <= 7.5e+41) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5200000000.0], 1.0, If[LessEqual[y, 7.5e+41], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5200000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+41}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.2e9 or 7.50000000000000072e41 < 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 77.9%
if -5.2e9 < y < 7.50000000000000072e41Initial 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 75.6%
mul-1-neg75.6%
distribute-neg-frac275.6%
neg-sub075.6%
associate-+l-75.6%
neg-sub075.6%
+-commutative75.6%
unsub-neg75.6%
Simplified75.6%
(FPCore (x y) :precision binary64 (if (<= x -62000000.0) -1.0 (if (<= x 42000000.0) 1.0 -1.0)))
double code(double x, double y) {
double tmp;
if (x <= -62000000.0) {
tmp = -1.0;
} else if (x <= 42000000.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 <= (-62000000.0d0)) then
tmp = -1.0d0
else if (x <= 42000000.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 <= -62000000.0) {
tmp = -1.0;
} else if (x <= 42000000.0) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -62000000.0: tmp = -1.0 elif x <= 42000000.0: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -62000000.0) tmp = -1.0; elseif (x <= 42000000.0) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -62000000.0) tmp = -1.0; elseif (x <= 42000000.0) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -62000000.0], -1.0, If[LessEqual[x, 42000000.0], 1.0, -1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -62000000:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 42000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if x < -6.2e7 or 4.2e7 < 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 82.1%
if -6.2e7 < x < 4.2e7Initial 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 55.7%
(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 39.7%
(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 2024181
(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))))