
(FPCore (alpha beta) :precision binary64 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0))
double code(double alpha, double beta) {
return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
}
real(8) function code(alpha, beta)
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
code = (((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0
end function
public static double code(double alpha, double beta) {
return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
}
def code(alpha, beta): return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0
function code(alpha, beta) return Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) end
function tmp = code(alpha, beta) tmp = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0; end
code[alpha_, beta_] := N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (alpha beta) :precision binary64 (/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0))
double code(double alpha, double beta) {
return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
}
real(8) function code(alpha, beta)
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
code = (((beta - alpha) / ((alpha + beta) + 2.0d0)) + 1.0d0) / 2.0d0
end function
public static double code(double alpha, double beta) {
return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0;
}
def code(alpha, beta): return (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0
function code(alpha, beta) return Float64(Float64(Float64(Float64(beta - alpha) / Float64(Float64(alpha + beta) + 2.0)) + 1.0) / 2.0) end
function tmp = code(alpha, beta) tmp = (((beta - alpha) / ((alpha + beta) + 2.0)) + 1.0) / 2.0; end
code[alpha_, beta_] := N[(N[(N[(N[(beta - alpha), $MachinePrecision] / N[(N[(alpha + beta), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\beta - \alpha}{\left(\alpha + \beta\right) + 2} + 1}{2}
\end{array}
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (/ (- beta alpha) (+ (+ beta alpha) 2.0))))
(if (<= t_0 -0.5)
(/
(+
(* (- (- -2.0 beta) beta) (/ (+ beta 2.0) (pow alpha 2.0)))
(/ (+ beta (- beta -2.0)) alpha))
2.0)
(/ (+ t_0 1.0) 2.0))))
double code(double alpha, double beta) {
double t_0 = (beta - alpha) / ((beta + alpha) + 2.0);
double tmp;
if (t_0 <= -0.5) {
tmp = ((((-2.0 - beta) - beta) * ((beta + 2.0) / pow(alpha, 2.0))) + ((beta + (beta - -2.0)) / alpha)) / 2.0;
} else {
tmp = (t_0 + 1.0) / 2.0;
}
return tmp;
}
real(8) function code(alpha, beta)
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
real(8) :: tmp
t_0 = (beta - alpha) / ((beta + alpha) + 2.0d0)
if (t_0 <= (-0.5d0)) then
tmp = (((((-2.0d0) - beta) - beta) * ((beta + 2.0d0) / (alpha ** 2.0d0))) + ((beta + (beta - (-2.0d0))) / alpha)) / 2.0d0
else
tmp = (t_0 + 1.0d0) / 2.0d0
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double t_0 = (beta - alpha) / ((beta + alpha) + 2.0);
double tmp;
if (t_0 <= -0.5) {
tmp = ((((-2.0 - beta) - beta) * ((beta + 2.0) / Math.pow(alpha, 2.0))) + ((beta + (beta - -2.0)) / alpha)) / 2.0;
} else {
tmp = (t_0 + 1.0) / 2.0;
}
return tmp;
}
def code(alpha, beta): t_0 = (beta - alpha) / ((beta + alpha) + 2.0) tmp = 0 if t_0 <= -0.5: tmp = ((((-2.0 - beta) - beta) * ((beta + 2.0) / math.pow(alpha, 2.0))) + ((beta + (beta - -2.0)) / alpha)) / 2.0 else: tmp = (t_0 + 1.0) / 2.0 return tmp
function code(alpha, beta) t_0 = Float64(Float64(beta - alpha) / Float64(Float64(beta + alpha) + 2.0)) tmp = 0.0 if (t_0 <= -0.5) tmp = Float64(Float64(Float64(Float64(Float64(-2.0 - beta) - beta) * Float64(Float64(beta + 2.0) / (alpha ^ 2.0))) + Float64(Float64(beta + Float64(beta - -2.0)) / alpha)) / 2.0); else tmp = Float64(Float64(t_0 + 1.0) / 2.0); end return tmp end
function tmp_2 = code(alpha, beta) t_0 = (beta - alpha) / ((beta + alpha) + 2.0); tmp = 0.0; if (t_0 <= -0.5) tmp = ((((-2.0 - beta) - beta) * ((beta + 2.0) / (alpha ^ 2.0))) + ((beta + (beta - -2.0)) / alpha)) / 2.0; else tmp = (t_0 + 1.0) / 2.0; end tmp_2 = tmp; end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(beta - alpha), $MachinePrecision] / N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.5], N[(N[(N[(N[(N[(-2.0 - beta), $MachinePrecision] - beta), $MachinePrecision] * N[(N[(beta + 2.0), $MachinePrecision] / N[Power[alpha, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(beta + N[(beta - -2.0), $MachinePrecision]), $MachinePrecision] / alpha), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\beta - \alpha}{\left(\beta + \alpha\right) + 2}\\
\mathbf{if}\;t\_0 \leq -0.5:\\
\;\;\;\;\frac{\left(\left(-2 - \beta\right) - \beta\right) \cdot \frac{\beta + 2}{{\alpha}^{2}} + \frac{\beta + \left(\beta - -2\right)}{\alpha}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 + 1}{2}\\
\end{array}
\end{array}
if (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) 2)) < -0.5Initial program 6.7%
+-commutative6.7%
Simplified6.7%
Taylor expanded in alpha around -inf 91.3%
mul-1-neg91.3%
unsub-neg91.3%
Simplified99.9%
if -0.5 < (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) 2)) Initial program 100.0%
Final simplification100.0%
(FPCore (alpha beta) :precision binary64 (if (<= (/ (- beta alpha) (+ (+ beta alpha) 2.0)) -0.99999998) (/ (+ beta 1.0) alpha) (/ (fma (/ 1.0 (+ beta (+ alpha 2.0))) (- beta alpha) 1.0) 2.0)))
double code(double alpha, double beta) {
double tmp;
if (((beta - alpha) / ((beta + alpha) + 2.0)) <= -0.99999998) {
tmp = (beta + 1.0) / alpha;
} else {
tmp = fma((1.0 / (beta + (alpha + 2.0))), (beta - alpha), 1.0) / 2.0;
}
return tmp;
}
function code(alpha, beta) tmp = 0.0 if (Float64(Float64(beta - alpha) / Float64(Float64(beta + alpha) + 2.0)) <= -0.99999998) tmp = Float64(Float64(beta + 1.0) / alpha); else tmp = Float64(fma(Float64(1.0 / Float64(beta + Float64(alpha + 2.0))), Float64(beta - alpha), 1.0) / 2.0); end return tmp end
code[alpha_, beta_] := If[LessEqual[N[(N[(beta - alpha), $MachinePrecision] / N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], -0.99999998], N[(N[(beta + 1.0), $MachinePrecision] / alpha), $MachinePrecision], N[(N[(N[(1.0 / N[(beta + N[(alpha + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(beta - alpha), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\beta - \alpha}{\left(\beta + \alpha\right) + 2} \leq -0.99999998:\\
\;\;\;\;\frac{\beta + 1}{\alpha}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{\beta + \left(\alpha + 2\right)}, \beta - \alpha, 1\right)}{2}\\
\end{array}
\end{array}
if (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) 2)) < -0.999999980000000011Initial program 5.8%
+-commutative5.8%
Simplified5.8%
Taylor expanded in alpha around inf 99.7%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in beta around 0 99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in beta around 0 99.7%
*-rgt-identity99.7%
associate-*r/99.6%
distribute-rgt1-in99.6%
associate-*r/99.7%
+-commutative99.7%
*-rgt-identity99.7%
Simplified99.7%
if -0.999999980000000011 < (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) 2)) Initial program 99.8%
+-commutative99.8%
Simplified99.8%
clear-num99.8%
associate-/r/99.8%
fma-define99.8%
associate-+l+99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (alpha beta) :precision binary64 (let* ((t_0 (/ (- beta alpha) (+ (+ beta alpha) 2.0)))) (if (<= t_0 -0.99999998) (/ (+ beta 1.0) alpha) (/ (+ t_0 1.0) 2.0))))
double code(double alpha, double beta) {
double t_0 = (beta - alpha) / ((beta + alpha) + 2.0);
double tmp;
if (t_0 <= -0.99999998) {
tmp = (beta + 1.0) / alpha;
} else {
tmp = (t_0 + 1.0) / 2.0;
}
return tmp;
}
real(8) function code(alpha, beta)
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
real(8) :: tmp
t_0 = (beta - alpha) / ((beta + alpha) + 2.0d0)
if (t_0 <= (-0.99999998d0)) then
tmp = (beta + 1.0d0) / alpha
else
tmp = (t_0 + 1.0d0) / 2.0d0
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double t_0 = (beta - alpha) / ((beta + alpha) + 2.0);
double tmp;
if (t_0 <= -0.99999998) {
tmp = (beta + 1.0) / alpha;
} else {
tmp = (t_0 + 1.0) / 2.0;
}
return tmp;
}
def code(alpha, beta): t_0 = (beta - alpha) / ((beta + alpha) + 2.0) tmp = 0 if t_0 <= -0.99999998: tmp = (beta + 1.0) / alpha else: tmp = (t_0 + 1.0) / 2.0 return tmp
function code(alpha, beta) t_0 = Float64(Float64(beta - alpha) / Float64(Float64(beta + alpha) + 2.0)) tmp = 0.0 if (t_0 <= -0.99999998) tmp = Float64(Float64(beta + 1.0) / alpha); else tmp = Float64(Float64(t_0 + 1.0) / 2.0); end return tmp end
function tmp_2 = code(alpha, beta) t_0 = (beta - alpha) / ((beta + alpha) + 2.0); tmp = 0.0; if (t_0 <= -0.99999998) tmp = (beta + 1.0) / alpha; else tmp = (t_0 + 1.0) / 2.0; end tmp_2 = tmp; end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(beta - alpha), $MachinePrecision] / N[(N[(beta + alpha), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.99999998], N[(N[(beta + 1.0), $MachinePrecision] / alpha), $MachinePrecision], N[(N[(t$95$0 + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\beta - \alpha}{\left(\beta + \alpha\right) + 2}\\
\mathbf{if}\;t\_0 \leq -0.99999998:\\
\;\;\;\;\frac{\beta + 1}{\alpha}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 + 1}{2}\\
\end{array}
\end{array}
if (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) 2)) < -0.999999980000000011Initial program 5.8%
+-commutative5.8%
Simplified5.8%
Taylor expanded in alpha around inf 99.7%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in beta around 0 99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in beta around 0 99.7%
*-rgt-identity99.7%
associate-*r/99.6%
distribute-rgt1-in99.6%
associate-*r/99.7%
+-commutative99.7%
*-rgt-identity99.7%
Simplified99.7%
if -0.999999980000000011 < (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) 2)) Initial program 99.8%
Final simplification99.8%
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (+ 0.5 (* alpha -0.25))))
(if (<= alpha -1.15e-111)
t_0
(if (<= alpha -5.4e-151)
1.0
(if (<= alpha 1.95) t_0 (/ (+ beta 1.0) alpha))))))
double code(double alpha, double beta) {
double t_0 = 0.5 + (alpha * -0.25);
double tmp;
if (alpha <= -1.15e-111) {
tmp = t_0;
} else if (alpha <= -5.4e-151) {
tmp = 1.0;
} else if (alpha <= 1.95) {
tmp = t_0;
} else {
tmp = (beta + 1.0) / alpha;
}
return tmp;
}
real(8) function code(alpha, beta)
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: t_0
real(8) :: tmp
t_0 = 0.5d0 + (alpha * (-0.25d0))
if (alpha <= (-1.15d-111)) then
tmp = t_0
else if (alpha <= (-5.4d-151)) then
tmp = 1.0d0
else if (alpha <= 1.95d0) then
tmp = t_0
else
tmp = (beta + 1.0d0) / alpha
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double t_0 = 0.5 + (alpha * -0.25);
double tmp;
if (alpha <= -1.15e-111) {
tmp = t_0;
} else if (alpha <= -5.4e-151) {
tmp = 1.0;
} else if (alpha <= 1.95) {
tmp = t_0;
} else {
tmp = (beta + 1.0) / alpha;
}
return tmp;
}
def code(alpha, beta): t_0 = 0.5 + (alpha * -0.25) tmp = 0 if alpha <= -1.15e-111: tmp = t_0 elif alpha <= -5.4e-151: tmp = 1.0 elif alpha <= 1.95: tmp = t_0 else: tmp = (beta + 1.0) / alpha return tmp
function code(alpha, beta) t_0 = Float64(0.5 + Float64(alpha * -0.25)) tmp = 0.0 if (alpha <= -1.15e-111) tmp = t_0; elseif (alpha <= -5.4e-151) tmp = 1.0; elseif (alpha <= 1.95) tmp = t_0; else tmp = Float64(Float64(beta + 1.0) / alpha); end return tmp end
function tmp_2 = code(alpha, beta) t_0 = 0.5 + (alpha * -0.25); tmp = 0.0; if (alpha <= -1.15e-111) tmp = t_0; elseif (alpha <= -5.4e-151) tmp = 1.0; elseif (alpha <= 1.95) tmp = t_0; else tmp = (beta + 1.0) / alpha; end tmp_2 = tmp; end
code[alpha_, beta_] := Block[{t$95$0 = N[(0.5 + N[(alpha * -0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[alpha, -1.15e-111], t$95$0, If[LessEqual[alpha, -5.4e-151], 1.0, If[LessEqual[alpha, 1.95], t$95$0, N[(N[(beta + 1.0), $MachinePrecision] / alpha), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + \alpha \cdot -0.25\\
\mathbf{if}\;\alpha \leq -1.15 \cdot 10^{-111}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\alpha \leq -5.4 \cdot 10^{-151}:\\
\;\;\;\;1\\
\mathbf{elif}\;\alpha \leq 1.95:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\beta + 1}{\alpha}\\
\end{array}
\end{array}
if alpha < -1.15e-111 or -5.40000000000000014e-151 < alpha < 1.94999999999999996Initial program 100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in beta around 0 72.0%
+-commutative72.0%
Simplified72.0%
Taylor expanded in alpha around 0 71.5%
*-commutative71.5%
Simplified71.5%
if -1.15e-111 < alpha < -5.40000000000000014e-151Initial program 100.0%
+-commutative100.0%
Simplified100.0%
clear-num100.0%
associate-/r/100.0%
fma-define100.0%
associate-+l+100.0%
Applied egg-rr100.0%
Taylor expanded in beta around inf 91.0%
if 1.94999999999999996 < alpha Initial program 23.2%
+-commutative23.2%
Simplified23.2%
Taylor expanded in alpha around inf 82.6%
associate-*r/82.6%
Simplified82.6%
Taylor expanded in beta around 0 82.6%
+-commutative82.6%
Simplified82.6%
Taylor expanded in beta around 0 82.6%
*-rgt-identity82.6%
associate-*r/82.6%
distribute-rgt1-in82.6%
associate-*r/82.6%
+-commutative82.6%
*-rgt-identity82.6%
Simplified82.6%
Final simplification75.9%
(FPCore (alpha beta) :precision binary64 (if (<= beta 1.02e-41) 0.5 (if (<= beta 7.5e-34) (/ 1.0 alpha) (if (<= beta 2.05) 0.5 1.0))))
double code(double alpha, double beta) {
double tmp;
if (beta <= 1.02e-41) {
tmp = 0.5;
} else if (beta <= 7.5e-34) {
tmp = 1.0 / alpha;
} else if (beta <= 2.05) {
tmp = 0.5;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(alpha, beta)
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 1.02d-41) then
tmp = 0.5d0
else if (beta <= 7.5d-34) then
tmp = 1.0d0 / alpha
else if (beta <= 2.05d0) then
tmp = 0.5d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 1.02e-41) {
tmp = 0.5;
} else if (beta <= 7.5e-34) {
tmp = 1.0 / alpha;
} else if (beta <= 2.05) {
tmp = 0.5;
} else {
tmp = 1.0;
}
return tmp;
}
def code(alpha, beta): tmp = 0 if beta <= 1.02e-41: tmp = 0.5 elif beta <= 7.5e-34: tmp = 1.0 / alpha elif beta <= 2.05: tmp = 0.5 else: tmp = 1.0 return tmp
function code(alpha, beta) tmp = 0.0 if (beta <= 1.02e-41) tmp = 0.5; elseif (beta <= 7.5e-34) tmp = Float64(1.0 / alpha); elseif (beta <= 2.05) tmp = 0.5; else tmp = 1.0; end return tmp end
function tmp_2 = code(alpha, beta) tmp = 0.0; if (beta <= 1.02e-41) tmp = 0.5; elseif (beta <= 7.5e-34) tmp = 1.0 / alpha; elseif (beta <= 2.05) tmp = 0.5; else tmp = 1.0; end tmp_2 = tmp; end
code[alpha_, beta_] := If[LessEqual[beta, 1.02e-41], 0.5, If[LessEqual[beta, 7.5e-34], N[(1.0 / alpha), $MachinePrecision], If[LessEqual[beta, 2.05], 0.5, 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 1.02 \cdot 10^{-41}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;\beta \leq 7.5 \cdot 10^{-34}:\\
\;\;\;\;\frac{1}{\alpha}\\
\mathbf{elif}\;\beta \leq 2.05:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if beta < 1.02e-41 or 7.5000000000000004e-34 < beta < 2.0499999999999998Initial program 71.3%
+-commutative71.3%
Simplified71.3%
Taylor expanded in beta around 0 70.3%
+-commutative70.3%
Simplified70.3%
Taylor expanded in alpha around 0 68.3%
if 1.02e-41 < beta < 7.5000000000000004e-34Initial program 5.9%
+-commutative5.9%
Simplified5.9%
Taylor expanded in beta around 0 5.9%
+-commutative5.9%
Simplified5.9%
Taylor expanded in alpha around inf 100.0%
Taylor expanded in alpha around 0 100.0%
if 2.0499999999999998 < beta Initial program 83.5%
+-commutative83.5%
Simplified83.5%
clear-num83.5%
associate-/r/83.6%
fma-define83.5%
associate-+l+83.5%
Applied egg-rr83.5%
Taylor expanded in beta around inf 82.9%
Final simplification74.2%
(FPCore (alpha beta) :precision binary64 (if (<= alpha 6.6e+16) (/ (+ (/ beta (+ beta 2.0)) 1.0) 2.0) (/ (+ beta 1.0) alpha)))
double code(double alpha, double beta) {
double tmp;
if (alpha <= 6.6e+16) {
tmp = ((beta / (beta + 2.0)) + 1.0) / 2.0;
} else {
tmp = (beta + 1.0) / alpha;
}
return tmp;
}
real(8) function code(alpha, beta)
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (alpha <= 6.6d+16) then
tmp = ((beta / (beta + 2.0d0)) + 1.0d0) / 2.0d0
else
tmp = (beta + 1.0d0) / alpha
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double tmp;
if (alpha <= 6.6e+16) {
tmp = ((beta / (beta + 2.0)) + 1.0) / 2.0;
} else {
tmp = (beta + 1.0) / alpha;
}
return tmp;
}
def code(alpha, beta): tmp = 0 if alpha <= 6.6e+16: tmp = ((beta / (beta + 2.0)) + 1.0) / 2.0 else: tmp = (beta + 1.0) / alpha return tmp
function code(alpha, beta) tmp = 0.0 if (alpha <= 6.6e+16) tmp = Float64(Float64(Float64(beta / Float64(beta + 2.0)) + 1.0) / 2.0); else tmp = Float64(Float64(beta + 1.0) / alpha); end return tmp end
function tmp_2 = code(alpha, beta) tmp = 0.0; if (alpha <= 6.6e+16) tmp = ((beta / (beta + 2.0)) + 1.0) / 2.0; else tmp = (beta + 1.0) / alpha; end tmp_2 = tmp; end
code[alpha_, beta_] := If[LessEqual[alpha, 6.6e+16], N[(N[(N[(beta / N[(beta + 2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(beta + 1.0), $MachinePrecision] / alpha), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\alpha \leq 6.6 \cdot 10^{+16}:\\
\;\;\;\;\frac{\frac{\beta}{\beta + 2} + 1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\beta + 1}{\alpha}\\
\end{array}
\end{array}
if alpha < 6.6e16Initial program 99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in alpha around 0 97.7%
if 6.6e16 < alpha Initial program 19.4%
+-commutative19.4%
Simplified19.4%
Taylor expanded in alpha around inf 85.9%
associate-*r/85.9%
Simplified85.9%
Taylor expanded in beta around 0 85.9%
+-commutative85.9%
Simplified85.9%
Taylor expanded in beta around 0 85.9%
*-rgt-identity85.9%
associate-*r/85.8%
distribute-rgt1-in85.8%
associate-*r/85.9%
+-commutative85.9%
*-rgt-identity85.9%
Simplified85.9%
Final simplification94.0%
(FPCore (alpha beta) :precision binary64 (if (<= beta 2.05) 0.5 1.0))
double code(double alpha, double beta) {
double tmp;
if (beta <= 2.05) {
tmp = 0.5;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(alpha, beta)
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (beta <= 2.05d0) then
tmp = 0.5d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double tmp;
if (beta <= 2.05) {
tmp = 0.5;
} else {
tmp = 1.0;
}
return tmp;
}
def code(alpha, beta): tmp = 0 if beta <= 2.05: tmp = 0.5 else: tmp = 1.0 return tmp
function code(alpha, beta) tmp = 0.0 if (beta <= 2.05) tmp = 0.5; else tmp = 1.0; end return tmp end
function tmp_2 = code(alpha, beta) tmp = 0.0; if (beta <= 2.05) tmp = 0.5; else tmp = 1.0; end tmp_2 = tmp; end
code[alpha_, beta_] := If[LessEqual[beta, 2.05], 0.5, 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 2.05:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if beta < 2.0499999999999998Initial program 69.3%
+-commutative69.3%
Simplified69.3%
Taylor expanded in beta around 0 68.4%
+-commutative68.4%
Simplified68.4%
Taylor expanded in alpha around 0 66.3%
if 2.0499999999999998 < beta Initial program 83.5%
+-commutative83.5%
Simplified83.5%
clear-num83.5%
associate-/r/83.6%
fma-define83.5%
associate-+l+83.5%
Applied egg-rr83.5%
Taylor expanded in beta around inf 82.9%
Final simplification72.3%
(FPCore (alpha beta) :precision binary64 0.5)
double code(double alpha, double beta) {
return 0.5;
}
real(8) function code(alpha, beta)
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
code = 0.5d0
end function
public static double code(double alpha, double beta) {
return 0.5;
}
def code(alpha, beta): return 0.5
function code(alpha, beta) return 0.5 end
function tmp = code(alpha, beta) tmp = 0.5; end
code[alpha_, beta_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 74.5%
+-commutative74.5%
Simplified74.5%
Taylor expanded in beta around 0 48.6%
+-commutative48.6%
Simplified48.6%
Taylor expanded in alpha around 0 48.2%
Final simplification48.2%
herbie shell --seed 2024050
(FPCore (alpha beta)
:name "Octave 3.8, jcobi/1"
:precision binary64
:pre (and (> alpha -1.0) (> beta -1.0))
(/ (+ (/ (- beta alpha) (+ (+ alpha beta) 2.0)) 1.0) 2.0))