
(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 (or (<= y -380000.0) (not (<= y 430000.0))) (+ x (/ (+ (- 1.0 x) (/ (+ x -1.0) y)) y)) (fma y (/ (- 1.0 x) (- -1.0 y)) 1.0)))
double code(double x, double y) {
double tmp;
if ((y <= -380000.0) || !(y <= 430000.0)) {
tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y);
} else {
tmp = fma(y, ((1.0 - x) / (-1.0 - y)), 1.0);
}
return tmp;
}
function code(x, y) tmp = 0.0 if ((y <= -380000.0) || !(y <= 430000.0)) tmp = Float64(x + Float64(Float64(Float64(1.0 - x) + Float64(Float64(x + -1.0) / y)) / y)); else tmp = fma(y, Float64(Float64(1.0 - x) / Float64(-1.0 - y)), 1.0); end return tmp end
code[x_, y_] := If[Or[LessEqual[y, -380000.0], N[Not[LessEqual[y, 430000.0]], $MachinePrecision]], N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(1.0 - x), $MachinePrecision] / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -380000 \lor \neg \left(y \leq 430000\right):\\
\;\;\;\;x + \frac{\left(1 - x\right) + \frac{x + -1}{y}}{y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{1 - x}{-1 - y}, 1\right)\\
\end{array}
\end{array}
if y < -3.8e5 or 4.3e5 < y Initial program 25.4%
associate-/l*56.0%
remove-double-neg56.0%
remove-double-neg56.0%
+-commutative56.0%
Simplified56.0%
Taylor expanded in y around inf 100.0%
Simplified100.0%
if -3.8e5 < y < 4.3e5Initial program 99.8%
sub-neg99.8%
+-commutative99.8%
*-commutative99.8%
associate-/l*99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
distribute-frac-neg299.8%
+-commutative99.8%
distribute-neg-in99.8%
metadata-eval99.8%
unsub-neg99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* y (- 1.0 x)) (+ y 1.0))))
(if (or (<= t_0 0.5) (not (<= t_0 1.002)))
(+ 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.5) || !(t_0 <= 1.002)) {
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.5d0) .or. (.not. (t_0 <= 1.002d0))) 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.5) || !(t_0 <= 1.002)) {
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.5) or not (t_0 <= 1.002): 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.5) || !(t_0 <= 1.002)) 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.5) || ~((t_0 <= 1.002))) 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.5], N[Not[LessEqual[t$95$0, 1.002]], $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.5 \lor \neg \left(t\_0 \leq 1.002\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.5 or 1.002 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) Initial program 81.1%
associate-/l*99.9%
remove-double-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
Simplified99.9%
if 0.5 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) y) (+.f64 y #s(literal 1 binary64))) < 1.002Initial program 5.8%
associate-/l*5.8%
remove-double-neg5.8%
remove-double-neg5.8%
+-commutative5.8%
Simplified5.8%
Taylor expanded in y around inf 99.2%
associate--l+99.2%
div-sub99.2%
Simplified99.2%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (or (<= y -2.35e+29) (not (<= y 2.9e+15))) (+ x (/ (- 1.0 x) y)) (* x (/ (/ (+ -1.0 (+ y (* y (- -1.0 x)))) x) (- -1.0 y)))))
double code(double x, double y) {
double tmp;
if ((y <= -2.35e+29) || !(y <= 2.9e+15)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = x * (((-1.0 + (y + (y * (-1.0 - x)))) / x) / (-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 <= (-2.35d+29)) .or. (.not. (y <= 2.9d+15))) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = x * ((((-1.0d0) + (y + (y * ((-1.0d0) - x)))) / x) / ((-1.0d0) - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -2.35e+29) || !(y <= 2.9e+15)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = x * (((-1.0 + (y + (y * (-1.0 - x)))) / x) / (-1.0 - y));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2.35e+29) or not (y <= 2.9e+15): tmp = x + ((1.0 - x) / y) else: tmp = x * (((-1.0 + (y + (y * (-1.0 - x)))) / x) / (-1.0 - y)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -2.35e+29) || !(y <= 2.9e+15)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(x * Float64(Float64(Float64(-1.0 + Float64(y + Float64(y * Float64(-1.0 - x)))) / x) / Float64(-1.0 - y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -2.35e+29) || ~((y <= 2.9e+15))) tmp = x + ((1.0 - x) / y); else tmp = x * (((-1.0 + (y + (y * (-1.0 - x)))) / x) / (-1.0 - y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2.35e+29], N[Not[LessEqual[y, 2.9e+15]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(N[(-1.0 + N[(y + N[(y * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.35 \cdot 10^{+29} \lor \neg \left(y \leq 2.9 \cdot 10^{+15}\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{-1 + \left(y + y \cdot \left(-1 - x\right)\right)}{x}}{-1 - y}\\
\end{array}
\end{array}
if y < -2.3500000000000001e29 or 2.9e15 < y Initial program 23.7%
associate-/l*56.4%
remove-double-neg56.4%
remove-double-neg56.4%
+-commutative56.4%
Simplified56.4%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
div-sub100.0%
Simplified100.0%
if -2.3500000000000001e29 < y < 2.9e15Initial program 97.0%
associate-/l*97.0%
remove-double-neg97.0%
remove-double-neg97.0%
+-commutative97.0%
Simplified97.0%
Taylor expanded in x around inf 96.9%
sub-neg96.9%
distribute-neg-in96.9%
add-sqr-sqrt42.8%
sqrt-unprod76.5%
mul-1-neg76.5%
mul-1-neg76.5%
sqr-neg76.5%
sqrt-unprod35.9%
add-sqr-sqrt69.7%
mul-1-neg69.7%
sub-neg69.7%
associate-*r/69.7%
associate-/r*69.8%
sub-div69.8%
neg-mul-169.8%
Applied egg-rr69.8%
frac-2neg69.8%
metadata-eval69.8%
frac-add70.2%
Applied egg-rr97.4%
cancel-sign-sub-inv97.4%
distribute-lft-neg-in97.4%
distribute-rgt-neg-in97.4%
associate-/r*97.4%
Simplified99.8%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= y -255000.0) (not (<= y 310000.0))) (+ x (/ (+ (- 1.0 x) (/ (+ x -1.0) y)) y)) (+ 1.0 (* (- 1.0 x) (/ y (- -1.0 y))))))
double code(double x, double y) {
double tmp;
if ((y <= -255000.0) || !(y <= 310000.0)) {
tmp = x + (((1.0 - x) + ((x + -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 <= (-255000.0d0)) .or. (.not. (y <= 310000.0d0))) then
tmp = x + (((1.0d0 - x) + ((x + (-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 <= -255000.0) || !(y <= 310000.0)) {
tmp = x + (((1.0 - x) + ((x + -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 <= -255000.0) or not (y <= 310000.0): tmp = x + (((1.0 - x) + ((x + -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 <= -255000.0) || !(y <= 310000.0)) tmp = Float64(x + Float64(Float64(Float64(1.0 - x) + Float64(Float64(x + -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 <= -255000.0) || ~((y <= 310000.0))) tmp = x + (((1.0 - x) + ((x + -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, -255000.0], N[Not[LessEqual[y, 310000.0]], $MachinePrecision]], N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / y), $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 -255000 \lor \neg \left(y \leq 310000\right):\\
\;\;\;\;x + \frac{\left(1 - x\right) + \frac{x + -1}{y}}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(1 - x\right) \cdot \frac{y}{-1 - y}\\
\end{array}
\end{array}
if y < -255000 or 3.1e5 < y Initial program 25.4%
associate-/l*56.0%
remove-double-neg56.0%
remove-double-neg56.0%
+-commutative56.0%
Simplified56.0%
Taylor expanded in y around inf 100.0%
Simplified100.0%
if -255000 < y < 3.1e5Initial program 99.8%
associate-/l*99.8%
remove-double-neg99.8%
remove-double-neg99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= (- 1.0 x) -50000000.0) (not (<= (- 1.0 x) 5e+44))) (* x (/ y (+ y 1.0))) (/ 1.0 (+ y 1.0))))
double code(double x, double y) {
double tmp;
if (((1.0 - x) <= -50000000.0) || !((1.0 - x) <= 5e+44)) {
tmp = x * (y / (y + 1.0));
} else {
tmp = 1.0 / (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 (((1.0d0 - x) <= (-50000000.0d0)) .or. (.not. ((1.0d0 - x) <= 5d+44))) then
tmp = x * (y / (y + 1.0d0))
else
tmp = 1.0d0 / (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (((1.0 - x) <= -50000000.0) || !((1.0 - x) <= 5e+44)) {
tmp = x * (y / (y + 1.0));
} else {
tmp = 1.0 / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if ((1.0 - x) <= -50000000.0) or not ((1.0 - x) <= 5e+44): tmp = x * (y / (y + 1.0)) else: tmp = 1.0 / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((Float64(1.0 - x) <= -50000000.0) || !(Float64(1.0 - x) <= 5e+44)) tmp = Float64(x * Float64(y / Float64(y + 1.0))); else tmp = Float64(1.0 / Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((1.0 - x) <= -50000000.0) || ~(((1.0 - x) <= 5e+44))) tmp = x * (y / (y + 1.0)); else tmp = 1.0 / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[(1.0 - x), $MachinePrecision], -50000000.0], N[Not[LessEqual[N[(1.0 - x), $MachinePrecision], 5e+44]], $MachinePrecision]], N[(x * N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - x \leq -50000000 \lor \neg \left(1 - x \leq 5 \cdot 10^{+44}\right):\\
\;\;\;\;x \cdot \frac{y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y + 1}\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) x) < -5e7 or 4.9999999999999996e44 < (-.f64 #s(literal 1 binary64) x) Initial program 69.4%
associate-/l*100.0%
remove-double-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 51.1%
associate-/l*81.6%
Simplified81.6%
if -5e7 < (-.f64 #s(literal 1 binary64) x) < 4.9999999999999996e44Initial program 59.9%
associate-/l*60.6%
remove-double-neg60.6%
remove-double-neg60.6%
+-commutative60.6%
Simplified60.6%
Taylor expanded in x around inf 60.8%
sub-neg60.8%
distribute-neg-in60.8%
add-sqr-sqrt26.2%
sqrt-unprod57.9%
mul-1-neg57.9%
mul-1-neg57.9%
sqr-neg57.9%
sqrt-unprod31.7%
add-sqr-sqrt57.9%
mul-1-neg57.9%
sub-neg57.9%
associate-*r/57.9%
associate-/r*57.2%
sub-div57.2%
neg-mul-157.2%
Applied egg-rr57.2%
frac-2neg57.2%
metadata-eval57.2%
frac-add57.4%
Applied egg-rr59.6%
cancel-sign-sub-inv59.6%
distribute-lft-neg-in59.6%
distribute-rgt-neg-in59.6%
associate-/r*59.7%
Simplified80.2%
Taylor expanded in x around 0 78.4%
+-commutative78.4%
Simplified78.4%
Final simplification79.9%
(FPCore (x y) :precision binary64 (if (or (<= y -66000000000.0) (not (<= y 480000000000.0))) (+ x (/ (- 1.0 x) y)) (/ 1.0 (+ y 1.0))))
double code(double x, double y) {
double tmp;
if ((y <= -66000000000.0) || !(y <= 480000000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 / (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 <= (-66000000000.0d0)) .or. (.not. (y <= 480000000000.0d0))) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = 1.0d0 / (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -66000000000.0) || !(y <= 480000000000.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -66000000000.0) or not (y <= 480000000000.0): tmp = x + ((1.0 - x) / y) else: tmp = 1.0 / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if ((y <= -66000000000.0) || !(y <= 480000000000.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(1.0 / Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -66000000000.0) || ~((y <= 480000000000.0))) tmp = x + ((1.0 - x) / y); else tmp = 1.0 / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -66000000000.0], N[Not[LessEqual[y, 480000000000.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -66000000000 \lor \neg \left(y \leq 480000000000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y + 1}\\
\end{array}
\end{array}
if y < -6.6e10 or 4.8e11 < y Initial program 25.1%
associate-/l*56.2%
remove-double-neg56.2%
remove-double-neg56.2%
+-commutative56.2%
Simplified56.2%
Taylor expanded in y around inf 100.0%
associate--l+100.0%
div-sub100.0%
Simplified100.0%
if -6.6e10 < y < 4.8e11Initial program 99.0%
associate-/l*99.0%
remove-double-neg99.0%
remove-double-neg99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in x around inf 98.8%
sub-neg98.8%
distribute-neg-in98.8%
add-sqr-sqrt44.7%
sqrt-unprod79.8%
mul-1-neg79.8%
mul-1-neg79.8%
sqr-neg79.8%
sqrt-unprod37.3%
add-sqr-sqrt72.6%
mul-1-neg72.6%
sub-neg72.6%
associate-*r/72.6%
associate-/r*72.7%
sub-div72.7%
neg-mul-172.7%
Applied egg-rr72.7%
frac-2neg72.7%
metadata-eval72.7%
frac-add73.2%
Applied egg-rr99.4%
cancel-sign-sub-inv99.4%
distribute-lft-neg-in99.4%
distribute-rgt-neg-in99.4%
associate-/r*99.4%
Simplified99.8%
Taylor expanded in x around 0 74.5%
+-commutative74.5%
Simplified74.5%
Final simplification86.4%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (+ x (/ (- 1.0 x) y)) (- 1.0 (* y (- 1.0 x)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x + ((1.0 - x) / y);
} else {
tmp = 1.0 - (y * (1.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 <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = x + ((1.0d0 - x) / y)
else
tmp = 1.0d0 - (y * (1.0d0 - 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 - x) / y);
} else {
tmp = 1.0 - (y * (1.0 - x));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = x + ((1.0 - x) / y) else: tmp = 1.0 - (y * (1.0 - x)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(x + Float64(Float64(1.0 - x) / y)); else tmp = Float64(1.0 - Float64(y * Float64(1.0 - 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 - x) / y); else tmp = 1.0 - (y * (1.0 - 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[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 - y \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 28.1%
associate-/l*57.5%
remove-double-neg57.5%
remove-double-neg57.5%
+-commutative57.5%
Simplified57.5%
Taylor expanded in y around inf 96.8%
associate--l+96.8%
div-sub96.8%
Simplified96.8%
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 y around 0 98.0%
Final simplification97.4%
(FPCore (x y) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (- x (/ x y)) (- 1.0 y)))
double code(double x, double y) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x - (x / y);
} else {
tmp = 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 <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = x - (x / y)
else
tmp = 1.0d0 - y
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 - (x / y);
} else {
tmp = 1.0 - y;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = x - (x / y) else: tmp = 1.0 - y return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(x - Float64(x / y)); else tmp = Float64(1.0 - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.0))) tmp = x - (x / y); else tmp = 1.0 - y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 28.1%
associate-/l*57.5%
remove-double-neg57.5%
remove-double-neg57.5%
+-commutative57.5%
Simplified57.5%
Taylor expanded in x around inf 43.5%
associate-/l*72.9%
Simplified72.9%
Taylor expanded in y around inf 71.8%
mul-1-neg71.8%
unsub-neg71.8%
Simplified71.8%
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 0 74.6%
Taylor expanded in y around 0 73.7%
neg-mul-173.7%
unsub-neg73.7%
Simplified73.7%
Final simplification72.8%
(FPCore (x y) :precision binary64 (if (<= y -1.15e+58) x (if (<= y 1300000000000.0) (/ 1.0 (+ y 1.0)) (- x (/ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -1.15e+58) {
tmp = x;
} else if (y <= 1300000000000.0) {
tmp = 1.0 / (y + 1.0);
} else {
tmp = x - (x / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.15d+58)) then
tmp = x
else if (y <= 1300000000000.0d0) then
tmp = 1.0d0 / (y + 1.0d0)
else
tmp = x - (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.15e+58) {
tmp = x;
} else if (y <= 1300000000000.0) {
tmp = 1.0 / (y + 1.0);
} else {
tmp = x - (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.15e+58: tmp = x elif y <= 1300000000000.0: tmp = 1.0 / (y + 1.0) else: tmp = x - (x / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.15e+58) tmp = x; elseif (y <= 1300000000000.0) tmp = Float64(1.0 / Float64(y + 1.0)); else tmp = Float64(x - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.15e+58) tmp = x; elseif (y <= 1300000000000.0) tmp = 1.0 / (y + 1.0); else tmp = x - (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.15e+58], x, If[LessEqual[y, 1300000000000.0], N[(1.0 / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+58}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1300000000000:\\
\;\;\;\;\frac{1}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x}{y}\\
\end{array}
\end{array}
if y < -1.15000000000000001e58Initial program 24.9%
associate-/l*58.5%
remove-double-neg58.5%
remove-double-neg58.5%
+-commutative58.5%
Simplified58.5%
Taylor expanded in y around inf 78.2%
if -1.15000000000000001e58 < y < 1.3e12Initial program 95.1%
associate-/l*95.7%
remove-double-neg95.7%
remove-double-neg95.7%
+-commutative95.7%
Simplified95.7%
Taylor expanded in x around inf 95.6%
sub-neg95.6%
distribute-neg-in95.6%
add-sqr-sqrt41.9%
sqrt-unprod75.0%
mul-1-neg75.0%
mul-1-neg75.0%
sqr-neg75.0%
sqrt-unprod35.2%
add-sqr-sqrt68.3%
mul-1-neg68.3%
sub-neg68.3%
associate-*r/68.3%
associate-/r*68.4%
sub-div68.4%
neg-mul-168.4%
Applied egg-rr68.4%
frac-2neg68.4%
metadata-eval68.4%
frac-add68.8%
Applied egg-rr95.4%
cancel-sign-sub-inv95.4%
distribute-lft-neg-in95.4%
distribute-rgt-neg-in95.4%
associate-/r*95.5%
Simplified99.2%
Taylor expanded in x around 0 73.4%
+-commutative73.4%
Simplified73.4%
if 1.3e12 < y Initial program 23.6%
associate-/l*55.6%
remove-double-neg55.6%
remove-double-neg55.6%
+-commutative55.6%
Simplified55.6%
Taylor expanded in x around inf 45.1%
associate-/l*77.2%
Simplified77.2%
Taylor expanded in y around inf 77.2%
mul-1-neg77.2%
unsub-neg77.2%
Simplified77.2%
Final simplification75.2%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.88) (- 1.0 y) x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 0.88) {
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 <= 0.88d0) 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 <= 0.88) {
tmp = 1.0 - y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 0.88: tmp = 1.0 - y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 0.88) 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 <= 0.88) tmp = 1.0 - y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 0.88], N[(1.0 - y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 0.88:\\
\;\;\;\;1 - y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 0.880000000000000004 < y Initial program 28.1%
associate-/l*57.5%
remove-double-neg57.5%
remove-double-neg57.5%
+-commutative57.5%
Simplified57.5%
Taylor expanded in y around inf 71.5%
if -1 < y < 0.880000000000000004Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 74.6%
Taylor expanded in y around 0 73.7%
neg-mul-173.7%
unsub-neg73.7%
Simplified73.7%
Final simplification72.6%
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 480000000000.0) 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.0) {
tmp = x;
} else if (y <= 480000000000.0) {
tmp = 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 <= 480000000000.0d0) then
tmp = 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 <= 480000000000.0) {
tmp = 1.0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.0: tmp = x elif y <= 480000000000.0: tmp = 1.0 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.0) tmp = x; elseif (y <= 480000000000.0) tmp = 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 <= 480000000000.0) tmp = 1.0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 480000000000.0], 1.0, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 480000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1 or 4.8e11 < y Initial program 28.0%
associate-/l*57.7%
remove-double-neg57.7%
remove-double-neg57.7%
+-commutative57.7%
Simplified57.7%
Taylor expanded in y around inf 72.1%
if -1 < y < 4.8e11Initial program 99.6%
associate-/l*99.5%
remove-double-neg99.5%
remove-double-neg99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in y around 0 73.0%
Final simplification72.5%
(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 64.3%
associate-/l*78.9%
remove-double-neg78.9%
remove-double-neg78.9%
+-commutative78.9%
Simplified78.9%
Taylor expanded in y around 0 38.7%
Final simplification38.7%
(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 2024079
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:precision binary64
:alt
(if (< y -3693.8482788297247) (- (/ 1.0 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) (- (/ 1.0 y) (- (/ x y) x))))
(- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))