
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
(FPCore (x y) :precision binary64 (/ (* (/ y (+ y x)) (/ x (+ y (+ x 1.0)))) (+ y x)))
double code(double x, double y) {
return ((y / (y + x)) * (x / (y + (x + 1.0)))) / (y + x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((y / (y + x)) * (x / (y + (x + 1.0d0)))) / (y + x)
end function
public static double code(double x, double y) {
return ((y / (y + x)) * (x / (y + (x + 1.0)))) / (y + x);
}
def code(x, y): return ((y / (y + x)) * (x / (y + (x + 1.0)))) / (y + x)
function code(x, y) return Float64(Float64(Float64(y / Float64(y + x)) * Float64(x / Float64(y + Float64(x + 1.0)))) / Float64(y + x)) end
function tmp = code(x, y) tmp = ((y / (y + x)) * (x / (y + (x + 1.0)))) / (y + x); end
code[x_, y_] := N[(N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{y + x} \cdot \frac{x}{y + \left(x + 1\right)}}{y + x}
\end{array}
Initial program 74.3%
associate-*l*74.3%
+-commutative74.3%
+-commutative74.3%
+-commutative74.3%
associate-*l*74.3%
associate-*l/83.7%
*-commutative83.7%
*-commutative83.7%
distribute-rgt1-in66.5%
fma-def83.7%
+-commutative83.7%
+-commutative83.7%
cube-unmult83.7%
+-commutative83.7%
Simplified83.7%
associate-*r/74.3%
fma-udef60.0%
cube-mult59.9%
distribute-rgt1-in74.3%
associate-+r+74.3%
*-commutative74.3%
frac-times88.3%
associate-/r*99.8%
associate-*l/99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= y 1.3e-89)
(/ (/ y x) (+ x 1.0))
(if (<= y 1.1e+95)
(/ (* y x) (* (+ y 1.0) (* (+ y x) (+ y x))))
(/ (/ x (+ y (+ x 1.0))) (+ y (* x 2.0))))))
double code(double x, double y) {
double tmp;
if (y <= 1.3e-89) {
tmp = (y / x) / (x + 1.0);
} else if (y <= 1.1e+95) {
tmp = (y * x) / ((y + 1.0) * ((y + x) * (y + x)));
} else {
tmp = (x / (y + (x + 1.0))) / (y + (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 <= 1.3d-89) then
tmp = (y / x) / (x + 1.0d0)
else if (y <= 1.1d+95) then
tmp = (y * x) / ((y + 1.0d0) * ((y + x) * (y + x)))
else
tmp = (x / (y + (x + 1.0d0))) / (y + (x * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.3e-89) {
tmp = (y / x) / (x + 1.0);
} else if (y <= 1.1e+95) {
tmp = (y * x) / ((y + 1.0) * ((y + x) * (y + x)));
} else {
tmp = (x / (y + (x + 1.0))) / (y + (x * 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.3e-89: tmp = (y / x) / (x + 1.0) elif y <= 1.1e+95: tmp = (y * x) / ((y + 1.0) * ((y + x) * (y + x))) else: tmp = (x / (y + (x + 1.0))) / (y + (x * 2.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.3e-89) tmp = Float64(Float64(y / x) / Float64(x + 1.0)); elseif (y <= 1.1e+95) tmp = Float64(Float64(y * x) / Float64(Float64(y + 1.0) * Float64(Float64(y + x) * Float64(y + x)))); else tmp = Float64(Float64(x / Float64(y + Float64(x + 1.0))) / Float64(y + Float64(x * 2.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.3e-89) tmp = (y / x) / (x + 1.0); elseif (y <= 1.1e+95) tmp = (y * x) / ((y + 1.0) * ((y + x) * (y + x))); else tmp = (x / (y + (x + 1.0))) / (y + (x * 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.3e-89], N[(N[(y / x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+95], N[(N[(y * x), $MachinePrecision] / N[(N[(y + 1.0), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.3 \cdot 10^{-89}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + 1}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+95}:\\
\;\;\;\;\frac{y \cdot x}{\left(y + 1\right) \cdot \left(\left(y + x\right) \cdot \left(y + x\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + \left(x + 1\right)}}{y + x \cdot 2}\\
\end{array}
\end{array}
if y < 1.2999999999999999e-89Initial program 78.1%
associate-*l*78.1%
+-commutative78.1%
+-commutative78.1%
+-commutative78.1%
associate-*l*78.1%
*-commutative78.1%
times-frac88.4%
+-commutative88.4%
+-commutative88.4%
+-commutative88.4%
associate-+l+88.4%
Simplified88.4%
Taylor expanded in y around 0 54.7%
associate-/r*59.0%
+-commutative59.0%
Simplified59.0%
if 1.2999999999999999e-89 < y < 1.0999999999999999e95Initial program 93.6%
Taylor expanded in x around 0 90.8%
+-commutative90.8%
Simplified90.8%
if 1.0999999999999999e95 < y Initial program 52.4%
associate-+r+52.4%
*-commutative52.4%
frac-times81.3%
associate-*l/81.3%
times-frac99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
Applied egg-rr99.9%
clear-num99.9%
+-commutative99.9%
frac-times98.8%
*-un-lft-identity98.8%
+-commutative98.8%
+-commutative98.8%
Applied egg-rr98.8%
Taylor expanded in y around inf 86.0%
*-commutative86.0%
Simplified86.0%
Final simplification69.6%
(FPCore (x y) :precision binary64 (if (<= y 1.5) (/ (* (/ y (+ y x)) (/ x (+ x 1.0))) (+ y x)) (/ (/ x (+ y (+ x 1.0))) (+ y (* x 2.0)))))
double code(double x, double y) {
double tmp;
if (y <= 1.5) {
tmp = ((y / (y + x)) * (x / (x + 1.0))) / (y + x);
} else {
tmp = (x / (y + (x + 1.0))) / (y + (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 <= 1.5d0) then
tmp = ((y / (y + x)) * (x / (x + 1.0d0))) / (y + x)
else
tmp = (x / (y + (x + 1.0d0))) / (y + (x * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.5) {
tmp = ((y / (y + x)) * (x / (x + 1.0))) / (y + x);
} else {
tmp = (x / (y + (x + 1.0))) / (y + (x * 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.5: tmp = ((y / (y + x)) * (x / (x + 1.0))) / (y + x) else: tmp = (x / (y + (x + 1.0))) / (y + (x * 2.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.5) tmp = Float64(Float64(Float64(y / Float64(y + x)) * Float64(x / Float64(x + 1.0))) / Float64(y + x)); else tmp = Float64(Float64(x / Float64(y + Float64(x + 1.0))) / Float64(y + Float64(x * 2.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.5) tmp = ((y / (y + x)) * (x / (x + 1.0))) / (y + x); else tmp = (x / (y + (x + 1.0))) / (y + (x * 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.5], N[(N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5:\\
\;\;\;\;\frac{\frac{y}{y + x} \cdot \frac{x}{x + 1}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + \left(x + 1\right)}}{y + x \cdot 2}\\
\end{array}
\end{array}
if y < 1.5Initial program 79.0%
associate-*l*79.0%
+-commutative79.0%
+-commutative79.0%
+-commutative79.0%
associate-*l*79.0%
associate-*l/85.6%
*-commutative85.6%
*-commutative85.6%
distribute-rgt1-in63.9%
fma-def85.7%
+-commutative85.7%
+-commutative85.7%
cube-unmult85.7%
+-commutative85.7%
Simplified85.7%
associate-*r/79.1%
fma-udef59.2%
cube-mult59.2%
distribute-rgt1-in79.0%
associate-+r+79.0%
*-commutative79.0%
frac-times89.5%
associate-/r*99.8%
associate-*l/99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 82.0%
+-commutative82.0%
Simplified82.0%
if 1.5 < y Initial program 63.0%
associate-+r+63.0%
*-commutative63.0%
frac-times85.4%
associate-*l/85.4%
times-frac99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
Applied egg-rr99.9%
clear-num99.8%
+-commutative99.8%
frac-times99.0%
*-un-lft-identity99.0%
+-commutative99.0%
+-commutative99.0%
Applied egg-rr99.0%
Taylor expanded in y around inf 86.6%
*-commutative86.6%
Simplified86.6%
Final simplification83.4%
(FPCore (x y) :precision binary64 (if (<= y 2.5e-42) (/ (* (/ y (+ y x)) (/ x (+ x 1.0))) (+ y x)) (/ (/ x (+ y 1.0)) (* (+ y x) (/ (+ y x) y)))))
double code(double x, double y) {
double tmp;
if (y <= 2.5e-42) {
tmp = ((y / (y + x)) * (x / (x + 1.0))) / (y + x);
} else {
tmp = (x / (y + 1.0)) / ((y + x) * ((y + 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 <= 2.5d-42) then
tmp = ((y / (y + x)) * (x / (x + 1.0d0))) / (y + x)
else
tmp = (x / (y + 1.0d0)) / ((y + x) * ((y + x) / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 2.5e-42) {
tmp = ((y / (y + x)) * (x / (x + 1.0))) / (y + x);
} else {
tmp = (x / (y + 1.0)) / ((y + x) * ((y + x) / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.5e-42: tmp = ((y / (y + x)) * (x / (x + 1.0))) / (y + x) else: tmp = (x / (y + 1.0)) / ((y + x) * ((y + x) / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= 2.5e-42) tmp = Float64(Float64(Float64(y / Float64(y + x)) * Float64(x / Float64(x + 1.0))) / Float64(y + x)); else tmp = Float64(Float64(x / Float64(y + 1.0)) / Float64(Float64(y + x) * Float64(Float64(y + x) / y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.5e-42) tmp = ((y / (y + x)) * (x / (x + 1.0))) / (y + x); else tmp = (x / (y + 1.0)) / ((y + x) * ((y + x) / y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.5e-42], N[(N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] * N[(N[(y + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.5 \cdot 10^{-42}:\\
\;\;\;\;\frac{\frac{y}{y + x} \cdot \frac{x}{x + 1}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + 1}}{\left(y + x\right) \cdot \frac{y + x}{y}}\\
\end{array}
\end{array}
if y < 2.50000000000000001e-42Initial program 78.6%
associate-*l*78.6%
+-commutative78.6%
+-commutative78.6%
+-commutative78.6%
associate-*l*78.6%
associate-*l/85.5%
*-commutative85.5%
*-commutative85.5%
distribute-rgt1-in62.6%
fma-def85.5%
+-commutative85.5%
+-commutative85.5%
cube-unmult85.5%
+-commutative85.5%
Simplified85.5%
associate-*r/78.7%
fma-udef57.8%
cube-mult57.7%
distribute-rgt1-in78.6%
associate-+r+78.6%
*-commutative78.6%
frac-times89.0%
associate-/r*99.8%
associate-*l/99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 81.4%
+-commutative81.4%
Simplified81.4%
if 2.50000000000000001e-42 < y Initial program 65.5%
associate-+r+65.5%
*-commutative65.5%
frac-times86.9%
associate-*l/86.6%
times-frac99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
Applied egg-rr99.8%
clear-num99.8%
+-commutative99.8%
frac-times99.0%
*-un-lft-identity99.0%
+-commutative99.0%
+-commutative99.0%
Applied egg-rr99.0%
Taylor expanded in x around 0 95.3%
+-commutative95.3%
Simplified95.3%
Final simplification86.0%
(FPCore (x y) :precision binary64 (* (/ y (+ y x)) (/ (/ x (+ y (+ x 1.0))) (+ y x))))
double code(double x, double y) {
return (y / (y + x)) * ((x / (y + (x + 1.0))) / (y + x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y / (y + x)) * ((x / (y + (x + 1.0d0))) / (y + x))
end function
public static double code(double x, double y) {
return (y / (y + x)) * ((x / (y + (x + 1.0))) / (y + x));
}
def code(x, y): return (y / (y + x)) * ((x / (y + (x + 1.0))) / (y + x))
function code(x, y) return Float64(Float64(y / Float64(y + x)) * Float64(Float64(x / Float64(y + Float64(x + 1.0))) / Float64(y + x))) end
function tmp = code(x, y) tmp = (y / (y + x)) * ((x / (y + (x + 1.0))) / (y + x)); end
code[x_, y_] := N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(N[(x / N[(y + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{y + x} \cdot \frac{\frac{x}{y + \left(x + 1\right)}}{y + x}
\end{array}
Initial program 74.3%
associate-+r+74.3%
*-commutative74.3%
frac-times88.3%
associate-*l/84.5%
times-frac99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= y 3e-88) (/ (/ y x) (+ x 1.0)) (/ (/ x (+ y (+ x 1.0))) (+ y (* x 2.0)))))
double code(double x, double y) {
double tmp;
if (y <= 3e-88) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / (y + (x + 1.0))) / (y + (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 <= 3d-88) then
tmp = (y / x) / (x + 1.0d0)
else
tmp = (x / (y + (x + 1.0d0))) / (y + (x * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 3e-88) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / (y + (x + 1.0))) / (y + (x * 2.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 3e-88: tmp = (y / x) / (x + 1.0) else: tmp = (x / (y + (x + 1.0))) / (y + (x * 2.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 3e-88) tmp = Float64(Float64(y / x) / Float64(x + 1.0)); else tmp = Float64(Float64(x / Float64(y + Float64(x + 1.0))) / Float64(y + Float64(x * 2.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3e-88) tmp = (y / x) / (x + 1.0); else tmp = (x / (y + (x + 1.0))) / (y + (x * 2.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 3e-88], N[(N[(y / x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3 \cdot 10^{-88}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + \left(x + 1\right)}}{y + x \cdot 2}\\
\end{array}
\end{array}
if y < 2.9999999999999999e-88Initial program 78.1%
associate-*l*78.1%
+-commutative78.1%
+-commutative78.1%
+-commutative78.1%
associate-*l*78.1%
*-commutative78.1%
times-frac88.4%
+-commutative88.4%
+-commutative88.4%
+-commutative88.4%
associate-+l+88.4%
Simplified88.4%
Taylor expanded in y around 0 54.7%
associate-/r*59.0%
+-commutative59.0%
Simplified59.0%
if 2.9999999999999999e-88 < y Initial program 67.7%
associate-+r+67.7%
*-commutative67.7%
frac-times88.1%
associate-*l/86.8%
times-frac99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
Applied egg-rr99.8%
clear-num99.8%
+-commutative99.8%
frac-times99.1%
*-un-lft-identity99.1%
+-commutative99.1%
+-commutative99.1%
Applied egg-rr99.1%
Taylor expanded in y around inf 79.6%
*-commutative79.6%
Simplified79.6%
Final simplification66.5%
(FPCore (x y) :precision binary64 (if (<= y 1.85e-88) (/ (/ y x) (+ x 1.0)) (/ (/ (- x) (+ y x)) (- -1.0 (+ y x)))))
double code(double x, double y) {
double tmp;
if (y <= 1.85e-88) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (-x / (y + x)) / (-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.85d-88) then
tmp = (y / x) / (x + 1.0d0)
else
tmp = (-x / (y + x)) / ((-1.0d0) - (y + x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.85e-88) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (-x / (y + x)) / (-1.0 - (y + x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.85e-88: tmp = (y / x) / (x + 1.0) else: tmp = (-x / (y + x)) / (-1.0 - (y + x)) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.85e-88) tmp = Float64(Float64(y / x) / Float64(x + 1.0)); else tmp = Float64(Float64(Float64(-x) / Float64(y + x)) / Float64(-1.0 - Float64(y + x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.85e-88) tmp = (y / x) / (x + 1.0); else tmp = (-x / (y + x)) / (-1.0 - (y + x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.85e-88], N[(N[(y / x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[((-x) / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(-1.0 - N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.85 \cdot 10^{-88}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-x}{y + x}}{-1 - \left(y + x\right)}\\
\end{array}
\end{array}
if y < 1.8499999999999999e-88Initial program 78.1%
associate-*l*78.1%
+-commutative78.1%
+-commutative78.1%
+-commutative78.1%
associate-*l*78.1%
*-commutative78.1%
times-frac88.4%
+-commutative88.4%
+-commutative88.4%
+-commutative88.4%
associate-+l+88.4%
Simplified88.4%
Taylor expanded in y around 0 54.7%
associate-/r*59.0%
+-commutative59.0%
Simplified59.0%
if 1.8499999999999999e-88 < y Initial program 67.7%
associate-*l*67.7%
+-commutative67.7%
+-commutative67.7%
+-commutative67.7%
associate-*l*67.7%
associate-*l/82.0%
*-commutative82.0%
*-commutative82.0%
distribute-rgt1-in74.7%
fma-def82.0%
+-commutative82.0%
+-commutative82.0%
cube-unmult81.9%
+-commutative81.9%
Simplified81.9%
associate-*r/67.7%
fma-udef64.5%
cube-mult64.6%
distribute-rgt1-in67.7%
associate-+r+67.7%
*-commutative67.7%
frac-times88.1%
associate-/r*99.8%
frac-2neg99.8%
frac-times88.2%
+-commutative88.2%
+-commutative88.2%
associate-+r+88.2%
+-commutative88.2%
distribute-neg-in88.2%
metadata-eval88.2%
+-commutative88.2%
Applied egg-rr88.2%
associate-/r*99.9%
associate-*l/74.6%
distribute-rgt-neg-out74.6%
*-commutative74.6%
distribute-rgt-neg-in74.6%
+-commutative74.6%
+-commutative74.6%
unsub-neg74.6%
+-commutative74.6%
Simplified74.6%
Taylor expanded in x around 0 79.1%
neg-mul-179.1%
Simplified79.1%
Final simplification66.3%
(FPCore (x y) :precision binary64 (if (<= y 8e-84) (/ (/ y x) (+ x 1.0)) (/ (/ x (+ y 1.0)) (+ y x))))
double code(double x, double y) {
double tmp;
if (y <= 8e-84) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / (y + 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 <= 8d-84) then
tmp = (y / x) / (x + 1.0d0)
else
tmp = (x / (y + 1.0d0)) / (y + x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 8e-84) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / (y + 1.0)) / (y + x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8e-84: tmp = (y / x) / (x + 1.0) else: tmp = (x / (y + 1.0)) / (y + x) return tmp
function code(x, y) tmp = 0.0 if (y <= 8e-84) tmp = Float64(Float64(y / x) / Float64(x + 1.0)); else tmp = Float64(Float64(x / Float64(y + 1.0)) / Float64(y + x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 8e-84) tmp = (y / x) / (x + 1.0); else tmp = (x / (y + 1.0)) / (y + x); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8e-84], N[(N[(y / x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{-84}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + 1}}{y + x}\\
\end{array}
\end{array}
if y < 8.0000000000000003e-84Initial program 78.2%
associate-*l*78.2%
+-commutative78.2%
+-commutative78.2%
+-commutative78.2%
associate-*l*78.2%
*-commutative78.2%
times-frac88.5%
+-commutative88.5%
+-commutative88.5%
+-commutative88.5%
associate-+l+88.5%
Simplified88.5%
Taylor expanded in y around 0 54.4%
associate-/r*58.6%
+-commutative58.6%
Simplified58.6%
if 8.0000000000000003e-84 < y Initial program 67.4%
associate-*l*67.4%
+-commutative67.4%
+-commutative67.4%
+-commutative67.4%
associate-*l*67.4%
associate-*l/81.8%
*-commutative81.8%
*-commutative81.8%
distribute-rgt1-in74.4%
fma-def81.8%
+-commutative81.8%
+-commutative81.8%
cube-unmult81.7%
+-commutative81.7%
Simplified81.7%
associate-*r/67.4%
fma-udef64.2%
cube-mult64.2%
distribute-rgt1-in67.4%
associate-+r+67.4%
*-commutative67.4%
frac-times88.0%
associate-/r*99.8%
associate-*l/99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 78.1%
+-commutative78.1%
Simplified78.1%
Final simplification65.7%
(FPCore (x y) :precision binary64 (if (<= y 0.76) (- (/ x y) x) (* (/ x y) (/ 1.0 y))))
double code(double x, double y) {
double tmp;
if (y <= 0.76) {
tmp = (x / y) - x;
} else {
tmp = (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 <= 0.76d0) then
tmp = (x / y) - x
else
tmp = (x / y) * (1.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 0.76) {
tmp = (x / y) - x;
} else {
tmp = (x / y) * (1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 0.76: tmp = (x / y) - x else: tmp = (x / y) * (1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 0.76) tmp = Float64(Float64(x / y) - x); else tmp = Float64(Float64(x / y) * Float64(1.0 / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 0.76) tmp = (x / y) - x; else tmp = (x / y) * (1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 0.76], N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.76:\\
\;\;\;\;\frac{x}{y} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{1}{y}\\
\end{array}
\end{array}
if y < 0.76000000000000001Initial program 79.0%
associate-*l*79.0%
+-commutative79.0%
+-commutative79.0%
+-commutative79.0%
associate-*l*79.0%
*-commutative79.0%
times-frac89.5%
+-commutative89.5%
+-commutative89.5%
+-commutative89.5%
associate-+l+89.5%
Simplified89.5%
Taylor expanded in x around 0 42.0%
+-commutative42.0%
Simplified42.0%
Taylor expanded in y around 0 18.7%
neg-mul-118.7%
+-commutative18.7%
unsub-neg18.7%
Simplified18.7%
if 0.76000000000000001 < y Initial program 63.0%
associate-*l*62.9%
+-commutative62.9%
+-commutative62.9%
+-commutative62.9%
associate-*l*63.0%
*-commutative63.0%
times-frac85.4%
+-commutative85.4%
+-commutative85.4%
+-commutative85.4%
associate-+l+85.4%
Simplified85.4%
Taylor expanded in y around inf 85.6%
Taylor expanded in y around inf 82.9%
Final simplification37.7%
(FPCore (x y) :precision binary64 (if (<= y 30000000000000.0) (/ x (* y (+ y 1.0))) (* (/ x y) (/ 1.0 y))))
double code(double x, double y) {
double tmp;
if (y <= 30000000000000.0) {
tmp = x / (y * (y + 1.0));
} else {
tmp = (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 <= 30000000000000.0d0) then
tmp = x / (y * (y + 1.0d0))
else
tmp = (x / y) * (1.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 30000000000000.0) {
tmp = x / (y * (y + 1.0));
} else {
tmp = (x / y) * (1.0 / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 30000000000000.0: tmp = x / (y * (y + 1.0)) else: tmp = (x / y) * (1.0 / y) return tmp
function code(x, y) tmp = 0.0 if (y <= 30000000000000.0) tmp = Float64(x / Float64(y * Float64(y + 1.0))); else tmp = Float64(Float64(x / y) * Float64(1.0 / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 30000000000000.0) tmp = x / (y * (y + 1.0)); else tmp = (x / y) * (1.0 / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 30000000000000.0], N[(x / N[(y * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 30000000000000:\\
\;\;\;\;\frac{x}{y \cdot \left(y + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{1}{y}\\
\end{array}
\end{array}
if y < 3e13Initial program 79.7%
associate-*l*79.7%
+-commutative79.7%
+-commutative79.7%
+-commutative79.7%
associate-*l*79.7%
*-commutative79.7%
times-frac89.8%
+-commutative89.8%
+-commutative89.8%
+-commutative89.8%
associate-+l+89.8%
Simplified89.8%
Taylor expanded in x around 0 42.8%
+-commutative42.8%
Simplified42.8%
if 3e13 < y Initial program 59.8%
associate-*l*59.8%
+-commutative59.8%
+-commutative59.8%
+-commutative59.8%
associate-*l*59.8%
*-commutative59.8%
times-frac84.2%
+-commutative84.2%
+-commutative84.2%
+-commutative84.2%
associate-+l+84.2%
Simplified84.2%
Taylor expanded in y around inf 87.2%
Taylor expanded in y around inf 86.9%
Final simplification54.9%
(FPCore (x y) :precision binary64 (if (<= y 8e-84) (/ (/ y x) (+ x 1.0)) (/ (/ x y) (+ y 1.0))))
double code(double x, double y) {
double tmp;
if (y <= 8e-84) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / y) / (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 <= 8d-84) then
tmp = (y / x) / (x + 1.0d0)
else
tmp = (x / y) / (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 8e-84) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / y) / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8e-84: tmp = (y / x) / (x + 1.0) else: tmp = (x / y) / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if (y <= 8e-84) tmp = Float64(Float64(y / x) / Float64(x + 1.0)); else tmp = Float64(Float64(x / y) / Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 8e-84) tmp = (y / x) / (x + 1.0); else tmp = (x / y) / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8e-84], N[(N[(y / x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{-84}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y + 1}\\
\end{array}
\end{array}
if y < 8.0000000000000003e-84Initial program 78.2%
associate-*l*78.2%
+-commutative78.2%
+-commutative78.2%
+-commutative78.2%
associate-*l*78.2%
*-commutative78.2%
times-frac88.5%
+-commutative88.5%
+-commutative88.5%
+-commutative88.5%
associate-+l+88.5%
Simplified88.5%
Taylor expanded in y around 0 54.4%
associate-/r*58.6%
+-commutative58.6%
Simplified58.6%
if 8.0000000000000003e-84 < y Initial program 67.4%
associate-*l*67.4%
+-commutative67.4%
+-commutative67.4%
+-commutative67.4%
associate-*l*67.4%
associate-*l/81.8%
*-commutative81.8%
*-commutative81.8%
distribute-rgt1-in74.4%
fma-def81.8%
+-commutative81.8%
+-commutative81.8%
cube-unmult81.7%
+-commutative81.7%
Simplified81.7%
associate-*r/67.4%
fma-udef64.2%
cube-mult64.2%
distribute-rgt1-in67.4%
associate-+r+67.4%
*-commutative67.4%
frac-times88.0%
associate-/r*99.8%
associate-*l/99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
Applied egg-rr99.9%
add-cube-cbrt99.7%
pow399.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 71.7%
associate-/r*77.8%
Simplified77.8%
Final simplification65.6%
(FPCore (x y) :precision binary64 (/ (/ x y) (+ y 1.0)))
double code(double x, double y) {
return (x / y) / (y + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / y) / (y + 1.0d0)
end function
public static double code(double x, double y) {
return (x / y) / (y + 1.0);
}
def code(x, y): return (x / y) / (y + 1.0)
function code(x, y) return Float64(Float64(x / y) / Float64(y + 1.0)) end
function tmp = code(x, y) tmp = (x / y) / (y + 1.0); end
code[x_, y_] := N[(N[(x / y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{x}{y}}{y + 1}
\end{array}
Initial program 74.3%
associate-*l*74.3%
+-commutative74.3%
+-commutative74.3%
+-commutative74.3%
associate-*l*74.3%
associate-*l/83.7%
*-commutative83.7%
*-commutative83.7%
distribute-rgt1-in66.5%
fma-def83.7%
+-commutative83.7%
+-commutative83.7%
cube-unmult83.7%
+-commutative83.7%
Simplified83.7%
associate-*r/74.3%
fma-udef60.0%
cube-mult59.9%
distribute-rgt1-in74.3%
associate-+r+74.3%
*-commutative74.3%
frac-times88.3%
associate-/r*99.8%
associate-*l/99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
Applied egg-rr99.9%
add-cube-cbrt99.4%
pow399.4%
Applied egg-rr99.4%
Taylor expanded in x around 0 52.7%
associate-/r*55.4%
Simplified55.4%
Final simplification55.4%
(FPCore (x y) :precision binary64 (if (<= x -6.5) (/ 1.0 x) (/ x y)))
double code(double x, double y) {
double tmp;
if (x <= -6.5) {
tmp = 1.0 / x;
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-6.5d0)) then
tmp = 1.0d0 / x
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -6.5) {
tmp = 1.0 / x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -6.5: tmp = 1.0 / x else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -6.5) tmp = Float64(1.0 / x); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -6.5) tmp = 1.0 / x; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -6.5], N[(1.0 / x), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -6.5Initial program 67.3%
associate-+r+67.3%
*-commutative67.3%
frac-times82.3%
associate-*l/82.3%
times-frac99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 75.7%
Taylor expanded in y around inf 6.2%
if -6.5 < x Initial program 76.8%
associate-*l*76.8%
+-commutative76.8%
+-commutative76.8%
+-commutative76.8%
associate-*l*76.8%
*-commutative76.8%
times-frac90.4%
+-commutative90.4%
+-commutative90.4%
+-commutative90.4%
associate-+l+90.4%
Simplified90.4%
Taylor expanded in x around 0 64.9%
+-commutative64.9%
Simplified64.9%
Taylor expanded in y around 0 34.2%
Final simplification26.7%
(FPCore (x y) :precision binary64 (/ 1.0 x))
double code(double x, double y) {
return 1.0 / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 / x
end function
public static double code(double x, double y) {
return 1.0 / x;
}
def code(x, y): return 1.0 / x
function code(x, y) return Float64(1.0 / x) end
function tmp = code(x, y) tmp = 1.0 / x; end
code[x_, y_] := N[(1.0 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x}
\end{array}
Initial program 74.3%
associate-+r+74.3%
*-commutative74.3%
frac-times88.3%
associate-*l/84.5%
times-frac99.9%
+-commutative99.9%
+-commutative99.9%
associate-+l+99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 36.2%
Taylor expanded in y around inf 4.1%
Final simplification4.1%
(FPCore (x y) :precision binary64 (/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x)))))
double code(double x, double y) {
return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / ((y + 1.0d0) + x)) / (y + x)) / (1.0d0 / (y / (y + x)))
end function
public static double code(double x, double y) {
return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)));
}
def code(x, y): return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)))
function code(x, y) return Float64(Float64(Float64(x / Float64(Float64(y + 1.0) + x)) / Float64(y + x)) / Float64(1.0 / Float64(y / Float64(y + x)))) end
function tmp = code(x, y) tmp = ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x))); end
code[x_, y_] := N[(N[(N[(x / N[(N[(y + 1.0), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{x}{\left(y + 1\right) + x}}{y + x}}{\frac{1}{\frac{y}{y + x}}}
\end{array}
herbie shell --seed 2024010
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
:precision binary64
:herbie-target
(/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x))))
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))