
(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 9 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 (if (<= (/ (- beta alpha) (+ (+ beta alpha) 2.0)) -1.0) (/ (/ (+ 2.0 (* beta 2.0)) alpha) 2.0) (/ (exp (log1p (/ (- beta alpha) (+ beta (+ alpha 2.0))))) 2.0)))
double code(double alpha, double beta) {
double tmp;
if (((beta - alpha) / ((beta + alpha) + 2.0)) <= -1.0) {
tmp = ((2.0 + (beta * 2.0)) / alpha) / 2.0;
} else {
tmp = exp(log1p(((beta - alpha) / (beta + (alpha + 2.0))))) / 2.0;
}
return tmp;
}
public static double code(double alpha, double beta) {
double tmp;
if (((beta - alpha) / ((beta + alpha) + 2.0)) <= -1.0) {
tmp = ((2.0 + (beta * 2.0)) / alpha) / 2.0;
} else {
tmp = Math.exp(Math.log1p(((beta - alpha) / (beta + (alpha + 2.0))))) / 2.0;
}
return tmp;
}
def code(alpha, beta): tmp = 0 if ((beta - alpha) / ((beta + alpha) + 2.0)) <= -1.0: tmp = ((2.0 + (beta * 2.0)) / alpha) / 2.0 else: tmp = math.exp(math.log1p(((beta - alpha) / (beta + (alpha + 2.0))))) / 2.0 return tmp
function code(alpha, beta) tmp = 0.0 if (Float64(Float64(beta - alpha) / Float64(Float64(beta + alpha) + 2.0)) <= -1.0) tmp = Float64(Float64(Float64(2.0 + Float64(beta * 2.0)) / alpha) / 2.0); else tmp = Float64(exp(log1p(Float64(Float64(beta - alpha) / Float64(beta + Float64(alpha + 2.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], -1.0], N[(N[(N[(2.0 + N[(beta * 2.0), $MachinePrecision]), $MachinePrecision] / alpha), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[Exp[N[Log[1 + N[(N[(beta - alpha), $MachinePrecision] / N[(beta + N[(alpha + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\beta - \alpha}{\left(\beta + \alpha\right) + 2} \leq -1:\\
\;\;\;\;\frac{\frac{2 + \beta \cdot 2}{\alpha}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\mathsf{log1p}\left(\frac{\beta - \alpha}{\beta + \left(\alpha + 2\right)}\right)}}{2}\\
\end{array}
\end{array}
if (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) 2)) < -1Initial program 5.5%
+-commutative5.5%
Simplified5.5%
Taylor expanded in alpha around inf 100.0%
if -1 < (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) 2)) Initial program 100.0%
+-commutative100.0%
Simplified100.0%
flip3-+99.9%
add-exp-log99.9%
flip3-+100.0%
+-commutative100.0%
log1p-udef100.0%
div-inv99.9%
div-inv100.0%
associate-+l+100.0%
Applied egg-rr100.0%
+-commutative100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (/ (- beta alpha) (+ (+ beta alpha) 2.0))))
(if (<= t_0 -1.0)
(/ (/ (+ 2.0 (* 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 <= -1.0) {
tmp = ((2.0 + (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 <= (-1.0d0)) then
tmp = ((2.0d0 + (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 <= -1.0) {
tmp = ((2.0 + (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 <= -1.0: tmp = ((2.0 + (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 <= -1.0) tmp = Float64(Float64(Float64(2.0 + 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 <= -1.0) tmp = ((2.0 + (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, -1.0], N[(N[(N[(2.0 + N[(beta * 2.0), $MachinePrecision]), $MachinePrecision] / alpha), $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 -1:\\
\;\;\;\;\frac{\frac{2 + \beta \cdot 2}{\alpha}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 + 1}{2}\\
\end{array}
\end{array}
if (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) 2)) < -1Initial program 5.5%
+-commutative5.5%
Simplified5.5%
Taylor expanded in alpha around inf 100.0%
if -1 < (/.f64 (-.f64 beta alpha) (+.f64 (+.f64 alpha beta) 2)) Initial program 100.0%
Final simplification100.0%
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (/ (+ 1.0 (* beta 0.5)) 2.0)))
(if (<= beta -3e-207)
t_0
(if (<= beta -2.5e-266)
(/ (/ 2.0 alpha) 2.0)
(if (<= beta 2.0) t_0 1.0)))))
double code(double alpha, double beta) {
double t_0 = (1.0 + (beta * 0.5)) / 2.0;
double tmp;
if (beta <= -3e-207) {
tmp = t_0;
} else if (beta <= -2.5e-266) {
tmp = (2.0 / alpha) / 2.0;
} else if (beta <= 2.0) {
tmp = t_0;
} else {
tmp = 1.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 = (1.0d0 + (beta * 0.5d0)) / 2.0d0
if (beta <= (-3d-207)) then
tmp = t_0
else if (beta <= (-2.5d-266)) then
tmp = (2.0d0 / alpha) / 2.0d0
else if (beta <= 2.0d0) then
tmp = t_0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double t_0 = (1.0 + (beta * 0.5)) / 2.0;
double tmp;
if (beta <= -3e-207) {
tmp = t_0;
} else if (beta <= -2.5e-266) {
tmp = (2.0 / alpha) / 2.0;
} else if (beta <= 2.0) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(alpha, beta): t_0 = (1.0 + (beta * 0.5)) / 2.0 tmp = 0 if beta <= -3e-207: tmp = t_0 elif beta <= -2.5e-266: tmp = (2.0 / alpha) / 2.0 elif beta <= 2.0: tmp = t_0 else: tmp = 1.0 return tmp
function code(alpha, beta) t_0 = Float64(Float64(1.0 + Float64(beta * 0.5)) / 2.0) tmp = 0.0 if (beta <= -3e-207) tmp = t_0; elseif (beta <= -2.5e-266) tmp = Float64(Float64(2.0 / alpha) / 2.0); elseif (beta <= 2.0) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(alpha, beta) t_0 = (1.0 + (beta * 0.5)) / 2.0; tmp = 0.0; if (beta <= -3e-207) tmp = t_0; elseif (beta <= -2.5e-266) tmp = (2.0 / alpha) / 2.0; elseif (beta <= 2.0) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(1.0 + N[(beta * 0.5), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[beta, -3e-207], t$95$0, If[LessEqual[beta, -2.5e-266], N[(N[(2.0 / alpha), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[beta, 2.0], t$95$0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 + \beta \cdot 0.5}{2}\\
\mathbf{if}\;\beta \leq -3 \cdot 10^{-207}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\beta \leq -2.5 \cdot 10^{-266}:\\
\;\;\;\;\frac{\frac{2}{\alpha}}{2}\\
\mathbf{elif}\;\beta \leq 2:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if beta < -2.9999999999999999e-207 or -2.49999999999999996e-266 < beta < 2Initial program 68.9%
+-commutative68.9%
Simplified68.9%
Taylor expanded in alpha around 0 67.5%
Taylor expanded in beta around 0 67.1%
*-commutative67.1%
Simplified67.1%
if -2.9999999999999999e-207 < beta < -2.49999999999999996e-266Initial program 32.8%
+-commutative32.8%
Simplified32.8%
Taylor expanded in alpha around inf 73.0%
Taylor expanded in beta around 0 73.0%
if 2 < beta Initial program 93.2%
+-commutative93.2%
Simplified93.2%
Taylor expanded in beta around inf 90.4%
Final simplification75.0%
(FPCore (alpha beta)
:precision binary64
(let* ((t_0 (/ (+ 1.0 (* beta 0.5)) 2.0)))
(if (<= beta -3e-207)
t_0
(if (<= beta -2.05e-266)
(/ (/ 2.0 alpha) 2.0)
(if (<= beta 2.0) t_0 (/ (- 2.0 (/ 2.0 beta)) 2.0))))))
double code(double alpha, double beta) {
double t_0 = (1.0 + (beta * 0.5)) / 2.0;
double tmp;
if (beta <= -3e-207) {
tmp = t_0;
} else if (beta <= -2.05e-266) {
tmp = (2.0 / alpha) / 2.0;
} else if (beta <= 2.0) {
tmp = t_0;
} else {
tmp = (2.0 - (2.0 / beta)) / 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 = (1.0d0 + (beta * 0.5d0)) / 2.0d0
if (beta <= (-3d-207)) then
tmp = t_0
else if (beta <= (-2.05d-266)) then
tmp = (2.0d0 / alpha) / 2.0d0
else if (beta <= 2.0d0) then
tmp = t_0
else
tmp = (2.0d0 - (2.0d0 / beta)) / 2.0d0
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double t_0 = (1.0 + (beta * 0.5)) / 2.0;
double tmp;
if (beta <= -3e-207) {
tmp = t_0;
} else if (beta <= -2.05e-266) {
tmp = (2.0 / alpha) / 2.0;
} else if (beta <= 2.0) {
tmp = t_0;
} else {
tmp = (2.0 - (2.0 / beta)) / 2.0;
}
return tmp;
}
def code(alpha, beta): t_0 = (1.0 + (beta * 0.5)) / 2.0 tmp = 0 if beta <= -3e-207: tmp = t_0 elif beta <= -2.05e-266: tmp = (2.0 / alpha) / 2.0 elif beta <= 2.0: tmp = t_0 else: tmp = (2.0 - (2.0 / beta)) / 2.0 return tmp
function code(alpha, beta) t_0 = Float64(Float64(1.0 + Float64(beta * 0.5)) / 2.0) tmp = 0.0 if (beta <= -3e-207) tmp = t_0; elseif (beta <= -2.05e-266) tmp = Float64(Float64(2.0 / alpha) / 2.0); elseif (beta <= 2.0) tmp = t_0; else tmp = Float64(Float64(2.0 - Float64(2.0 / beta)) / 2.0); end return tmp end
function tmp_2 = code(alpha, beta) t_0 = (1.0 + (beta * 0.5)) / 2.0; tmp = 0.0; if (beta <= -3e-207) tmp = t_0; elseif (beta <= -2.05e-266) tmp = (2.0 / alpha) / 2.0; elseif (beta <= 2.0) tmp = t_0; else tmp = (2.0 - (2.0 / beta)) / 2.0; end tmp_2 = tmp; end
code[alpha_, beta_] := Block[{t$95$0 = N[(N[(1.0 + N[(beta * 0.5), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[beta, -3e-207], t$95$0, If[LessEqual[beta, -2.05e-266], N[(N[(2.0 / alpha), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[beta, 2.0], t$95$0, N[(N[(2.0 - N[(2.0 / beta), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 + \beta \cdot 0.5}{2}\\
\mathbf{if}\;\beta \leq -3 \cdot 10^{-207}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\beta \leq -2.05 \cdot 10^{-266}:\\
\;\;\;\;\frac{\frac{2}{\alpha}}{2}\\
\mathbf{elif}\;\beta \leq 2:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{2 - \frac{2}{\beta}}{2}\\
\end{array}
\end{array}
if beta < -2.9999999999999999e-207 or -2.0500000000000001e-266 < beta < 2Initial program 68.9%
+-commutative68.9%
Simplified68.9%
Taylor expanded in alpha around 0 67.5%
Taylor expanded in beta around 0 67.1%
*-commutative67.1%
Simplified67.1%
if -2.9999999999999999e-207 < beta < -2.0500000000000001e-266Initial program 32.8%
+-commutative32.8%
Simplified32.8%
Taylor expanded in alpha around inf 73.0%
Taylor expanded in beta around 0 73.0%
if 2 < beta Initial program 93.2%
+-commutative93.2%
Simplified93.2%
Taylor expanded in alpha around 0 93.3%
Taylor expanded in beta around inf 91.9%
associate-*r/91.9%
metadata-eval91.9%
Simplified91.9%
Final simplification75.5%
(FPCore (alpha beta) :precision binary64 (if (<= alpha 8.8e+23) (/ (+ 1.0 (/ beta (+ beta 2.0))) 2.0) (/ (/ 2.0 alpha) 2.0)))
double code(double alpha, double beta) {
double tmp;
if (alpha <= 8.8e+23) {
tmp = (1.0 + (beta / (beta + 2.0))) / 2.0;
} else {
tmp = (2.0 / alpha) / 2.0;
}
return tmp;
}
real(8) function code(alpha, beta)
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (alpha <= 8.8d+23) then
tmp = (1.0d0 + (beta / (beta + 2.0d0))) / 2.0d0
else
tmp = (2.0d0 / alpha) / 2.0d0
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double tmp;
if (alpha <= 8.8e+23) {
tmp = (1.0 + (beta / (beta + 2.0))) / 2.0;
} else {
tmp = (2.0 / alpha) / 2.0;
}
return tmp;
}
def code(alpha, beta): tmp = 0 if alpha <= 8.8e+23: tmp = (1.0 + (beta / (beta + 2.0))) / 2.0 else: tmp = (2.0 / alpha) / 2.0 return tmp
function code(alpha, beta) tmp = 0.0 if (alpha <= 8.8e+23) tmp = Float64(Float64(1.0 + Float64(beta / Float64(beta + 2.0))) / 2.0); else tmp = Float64(Float64(2.0 / alpha) / 2.0); end return tmp end
function tmp_2 = code(alpha, beta) tmp = 0.0; if (alpha <= 8.8e+23) tmp = (1.0 + (beta / (beta + 2.0))) / 2.0; else tmp = (2.0 / alpha) / 2.0; end tmp_2 = tmp; end
code[alpha_, beta_] := If[LessEqual[alpha, 8.8e+23], N[(N[(1.0 + N[(beta / N[(beta + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 / alpha), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\alpha \leq 8.8 \cdot 10^{+23}:\\
\;\;\;\;\frac{1 + \frac{\beta}{\beta + 2}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{\alpha}}{2}\\
\end{array}
\end{array}
if alpha < 8.80000000000000034e23Initial program 99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in alpha around 0 98.3%
if 8.80000000000000034e23 < alpha Initial program 20.9%
+-commutative20.9%
Simplified20.9%
Taylor expanded in alpha around inf 84.7%
Taylor expanded in beta around 0 76.1%
Final simplification91.4%
(FPCore (alpha beta) :precision binary64 (if (<= alpha 3.3e+23) (/ (+ 1.0 (/ beta (+ beta 2.0))) 2.0) (/ (/ (+ 2.0 (* beta 2.0)) alpha) 2.0)))
double code(double alpha, double beta) {
double tmp;
if (alpha <= 3.3e+23) {
tmp = (1.0 + (beta / (beta + 2.0))) / 2.0;
} else {
tmp = ((2.0 + (beta * 2.0)) / alpha) / 2.0;
}
return tmp;
}
real(8) function code(alpha, beta)
real(8), intent (in) :: alpha
real(8), intent (in) :: beta
real(8) :: tmp
if (alpha <= 3.3d+23) then
tmp = (1.0d0 + (beta / (beta + 2.0d0))) / 2.0d0
else
tmp = ((2.0d0 + (beta * 2.0d0)) / alpha) / 2.0d0
end if
code = tmp
end function
public static double code(double alpha, double beta) {
double tmp;
if (alpha <= 3.3e+23) {
tmp = (1.0 + (beta / (beta + 2.0))) / 2.0;
} else {
tmp = ((2.0 + (beta * 2.0)) / alpha) / 2.0;
}
return tmp;
}
def code(alpha, beta): tmp = 0 if alpha <= 3.3e+23: tmp = (1.0 + (beta / (beta + 2.0))) / 2.0 else: tmp = ((2.0 + (beta * 2.0)) / alpha) / 2.0 return tmp
function code(alpha, beta) tmp = 0.0 if (alpha <= 3.3e+23) tmp = Float64(Float64(1.0 + Float64(beta / Float64(beta + 2.0))) / 2.0); else tmp = Float64(Float64(Float64(2.0 + Float64(beta * 2.0)) / alpha) / 2.0); end return tmp end
function tmp_2 = code(alpha, beta) tmp = 0.0; if (alpha <= 3.3e+23) tmp = (1.0 + (beta / (beta + 2.0))) / 2.0; else tmp = ((2.0 + (beta * 2.0)) / alpha) / 2.0; end tmp_2 = tmp; end
code[alpha_, beta_] := If[LessEqual[alpha, 3.3e+23], N[(N[(1.0 + N[(beta / N[(beta + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(2.0 + N[(beta * 2.0), $MachinePrecision]), $MachinePrecision] / alpha), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\alpha \leq 3.3 \cdot 10^{+23}:\\
\;\;\;\;\frac{1 + \frac{\beta}{\beta + 2}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2 + \beta \cdot 2}{\alpha}}{2}\\
\end{array}
\end{array}
if alpha < 3.30000000000000029e23Initial program 99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in alpha around 0 98.3%
if 3.30000000000000029e23 < alpha Initial program 20.9%
+-commutative20.9%
Simplified20.9%
Taylor expanded in alpha around inf 84.7%
Final simplification94.1%
(FPCore (alpha beta) :precision binary64 (if (<= beta -3e-207) 0.5 (if (<= beta -2.45e-266) (/ (/ 2.0 alpha) 2.0) (if (<= beta 2.0) 0.5 1.0))))
double code(double alpha, double beta) {
double tmp;
if (beta <= -3e-207) {
tmp = 0.5;
} else if (beta <= -2.45e-266) {
tmp = (2.0 / alpha) / 2.0;
} else if (beta <= 2.0) {
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 <= (-3d-207)) then
tmp = 0.5d0
else if (beta <= (-2.45d-266)) then
tmp = (2.0d0 / alpha) / 2.0d0
else if (beta <= 2.0d0) 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 <= -3e-207) {
tmp = 0.5;
} else if (beta <= -2.45e-266) {
tmp = (2.0 / alpha) / 2.0;
} else if (beta <= 2.0) {
tmp = 0.5;
} else {
tmp = 1.0;
}
return tmp;
}
def code(alpha, beta): tmp = 0 if beta <= -3e-207: tmp = 0.5 elif beta <= -2.45e-266: tmp = (2.0 / alpha) / 2.0 elif beta <= 2.0: tmp = 0.5 else: tmp = 1.0 return tmp
function code(alpha, beta) tmp = 0.0 if (beta <= -3e-207) tmp = 0.5; elseif (beta <= -2.45e-266) tmp = Float64(Float64(2.0 / alpha) / 2.0); elseif (beta <= 2.0) tmp = 0.5; else tmp = 1.0; end return tmp end
function tmp_2 = code(alpha, beta) tmp = 0.0; if (beta <= -3e-207) tmp = 0.5; elseif (beta <= -2.45e-266) tmp = (2.0 / alpha) / 2.0; elseif (beta <= 2.0) tmp = 0.5; else tmp = 1.0; end tmp_2 = tmp; end
code[alpha_, beta_] := If[LessEqual[beta, -3e-207], 0.5, If[LessEqual[beta, -2.45e-266], N[(N[(2.0 / alpha), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[beta, 2.0], 0.5, 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq -3 \cdot 10^{-207}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;\beta \leq -2.45 \cdot 10^{-266}:\\
\;\;\;\;\frac{\frac{2}{\alpha}}{2}\\
\mathbf{elif}\;\beta \leq 2:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if beta < -2.9999999999999999e-207 or -2.4500000000000001e-266 < beta < 2Initial program 68.9%
+-commutative68.9%
Simplified68.9%
flip3-+68.8%
add-exp-log68.8%
flip3-+68.9%
+-commutative68.9%
log1p-udef68.9%
div-inv68.8%
div-inv68.9%
associate-+l+68.9%
Applied egg-rr68.9%
+-commutative68.9%
+-commutative68.9%
+-commutative68.9%
Simplified68.9%
Taylor expanded in beta around 0 67.3%
log1p-def67.3%
associate-*r/67.3%
neg-mul-167.3%
+-commutative67.3%
Simplified67.3%
Taylor expanded in alpha around 0 66.0%
if -2.9999999999999999e-207 < beta < -2.4500000000000001e-266Initial program 32.8%
+-commutative32.8%
Simplified32.8%
Taylor expanded in alpha around inf 73.0%
Taylor expanded in beta around 0 73.0%
if 2 < beta Initial program 93.2%
+-commutative93.2%
Simplified93.2%
Taylor expanded in beta around inf 90.4%
Final simplification74.4%
(FPCore (alpha beta) :precision binary64 (if (<= beta 2.0) 0.5 1.0))
double code(double alpha, double beta) {
double tmp;
if (beta <= 2.0) {
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.0d0) 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.0) {
tmp = 0.5;
} else {
tmp = 1.0;
}
return tmp;
}
def code(alpha, beta): tmp = 0 if beta <= 2.0: tmp = 0.5 else: tmp = 1.0 return tmp
function code(alpha, beta) tmp = 0.0 if (beta <= 2.0) tmp = 0.5; else tmp = 1.0; end return tmp end
function tmp_2 = code(alpha, beta) tmp = 0.0; if (beta <= 2.0) tmp = 0.5; else tmp = 1.0; end tmp_2 = tmp; end
code[alpha_, beta_] := If[LessEqual[beta, 2.0], 0.5, 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\beta \leq 2:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if beta < 2Initial program 66.0%
+-commutative66.0%
Simplified66.0%
flip3-+65.9%
add-exp-log65.9%
flip3-+66.0%
+-commutative66.0%
log1p-udef66.0%
div-inv65.9%
div-inv66.0%
associate-+l+66.0%
Applied egg-rr66.0%
+-commutative66.0%
+-commutative66.0%
+-commutative66.0%
Simplified66.0%
Taylor expanded in beta around 0 64.5%
log1p-def64.5%
associate-*r/64.5%
neg-mul-164.5%
+-commutative64.5%
Simplified64.5%
Taylor expanded in alpha around 0 63.1%
if 2 < beta Initial program 93.2%
+-commutative93.2%
Simplified93.2%
Taylor expanded in beta around inf 90.4%
Final simplification72.0%
(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.9%
+-commutative74.9%
Simplified74.9%
flip3-+74.8%
add-exp-log74.8%
flip3-+74.9%
+-commutative74.9%
log1p-udef74.9%
div-inv74.8%
div-inv74.9%
associate-+l+74.9%
Applied egg-rr74.9%
+-commutative74.9%
+-commutative74.9%
+-commutative74.9%
Simplified74.9%
Taylor expanded in beta around 0 48.1%
log1p-def48.1%
associate-*r/48.1%
neg-mul-148.1%
+-commutative48.1%
Simplified48.1%
Taylor expanded in alpha around 0 48.2%
Final simplification48.2%
herbie shell --seed 2023322
(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))