
(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 10 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 (/ (* (/ x (+ x y)) (/ y (+ x y))) (+ x (+ y 1.0))))
double code(double x, double y) {
return ((x / (x + y)) * (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 / (x + y)) * (y / (x + y))) / (x + (y + 1.0d0))
end function
public static double code(double x, double y) {
return ((x / (x + y)) * (y / (x + y))) / (x + (y + 1.0));
}
def code(x, y): return ((x / (x + y)) * (y / (x + y))) / (x + (y + 1.0))
function code(x, y) return Float64(Float64(Float64(x / Float64(x + y)) * Float64(y / Float64(x + y))) / Float64(x + Float64(y + 1.0))) end
function tmp = code(x, y) tmp = ((x / (x + y)) * (y / (x + y))) / (x + (y + 1.0)); end
code[x_, y_] := N[(N[(N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{x}{x + y} \cdot \frac{y}{x + y}}{x + \left(y + 1\right)}
\end{array}
Initial program 68.8%
times-frac89.5%
associate-*r/89.5%
pow289.5%
associate-+l+89.5%
Applied egg-rr89.5%
pow289.5%
associate-*l/73.7%
times-frac99.8%
+-commutative99.8%
+-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (<= x -5.5e+70)
(* (/ y (+ x y)) (/ 1.0 x))
(if (<= x -6.8e-161)
(/ (* x y) (* (* (+ x y) (+ x y)) (+ 1.0 (+ x y))))
(/ (/ x y) (+ y 1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -5.5e+70) {
tmp = (y / (x + y)) * (1.0 / x);
} else if (x <= -6.8e-161) {
tmp = (x * y) / (((x + y) * (x + y)) * (1.0 + (x + y)));
} 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 (x <= (-5.5d+70)) then
tmp = (y / (x + y)) * (1.0d0 / x)
else if (x <= (-6.8d-161)) then
tmp = (x * y) / (((x + y) * (x + y)) * (1.0d0 + (x + y)))
else
tmp = (x / y) / (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5.5e+70) {
tmp = (y / (x + y)) * (1.0 / x);
} else if (x <= -6.8e-161) {
tmp = (x * y) / (((x + y) * (x + y)) * (1.0 + (x + y)));
} else {
tmp = (x / y) / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.5e+70: tmp = (y / (x + y)) * (1.0 / x) elif x <= -6.8e-161: tmp = (x * y) / (((x + y) * (x + y)) * (1.0 + (x + y))) else: tmp = (x / y) / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -5.5e+70) tmp = Float64(Float64(y / Float64(x + y)) * Float64(1.0 / x)); elseif (x <= -6.8e-161) tmp = Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(1.0 + Float64(x + y)))); else tmp = Float64(Float64(x / y) / Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.5e+70) tmp = (y / (x + y)) * (1.0 / x); elseif (x <= -6.8e-161) tmp = (x * y) / (((x + y) * (x + y)) * (1.0 + (x + y))); else tmp = (x / y) / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.5e+70], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -6.8e-161], N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+70}:\\
\;\;\;\;\frac{y}{x + y} \cdot \frac{1}{x}\\
\mathbf{elif}\;x \leq -6.8 \cdot 10^{-161}:\\
\;\;\;\;\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(1 + \left(x + y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y + 1}\\
\end{array}
\end{array}
if x < -5.49999999999999986e70Initial program 39.7%
*-commutative39.7%
associate-*l*39.7%
times-frac81.7%
+-commutative81.7%
distribute-lft-in81.7%
*-rgt-identity81.7%
pow281.7%
Applied egg-rr81.7%
Taylor expanded in x around inf 76.1%
if -5.49999999999999986e70 < x < -6.79999999999999964e-161Initial program 90.8%
if -6.79999999999999964e-161 < x Initial program 69.1%
Taylor expanded in x around 0 51.7%
div-inv51.7%
+-commutative51.7%
Applied egg-rr51.7%
associate-*r/51.7%
*-rgt-identity51.7%
associate-/r*54.0%
Simplified54.0%
Final simplification65.9%
(FPCore (x y)
:precision binary64
(if (<= x -6e+164)
(* (/ y (+ x y)) (/ 1.0 x))
(if (<= x -5.05e-138)
(/ y (+ x (+ y (* (+ x y) (+ x y)))))
(/ (/ x y) (+ y 1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -6e+164) {
tmp = (y / (x + y)) * (1.0 / x);
} else if (x <= -5.05e-138) {
tmp = y / (x + (y + ((x + y) * (x + y))));
} 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 (x <= (-6d+164)) then
tmp = (y / (x + y)) * (1.0d0 / x)
else if (x <= (-5.05d-138)) then
tmp = y / (x + (y + ((x + y) * (x + y))))
else
tmp = (x / y) / (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -6e+164) {
tmp = (y / (x + y)) * (1.0 / x);
} else if (x <= -5.05e-138) {
tmp = y / (x + (y + ((x + y) * (x + y))));
} else {
tmp = (x / y) / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -6e+164: tmp = (y / (x + y)) * (1.0 / x) elif x <= -5.05e-138: tmp = y / (x + (y + ((x + y) * (x + y)))) else: tmp = (x / y) / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -6e+164) tmp = Float64(Float64(y / Float64(x + y)) * Float64(1.0 / x)); elseif (x <= -5.05e-138) tmp = Float64(y / Float64(x + Float64(y + Float64(Float64(x + y) * Float64(x + y))))); else tmp = Float64(Float64(x / y) / Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -6e+164) tmp = (y / (x + y)) * (1.0 / x); elseif (x <= -5.05e-138) tmp = y / (x + (y + ((x + y) * (x + y)))); else tmp = (x / y) / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -6e+164], N[(N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5.05e-138], N[(y / N[(x + N[(y + N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{+164}:\\
\;\;\;\;\frac{y}{x + y} \cdot \frac{1}{x}\\
\mathbf{elif}\;x \leq -5.05 \cdot 10^{-138}:\\
\;\;\;\;\frac{y}{x + \left(y + \left(x + y\right) \cdot \left(x + y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y + 1}\\
\end{array}
\end{array}
if x < -6.00000000000000001e164Initial program 42.1%
*-commutative42.1%
associate-*l*42.1%
times-frac72.2%
+-commutative72.2%
distribute-lft-in72.2%
*-rgt-identity72.2%
pow272.2%
Applied egg-rr72.2%
Taylor expanded in x around inf 87.0%
if -6.00000000000000001e164 < x < -5.0499999999999997e-138Initial program 77.2%
*-commutative77.2%
associate-*l*77.2%
times-frac98.4%
+-commutative98.4%
distribute-lft-in98.4%
*-rgt-identity98.4%
pow298.4%
Applied egg-rr98.4%
associate-*r/98.4%
associate-+l+98.4%
Applied egg-rr98.4%
unpow298.4%
Applied egg-rr98.4%
Taylor expanded in y around 0 73.9%
if -5.0499999999999997e-138 < x Initial program 70.2%
Taylor expanded in x around 0 53.5%
div-inv53.4%
+-commutative53.4%
Applied egg-rr53.4%
associate-*r/53.5%
*-rgt-identity53.5%
associate-/r*55.7%
Simplified55.7%
(FPCore (x y)
:precision binary64
(if (<= y 1e-175)
(/ (/ y x) (+ x 1.0))
(if (<= y 1.8e+155)
(/ x (+ x (+ y (* (+ x y) (+ x y)))))
(/ (/ x y) (+ y 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= 1e-175) {
tmp = (y / x) / (x + 1.0);
} else if (y <= 1.8e+155) {
tmp = x / (x + (y + ((x + y) * (x + y))));
} 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 <= 1d-175) then
tmp = (y / x) / (x + 1.0d0)
else if (y <= 1.8d+155) then
tmp = x / (x + (y + ((x + y) * (x + y))))
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 <= 1e-175) {
tmp = (y / x) / (x + 1.0);
} else if (y <= 1.8e+155) {
tmp = x / (x + (y + ((x + y) * (x + y))));
} else {
tmp = (x / y) / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1e-175: tmp = (y / x) / (x + 1.0) elif y <= 1.8e+155: tmp = x / (x + (y + ((x + y) * (x + y)))) else: tmp = (x / y) / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if (y <= 1e-175) tmp = Float64(Float64(y / x) / Float64(x + 1.0)); elseif (y <= 1.8e+155) tmp = Float64(x / Float64(x + Float64(y + Float64(Float64(x + y) * Float64(x + y))))); 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 <= 1e-175) tmp = (y / x) / (x + 1.0); elseif (y <= 1.8e+155) tmp = x / (x + (y + ((x + y) * (x + y)))); else tmp = (x / y) / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1e-175], N[(N[(y / x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+155], N[(x / N[(x + N[(y + N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{-175}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + 1}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+155}:\\
\;\;\;\;\frac{x}{x + \left(y + \left(x + y\right) \cdot \left(x + y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y + 1}\\
\end{array}
\end{array}
if y < 1e-175Initial program 69.3%
*-commutative69.3%
associate-*l*69.4%
times-frac96.6%
+-commutative96.6%
distribute-lft-in96.6%
*-rgt-identity96.6%
pow296.6%
Applied egg-rr96.6%
associate-*r/96.6%
associate-+l+96.6%
Applied egg-rr96.6%
Taylor expanded in y around 0 58.7%
*-rgt-identity58.7%
unpow258.7%
distribute-lft-in58.7%
associate-/r*60.2%
Simplified60.2%
if 1e-175 < y < 1.80000000000000004e155Initial program 68.5%
*-commutative68.5%
associate-*l*68.6%
times-frac92.2%
+-commutative92.2%
distribute-lft-in92.2%
*-rgt-identity92.2%
pow292.2%
Applied egg-rr92.2%
associate-*r/92.2%
associate-+l+92.2%
Applied egg-rr92.2%
unpow292.2%
Applied egg-rr92.2%
Taylor expanded in y around inf 65.0%
if 1.80000000000000004e155 < y Initial program 67.1%
Taylor expanded in x around 0 82.3%
div-inv82.3%
+-commutative82.3%
Applied egg-rr82.3%
associate-*r/82.3%
*-rgt-identity82.3%
associate-/r*96.8%
Simplified96.8%
Final simplification66.7%
(FPCore (x y) :precision binary64 (if (<= x -5.05e-138) (/ (/ y x) (+ x 1.0)) (/ (/ x y) (+ y 1.0))))
double code(double x, double y) {
double tmp;
if (x <= -5.05e-138) {
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 (x <= (-5.05d-138)) 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 (x <= -5.05e-138) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / y) / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.05e-138: tmp = (y / x) / (x + 1.0) else: tmp = (x / y) / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -5.05e-138) 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 (x <= -5.05e-138) tmp = (y / x) / (x + 1.0); else tmp = (x / y) / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.05e-138], 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}\;x \leq -5.05 \cdot 10^{-138}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y + 1}\\
\end{array}
\end{array}
if x < -5.0499999999999997e-138Initial program 66.4%
*-commutative66.4%
associate-*l*66.4%
times-frac90.3%
+-commutative90.3%
distribute-lft-in90.3%
*-rgt-identity90.3%
pow290.3%
Applied egg-rr90.3%
associate-*r/90.3%
associate-+l+90.3%
Applied egg-rr90.3%
Taylor expanded in y around 0 55.3%
*-rgt-identity55.3%
unpow255.3%
distribute-lft-in55.4%
associate-/r*59.8%
Simplified59.8%
if -5.0499999999999997e-138 < x Initial program 70.2%
Taylor expanded in x around 0 53.5%
div-inv53.4%
+-commutative53.4%
Applied egg-rr53.4%
associate-*r/53.5%
*-rgt-identity53.5%
associate-/r*55.7%
Simplified55.7%
Final simplification57.2%
(FPCore (x y) :precision binary64 (if (<= x -5.05e-138) (/ y (* x (+ x 1.0))) (/ (/ x y) (+ y 1.0))))
double code(double x, double y) {
double tmp;
if (x <= -5.05e-138) {
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 (x <= (-5.05d-138)) 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 (x <= -5.05e-138) {
tmp = y / (x * (x + 1.0));
} else {
tmp = (x / y) / (y + 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.05e-138: tmp = y / (x * (x + 1.0)) else: tmp = (x / y) / (y + 1.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -5.05e-138) tmp = Float64(y / Float64(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 (x <= -5.05e-138) tmp = y / (x * (x + 1.0)); else tmp = (x / y) / (y + 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.05e-138], N[(y / N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.05 \cdot 10^{-138}:\\
\;\;\;\;\frac{y}{x \cdot \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y + 1}\\
\end{array}
\end{array}
if x < -5.0499999999999997e-138Initial program 66.4%
Taylor expanded in y around 0 55.4%
if -5.0499999999999997e-138 < x Initial program 70.2%
Taylor expanded in x around 0 53.5%
div-inv53.4%
+-commutative53.4%
Applied egg-rr53.4%
associate-*r/53.5%
*-rgt-identity53.5%
associate-/r*55.7%
Simplified55.7%
Final simplification55.6%
(FPCore (x y) :precision binary64 (if (<= x -5.05e-138) (/ y (* x (+ x 1.0))) (/ x (* y (+ y 1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -5.05e-138) {
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 (x <= (-5.05d-138)) 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 (x <= -5.05e-138) {
tmp = y / (x * (x + 1.0));
} else {
tmp = x / (y * (y + 1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.05e-138: tmp = y / (x * (x + 1.0)) else: tmp = x / (y * (y + 1.0)) return tmp
function code(x, y) tmp = 0.0 if (x <= -5.05e-138) tmp = Float64(y / Float64(x * Float64(x + 1.0))); else tmp = Float64(x / Float64(y * Float64(y + 1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.05e-138) tmp = y / (x * (x + 1.0)); else tmp = x / (y * (y + 1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.05e-138], N[(y / N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.05 \cdot 10^{-138}:\\
\;\;\;\;\frac{y}{x \cdot \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \left(y + 1\right)}\\
\end{array}
\end{array}
if x < -5.0499999999999997e-138Initial program 66.4%
Taylor expanded in y around 0 55.4%
if -5.0499999999999997e-138 < x Initial program 70.2%
Taylor expanded in x around 0 53.5%
Final simplification54.2%
(FPCore (x y) :precision binary64 (if (<= y 1.9e-183) (/ y x) (/ x (* y (+ y 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= 1.9e-183) {
tmp = y / x;
} 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 <= 1.9d-183) then
tmp = y / x
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 <= 1.9e-183) {
tmp = y / x;
} else {
tmp = x / (y * (y + 1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.9e-183: tmp = y / x else: tmp = x / (y * (y + 1.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.9e-183) tmp = Float64(y / x); else tmp = Float64(x / Float64(y * Float64(y + 1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.9e-183) tmp = y / x; else tmp = x / (y * (y + 1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.9e-183], N[(y / x), $MachinePrecision], N[(x / N[(y * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{-183}:\\
\;\;\;\;\frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \left(y + 1\right)}\\
\end{array}
\end{array}
if y < 1.8999999999999998e-183Initial program 69.8%
*-commutative69.8%
associate-*l*69.8%
times-frac96.6%
+-commutative96.6%
distribute-lft-in96.6%
*-rgt-identity96.6%
pow296.6%
Applied egg-rr96.6%
associate-*r/96.6%
associate-+l+96.6%
Applied egg-rr96.6%
Taylor expanded in y around 0 59.1%
*-rgt-identity59.1%
unpow259.1%
distribute-lft-in59.1%
associate-/r*60.5%
Simplified60.5%
Taylor expanded in x around 0 40.0%
if 1.8999999999999998e-183 < y Initial program 67.4%
Taylor expanded in x around 0 57.9%
Final simplification47.5%
(FPCore (x y) :precision binary64 (if (<= x -5.05e-138) (/ y x) (/ x y)))
double code(double x, double y) {
double tmp;
if (x <= -5.05e-138) {
tmp = y / 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 <= (-5.05d-138)) then
tmp = y / x
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5.05e-138) {
tmp = y / x;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.05e-138: tmp = y / x else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -5.05e-138) tmp = Float64(y / x); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.05e-138) tmp = y / x; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.05e-138], N[(y / x), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.05 \cdot 10^{-138}:\\
\;\;\;\;\frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -5.0499999999999997e-138Initial program 66.4%
*-commutative66.4%
associate-*l*66.4%
times-frac90.3%
+-commutative90.3%
distribute-lft-in90.3%
*-rgt-identity90.3%
pow290.3%
Applied egg-rr90.3%
associate-*r/90.3%
associate-+l+90.3%
Applied egg-rr90.3%
Taylor expanded in y around 0 55.3%
*-rgt-identity55.3%
unpow255.3%
distribute-lft-in55.4%
associate-/r*59.8%
Simplified59.8%
Taylor expanded in x around 0 28.8%
if -5.0499999999999997e-138 < x Initial program 70.2%
Taylor expanded in x around 0 53.5%
Taylor expanded in y around 0 35.8%
(FPCore (x y) :precision binary64 (/ x y))
double code(double x, double y) {
return x / y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / y
end function
public static double code(double x, double y) {
return x / y;
}
def code(x, y): return x / y
function code(x, y) return Float64(x / y) end
function tmp = code(x, y) tmp = x / y; end
code[x_, y_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y}
\end{array}
Initial program 68.8%
Taylor expanded in x around 0 47.7%
Taylor expanded in y around 0 25.6%
(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 2024096
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
:precision binary64
:alt
(/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x))))
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))