
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 20 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma (fma 0.5 a 1.0) a 1.0)))
(if (<= (/ (exp a) (+ (exp a) (exp b))) 4e-48)
(/ (exp a) (+ 1.0 (exp b)))
(pow (/ (+ (exp b) t_0) t_0) -1.0))))
double code(double a, double b) {
double t_0 = fma(fma(0.5, a, 1.0), a, 1.0);
double tmp;
if ((exp(a) / (exp(a) + exp(b))) <= 4e-48) {
tmp = exp(a) / (1.0 + exp(b));
} else {
tmp = pow(((exp(b) + t_0) / t_0), -1.0);
}
return tmp;
}
function code(a, b) t_0 = fma(fma(0.5, a, 1.0), a, 1.0) tmp = 0.0 if (Float64(exp(a) / Float64(exp(a) + exp(b))) <= 4e-48) tmp = Float64(exp(a) / Float64(1.0 + exp(b))); else tmp = Float64(Float64(exp(b) + t_0) / t_0) ^ -1.0; end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e-48], N[(N[Exp[a], $MachinePrecision] / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[(N[Exp[b], $MachinePrecision] + t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], -1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)\\
\mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 4 \cdot 10^{-48}:\\
\;\;\;\;\frac{e^{a}}{1 + e^{b}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{e^{b} + t\_0}{t\_0}\right)}^{-1}\\
\end{array}
\end{array}
if (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) < 3.9999999999999999e-48Initial program 100.0%
Taylor expanded in a around 0
Applied rewrites99.3%
if 3.9999999999999999e-48 < (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) Initial program 98.4%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6496.4
Applied rewrites96.4%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6499.2
Applied rewrites99.2%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6499.2
lift-+.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-exp.f6499.2
Applied rewrites99.2%
Final simplification99.3%
(FPCore (a b) :precision binary64 (if (<= (/ (exp a) (+ (exp a) (exp b))) 0.499999999995) (pow (* (fma (+ (/ 2.0 (* b b)) 0.5) b 1.0) b) -1.0) (pow (- 2.0 a) -1.0)))
double code(double a, double b) {
double tmp;
if ((exp(a) / (exp(a) + exp(b))) <= 0.499999999995) {
tmp = pow((fma(((2.0 / (b * b)) + 0.5), b, 1.0) * b), -1.0);
} else {
tmp = pow((2.0 - a), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(exp(a) / Float64(exp(a) + exp(b))) <= 0.499999999995) tmp = Float64(fma(Float64(Float64(2.0 / Float64(b * b)) + 0.5), b, 1.0) * b) ^ -1.0; else tmp = Float64(2.0 - a) ^ -1.0; end return tmp end
code[a_, b_] := If[LessEqual[N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.499999999995], N[Power[N[(N[(N[(N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision] * b + 1.0), $MachinePrecision] * b), $MachinePrecision], -1.0], $MachinePrecision], N[Power[N[(2.0 - a), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0.499999999995:\\
\;\;\;\;{\left(\mathsf{fma}\left(\frac{2}{b \cdot b} + 0.5, b, 1\right) \cdot b\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;{\left(2 - a\right)}^{-1}\\
\end{array}
\end{array}
if (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) < 0.499999999995Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6459.9
Applied rewrites59.9%
Taylor expanded in b around 0
Applied rewrites36.5%
Taylor expanded in b around inf
Applied rewrites34.3%
Taylor expanded in b around inf
Applied rewrites59.2%
if 0.499999999995 < (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) Initial program 98.4%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6496.4
Applied rewrites96.4%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6496.4
Applied rewrites96.4%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-rgt1-inN/A
lower-fma.f64N/A
+-commutativeN/A
unsub-negN/A
lower--.f64N/A
lower-exp.f6498.3
Applied rewrites98.3%
Taylor expanded in b around 0
Applied rewrites67.9%
Final simplification63.6%
(FPCore (a b)
:precision binary64
(if (<= (/ (exp a) (+ (exp a) (exp b))) 0.6)
(pow
(fma (- 1.0 a) (fma (fma (fma 0.16666666666666666 b 0.5) b 1.0) b 1.0) 1.0)
-1.0)
0.5))
double code(double a, double b) {
double tmp;
if ((exp(a) / (exp(a) + exp(b))) <= 0.6) {
tmp = pow(fma((1.0 - a), fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 1.0), 1.0), -1.0);
} else {
tmp = 0.5;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(exp(a) / Float64(exp(a) + exp(b))) <= 0.6) tmp = fma(Float64(1.0 - a), fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 1.0), 1.0) ^ -1.0; else tmp = 0.5; end return tmp end
code[a_, b_] := If[LessEqual[N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.6], N[Power[N[(N[(1.0 - a), $MachinePrecision] * N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * b + 1.0), $MachinePrecision] * b + 1.0), $MachinePrecision] + 1.0), $MachinePrecision], -1.0], $MachinePrecision], 0.5]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0.6:\\
\;\;\;\;{\left(\mathsf{fma}\left(1 - a, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 1\right), 1\right)\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) < 0.599999999999999978Initial program 99.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6499.5
Applied rewrites99.5%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6499.5
Applied rewrites99.5%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-rgt1-inN/A
lower-fma.f64N/A
+-commutativeN/A
unsub-negN/A
lower--.f64N/A
lower-exp.f6476.0
Applied rewrites76.0%
Taylor expanded in b around 0
Applied rewrites67.1%
if 0.599999999999999978 < (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) Initial program 95.8%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6496.6
Applied rewrites96.6%
Taylor expanded in b around 0
Applied rewrites18.8%
Final simplification58.1%
(FPCore (a b) :precision binary64 (exp (fma (log (+ (exp b) (exp a))) -1.0 a)))
double code(double a, double b) {
return exp(fma(log((exp(b) + exp(a))), -1.0, a));
}
function code(a, b) return exp(fma(log(Float64(exp(b) + exp(a))), -1.0, a)) end
code[a_, b_] := N[Exp[N[(N[Log[N[(N[Exp[b], $MachinePrecision] + N[Exp[a], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -1.0 + a), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\mathsf{fma}\left(\log \left(e^{b} + e^{a}\right), -1, a\right)}
\end{array}
Initial program 99.2%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
lift-exp.f64N/A
prod-expN/A
lower-exp.f64N/A
lower-fma.f64N/A
lower-log.f6499.2
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.2
Applied rewrites99.2%
(FPCore (a b) :precision binary64 (pow (/ (+ (fma (fma 0.5 a 1.0) a 1.0) (exp b)) (exp a)) -1.0))
double code(double a, double b) {
return pow(((fma(fma(0.5, a, 1.0), a, 1.0) + exp(b)) / exp(a)), -1.0);
}
function code(a, b) return Float64(Float64(fma(fma(0.5, a, 1.0), a, 1.0) + exp(b)) / exp(a)) ^ -1.0 end
code[a_, b_] := N[Power[N[(N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision] / N[Exp[a], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + e^{b}}{e^{a}}\right)}^{-1}
\end{array}
Initial program 99.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6497.8
Applied rewrites97.8%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6497.8
Applied rewrites97.8%
Final simplification97.8%
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Initial program 99.2%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma (fma 0.5 a 1.0) a 1.0)))
(if (<= a -200000000.0)
(/ (exp a) (+ 1.0 (+ 1.0 b)))
(pow (/ (+ (exp b) t_0) t_0) -1.0))))
double code(double a, double b) {
double t_0 = fma(fma(0.5, a, 1.0), a, 1.0);
double tmp;
if (a <= -200000000.0) {
tmp = exp(a) / (1.0 + (1.0 + b));
} else {
tmp = pow(((exp(b) + t_0) / t_0), -1.0);
}
return tmp;
}
function code(a, b) t_0 = fma(fma(0.5, a, 1.0), a, 1.0) tmp = 0.0 if (a <= -200000000.0) tmp = Float64(exp(a) / Float64(1.0 + Float64(1.0 + b))); else tmp = Float64(Float64(exp(b) + t_0) / t_0) ^ -1.0; end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision]}, If[LessEqual[a, -200000000.0], N[(N[Exp[a], $MachinePrecision] / N[(1.0 + N[(1.0 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[(N[Exp[b], $MachinePrecision] + t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], -1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)\\
\mathbf{if}\;a \leq -200000000:\\
\;\;\;\;\frac{e^{a}}{1 + \left(1 + b\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{e^{b} + t\_0}{t\_0}\right)}^{-1}\\
\end{array}
\end{array}
if a < -2e8Initial program 100.0%
Taylor expanded in b around 0
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
if -2e8 < a Initial program 98.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6496.9
Applied rewrites96.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6498.9
Applied rewrites98.9%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6498.9
lift-+.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-exp.f6498.9
Applied rewrites98.9%
Final simplification99.2%
(FPCore (a b) :precision binary64 (/ (exp a) (+ (fma (fma 0.5 a 1.0) a 1.0) (exp b))))
double code(double a, double b) {
return exp(a) / (fma(fma(0.5, a, 1.0), a, 1.0) + exp(b));
}
function code(a, b) return Float64(exp(a) / Float64(fma(fma(0.5, a, 1.0), a, 1.0) + exp(b))) end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + e^{b}}
\end{array}
Initial program 99.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6497.8
Applied rewrites97.8%
(FPCore (a b) :precision binary64 (if (<= a -180000000.0) (/ (exp a) (+ 1.0 (+ 1.0 b))) (pow (fma (- 1.0 a) (exp b) 1.0) -1.0)))
double code(double a, double b) {
double tmp;
if (a <= -180000000.0) {
tmp = exp(a) / (1.0 + (1.0 + b));
} else {
tmp = pow(fma((1.0 - a), exp(b), 1.0), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -180000000.0) tmp = Float64(exp(a) / Float64(1.0 + Float64(1.0 + b))); else tmp = fma(Float64(1.0 - a), exp(b), 1.0) ^ -1.0; end return tmp end
code[a_, b_] := If[LessEqual[a, -180000000.0], N[(N[Exp[a], $MachinePrecision] / N[(1.0 + N[(1.0 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[(1.0 - a), $MachinePrecision] * N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -180000000:\\
\;\;\;\;\frac{e^{a}}{1 + \left(1 + b\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{fma}\left(1 - a, e^{b}, 1\right)\right)}^{-1}\\
\end{array}
\end{array}
if a < -1.8e8Initial program 100.0%
Taylor expanded in b around 0
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
if -1.8e8 < a Initial program 98.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6496.9
Applied rewrites96.9%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6496.9
Applied rewrites96.9%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-rgt1-inN/A
lower-fma.f64N/A
+-commutativeN/A
unsub-negN/A
lower--.f64N/A
lower-exp.f6498.0
Applied rewrites98.0%
Final simplification98.6%
(FPCore (a b) :precision binary64 (if (<= a -180000000.0) (/ (exp a) (+ 1.0 (+ 1.0 b))) (pow (+ (exp b) 1.0) -1.0)))
double code(double a, double b) {
double tmp;
if (a <= -180000000.0) {
tmp = exp(a) / (1.0 + (1.0 + b));
} else {
tmp = pow((exp(b) + 1.0), -1.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-180000000.0d0)) then
tmp = exp(a) / (1.0d0 + (1.0d0 + b))
else
tmp = (exp(b) + 1.0d0) ** (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -180000000.0) {
tmp = Math.exp(a) / (1.0 + (1.0 + b));
} else {
tmp = Math.pow((Math.exp(b) + 1.0), -1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -180000000.0: tmp = math.exp(a) / (1.0 + (1.0 + b)) else: tmp = math.pow((math.exp(b) + 1.0), -1.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -180000000.0) tmp = Float64(exp(a) / Float64(1.0 + Float64(1.0 + b))); else tmp = Float64(exp(b) + 1.0) ^ -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -180000000.0) tmp = exp(a) / (1.0 + (1.0 + b)); else tmp = (exp(b) + 1.0) ^ -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -180000000.0], N[(N[Exp[a], $MachinePrecision] / N[(1.0 + N[(1.0 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -180000000:\\
\;\;\;\;\frac{e^{a}}{1 + \left(1 + b\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(e^{b} + 1\right)}^{-1}\\
\end{array}
\end{array}
if a < -1.8e8Initial program 100.0%
Taylor expanded in b around 0
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
if -1.8e8 < a Initial program 98.8%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6497.1
Applied rewrites97.1%
Final simplification98.0%
(FPCore (a b) :precision binary64 (if (<= a -660000000.0) (pow (* (fma (+ (/ 2.0 (* b b)) 0.5) b 1.0) b) -1.0) (pow (+ (exp b) 1.0) -1.0)))
double code(double a, double b) {
double tmp;
if (a <= -660000000.0) {
tmp = pow((fma(((2.0 / (b * b)) + 0.5), b, 1.0) * b), -1.0);
} else {
tmp = pow((exp(b) + 1.0), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -660000000.0) tmp = Float64(fma(Float64(Float64(2.0 / Float64(b * b)) + 0.5), b, 1.0) * b) ^ -1.0; else tmp = Float64(exp(b) + 1.0) ^ -1.0; end return tmp end
code[a_, b_] := If[LessEqual[a, -660000000.0], N[Power[N[(N[(N[(N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision] * b + 1.0), $MachinePrecision] * b), $MachinePrecision], -1.0], $MachinePrecision], N[Power[N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -660000000:\\
\;\;\;\;{\left(\mathsf{fma}\left(\frac{2}{b \cdot b} + 0.5, b, 1\right) \cdot b\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;{\left(e^{b} + 1\right)}^{-1}\\
\end{array}
\end{array}
if a < -6.6e8Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6435.0
Applied rewrites35.0%
Taylor expanded in b around 0
Applied rewrites22.4%
Taylor expanded in b around inf
Applied rewrites21.6%
Taylor expanded in b around inf
Applied rewrites60.7%
if -6.6e8 < a Initial program 98.8%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6497.1
Applied rewrites97.1%
Final simplification86.3%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma (fma 0.5 a 1.0) a 1.0)))
(if (<= a -200000000.0)
(/ (exp a) (+ 1.0 (+ 1.0 b)))
(/ t_0 (+ t_0 (exp b))))))
double code(double a, double b) {
double t_0 = fma(fma(0.5, a, 1.0), a, 1.0);
double tmp;
if (a <= -200000000.0) {
tmp = exp(a) / (1.0 + (1.0 + b));
} else {
tmp = t_0 / (t_0 + exp(b));
}
return tmp;
}
function code(a, b) t_0 = fma(fma(0.5, a, 1.0), a, 1.0) tmp = 0.0 if (a <= -200000000.0) tmp = Float64(exp(a) / Float64(1.0 + Float64(1.0 + b))); else tmp = Float64(t_0 / Float64(t_0 + exp(b))); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision]}, If[LessEqual[a, -200000000.0], N[(N[Exp[a], $MachinePrecision] / N[(1.0 + N[(1.0 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(t$95$0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)\\
\mathbf{if}\;a \leq -200000000:\\
\;\;\;\;\frac{e^{a}}{1 + \left(1 + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{t\_0 + e^{b}}\\
\end{array}
\end{array}
if a < -2e8Initial program 100.0%
Taylor expanded in b around 0
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
if -2e8 < a Initial program 98.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6496.9
Applied rewrites96.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6498.9
Applied rewrites98.9%
(FPCore (a b)
:precision binary64
(if (<= b -3.1)
0.5
(if (<= b 5.2e+102)
(pow (fma (- 1.0 a) (fma (fma 0.5 b 1.0) b 1.0) 1.0) -1.0)
(pow (fma (fma (fma 0.16666666666666666 b 0.5) b 1.0) b 2.0) -1.0))))
double code(double a, double b) {
double tmp;
if (b <= -3.1) {
tmp = 0.5;
} else if (b <= 5.2e+102) {
tmp = pow(fma((1.0 - a), fma(fma(0.5, b, 1.0), b, 1.0), 1.0), -1.0);
} else {
tmp = pow(fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -3.1) tmp = 0.5; elseif (b <= 5.2e+102) tmp = fma(Float64(1.0 - a), fma(fma(0.5, b, 1.0), b, 1.0), 1.0) ^ -1.0; else tmp = fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0) ^ -1.0; end return tmp end
code[a_, b_] := If[LessEqual[b, -3.1], 0.5, If[LessEqual[b, 5.2e+102], N[Power[N[(N[(1.0 - a), $MachinePrecision] * N[(N[(0.5 * b + 1.0), $MachinePrecision] * b + 1.0), $MachinePrecision] + 1.0), $MachinePrecision], -1.0], $MachinePrecision], N[Power[N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision], -1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.1:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{+102}:\\
\;\;\;\;{\left(\mathsf{fma}\left(1 - a, \mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, 1\right), 1\right)\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)\right)}^{-1}\\
\end{array}
\end{array}
if b < -3.10000000000000009Initial program 97.8%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites18.8%
if -3.10000000000000009 < b < 5.20000000000000013e102Initial program 99.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6498.3
Applied rewrites98.3%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6498.3
Applied rewrites98.3%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-rgt1-inN/A
lower-fma.f64N/A
+-commutativeN/A
unsub-negN/A
lower--.f64N/A
lower-exp.f6468.0
Applied rewrites68.0%
Taylor expanded in b around 0
Applied rewrites55.6%
if 5.20000000000000013e102 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites100.0%
Final simplification57.3%
(FPCore (a b) :precision binary64 (if (<= a -125000000.0) (/ (exp a) (+ 1.0 (+ 1.0 b))) (/ (+ 1.0 a) (+ (+ (exp b) a) 1.0))))
double code(double a, double b) {
double tmp;
if (a <= -125000000.0) {
tmp = exp(a) / (1.0 + (1.0 + b));
} else {
tmp = (1.0 + a) / ((exp(b) + a) + 1.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-125000000.0d0)) then
tmp = exp(a) / (1.0d0 + (1.0d0 + b))
else
tmp = (1.0d0 + a) / ((exp(b) + a) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -125000000.0) {
tmp = Math.exp(a) / (1.0 + (1.0 + b));
} else {
tmp = (1.0 + a) / ((Math.exp(b) + a) + 1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -125000000.0: tmp = math.exp(a) / (1.0 + (1.0 + b)) else: tmp = (1.0 + a) / ((math.exp(b) + a) + 1.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -125000000.0) tmp = Float64(exp(a) / Float64(1.0 + Float64(1.0 + b))); else tmp = Float64(Float64(1.0 + a) / Float64(Float64(exp(b) + a) + 1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -125000000.0) tmp = exp(a) / (1.0 + (1.0 + b)); else tmp = (1.0 + a) / ((exp(b) + a) + 1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -125000000.0], N[(N[Exp[a], $MachinePrecision] / N[(1.0 + N[(1.0 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + a), $MachinePrecision] / N[(N[(N[Exp[b], $MachinePrecision] + a), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -125000000:\\
\;\;\;\;\frac{e^{a}}{1 + \left(1 + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + a}{\left(e^{b} + a\right) + 1}\\
\end{array}
\end{array}
if a < -1.25e8Initial program 100.0%
Taylor expanded in b around 0
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
if -1.25e8 < a Initial program 98.8%
Taylor expanded in a around 0
Applied rewrites94.0%
Taylor expanded in a around 0
lower-+.f6494.0
Applied rewrites94.0%
Taylor expanded in a around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6498.4
Applied rewrites98.4%
(FPCore (a b)
:precision binary64
(if (<= b -1.25)
0.5
(if (<= b 2e+118)
(pow (fma (- 1.0 a) (+ 1.0 b) 1.0) -1.0)
(pow (* (* b b) 0.5) -1.0))))
double code(double a, double b) {
double tmp;
if (b <= -1.25) {
tmp = 0.5;
} else if (b <= 2e+118) {
tmp = pow(fma((1.0 - a), (1.0 + b), 1.0), -1.0);
} else {
tmp = pow(((b * b) * 0.5), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -1.25) tmp = 0.5; elseif (b <= 2e+118) tmp = fma(Float64(1.0 - a), Float64(1.0 + b), 1.0) ^ -1.0; else tmp = Float64(Float64(b * b) * 0.5) ^ -1.0; end return tmp end
code[a_, b_] := If[LessEqual[b, -1.25], 0.5, If[LessEqual[b, 2e+118], N[Power[N[(N[(1.0 - a), $MachinePrecision] * N[(1.0 + b), $MachinePrecision] + 1.0), $MachinePrecision], -1.0], $MachinePrecision], N[Power[N[(N[(b * b), $MachinePrecision] * 0.5), $MachinePrecision], -1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+118}:\\
\;\;\;\;{\left(\mathsf{fma}\left(1 - a, 1 + b, 1\right)\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;{\left(\left(b \cdot b\right) \cdot 0.5\right)}^{-1}\\
\end{array}
\end{array}
if b < -1.25Initial program 97.8%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites18.8%
if -1.25 < b < 1.99999999999999993e118Initial program 99.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6498.3
Applied rewrites98.3%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6498.3
Applied rewrites98.3%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-rgt1-inN/A
lower-fma.f64N/A
+-commutativeN/A
unsub-negN/A
lower--.f64N/A
lower-exp.f6468.8
Applied rewrites68.8%
Taylor expanded in b around 0
Applied rewrites53.9%
if 1.99999999999999993e118 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites93.8%
Taylor expanded in b around inf
Applied rewrites93.8%
Final simplification54.5%
(FPCore (a b) :precision binary64 (if (<= b 1.5e-15) (pow (- 2.0 a) -1.0) (pow (fma (fma (fma 0.16666666666666666 b 0.5) b 1.0) b 2.0) -1.0)))
double code(double a, double b) {
double tmp;
if (b <= 1.5e-15) {
tmp = pow((2.0 - a), -1.0);
} else {
tmp = pow(fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 1.5e-15) tmp = Float64(2.0 - a) ^ -1.0; else tmp = fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0) ^ -1.0; end return tmp end
code[a_, b_] := If[LessEqual[b, 1.5e-15], N[Power[N[(2.0 - a), $MachinePrecision], -1.0], $MachinePrecision], N[Power[N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.5 \cdot 10^{-15}:\\
\;\;\;\;{\left(2 - a\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)\right)}^{-1}\\
\end{array}
\end{array}
if b < 1.5e-15Initial program 98.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6496.9
Applied rewrites96.9%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6496.9
Applied rewrites96.9%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-rgt1-inN/A
lower-fma.f64N/A
+-commutativeN/A
unsub-negN/A
lower--.f64N/A
lower-exp.f6471.4
Applied rewrites71.4%
Taylor expanded in b around 0
Applied rewrites49.9%
if 1.5e-15 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6499.4
Applied rewrites99.4%
Taylor expanded in b around 0
Applied rewrites69.0%
Final simplification55.5%
(FPCore (a b) :precision binary64 (if (<= b 1.5e-15) (pow (- 2.0 a) -1.0) (pow (fma (fma 0.5 b 1.0) b 2.0) -1.0)))
double code(double a, double b) {
double tmp;
if (b <= 1.5e-15) {
tmp = pow((2.0 - a), -1.0);
} else {
tmp = pow(fma(fma(0.5, b, 1.0), b, 2.0), -1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 1.5e-15) tmp = Float64(2.0 - a) ^ -1.0; else tmp = fma(fma(0.5, b, 1.0), b, 2.0) ^ -1.0; end return tmp end
code[a_, b_] := If[LessEqual[b, 1.5e-15], N[Power[N[(2.0 - a), $MachinePrecision], -1.0], $MachinePrecision], N[Power[N[(N[(0.5 * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.5 \cdot 10^{-15}:\\
\;\;\;\;{\left(2 - a\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, 2\right)\right)}^{-1}\\
\end{array}
\end{array}
if b < 1.5e-15Initial program 98.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6496.9
Applied rewrites96.9%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6496.9
Applied rewrites96.9%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-rgt1-inN/A
lower-fma.f64N/A
+-commutativeN/A
unsub-negN/A
lower--.f64N/A
lower-exp.f6471.4
Applied rewrites71.4%
Taylor expanded in b around 0
Applied rewrites49.9%
if 1.5e-15 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6499.4
Applied rewrites99.4%
Taylor expanded in b around 0
Applied rewrites59.5%
Final simplification52.7%
(FPCore (a b) :precision binary64 (if (<= b 1.15e+54) (pow (- 2.0 a) -1.0) (pow (* (* b b) 0.5) -1.0)))
double code(double a, double b) {
double tmp;
if (b <= 1.15e+54) {
tmp = pow((2.0 - a), -1.0);
} else {
tmp = pow(((b * b) * 0.5), -1.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.15d+54) then
tmp = (2.0d0 - a) ** (-1.0d0)
else
tmp = ((b * b) * 0.5d0) ** (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.15e+54) {
tmp = Math.pow((2.0 - a), -1.0);
} else {
tmp = Math.pow(((b * b) * 0.5), -1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.15e+54: tmp = math.pow((2.0 - a), -1.0) else: tmp = math.pow(((b * b) * 0.5), -1.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.15e+54) tmp = Float64(2.0 - a) ^ -1.0; else tmp = Float64(Float64(b * b) * 0.5) ^ -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.15e+54) tmp = (2.0 - a) ^ -1.0; else tmp = ((b * b) * 0.5) ^ -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.15e+54], N[Power[N[(2.0 - a), $MachinePrecision], -1.0], $MachinePrecision], N[Power[N[(N[(b * b), $MachinePrecision] * 0.5), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.15 \cdot 10^{+54}:\\
\;\;\;\;{\left(2 - a\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;{\left(\left(b \cdot b\right) \cdot 0.5\right)}^{-1}\\
\end{array}
\end{array}
if b < 1.14999999999999997e54Initial program 98.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6497.2
Applied rewrites97.2%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6497.2
Applied rewrites97.2%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-rgt1-inN/A
lower-fma.f64N/A
+-commutativeN/A
unsub-negN/A
lower--.f64N/A
lower-exp.f6473.8
Applied rewrites73.8%
Taylor expanded in b around 0
Applied rewrites46.7%
if 1.14999999999999997e54 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites72.4%
Taylor expanded in b around inf
Applied rewrites72.4%
Final simplification52.5%
(FPCore (a b) :precision binary64 (pow (- 2.0 a) -1.0))
double code(double a, double b) {
return pow((2.0 - a), -1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (2.0d0 - a) ** (-1.0d0)
end function
public static double code(double a, double b) {
return Math.pow((2.0 - a), -1.0);
}
def code(a, b): return math.pow((2.0 - a), -1.0)
function code(a, b) return Float64(2.0 - a) ^ -1.0 end
function tmp = code(a, b) tmp = (2.0 - a) ^ -1.0; end
code[a_, b_] := N[Power[N[(2.0 - a), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(2 - a\right)}^{-1}
\end{array}
Initial program 99.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6497.8
Applied rewrites97.8%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6497.8
Applied rewrites97.8%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-rgt1-inN/A
lower-fma.f64N/A
+-commutativeN/A
unsub-negN/A
lower--.f64N/A
lower-exp.f6479.7
Applied rewrites79.7%
Taylor expanded in b around 0
Applied rewrites37.0%
Final simplification37.0%
(FPCore (a b) :precision binary64 0.5)
double code(double a, double b) {
return 0.5;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0
end function
public static double code(double a, double b) {
return 0.5;
}
def code(a, b): return 0.5
function code(a, b) return 0.5 end
function tmp = code(a, b) tmp = 0.5; end
code[a_, b_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 99.2%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6478.7
Applied rewrites78.7%
Taylor expanded in b around 0
Applied rewrites35.9%
(FPCore (a b) :precision binary64 (/ 1.0 (+ 1.0 (exp (- b a)))))
double code(double a, double b) {
return 1.0 / (1.0 + exp((b - a)));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (1.0d0 + exp((b - a)))
end function
public static double code(double a, double b) {
return 1.0 / (1.0 + Math.exp((b - a)));
}
def code(a, b): return 1.0 / (1.0 + math.exp((b - a)))
function code(a, b) return Float64(1.0 / Float64(1.0 + exp(Float64(b - a)))) end
function tmp = code(a, b) tmp = 1.0 / (1.0 + exp((b - a))); end
code[a_, b_] := N[(1.0 / N[(1.0 + N[Exp[N[(b - a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 + e^{b - a}}
\end{array}
herbie shell --seed 2024312
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:alt
(! :herbie-platform default (/ 1 (+ 1 (exp (- b a)))))
(/ (exp a) (+ (exp a) (exp b))))