
(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 (if (<= (exp a) 0.999999998) (/ (exp a) (+ (fma (fma 0.5 b 1.0) b (exp a)) 1.0)) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.999999998) {
tmp = exp(a) / (fma(fma(0.5, b, 1.0), b, exp(a)) + 1.0);
} else {
tmp = 1.0 / (1.0 + exp(b));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (exp(a) <= 0.999999998) tmp = Float64(exp(a) / Float64(fma(fma(0.5, b, 1.0), b, exp(a)) + 1.0)); else tmp = Float64(1.0 / Float64(1.0 + exp(b))); end return tmp end
code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.999999998], N[(N[Exp[a], $MachinePrecision] / N[(N[(N[(0.5 * b + 1.0), $MachinePrecision] * b + N[Exp[a], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0.999999998:\\
\;\;\;\;\frac{e^{a}}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, e^{a}\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.999999997999999946Initial program 97.1%
Taylor expanded in b around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-exp.f6498.0
Applied rewrites98.0%
Applied rewrites98.0%
if 0.999999997999999946 < (exp.f64 a) Initial program 99.4%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6499.5
Applied rewrites99.5%
Final simplification99.1%
(FPCore (a b) :precision binary64 (* (/ (- -1.0) (+ (exp a) (exp b))) (exp a)))
double code(double a, double b) {
return (-(-1.0) / (exp(a) + exp(b))) * exp(a);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-(-1.0d0) / (exp(a) + exp(b))) * exp(a)
end function
public static double code(double a, double b) {
return (-(-1.0) / (Math.exp(a) + Math.exp(b))) * Math.exp(a);
}
def code(a, b): return (-(-1.0) / (math.exp(a) + math.exp(b))) * math.exp(a)
function code(a, b) return Float64(Float64(Float64(-(-1.0)) / Float64(exp(a) + exp(b))) * exp(a)) end
function tmp = code(a, b) tmp = (-(-1.0) / (exp(a) + exp(b))) * exp(a); end
code[a_, b_] := N[(N[((--1.0) / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Exp[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{--1}{e^{a} + e^{b}} \cdot e^{a}
\end{array}
Initial program 98.8%
lift-/.f64N/A
clear-numN/A
frac-2negN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
frac-2negN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6498.8
Applied rewrites98.8%
Final simplification98.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 98.8%
(FPCore (a b) :precision binary64 (if (<= (exp a) 0.999999998) (/ 1.0 (fma (+ 1.0 b) (exp (- a)) 1.0)) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.999999998) {
tmp = 1.0 / fma((1.0 + b), exp(-a), 1.0);
} else {
tmp = 1.0 / (1.0 + exp(b));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (exp(a) <= 0.999999998) tmp = Float64(1.0 / fma(Float64(1.0 + b), exp(Float64(-a)), 1.0)); else tmp = Float64(1.0 / Float64(1.0 + exp(b))); end return tmp end
code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.999999998], N[(1.0 / N[(N[(1.0 + b), $MachinePrecision] * N[Exp[(-a)], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0.999999998:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(1 + b, e^{-a}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.999999997999999946Initial program 97.1%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6498.1
Applied rewrites98.1%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6498.2
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.2
Applied rewrites98.2%
Taylor expanded in b around 0
+-commutativeN/A
*-rgt-identityN/A
associate-*r/N/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6497.8
Applied rewrites97.8%
if 0.999999997999999946 < (exp.f64 a) Initial program 99.4%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6499.5
Applied rewrites99.5%
Final simplification99.0%
(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) / fma(fma(0.5, a, 1.0), a, Float64(1.0 + exp(b)))) end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1 + e^{b}\right)}
\end{array}
Initial program 98.8%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6498.7
Applied rewrites98.7%
Final simplification98.7%
(FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (/ (exp a) (+ (+ 1.0 b) 1.0)) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = exp(a) / ((1.0 + b) + 1.0);
} else {
tmp = 1.0 / (1.0 + exp(b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (exp(a) <= 0.0d0) then
tmp = exp(a) / ((1.0d0 + b) + 1.0d0)
else
tmp = 1.0d0 / (1.0d0 + exp(b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = Math.exp(a) / ((1.0 + b) + 1.0);
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = math.exp(a) / ((1.0 + b) + 1.0) else: tmp = 1.0 / (1.0 + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(exp(a) / Float64(Float64(1.0 + b) + 1.0)); else tmp = Float64(1.0 / Float64(1.0 + exp(b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (exp(a) <= 0.0) tmp = exp(a) / ((1.0 + b) + 1.0); else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(N[Exp[a], $MachinePrecision] / N[(N[(1.0 + b), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{e^{a}}{\left(1 + b\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 96.9%
Taylor expanded in b around 0
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
if 0.0 < (exp.f64 a) Initial program 99.4%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6498.3
Applied rewrites98.3%
Final simplification98.7%
(FPCore (a b) :precision binary64 (if (<= (exp b) 2.0) 0.5 (/ 1.0 (* (* (* b b) 0.16666666666666666) b))))
double code(double a, double b) {
double tmp;
if (exp(b) <= 2.0) {
tmp = 0.5;
} else {
tmp = 1.0 / (((b * b) * 0.16666666666666666) * b);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (exp(b) <= 2.0d0) then
tmp = 0.5d0
else
tmp = 1.0d0 / (((b * b) * 0.16666666666666666d0) * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (Math.exp(b) <= 2.0) {
tmp = 0.5;
} else {
tmp = 1.0 / (((b * b) * 0.16666666666666666) * b);
}
return tmp;
}
def code(a, b): tmp = 0 if math.exp(b) <= 2.0: tmp = 0.5 else: tmp = 1.0 / (((b * b) * 0.16666666666666666) * b) return tmp
function code(a, b) tmp = 0.0 if (exp(b) <= 2.0) tmp = 0.5; else tmp = Float64(1.0 / Float64(Float64(Float64(b * b) * 0.16666666666666666) * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (exp(b) <= 2.0) tmp = 0.5; else tmp = 1.0 / (((b * b) * 0.16666666666666666) * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[Exp[b], $MachinePrecision], 2.0], 0.5, N[(1.0 / N[(N[(N[(b * b), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{b} \leq 2:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(b \cdot b\right) \cdot 0.16666666666666666\right) \cdot b}\\
\end{array}
\end{array}
if (exp.f64 b) < 2Initial program 98.3%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6476.0
Applied rewrites76.0%
Taylor expanded in b around 0
Applied rewrites56.2%
if 2 < (exp.f64 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 rewrites67.5%
Taylor expanded in b around inf
Applied rewrites67.5%
Taylor expanded in b around inf
Applied rewrites67.5%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma (fma 0.5 a 1.0) a 1.0)))
(if (<= a -1.9e+154)
(/ 1.0 (+ t_0 (+ 1.0 b)))
(if (<= a -6.2e+96)
(/
t_0
(fma
(fma 0.5 b 1.0)
b
(fma (fma (fma 0.16666666666666666 a 0.5) a 1.0) a 2.0)))
(/ 1.0 (+ 1.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 <= -1.9e+154) {
tmp = 1.0 / (t_0 + (1.0 + b));
} else if (a <= -6.2e+96) {
tmp = t_0 / fma(fma(0.5, b, 1.0), b, fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 2.0));
} else {
tmp = 1.0 / (1.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 <= -1.9e+154) tmp = Float64(1.0 / Float64(t_0 + Float64(1.0 + b))); elseif (a <= -6.2e+96) tmp = Float64(t_0 / fma(fma(0.5, b, 1.0), b, fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 2.0))); else tmp = Float64(1.0 / Float64(1.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, -1.9e+154], N[(1.0 / N[(t$95$0 + N[(1.0 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -6.2e+96], N[(t$95$0 / N[(N[(0.5 * b + 1.0), $MachinePrecision] * b + N[(N[(N[(0.16666666666666666 * a + 0.5), $MachinePrecision] * a + 1.0), $MachinePrecision] * a + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.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 -1.9 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{t\_0 + \left(1 + b\right)}\\
\mathbf{elif}\;a \leq -6.2 \cdot 10^{+96}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -1.8999999999999999e154Initial program 96.6%
Taylor expanded in b around 0
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
if -1.8999999999999999e154 < a < -6.1999999999999996e96Initial program 92.9%
Taylor expanded in b around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6417.0
Applied rewrites17.0%
Taylor expanded in a around 0
Applied rewrites79.4%
if -6.1999999999999996e96 < a Initial program 99.5%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6492.1
Applied rewrites92.1%
Final simplification92.3%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma (fma 0.5 b 1.0) b (fma (fma 0.5 a 1.0) a 2.0))))
(if (<= b -680000000.0)
0.5
(if (<= b 720.0)
(/ (+ 1.0 a) t_0)
(if (<= b 2.65e+101)
(/ (* (* a a) 0.5) t_0)
(/ 1.0 (* (* (* b b) 0.16666666666666666) b)))))))
double code(double a, double b) {
double t_0 = fma(fma(0.5, b, 1.0), b, fma(fma(0.5, a, 1.0), a, 2.0));
double tmp;
if (b <= -680000000.0) {
tmp = 0.5;
} else if (b <= 720.0) {
tmp = (1.0 + a) / t_0;
} else if (b <= 2.65e+101) {
tmp = ((a * a) * 0.5) / t_0;
} else {
tmp = 1.0 / (((b * b) * 0.16666666666666666) * b);
}
return tmp;
}
function code(a, b) t_0 = fma(fma(0.5, b, 1.0), b, fma(fma(0.5, a, 1.0), a, 2.0)) tmp = 0.0 if (b <= -680000000.0) tmp = 0.5; elseif (b <= 720.0) tmp = Float64(Float64(1.0 + a) / t_0); elseif (b <= 2.65e+101) tmp = Float64(Float64(Float64(a * a) * 0.5) / t_0); else tmp = Float64(1.0 / Float64(Float64(Float64(b * b) * 0.16666666666666666) * b)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(0.5 * b + 1.0), $MachinePrecision] * b + N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -680000000.0], 0.5, If[LessEqual[b, 720.0], N[(N[(1.0 + a), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[b, 2.65e+101], N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] / t$95$0), $MachinePrecision], N[(1.0 / N[(N[(N[(b * b), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, \mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 2\right)\right)\\
\mathbf{if}\;b \leq -680000000:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq 720:\\
\;\;\;\;\frac{1 + a}{t\_0}\\
\mathbf{elif}\;b \leq 2.65 \cdot 10^{+101}:\\
\;\;\;\;\frac{\left(a \cdot a\right) \cdot 0.5}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(b \cdot b\right) \cdot 0.16666666666666666\right) \cdot b}\\
\end{array}
\end{array}
if b < -6.8e8Initial 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 rewrites18.8%
if -6.8e8 < b < 720Initial program 97.8%
Taylor expanded in b around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-exp.f6498.9
Applied rewrites98.9%
Taylor expanded in a around 0
Applied rewrites98.3%
Taylor expanded in a around 0
lower-+.f6482.3
Applied rewrites82.3%
if 720 < b < 2.65000000000000003e101Initial program 100.0%
Taylor expanded in b around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-exp.f6432.1
Applied rewrites32.1%
Taylor expanded in a around 0
Applied rewrites32.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f643.6
Applied rewrites3.6%
Taylor expanded in a around inf
Applied rewrites50.9%
if 2.65000000000000003e101 < 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 rewrites98.2%
Taylor expanded in b around inf
Applied rewrites98.2%
Taylor expanded in b around inf
Applied rewrites98.2%
(FPCore (a b)
:precision binary64
(if (<= b -680000000.0)
0.5
(if (<= b 1.05e+34)
(/ (+ 1.0 a) (fma (fma 0.5 b 1.0) b (fma (fma 0.5 a 1.0) a 2.0)))
(/ 1.0 (* (* (* b b) 0.16666666666666666) b)))))
double code(double a, double b) {
double tmp;
if (b <= -680000000.0) {
tmp = 0.5;
} else if (b <= 1.05e+34) {
tmp = (1.0 + a) / fma(fma(0.5, b, 1.0), b, fma(fma(0.5, a, 1.0), a, 2.0));
} else {
tmp = 1.0 / (((b * b) * 0.16666666666666666) * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -680000000.0) tmp = 0.5; elseif (b <= 1.05e+34) tmp = Float64(Float64(1.0 + a) / fma(fma(0.5, b, 1.0), b, fma(fma(0.5, a, 1.0), a, 2.0))); else tmp = Float64(1.0 / Float64(Float64(Float64(b * b) * 0.16666666666666666) * b)); end return tmp end
code[a_, b_] := If[LessEqual[b, -680000000.0], 0.5, If[LessEqual[b, 1.05e+34], N[(N[(1.0 + a), $MachinePrecision] / N[(N[(0.5 * b + 1.0), $MachinePrecision] * b + N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(b * b), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -680000000:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{+34}:\\
\;\;\;\;\frac{1 + a}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, \mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(b \cdot b\right) \cdot 0.16666666666666666\right) \cdot b}\\
\end{array}
\end{array}
if b < -6.8e8Initial 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 rewrites18.8%
if -6.8e8 < b < 1.05000000000000009e34Initial program 97.9%
Taylor expanded in b around 0
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-exp.f6495.7
Applied rewrites95.7%
Taylor expanded in a around 0
Applied rewrites95.1%
Taylor expanded in a around 0
lower-+.f6479.4
Applied rewrites79.4%
if 1.05000000000000009e34 < 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 rewrites75.4%
Taylor expanded in b around inf
Applied rewrites75.4%
Taylor expanded in b around inf
Applied rewrites75.4%
(FPCore (a b)
:precision binary64
(if (<= b -680000000.0)
0.5
(if (<= b 1.05e+34)
(/ (+ 1.0 a) (+ (fma (fma 0.5 a 1.0) a 1.0) (+ 1.0 b)))
(/ 1.0 (* (* (* b b) 0.16666666666666666) b)))))
double code(double a, double b) {
double tmp;
if (b <= -680000000.0) {
tmp = 0.5;
} else if (b <= 1.05e+34) {
tmp = (1.0 + a) / (fma(fma(0.5, a, 1.0), a, 1.0) + (1.0 + b));
} else {
tmp = 1.0 / (((b * b) * 0.16666666666666666) * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -680000000.0) tmp = 0.5; elseif (b <= 1.05e+34) tmp = Float64(Float64(1.0 + a) / Float64(fma(fma(0.5, a, 1.0), a, 1.0) + Float64(1.0 + b))); else tmp = Float64(1.0 / Float64(Float64(Float64(b * b) * 0.16666666666666666) * b)); end return tmp end
code[a_, b_] := If[LessEqual[b, -680000000.0], 0.5, If[LessEqual[b, 1.05e+34], N[(N[(1.0 + a), $MachinePrecision] / N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + N[(1.0 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(b * b), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -680000000:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{+34}:\\
\;\;\;\;\frac{1 + a}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + \left(1 + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(b \cdot b\right) \cdot 0.16666666666666666\right) \cdot b}\\
\end{array}
\end{array}
if b < -6.8e8Initial 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 rewrites18.8%
if -6.8e8 < b < 1.05000000000000009e34Initial program 97.9%
Taylor expanded in b around 0
lower-+.f6495.6
Applied rewrites95.6%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6495.0
Applied rewrites95.0%
Taylor expanded in a around 0
lower-+.f6479.3
Applied rewrites79.3%
if 1.05000000000000009e34 < 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 rewrites75.4%
Taylor expanded in b around inf
Applied rewrites75.4%
Taylor expanded in b around inf
Applied rewrites75.4%
(FPCore (a b)
:precision binary64
(if (<= b -680000000.0)
0.5
(if (<= b 7.5e+51)
(/ 1.0 (+ (fma (fma 0.5 a 1.0) a 1.0) (+ 1.0 b)))
(/ 1.0 (* (* (* b b) 0.16666666666666666) b)))))
double code(double a, double b) {
double tmp;
if (b <= -680000000.0) {
tmp = 0.5;
} else if (b <= 7.5e+51) {
tmp = 1.0 / (fma(fma(0.5, a, 1.0), a, 1.0) + (1.0 + b));
} else {
tmp = 1.0 / (((b * b) * 0.16666666666666666) * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -680000000.0) tmp = 0.5; elseif (b <= 7.5e+51) tmp = Float64(1.0 / Float64(fma(fma(0.5, a, 1.0), a, 1.0) + Float64(1.0 + b))); else tmp = Float64(1.0 / Float64(Float64(Float64(b * b) * 0.16666666666666666) * b)); end return tmp end
code[a_, b_] := If[LessEqual[b, -680000000.0], 0.5, If[LessEqual[b, 7.5e+51], N[(1.0 / N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + N[(1.0 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(b * b), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -680000000:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{+51}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + \left(1 + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(b \cdot b\right) \cdot 0.16666666666666666\right) \cdot b}\\
\end{array}
\end{array}
if b < -6.8e8Initial 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 rewrites18.8%
if -6.8e8 < b < 7.4999999999999999e51Initial program 98.0%
Taylor expanded in b around 0
lower-+.f6494.4
Applied rewrites94.4%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6493.9
Applied rewrites93.9%
Taylor expanded in a around 0
Applied rewrites77.0%
if 7.4999999999999999e51 < 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 rewrites80.0%
Taylor expanded in b around inf
Applied rewrites80.0%
Taylor expanded in b around inf
Applied rewrites80.0%
(FPCore (a b) :precision binary64 (if (<= b -100000000.0) 0.5 (/ 1.0 (fma (fma (fma 0.16666666666666666 b 0.5) b 1.0) b 2.0))))
double code(double a, double b) {
double tmp;
if (b <= -100000000.0) {
tmp = 0.5;
} else {
tmp = 1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -100000000.0) tmp = 0.5; else tmp = Float64(1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0)); end return tmp end
code[a_, b_] := If[LessEqual[b, -100000000.0], 0.5, N[(1.0 / N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -100000000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), b, 1\right), b, 2\right)}\\
\end{array}
\end{array}
if b < -1e8Initial 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 rewrites18.8%
if -1e8 < b Initial program 98.6%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6479.3
Applied rewrites79.3%
Taylor expanded in b around 0
Applied rewrites68.2%
(FPCore (a b) :precision binary64 (if (<= b -100000000.0) 0.5 (/ 1.0 (fma (fma (* 0.16666666666666666 b) b 1.0) b 2.0))))
double code(double a, double b) {
double tmp;
if (b <= -100000000.0) {
tmp = 0.5;
} else {
tmp = 1.0 / fma(fma((0.16666666666666666 * b), b, 1.0), b, 2.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -100000000.0) tmp = 0.5; else tmp = Float64(1.0 / fma(fma(Float64(0.16666666666666666 * b), b, 1.0), b, 2.0)); end return tmp end
code[a_, b_] := If[LessEqual[b, -100000000.0], 0.5, N[(1.0 / N[(N[(N[(0.16666666666666666 * b), $MachinePrecision] * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -100000000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666 \cdot b, b, 1\right), b, 2\right)}\\
\end{array}
\end{array}
if b < -1e8Initial 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 rewrites18.8%
if -1e8 < b Initial program 98.6%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6479.3
Applied rewrites79.3%
Taylor expanded in b around 0
Applied rewrites68.2%
Taylor expanded in b around inf
Applied rewrites68.2%
(FPCore (a b) :precision binary64 (if (<= b -100000000.0) 0.5 (/ 1.0 (fma (* (fma 0.16666666666666666 b 0.5) b) b 2.0))))
double code(double a, double b) {
double tmp;
if (b <= -100000000.0) {
tmp = 0.5;
} else {
tmp = 1.0 / fma((fma(0.16666666666666666, b, 0.5) * b), b, 2.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -100000000.0) tmp = 0.5; else tmp = Float64(1.0 / fma(Float64(fma(0.16666666666666666, b, 0.5) * b), b, 2.0)); end return tmp end
code[a_, b_] := If[LessEqual[b, -100000000.0], 0.5, N[(1.0 / N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * b), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -100000000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right) \cdot b, b, 2\right)}\\
\end{array}
\end{array}
if b < -1e8Initial 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 rewrites18.8%
if -1e8 < b Initial program 98.6%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6479.3
Applied rewrites79.3%
Taylor expanded in b around 0
Applied rewrites68.2%
Taylor expanded in b around inf
Applied rewrites67.7%
(FPCore (a b) :precision binary64 (if (<= b -100000000.0) 0.5 (/ 1.0 (fma (* (* b b) 0.16666666666666666) b 2.0))))
double code(double a, double b) {
double tmp;
if (b <= -100000000.0) {
tmp = 0.5;
} else {
tmp = 1.0 / fma(((b * b) * 0.16666666666666666), b, 2.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -100000000.0) tmp = 0.5; else tmp = Float64(1.0 / fma(Float64(Float64(b * b) * 0.16666666666666666), b, 2.0)); end return tmp end
code[a_, b_] := If[LessEqual[b, -100000000.0], 0.5, N[(1.0 / N[(N[(N[(b * b), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -100000000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\left(b \cdot b\right) \cdot 0.16666666666666666, b, 2\right)}\\
\end{array}
\end{array}
if b < -1e8Initial 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 rewrites18.8%
if -1e8 < b Initial program 98.6%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6479.3
Applied rewrites79.3%
Taylor expanded in b around 0
Applied rewrites68.2%
Taylor expanded in b around inf
Applied rewrites67.7%
(FPCore (a b) :precision binary64 (if (<= b 1.6) 0.5 (/ 1.0 (* (* (fma 0.16666666666666666 b 0.5) b) b))))
double code(double a, double b) {
double tmp;
if (b <= 1.6) {
tmp = 0.5;
} else {
tmp = 1.0 / ((fma(0.16666666666666666, b, 0.5) * b) * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 1.6) tmp = 0.5; else tmp = Float64(1.0 / Float64(Float64(fma(0.16666666666666666, b, 0.5) * b) * b)); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.6], 0.5, N[(1.0 / N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.6:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right) \cdot b\right) \cdot b}\\
\end{array}
\end{array}
if b < 1.6000000000000001Initial program 98.3%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6476.0
Applied rewrites76.0%
Taylor expanded in b around 0
Applied rewrites56.2%
if 1.6000000000000001 < 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 rewrites67.5%
Taylor expanded in b around inf
Applied rewrites67.5%
(FPCore (a b) :precision binary64 (if (<= b -100000000.0) 0.5 (/ 1.0 (fma (fma 0.5 b 1.0) b 2.0))))
double code(double a, double b) {
double tmp;
if (b <= -100000000.0) {
tmp = 0.5;
} else {
tmp = 1.0 / fma(fma(0.5, b, 1.0), b, 2.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -100000000.0) tmp = 0.5; else tmp = Float64(1.0 / fma(fma(0.5, b, 1.0), b, 2.0)); end return tmp end
code[a_, b_] := If[LessEqual[b, -100000000.0], 0.5, N[(1.0 / N[(N[(0.5 * b + 1.0), $MachinePrecision] * b + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -100000000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, 2\right)}\\
\end{array}
\end{array}
if b < -1e8Initial 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 rewrites18.8%
if -1e8 < b Initial program 98.6%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6479.3
Applied rewrites79.3%
Taylor expanded in b around 0
Applied rewrites62.9%
(FPCore (a b) :precision binary64 (if (<= b 1.25) 0.5 (/ 1.0 (* (fma 0.5 b 1.0) b))))
double code(double a, double b) {
double tmp;
if (b <= 1.25) {
tmp = 0.5;
} else {
tmp = 1.0 / (fma(0.5, b, 1.0) * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 1.25) tmp = 0.5; else tmp = Float64(1.0 / Float64(fma(0.5, b, 1.0) * b)); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.25], 0.5, N[(1.0 / N[(N[(0.5 * b + 1.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.25:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(0.5, b, 1\right) \cdot b}\\
\end{array}
\end{array}
if b < 1.25Initial program 98.3%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6476.0
Applied rewrites76.0%
Taylor expanded in b around 0
Applied rewrites56.2%
if 1.25 < 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 rewrites67.5%
Taylor expanded in b around inf
Applied rewrites67.5%
Taylor expanded in b around 0
Applied rewrites52.1%
(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 98.8%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6482.8
Applied rewrites82.8%
Taylor expanded in b around 0
Applied rewrites41.1%
(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 2024276
(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))))