
(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 14 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 (/ (exp a) (+ (exp b) (exp a))))
double code(double a, double b) {
return exp(a) / (exp(b) + exp(a));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(b) + exp(a))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(b) + Math.exp(a));
}
def code(a, b): return math.exp(a) / (math.exp(b) + math.exp(a))
function code(a, b) return Float64(exp(a) / Float64(exp(b) + exp(a))) end
function tmp = code(a, b) tmp = exp(a) / (exp(b) + exp(a)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[b], $MachinePrecision] + N[Exp[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{b} + e^{a}}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (/ (exp a) (+ 1.0 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 + 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 + 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 + 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 + 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(1.0 + 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 + 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[(1.0 + 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}}{1 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
if 0.0 < (exp.f64 a) Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6499.6
Applied rewrites99.6%
Final simplification99.7%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (fma 0.5 a 1.0) a)))
(if (<= a -5e+155)
(/ 1.0 (+ (* (* a a) 0.5) 1.0))
(if (<= a -7.6e+62)
(/ 1.0 (+ (/ (fma t_0 t_0 -1.0) (fma (fma 0.5 a 1.0) a -1.0)) 1.0))
(/ 1.0 (+ 1.0 (exp b)))))))
double code(double a, double b) {
double t_0 = fma(0.5, a, 1.0) * a;
double tmp;
if (a <= -5e+155) {
tmp = 1.0 / (((a * a) * 0.5) + 1.0);
} else if (a <= -7.6e+62) {
tmp = 1.0 / ((fma(t_0, t_0, -1.0) / fma(fma(0.5, a, 1.0), a, -1.0)) + 1.0);
} else {
tmp = 1.0 / (1.0 + exp(b));
}
return tmp;
}
function code(a, b) t_0 = Float64(fma(0.5, a, 1.0) * a) tmp = 0.0 if (a <= -5e+155) tmp = Float64(1.0 / Float64(Float64(Float64(a * a) * 0.5) + 1.0)); elseif (a <= -7.6e+62) tmp = Float64(1.0 / Float64(Float64(fma(t_0, t_0, -1.0) / fma(fma(0.5, a, 1.0), a, -1.0)) + 1.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), $MachinePrecision]}, If[LessEqual[a, -5e+155], N[(1.0 / N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -7.6e+62], N[(1.0 / N[(N[(N[(t$95$0 * t$95$0 + -1.0), $MachinePrecision] / N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + -1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $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(0.5, a, 1\right) \cdot a\\
\mathbf{if}\;a \leq -5 \cdot 10^{+155}:\\
\;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\
\mathbf{elif}\;a \leq -7.6 \cdot 10^{+62}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(t\_0, t\_0, -1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, -1\right)} + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -4.9999999999999999e155Initial program 100.0%
Taylor expanded in b around 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%
Taylor expanded in a around inf
Applied rewrites100.0%
if -4.9999999999999999e155 < a < -7.59999999999999967e62Initial program 100.0%
Taylor expanded in b around 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 rewrites6.5%
Applied rewrites95.7%
if -7.59999999999999967e62 < a Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6497.2
Applied rewrites97.2%
Final simplification97.5%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (* b b) b)))
(if (<= b -6.6)
(/ (fma (fma 0.5 a 1.0) a 1.0) (+ (* (fma 0.5 a 1.0) a) 1.0))
(if (<= b 2.3e+51)
(/ 1.0 (+ (fma (fma (fma 0.16666666666666666 a 0.5) a 1.0) a 1.0) 1.0))
(/ 1.0 (/ (- 64.0 (* t_0 t_0)) 32.0))))))
double code(double a, double b) {
double t_0 = (b * b) * b;
double tmp;
if (b <= -6.6) {
tmp = fma(fma(0.5, a, 1.0), a, 1.0) / ((fma(0.5, a, 1.0) * a) + 1.0);
} else if (b <= 2.3e+51) {
tmp = 1.0 / (fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0);
} else {
tmp = 1.0 / ((64.0 - (t_0 * t_0)) / 32.0);
}
return tmp;
}
function code(a, b) t_0 = Float64(Float64(b * b) * b) tmp = 0.0 if (b <= -6.6) tmp = Float64(fma(fma(0.5, a, 1.0), a, 1.0) / Float64(Float64(fma(0.5, a, 1.0) * a) + 1.0)); elseif (b <= 2.3e+51) tmp = Float64(1.0 / Float64(fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0)); else tmp = Float64(1.0 / Float64(Float64(64.0 - Float64(t_0 * t_0)) / 32.0)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[b, -6.6], N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] / N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.3e+51], N[(1.0 / N[(N[(N[(N[(0.16666666666666666 * a + 0.5), $MachinePrecision] * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(64.0 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / 32.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b \cdot b\right) \cdot b\\
\mathbf{if}\;b \leq -6.6:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)}{\mathsf{fma}\left(0.5, a, 1\right) \cdot a + 1}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{+51}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{64 - t\_0 \cdot t\_0}{32}}\\
\end{array}
\end{array}
if b < -6.5999999999999996Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites18.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6418.8
Applied rewrites18.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6418.8
Applied rewrites18.8%
Taylor expanded in a around inf
Applied rewrites100.0%
if -6.5999999999999996 < b < 2.30000000000000005e51Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites93.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6493.2
Applied rewrites93.2%
Taylor expanded in a around 0
Applied rewrites77.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6483.6
Applied rewrites83.6%
if 2.30000000000000005e51 < 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 rewrites5.9%
Applied rewrites4.8%
Taylor expanded in b around 0
Applied rewrites100.0%
Final simplification90.7%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma (fma 0.5 a 1.0) a 1.0)))
(if (<= b -6.6)
(/ t_0 (+ (* (fma 0.5 a 1.0) a) 1.0))
(if (<= b 20000.0)
(/ 1.0 (+ (fma (fma (fma 0.16666666666666666 a 0.5) a 1.0) a 1.0) 1.0))
(if (<= b 3.1e+82)
(/ (* (* a a) 0.5) (+ t_0 1.0))
(/ 1.0 (fma (fma (fma 0.16666666666666666 b 0.5) b 1.0) b 2.0)))))))
double code(double a, double b) {
double t_0 = fma(fma(0.5, a, 1.0), a, 1.0);
double tmp;
if (b <= -6.6) {
tmp = t_0 / ((fma(0.5, a, 1.0) * a) + 1.0);
} else if (b <= 20000.0) {
tmp = 1.0 / (fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0);
} else if (b <= 3.1e+82) {
tmp = ((a * a) * 0.5) / (t_0 + 1.0);
} else {
tmp = 1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0);
}
return tmp;
}
function code(a, b) t_0 = fma(fma(0.5, a, 1.0), a, 1.0) tmp = 0.0 if (b <= -6.6) tmp = Float64(t_0 / Float64(Float64(fma(0.5, a, 1.0) * a) + 1.0)); elseif (b <= 20000.0) tmp = Float64(1.0 / Float64(fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0)); elseif (b <= 3.1e+82) tmp = Float64(Float64(Float64(a * a) * 0.5) / Float64(t_0 + 1.0)); 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_] := Block[{t$95$0 = N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision]}, If[LessEqual[b, -6.6], N[(t$95$0 / N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 20000.0], N[(1.0 / N[(N[(N[(N[(0.16666666666666666 * a + 0.5), $MachinePrecision] * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.1e+82], N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], 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}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right)\\
\mathbf{if}\;b \leq -6.6:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(0.5, a, 1\right) \cdot a + 1}\\
\mathbf{elif}\;b \leq 20000:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\
\mathbf{elif}\;b \leq 3.1 \cdot 10^{+82}:\\
\;\;\;\;\frac{\left(a \cdot a\right) \cdot 0.5}{t\_0 + 1}\\
\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 < -6.5999999999999996Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites18.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6418.8
Applied rewrites18.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6418.8
Applied rewrites18.8%
Taylor expanded in a around inf
Applied rewrites100.0%
if -6.5999999999999996 < b < 2e4Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites99.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6499.1
Applied rewrites99.1%
Taylor expanded in a around 0
Applied rewrites83.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6490.0
Applied rewrites90.0%
if 2e4 < b < 3.10000000000000032e82Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites29.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6429.5
Applied rewrites29.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f643.0
Applied rewrites3.0%
Taylor expanded in a around inf
Applied rewrites38.7%
if 3.10000000000000032e82 < 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 rewrites91.4%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (* a a) 0.5)))
(if (<= b -2.9)
(/ 1.0 (+ t_0 1.0))
(if (<= b 20000.0)
(/ 1.0 (+ (fma (fma (fma 0.16666666666666666 a 0.5) a 1.0) a 1.0) 1.0))
(if (<= b 3.1e+82)
(/ t_0 (+ (fma (fma 0.5 a 1.0) a 1.0) 1.0))
(/ 1.0 (fma (fma (fma 0.16666666666666666 b 0.5) b 1.0) b 2.0)))))))
double code(double a, double b) {
double t_0 = (a * a) * 0.5;
double tmp;
if (b <= -2.9) {
tmp = 1.0 / (t_0 + 1.0);
} else if (b <= 20000.0) {
tmp = 1.0 / (fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0);
} else if (b <= 3.1e+82) {
tmp = t_0 / (fma(fma(0.5, a, 1.0), a, 1.0) + 1.0);
} else {
tmp = 1.0 / fma(fma(fma(0.16666666666666666, b, 0.5), b, 1.0), b, 2.0);
}
return tmp;
}
function code(a, b) t_0 = Float64(Float64(a * a) * 0.5) tmp = 0.0 if (b <= -2.9) tmp = Float64(1.0 / Float64(t_0 + 1.0)); elseif (b <= 20000.0) tmp = Float64(1.0 / Float64(fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0)); elseif (b <= 3.1e+82) tmp = Float64(t_0 / Float64(fma(fma(0.5, a, 1.0), a, 1.0) + 1.0)); 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_] := Block[{t$95$0 = N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[b, -2.9], N[(1.0 / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 20000.0], N[(1.0 / N[(N[(N[(N[(0.16666666666666666 * a + 0.5), $MachinePrecision] * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.1e+82], N[(t$95$0 / N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 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}
t_0 := \left(a \cdot a\right) \cdot 0.5\\
\mathbf{if}\;b \leq -2.9:\\
\;\;\;\;\frac{1}{t\_0 + 1}\\
\mathbf{elif}\;b \leq 20000:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\
\mathbf{elif}\;b \leq 3.1 \cdot 10^{+82}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + 1}\\
\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 < -2.89999999999999991Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites18.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6418.8
Applied rewrites18.8%
Taylor expanded in a around 0
Applied rewrites18.7%
Taylor expanded in a around inf
Applied rewrites98.6%
if -2.89999999999999991 < b < 2e4Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites99.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6499.1
Applied rewrites99.1%
Taylor expanded in a around 0
Applied rewrites83.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6490.0
Applied rewrites90.0%
if 2e4 < b < 3.10000000000000032e82Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites29.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6429.5
Applied rewrites29.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f643.0
Applied rewrites3.0%
Taylor expanded in a around inf
Applied rewrites38.7%
if 3.10000000000000032e82 < 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 rewrites91.4%
(FPCore (a b)
:precision binary64
(if (<= b -2.9)
(/ 1.0 (+ (* (* a a) 0.5) 1.0))
(if (<= b 8e+84)
(/ 1.0 (+ (fma (fma (fma 0.16666666666666666 a 0.5) a 1.0) a 1.0) 1.0))
(/ 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 <= -2.9) {
tmp = 1.0 / (((a * a) * 0.5) + 1.0);
} else if (b <= 8e+84) {
tmp = 1.0 / (fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0);
} 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 <= -2.9) tmp = Float64(1.0 / Float64(Float64(Float64(a * a) * 0.5) + 1.0)); elseif (b <= 8e+84) tmp = Float64(1.0 / Float64(fma(fma(fma(0.16666666666666666, a, 0.5), a, 1.0), a, 1.0) + 1.0)); 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, -2.9], N[(1.0 / N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e+84], N[(1.0 / N[(N[(N[(N[(0.16666666666666666 * a + 0.5), $MachinePrecision] * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 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 -2.9:\\
\;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\
\mathbf{elif}\;b \leq 8 \cdot 10^{+84}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, a, 0.5\right), a, 1\right), a, 1\right) + 1}\\
\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 < -2.89999999999999991Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites18.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6418.8
Applied rewrites18.8%
Taylor expanded in a around 0
Applied rewrites18.7%
Taylor expanded in a around inf
Applied rewrites98.6%
if -2.89999999999999991 < b < 8.00000000000000046e84Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites89.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6489.3
Applied rewrites89.3%
Taylor expanded in a around 0
Applied rewrites73.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6479.1
Applied rewrites79.1%
if 8.00000000000000046e84 < 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 rewrites94.7%
(FPCore (a b)
:precision binary64
(if (<= b -1.6e-8)
(/ 1.0 (+ (* (* a a) 0.5) 1.0))
(if (<= b 8e+84)
(/ (+ 1.0 a) (+ (fma (fma 0.5 a 1.0) a 1.0) 1.0))
(/ 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 <= -1.6e-8) {
tmp = 1.0 / (((a * a) * 0.5) + 1.0);
} else if (b <= 8e+84) {
tmp = (1.0 + a) / (fma(fma(0.5, a, 1.0), a, 1.0) + 1.0);
} 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 <= -1.6e-8) tmp = Float64(1.0 / Float64(Float64(Float64(a * a) * 0.5) + 1.0)); elseif (b <= 8e+84) tmp = Float64(Float64(1.0 + a) / Float64(fma(fma(0.5, a, 1.0), a, 1.0) + 1.0)); 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, -1.6e-8], N[(1.0 / N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e+84], N[(N[(1.0 + a), $MachinePrecision] / N[(N[(N[(0.5 * a + 1.0), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 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 -1.6 \cdot 10^{-8}:\\
\;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\
\mathbf{elif}\;b \leq 8 \cdot 10^{+84}:\\
\;\;\;\;\frac{1 + a}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, a, 1\right), a, 1\right) + 1}\\
\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 < -1.6000000000000001e-8Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites20.4%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6420.4
Applied rewrites20.4%
Taylor expanded in a around 0
Applied rewrites18.5%
Taylor expanded in a around inf
Applied rewrites96.7%
if -1.6000000000000001e-8 < b < 8.00000000000000046e84Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites89.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6489.2
Applied rewrites89.2%
Taylor expanded in a around 0
lower-+.f6473.6
Applied rewrites73.6%
if 8.00000000000000046e84 < 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 rewrites94.7%
(FPCore (a b)
:precision binary64
(if (<= b -1.1)
(/ 1.0 (+ (* (* a a) 0.5) 1.0))
(if (<= b 8e+84)
(/ 1.0 (+ (fma (* 0.5 a) a 1.0) 1.0))
(/ 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 <= -1.1) {
tmp = 1.0 / (((a * a) * 0.5) + 1.0);
} else if (b <= 8e+84) {
tmp = 1.0 / (fma((0.5 * a), a, 1.0) + 1.0);
} 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 <= -1.1) tmp = Float64(1.0 / Float64(Float64(Float64(a * a) * 0.5) + 1.0)); elseif (b <= 8e+84) tmp = Float64(1.0 / Float64(fma(Float64(0.5 * a), a, 1.0) + 1.0)); 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, -1.1], N[(1.0 / N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e+84], N[(1.0 / N[(N[(N[(0.5 * a), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 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 -1.1:\\
\;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\
\mathbf{elif}\;b \leq 8 \cdot 10^{+84}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(0.5 \cdot a, a, 1\right) + 1}\\
\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 < -1.1000000000000001Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites18.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6418.8
Applied rewrites18.8%
Taylor expanded in a around 0
Applied rewrites18.7%
Taylor expanded in a around inf
Applied rewrites98.6%
if -1.1000000000000001 < b < 8.00000000000000046e84Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites89.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6489.3
Applied rewrites89.3%
Taylor expanded in a around 0
Applied rewrites73.0%
Taylor expanded in a around inf
Applied rewrites73.1%
if 8.00000000000000046e84 < 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 rewrites94.7%
(FPCore (a b)
:precision binary64
(if (<= b -1.1)
(/ 1.0 (+ (* (* a a) 0.5) 1.0))
(if (<= b 4.6e+117)
(/ 1.0 (+ (fma (* 0.5 a) a 1.0) 1.0))
(/ 1.0 (fma (fma 0.5 b 1.0) b 2.0)))))
double code(double a, double b) {
double tmp;
if (b <= -1.1) {
tmp = 1.0 / (((a * a) * 0.5) + 1.0);
} else if (b <= 4.6e+117) {
tmp = 1.0 / (fma((0.5 * a), a, 1.0) + 1.0);
} 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 <= -1.1) tmp = Float64(1.0 / Float64(Float64(Float64(a * a) * 0.5) + 1.0)); elseif (b <= 4.6e+117) tmp = Float64(1.0 / Float64(fma(Float64(0.5 * a), a, 1.0) + 1.0)); 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, -1.1], N[(1.0 / N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.6e+117], N[(1.0 / N[(N[(N[(0.5 * a), $MachinePrecision] * a + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 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 -1.1:\\
\;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\
\mathbf{elif}\;b \leq 4.6 \cdot 10^{+117}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(0.5 \cdot a, a, 1\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, 2\right)}\\
\end{array}
\end{array}
if b < -1.1000000000000001Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites18.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6418.8
Applied rewrites18.8%
Taylor expanded in a around 0
Applied rewrites18.7%
Taylor expanded in a around inf
Applied rewrites98.6%
if -1.1000000000000001 < b < 4.59999999999999976e117Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites86.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6486.9
Applied rewrites86.9%
Taylor expanded in a around 0
Applied rewrites70.2%
Taylor expanded in a around inf
Applied rewrites70.3%
if 4.59999999999999976e117 < 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 rewrites91.8%
(FPCore (a b) :precision binary64 (if (<= b -2.5e-79) (/ 1.0 (+ (* (* a a) 0.5) 1.0)) (/ 1.0 (fma (fma 0.5 b 1.0) b 2.0))))
double code(double a, double b) {
double tmp;
if (b <= -2.5e-79) {
tmp = 1.0 / (((a * a) * 0.5) + 1.0);
} 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 <= -2.5e-79) tmp = Float64(1.0 / Float64(Float64(Float64(a * a) * 0.5) + 1.0)); 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, -2.5e-79], N[(1.0 / N[(N[(N[(a * a), $MachinePrecision] * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 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 -2.5 \cdot 10^{-79}:\\
\;\;\;\;\frac{1}{\left(a \cdot a\right) \cdot 0.5 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, 2\right)}\\
\end{array}
\end{array}
if b < -2.5e-79Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites39.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6439.3
Applied rewrites39.3%
Taylor expanded in a around 0
Applied rewrites32.8%
Taylor expanded in a around inf
Applied rewrites85.7%
if -2.5e-79 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6481.1
Applied rewrites81.1%
Taylor expanded in b around 0
Applied rewrites62.5%
(FPCore (a b) :precision binary64 (if (<= b 1.25e-10) (/ 1.0 (+ (+ 1.0 a) 1.0)) (/ 1.0 (fma (fma 0.5 b 1.0) b 2.0))))
double code(double a, double b) {
double tmp;
if (b <= 1.25e-10) {
tmp = 1.0 / ((1.0 + a) + 1.0);
} 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 <= 1.25e-10) tmp = Float64(1.0 / Float64(Float64(1.0 + a) + 1.0)); 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, 1.25e-10], N[(1.0 / N[(N[(1.0 + a), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 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 1.25 \cdot 10^{-10}:\\
\;\;\;\;\frac{1}{\left(1 + a\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, b, 1\right), b, 2\right)}\\
\end{array}
\end{array}
if b < 1.25000000000000008e-10Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites77.7%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6477.7
Applied rewrites77.7%
Taylor expanded in a around 0
Applied rewrites67.1%
Taylor expanded in a around 0
lower-+.f6452.3
Applied rewrites52.3%
if 1.25000000000000008e-10 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6498.8
Applied rewrites98.8%
Taylor expanded in b around 0
Applied rewrites53.8%
(FPCore (a b) :precision binary64 (/ 1.0 (+ (+ 1.0 a) 1.0)))
double code(double a, double b) {
return 1.0 / ((1.0 + a) + 1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / ((1.0d0 + a) + 1.0d0)
end function
public static double code(double a, double b) {
return 1.0 / ((1.0 + a) + 1.0);
}
def code(a, b): return 1.0 / ((1.0 + a) + 1.0)
function code(a, b) return Float64(1.0 / Float64(Float64(1.0 + a) + 1.0)) end
function tmp = code(a, b) tmp = 1.0 / ((1.0 + a) + 1.0); end
code[a_, b_] := N[(1.0 / N[(N[(1.0 + a), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(1 + a\right) + 1}
\end{array}
Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites64.6%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6464.6
Applied rewrites64.6%
Taylor expanded in a around 0
Applied rewrites52.2%
Taylor expanded in a around 0
lower-+.f6437.4
Applied rewrites37.4%
(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 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f6481.6
Applied rewrites81.6%
Taylor expanded in b around 0
Applied rewrites36.7%
(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 2024235
(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))))