
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y): return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function tmp = code(x, y) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\end{array}
(FPCore (x y)
:precision binary64
(if (<= y -11000.0)
(+ x (/ (- (- 1.0 x) (/ (+ (- 1.0 x) (/ (+ x -1.0) y)) y)) y))
(if (<= y 3100000.0)
(+ 1.0 (* (- 1.0 x) (/ y (- -1.0 y))))
(+ x (+ (/ (- 1.0 x) y) (/ (/ -1.0 y) y))))))
double code(double x, double y) {
double tmp;
if (y <= -11000.0) {
tmp = x + (((1.0 - x) - (((1.0 - x) + ((x + -1.0) / y)) / y)) / y);
} else if (y <= 3100000.0) {
tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
} else {
tmp = x + (((1.0 - x) / y) + ((-1.0 / y) / y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-11000.0d0)) then
tmp = x + (((1.0d0 - x) - (((1.0d0 - x) + ((x + (-1.0d0)) / y)) / y)) / y)
else if (y <= 3100000.0d0) then
tmp = 1.0d0 + ((1.0d0 - x) * (y / ((-1.0d0) - y)))
else
tmp = x + (((1.0d0 - x) / y) + (((-1.0d0) / y) / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -11000.0) {
tmp = x + (((1.0 - x) - (((1.0 - x) + ((x + -1.0) / y)) / y)) / y);
} else if (y <= 3100000.0) {
tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
} else {
tmp = x + (((1.0 - x) / y) + ((-1.0 / y) / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -11000.0: tmp = x + (((1.0 - x) - (((1.0 - x) + ((x + -1.0) / y)) / y)) / y) elif y <= 3100000.0: tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y))) else: tmp = x + (((1.0 - x) / y) + ((-1.0 / y) / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -11000.0) tmp = Float64(x + Float64(Float64(Float64(1.0 - x) - Float64(Float64(Float64(1.0 - x) + Float64(Float64(x + -1.0) / y)) / y)) / y)); elseif (y <= 3100000.0) tmp = Float64(1.0 + Float64(Float64(1.0 - x) * Float64(y / Float64(-1.0 - y)))); else tmp = Float64(x + Float64(Float64(Float64(1.0 - x) / y) + Float64(Float64(-1.0 / y) / y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -11000.0) tmp = x + (((1.0 - x) - (((1.0 - x) + ((x + -1.0) / y)) / y)) / y); elseif (y <= 3100000.0) tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y))); else tmp = x + (((1.0 - x) / y) + ((-1.0 / y) / y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -11000.0], N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] - N[(N[(N[(1.0 - x), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3100000.0], N[(1.0 + N[(N[(1.0 - x), $MachinePrecision] * N[(y / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] + N[(N[(-1.0 / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -11000:\\
\;\;\;\;x + \frac{\left(1 - x\right) - \frac{\left(1 - x\right) + \frac{x + -1}{y}}{y}}{y}\\
\mathbf{elif}\;y \leq 3100000:\\
\;\;\;\;1 + \left(1 - x\right) \cdot \frac{y}{-1 - y}\\
\mathbf{else}:\\
\;\;\;\;x + \left(\frac{1 - x}{y} + \frac{\frac{-1}{y}}{y}\right)\\
\end{array}
\end{array}
if y < -11000Initial program 31.2%
associate-/l*54.1%
remove-double-neg54.1%
remove-double-neg54.1%
+-commutative54.1%
Simplified54.1%
Taylor expanded in y around -inf 99.9%
Simplified99.9%
if -11000 < y < 3.1e6Initial program 99.9%
associate-/l*99.9%
remove-double-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
Simplified99.9%
if 3.1e6 < y Initial program 30.3%
associate-/l*45.2%
remove-double-neg45.2%
remove-double-neg45.2%
+-commutative45.2%
Simplified45.2%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
neg-mul-1100.0%
sub-neg100.0%
associate--l+100.0%
div-sub100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
mul-1-neg100.0%
associate-*r/100.0%
+-commutative100.0%
Simplified100.0%
*-un-lft-identity100.0%
unpow2100.0%
times-frac100.0%
+-commutative100.0%
Applied egg-rr100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* y (- 1.0 x)) (+ y 1.0))))
(if (or (<= t_0 0.9988) (not (<= t_0 1.000002)))
(+ 1.0 (* (- 1.0 x) (/ y (- -1.0 y))))
(+ x (/ (- 1.0 x) y)))))
double code(double x, double y) {
double t_0 = (y * (1.0 - x)) / (y + 1.0);
double tmp;
if ((t_0 <= 0.9988) || !(t_0 <= 1.000002)) {
tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
} else {
tmp = x + ((1.0 - x) / y);
}
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 = (y * (1.0d0 - x)) / (y + 1.0d0)
if ((t_0 <= 0.9988d0) .or. (.not. (t_0 <= 1.000002d0))) then
tmp = 1.0d0 + ((1.0d0 - x) * (y / ((-1.0d0) - y)))
else
tmp = x + ((1.0d0 - x) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (y * (1.0 - x)) / (y + 1.0);
double tmp;
if ((t_0 <= 0.9988) || !(t_0 <= 1.000002)) {
tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
} else {
tmp = x + ((1.0 - x) / y);
}
return tmp;
}
def code(x, y): t_0 = (y * (1.0 - x)) / (y + 1.0) tmp = 0 if (t_0 <= 0.9988) or not (t_0 <= 1.000002): tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y))) else: tmp = x + ((1.0 - x) / y) return tmp
function code(x, y) t_0 = Float64(Float64(y * Float64(1.0 - x)) / Float64(y + 1.0)) tmp = 0.0 if ((t_0 <= 0.9988) || !(t_0 <= 1.000002)) tmp = Float64(1.0 + Float64(Float64(1.0 - x) * Float64(y / Float64(-1.0 - y)))); else tmp = Float64(x + Float64(Float64(1.0 - x) / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = (y * (1.0 - x)) / (y + 1.0); tmp = 0.0; if ((t_0 <= 0.9988) || ~((t_0 <= 1.000002))) tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y))); else tmp = x + ((1.0 - x) / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, 0.9988], N[Not[LessEqual[t$95$0, 1.000002]], $MachinePrecision]], N[(1.0 + N[(N[(1.0 - x), $MachinePrecision] * N[(y / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y \cdot \left(1 - x\right)}{y + 1}\\
\mathbf{if}\;t\_0 \leq 0.9988 \lor \neg \left(t\_0 \leq 1.000002\right):\\
\;\;\;\;1 + \left(1 - x\right) \cdot \frac{y}{-1 - y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1 - x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 0.998800000000000021 or 1.00000200000000006 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) Initial program 84.3%
associate-/l*99.8%
remove-double-neg99.8%
remove-double-neg99.8%
+-commutative99.8%
Simplified99.8%
if 0.998800000000000021 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1.00000200000000006Initial program 10.6%
associate-/l*10.6%
remove-double-neg10.6%
remove-double-neg10.6%
+-commutative10.6%
Simplified10.6%
Taylor expanded in y around inf 98.4%
associate--l+98.4%
div-sub98.4%
Simplified98.4%
Final simplification99.4%
(FPCore (x y)
:precision binary64
(if (<= y -6.1e+71)
x
(if (<= y -1.0)
(/ 1.0 y)
(if (<= y 16.0) (+ 1.0 (* y x)) (if (<= y 2.9e+32) (/ 1.0 y) x)))))
double code(double x, double y) {
double tmp;
if (y <= -6.1e+71) {
tmp = x;
} else if (y <= -1.0) {
tmp = 1.0 / y;
} else if (y <= 16.0) {
tmp = 1.0 + (y * x);
} else if (y <= 2.9e+32) {
tmp = 1.0 / y;
} else {
tmp = 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.1d+71)) then
tmp = x
else if (y <= (-1.0d0)) then
tmp = 1.0d0 / y
else if (y <= 16.0d0) then
tmp = 1.0d0 + (y * x)
else if (y <= 2.9d+32) then
tmp = 1.0d0 / y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -6.1e+71) {
tmp = x;
} else if (y <= -1.0) {
tmp = 1.0 / y;
} else if (y <= 16.0) {
tmp = 1.0 + (y * x);
} else if (y <= 2.9e+32) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6.1e+71: tmp = x elif y <= -1.0: tmp = 1.0 / y elif y <= 16.0: tmp = 1.0 + (y * x) elif y <= 2.9e+32: tmp = 1.0 / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -6.1e+71) tmp = x; elseif (y <= -1.0) tmp = Float64(1.0 / y); elseif (y <= 16.0) tmp = Float64(1.0 + Float64(y * x)); elseif (y <= 2.9e+32) tmp = Float64(1.0 / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -6.1e+71) tmp = x; elseif (y <= -1.0) tmp = 1.0 / y; elseif (y <= 16.0) tmp = 1.0 + (y * x); elseif (y <= 2.9e+32) tmp = 1.0 / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6.1e+71], x, If[LessEqual[y, -1.0], N[(1.0 / y), $MachinePrecision], If[LessEqual[y, 16.0], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.9e+32], N[(1.0 / y), $MachinePrecision], x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.1 \cdot 10^{+71}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -1:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{elif}\;y \leq 16:\\
\;\;\;\;1 + y \cdot x\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+32}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -6.1000000000000003e71 or 2.90000000000000003e32 < y Initial program 30.7%
associate-/l*52.8%
remove-double-neg52.8%
remove-double-neg52.8%
+-commutative52.8%
Simplified52.8%
Taylor expanded in y around inf 78.9%
if -6.1000000000000003e71 < y < -1 or 16 < y < 2.90000000000000003e32Initial program 33.2%
associate-/l*39.5%
remove-double-neg39.5%
remove-double-neg39.5%
+-commutative39.5%
Simplified39.5%
Taylor expanded in x around 0 15.9%
+-commutative15.9%
Simplified15.9%
Taylor expanded in y around inf 65.0%
if -1 < y < 16Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 98.8%
mul-1-neg98.8%
distribute-neg-frac298.8%
*-commutative98.8%
distribute-neg-in98.8%
metadata-eval98.8%
sub-neg98.8%
Simplified98.8%
Taylor expanded in y around 0 96.8%
*-commutative96.8%
Simplified96.8%
(FPCore (x y)
:precision binary64
(if (<= y -5e+70)
x
(if (<= y -1.0)
(/ 1.0 y)
(if (<= y 7.8e-8) (- 1.0 y) (if (<= y 1.55e+32) (/ 1.0 y) x)))))
double code(double x, double y) {
double tmp;
if (y <= -5e+70) {
tmp = x;
} else if (y <= -1.0) {
tmp = 1.0 / y;
} else if (y <= 7.8e-8) {
tmp = 1.0 - y;
} else if (y <= 1.55e+32) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-5d+70)) then
tmp = x
else if (y <= (-1.0d0)) then
tmp = 1.0d0 / y
else if (y <= 7.8d-8) then
tmp = 1.0d0 - y
else if (y <= 1.55d+32) then
tmp = 1.0d0 / y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -5e+70) {
tmp = x;
} else if (y <= -1.0) {
tmp = 1.0 / y;
} else if (y <= 7.8e-8) {
tmp = 1.0 - y;
} else if (y <= 1.55e+32) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5e+70: tmp = x elif y <= -1.0: tmp = 1.0 / y elif y <= 7.8e-8: tmp = 1.0 - y elif y <= 1.55e+32: tmp = 1.0 / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -5e+70) tmp = x; elseif (y <= -1.0) tmp = Float64(1.0 / y); elseif (y <= 7.8e-8) tmp = Float64(1.0 - y); elseif (y <= 1.55e+32) tmp = Float64(1.0 / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5e+70) tmp = x; elseif (y <= -1.0) tmp = 1.0 / y; elseif (y <= 7.8e-8) tmp = 1.0 - y; elseif (y <= 1.55e+32) tmp = 1.0 / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5e+70], x, If[LessEqual[y, -1.0], N[(1.0 / y), $MachinePrecision], If[LessEqual[y, 7.8e-8], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 1.55e+32], N[(1.0 / y), $MachinePrecision], x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+70}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -1:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{-8}:\\
\;\;\;\;1 - y\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+32}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -5.0000000000000002e70 or 1.54999999999999997e32 < y Initial program 30.7%
associate-/l*52.8%
remove-double-neg52.8%
remove-double-neg52.8%
+-commutative52.8%
Simplified52.8%
Taylor expanded in y around inf 78.9%
if -5.0000000000000002e70 < y < -1 or 7.7999999999999997e-8 < y < 1.54999999999999997e32Initial program 39.4%
associate-/l*45.2%
remove-double-neg45.2%
remove-double-neg45.2%
+-commutative45.2%
Simplified45.2%
Taylor expanded in x around 0 15.0%
+-commutative15.0%
Simplified15.0%
Taylor expanded in y around inf 59.5%
if -1 < y < 7.7999999999999997e-8Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 98.7%
Taylor expanded in x around 0 76.1%
(FPCore (x y) :precision binary64 (if (or (<= y -330000.0) (not (<= y 3700000.0))) (+ x (+ (/ (- 1.0 x) y) (/ (/ -1.0 y) y))) (+ 1.0 (* (- 1.0 x) (/ y (- -1.0 y))))))
double code(double x, double y) {
double tmp;
if ((y <= -330000.0) || !(y <= 3700000.0)) {
tmp = x + (((1.0 - x) / y) + ((-1.0 / y) / y));
} else {
tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-330000.0d0)) .or. (.not. (y <= 3700000.0d0))) then
tmp = x + (((1.0d0 - x) / y) + (((-1.0d0) / y) / y))
else
tmp = 1.0d0 + ((1.0d0 - x) * (y / ((-1.0d0) - y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -330000.0) || !(y <= 3700000.0)) {
tmp = x + (((1.0 - x) / y) + ((-1.0 / y) / y));
} else {
tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -330000.0) or not (y <= 3700000.0): tmp = x + (((1.0 - x) / y) + ((-1.0 / y) / y)) else: tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y))) return tmp
function code(x, y) tmp = 0.0 if ((y <= -330000.0) || !(y <= 3700000.0)) tmp = Float64(x + Float64(Float64(Float64(1.0 - x) / y) + Float64(Float64(-1.0 / y) / y))); else tmp = Float64(1.0 + Float64(Float64(1.0 - x) * Float64(y / Float64(-1.0 - y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -330000.0) || ~((y <= 3700000.0))) tmp = x + (((1.0 - x) / y) + ((-1.0 / y) / y)); else tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -330000.0], N[Not[LessEqual[y, 3700000.0]], $MachinePrecision]], N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] + N[(N[(-1.0 / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(1.0 - x), $MachinePrecision] * N[(y / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -330000 \lor \neg \left(y \leq 3700000\right):\\
\;\;\;\;x + \left(\frac{1 - x}{y} + \frac{\frac{-1}{y}}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(1 - x\right) \cdot \frac{y}{-1 - y}\\
\end{array}
\end{array}
if y < -3.3e5 or 3.7e6 < y Initial program 30.8%
associate-/l*49.8%
remove-double-neg49.8%
remove-double-neg49.8%
+-commutative49.8%
Simplified49.8%
Taylor expanded in y around inf 99.8%
associate--l+99.8%
neg-mul-199.8%
sub-neg99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
+-commutative99.8%
neg-sub099.8%
associate-+l-99.8%
neg-sub099.8%
mul-1-neg99.8%
associate-*r/99.8%
+-commutative99.8%
Simplified99.8%
*-un-lft-identity99.8%
unpow299.8%
times-frac99.8%
+-commutative99.8%
Applied egg-rr99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
if -3.3e5 < y < 3.7e6Initial program 99.9%
associate-/l*99.9%
remove-double-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= y -11500.0) (not (<= y 600.0))) (+ x (/ 1.0 y)) (+ 1.0 (/ (* y x) (+ y 1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -11500.0) || !(y <= 600.0)) {
tmp = x + (1.0 / y);
} else {
tmp = 1.0 + ((y * x) / (y + 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 <= (-11500.0d0)) .or. (.not. (y <= 600.0d0))) then
tmp = x + (1.0d0 / y)
else
tmp = 1.0d0 + ((y * x) / (y + 1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -11500.0) || !(y <= 600.0)) {
tmp = x + (1.0 / y);
} else {
tmp = 1.0 + ((y * x) / (y + 1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -11500.0) or not (y <= 600.0): tmp = x + (1.0 / y) else: tmp = 1.0 + ((y * x) / (y + 1.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -11500.0) || !(y <= 600.0)) tmp = Float64(x + Float64(1.0 / y)); else tmp = Float64(1.0 + Float64(Float64(y * x) / Float64(y + 1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -11500.0) || ~((y <= 600.0))) tmp = x + (1.0 / y); else tmp = 1.0 + ((y * x) / (y + 1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -11500.0], N[Not[LessEqual[y, 600.0]], $MachinePrecision]], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(y * x), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -11500 \lor \neg \left(y \leq 600\right):\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{y \cdot x}{y + 1}\\
\end{array}
\end{array}
if y < -11500 or 600 < y Initial program 31.2%
associate-/l*50.1%
remove-double-neg50.1%
remove-double-neg50.1%
+-commutative50.1%
Simplified50.1%
Taylor expanded in y around inf 98.3%
associate--l+98.3%
div-sub98.3%
Simplified98.3%
Taylor expanded in x around 0 98.3%
if -11500 < y < 600Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 98.8%
mul-1-neg98.8%
distribute-neg-frac298.8%
*-commutative98.8%
distribute-neg-in98.8%
metadata-eval98.8%
sub-neg98.8%
Simplified98.8%
Final simplification98.5%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.8))) (+ x (/ 1.0 y)) (+ 1.0 (* y (+ x -1.0)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.8)) {
tmp = x + (1.0 / y);
} else {
tmp = 1.0 + (y * (x + -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 <= (-1.0d0)) .or. (.not. (y <= 0.8d0))) then
tmp = x + (1.0d0 / y)
else
tmp = 1.0d0 + (y * (x + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 0.8)) {
tmp = x + (1.0 / y);
} else {
tmp = 1.0 + (y * (x + -1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 0.8): tmp = x + (1.0 / y) else: tmp = 1.0 + (y * (x + -1.0)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.8)) tmp = Float64(x + Float64(1.0 / y)); else tmp = Float64(1.0 + Float64(y * Float64(x + -1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 0.8))) tmp = x + (1.0 / y); else tmp = 1.0 + (y * (x + -1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 0.8]], $MachinePrecision]], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 0.8\right):\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot \left(x + -1\right)\\
\end{array}
\end{array}
if y < -1 or 0.80000000000000004 < y Initial program 31.2%
associate-/l*50.1%
remove-double-neg50.1%
remove-double-neg50.1%
+-commutative50.1%
Simplified50.1%
Taylor expanded in y around inf 98.3%
associate--l+98.3%
div-sub98.3%
Simplified98.3%
Taylor expanded in x around 0 98.3%
if -1 < y < 0.80000000000000004Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 97.4%
Final simplification97.9%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (+ x (/ 1.0 y)) (+ 1.0 (* y x))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x + (1.0 / y);
} else {
tmp = 1.0 + (y * x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = x + (1.0d0 / y)
else
tmp = 1.0d0 + (y * x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x + (1.0 / y);
} else {
tmp = 1.0 + (y * x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = x + (1.0 / y) else: tmp = 1.0 + (y * x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(x + Float64(1.0 / y)); else tmp = Float64(1.0 + Float64(y * x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = x + (1.0 / y); else tmp = 1.0 + (y * x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + y \cdot x\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 31.2%
associate-/l*50.1%
remove-double-neg50.1%
remove-double-neg50.1%
+-commutative50.1%
Simplified50.1%
Taylor expanded in y around inf 98.3%
associate--l+98.3%
div-sub98.3%
Simplified98.3%
Taylor expanded in x around 0 98.3%
if -1 < y < 1Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 98.8%
mul-1-neg98.8%
distribute-neg-frac298.8%
*-commutative98.8%
distribute-neg-in98.8%
metadata-eval98.8%
sub-neg98.8%
Simplified98.8%
Taylor expanded in y around 0 96.8%
*-commutative96.8%
Simplified96.8%
Final simplification97.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 7.8e-8) (- 1.0 y) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 7.8e-8) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = x
else if (y <= 7.8d-8) then
tmp = 1.0d0 - y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 7.8e-8) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 7.8e-8: tmp = 1.0 - y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 7.8e-8) tmp = Float64(1.0 - y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x; elseif (y <= 7.8e-8) tmp = 1.0 - y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 7.8e-8], N[(1.0 - y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{-8}:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 7.7999999999999997e-8 < y Initial program 32.6%
associate-/l*51.1%
remove-double-neg51.1%
remove-double-neg51.1%
+-commutative51.1%
Simplified51.1%
Taylor expanded in y around inf 67.5%
if -1 < y < 7.7999999999999997e-8Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 98.7%
Taylor expanded in x around 0 76.1%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 4.4e+21) (+ x 1.0) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 4.4e+21) {
tmp = x + 1.0;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = x
else if (y <= 4.4d+21) then
tmp = x + 1.0d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 4.4e+21) {
tmp = x + 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 4.4e+21: tmp = x + 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 4.4e+21) tmp = Float64(x + 1.0); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x; elseif (y <= 4.4e+21) tmp = x + 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 4.4e+21], N[(x + 1.0), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{+21}:\\
\;\;\;\;x + 1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 4.4e21 < y Initial program 30.9%
associate-/l*50.5%
remove-double-neg50.5%
remove-double-neg50.5%
+-commutative50.5%
Simplified50.5%
Taylor expanded in y around inf 71.0%
if -1 < y < 4.4e21Initial program 97.4%
associate-/l*97.4%
remove-double-neg97.4%
remove-double-neg97.4%
+-commutative97.4%
Simplified97.4%
Taylor expanded in x around inf 95.1%
mul-1-neg95.1%
distribute-neg-frac295.1%
*-commutative95.1%
distribute-neg-in95.1%
metadata-eval95.1%
sub-neg95.1%
Simplified95.1%
Taylor expanded in y around inf 52.6%
sub-neg52.6%
neg-mul-152.6%
remove-double-neg52.6%
Simplified52.6%
Final simplification62.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 8e+20) (* y x) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 8e+20) {
tmp = y * x;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = x
else if (y <= 8d+20) then
tmp = y * x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 8e+20) {
tmp = y * x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 8e+20: tmp = y * x else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 8e+20) tmp = Float64(y * x); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.0) tmp = x; elseif (y <= 8e+20) tmp = y * x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 8e+20], N[(y * x), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+20}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 8e20 < y Initial program 30.9%
associate-/l*50.5%
remove-double-neg50.5%
remove-double-neg50.5%
+-commutative50.5%
Simplified50.5%
Taylor expanded in y around inf 71.0%
if -1 < y < 8e20Initial program 97.4%
sub-neg97.4%
+-commutative97.4%
*-commutative97.4%
associate-/l*97.4%
distribute-rgt-neg-in97.4%
fma-define97.4%
distribute-frac-neg297.4%
+-commutative97.4%
distribute-neg-in97.4%
metadata-eval97.4%
unsub-neg97.4%
Simplified97.4%
Taylor expanded in x around inf 24.7%
associate-/l*24.7%
+-commutative24.7%
Simplified24.7%
Taylor expanded in y around 0 23.1%
*-commutative23.1%
Simplified23.1%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 61.3%
associate-/l*71.9%
remove-double-neg71.9%
remove-double-neg71.9%
+-commutative71.9%
Simplified71.9%
Taylor expanded in y around inf 40.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (/ 1.0 y) (- (/ x y) x))))
(if (< y -3693.8482788297247)
t_0
(if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) t_0))))
double code(double x, double y) {
double t_0 = (1.0 / y) - ((x / y) - x);
double tmp;
if (y < -3693.8482788297247) {
tmp = t_0;
} else if (y < 6799310503.41891) {
tmp = 1.0 - (((1.0 - x) * y) / (y + 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 / y) - ((x / y) - x)
if (y < (-3693.8482788297247d0)) then
tmp = t_0
else if (y < 6799310503.41891d0) then
tmp = 1.0d0 - (((1.0d0 - x) * y) / (y + 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 / y) - ((x / y) - x);
double tmp;
if (y < -3693.8482788297247) {
tmp = t_0;
} else if (y < 6799310503.41891) {
tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (1.0 / y) - ((x / y) - x) tmp = 0 if y < -3693.8482788297247: tmp = t_0 elif y < 6799310503.41891: tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(1.0 / y) - Float64(Float64(x / y) - x)) tmp = 0.0 if (y < -3693.8482788297247) tmp = t_0; elseif (y < 6799310503.41891) tmp = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (1.0 / y) - ((x / y) - x); tmp = 0.0; if (y < -3693.8482788297247) tmp = t_0; elseif (y < 6799310503.41891) tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]}, If[Less[y, -3693.8482788297247], t$95$0, If[Less[y, 6799310503.41891], N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{y} - \left(\frac{x}{y} - x\right)\\
\mathbf{if}\;y < -3693.8482788297247:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y < 6799310503.41891:\\
\;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024143
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:precision binary64
:alt
(! :herbie-platform default (if (< y -36938482788297247/10000000000000) (- (/ 1 y) (- (/ x y) x)) (if (< y 679931050341891/100000) (- 1 (/ (* (- 1 x) y) (+ y 1))) (- (/ 1 y) (- (/ x y) x)))))
(- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))