
(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 17 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 a (fma a 0.16666666666666666 0.5) 1.0)))
(if (<= (exp a) 0.0)
(/ (exp a) (+ 1.0 1.0))
(/ (fma a t_0 1.0) (fma a t_0 (+ (exp b) 1.0))))))
double code(double a, double b) {
double t_0 = fma(a, fma(a, 0.16666666666666666, 0.5), 1.0);
double tmp;
if (exp(a) <= 0.0) {
tmp = exp(a) / (1.0 + 1.0);
} else {
tmp = fma(a, t_0, 1.0) / fma(a, t_0, (exp(b) + 1.0));
}
return tmp;
}
function code(a, b) t_0 = fma(a, fma(a, 0.16666666666666666, 0.5), 1.0) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(exp(a) / Float64(1.0 + 1.0)); else tmp = Float64(fma(a, t_0, 1.0) / fma(a, t_0, Float64(exp(b) + 1.0))); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(a * N[(a * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(N[Exp[a], $MachinePrecision] / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(a * t$95$0 + 1.0), $MachinePrecision] / N[(a * t$95$0 + N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.16666666666666666, 0.5\right), 1\right)\\
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{e^{a}}{1 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, t\_0, 1\right)}{\mathsf{fma}\left(a, t\_0, e^{b} + 1\right)}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 98.5%
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 99.5%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-exp.f6498.7
Applied rewrites98.7%
Taylor expanded in a around 0
+-commutativeN/A
Applied rewrites99.7%
Final simplification99.7%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma a (fma a 0.16666666666666666 0.5) 1.0)))
(if (<= (/ (exp a) (+ (exp a) (exp b))) 0.0)
(/
1.0
(*
(* b b)
(*
b
(-
(/
(* (+ 0.125 (/ 1.0 (* b (* b b)))) (/ 1.0 b))
(+ 0.25 (/ (- (/ 1.0 b) 0.5) b)))
-0.16666666666666666))))
(/ (fma a t_0 1.0) (fma a t_0 2.0)))))
double code(double a, double b) {
double t_0 = fma(a, fma(a, 0.16666666666666666, 0.5), 1.0);
double tmp;
if ((exp(a) / (exp(a) + exp(b))) <= 0.0) {
tmp = 1.0 / ((b * b) * (b * ((((0.125 + (1.0 / (b * (b * b)))) * (1.0 / b)) / (0.25 + (((1.0 / b) - 0.5) / b))) - -0.16666666666666666)));
} else {
tmp = fma(a, t_0, 1.0) / fma(a, t_0, 2.0);
}
return tmp;
}
function code(a, b) t_0 = fma(a, fma(a, 0.16666666666666666, 0.5), 1.0) tmp = 0.0 if (Float64(exp(a) / Float64(exp(a) + exp(b))) <= 0.0) tmp = Float64(1.0 / Float64(Float64(b * b) * Float64(b * Float64(Float64(Float64(Float64(0.125 + Float64(1.0 / Float64(b * Float64(b * b)))) * Float64(1.0 / b)) / Float64(0.25 + Float64(Float64(Float64(1.0 / b) - 0.5) / b))) - -0.16666666666666666)))); else tmp = Float64(fma(a, t_0, 1.0) / fma(a, t_0, 2.0)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(a * N[(a * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(1.0 / N[(N[(b * b), $MachinePrecision] * N[(b * N[(N[(N[(N[(0.125 + N[(1.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / b), $MachinePrecision]), $MachinePrecision] / N[(0.25 + N[(N[(N[(1.0 / b), $MachinePrecision] - 0.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * t$95$0 + 1.0), $MachinePrecision] / N[(a * t$95$0 + 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.16666666666666666, 0.5\right), 1\right)\\
\mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0:\\
\;\;\;\;\frac{1}{\left(b \cdot b\right) \cdot \left(b \cdot \left(\frac{\left(0.125 + \frac{1}{b \cdot \left(b \cdot b\right)}\right) \cdot \frac{1}{b}}{0.25 + \frac{\frac{1}{b} - 0.5}{b}} - -0.16666666666666666\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, t\_0, 1\right)}{\mathsf{fma}\left(a, t\_0, 2\right)}\\
\end{array}
\end{array}
if (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) < 0.0Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6460.3
Applied rewrites60.3%
Taylor expanded in b around 0
Applied rewrites45.2%
Taylor expanded in b around -inf
Applied rewrites47.3%
Applied rewrites54.7%
if 0.0 < (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) Initial program 98.7%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-exp.f6498.4
Applied rewrites98.4%
Taylor expanded in a around 0
+-commutativeN/A
Applied rewrites98.9%
Taylor expanded in b around 0
Applied rewrites67.5%
Final simplification62.2%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma a (fma a 0.16666666666666666 0.5) 1.0)))
(if (<= (/ (exp a) (+ (exp a) (exp b))) 0.0)
(/
1.0
(*
b
(+
(fma b 0.5 1.0)
(* (* b b) (+ 0.16666666666666666 (/ 2.0 (* b (* b b))))))))
(/ (fma a t_0 1.0) (fma a t_0 2.0)))))
double code(double a, double b) {
double t_0 = fma(a, fma(a, 0.16666666666666666, 0.5), 1.0);
double tmp;
if ((exp(a) / (exp(a) + exp(b))) <= 0.0) {
tmp = 1.0 / (b * (fma(b, 0.5, 1.0) + ((b * b) * (0.16666666666666666 + (2.0 / (b * (b * b)))))));
} else {
tmp = fma(a, t_0, 1.0) / fma(a, t_0, 2.0);
}
return tmp;
}
function code(a, b) t_0 = fma(a, fma(a, 0.16666666666666666, 0.5), 1.0) tmp = 0.0 if (Float64(exp(a) / Float64(exp(a) + exp(b))) <= 0.0) tmp = Float64(1.0 / Float64(b * Float64(fma(b, 0.5, 1.0) + Float64(Float64(b * b) * Float64(0.16666666666666666 + Float64(2.0 / Float64(b * Float64(b * b)))))))); else tmp = Float64(fma(a, t_0, 1.0) / fma(a, t_0, 2.0)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(a * N[(a * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(1.0 / N[(b * N[(N[(b * 0.5 + 1.0), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(0.16666666666666666 + N[(2.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * t$95$0 + 1.0), $MachinePrecision] / N[(a * t$95$0 + 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.16666666666666666, 0.5\right), 1\right)\\
\mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0:\\
\;\;\;\;\frac{1}{b \cdot \left(\mathsf{fma}\left(b, 0.5, 1\right) + \left(b \cdot b\right) \cdot \left(0.16666666666666666 + \frac{2}{b \cdot \left(b \cdot b\right)}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, t\_0, 1\right)}{\mathsf{fma}\left(a, t\_0, 2\right)}\\
\end{array}
\end{array}
if (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) < 0.0Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6460.3
Applied rewrites60.3%
Taylor expanded in b around 0
Applied rewrites45.2%
Taylor expanded in b around inf
Applied rewrites52.9%
if 0.0 < (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) Initial program 98.7%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-exp.f6498.4
Applied rewrites98.4%
Taylor expanded in a around 0
+-commutativeN/A
Applied rewrites98.9%
Taylor expanded in b around 0
Applied rewrites67.5%
(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 (if (<= (exp a) 0.0) (/ (exp a) (+ 1.0 1.0)) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = exp(a) / (1.0 + 1.0);
} else {
tmp = 1.0 / (exp(b) + 1.0);
}
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 / (exp(b) + 1.0d0)
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 / (Math.exp(b) + 1.0);
}
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 / (math.exp(b) + 1.0) 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(exp(b) + 1.0)); 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 / (exp(b) + 1.0); 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[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{e^{a}}{1 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 98.5%
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 99.5%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6499.3
Applied rewrites99.3%
Final simplification99.5%
(FPCore (a b) :precision binary64 (if (<= (exp b) 1.0) (/ 1.0 (+ 1.0 (+ a 1.0))) (/ 1.0 (fma b (fma b (fma b 0.16666666666666666 0.5) 1.0) 2.0))))
double code(double a, double b) {
double tmp;
if (exp(b) <= 1.0) {
tmp = 1.0 / (1.0 + (a + 1.0));
} else {
tmp = 1.0 / fma(b, fma(b, fma(b, 0.16666666666666666, 0.5), 1.0), 2.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (exp(b) <= 1.0) tmp = Float64(1.0 / Float64(1.0 + Float64(a + 1.0))); else tmp = Float64(1.0 / fma(b, fma(b, fma(b, 0.16666666666666666, 0.5), 1.0), 2.0)); end return tmp end
code[a_, b_] := If[LessEqual[N[Exp[b], $MachinePrecision], 1.0], N[(1.0 / N[(1.0 + N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{b} \leq 1:\\
\;\;\;\;\frac{1}{1 + \left(a + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), 1\right), 2\right)}\\
\end{array}
\end{array}
if (exp.f64 b) < 1Initial program 99.5%
Taylor expanded in b around 0
Applied rewrites76.0%
Taylor expanded in a around 0
lower-+.f6475.5
Applied rewrites75.5%
Taylor expanded in a around 0
Applied rewrites53.6%
if 1 < (exp.f64 b) Initial program 98.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites73.7%
Final simplification58.6%
(FPCore (a b) :precision binary64 (if (<= (exp b) 1.0) (/ 1.0 (+ 1.0 (+ a 1.0))) (/ 1.0 (fma b (fma b (* b 0.16666666666666666) 1.0) 2.0))))
double code(double a, double b) {
double tmp;
if (exp(b) <= 1.0) {
tmp = 1.0 / (1.0 + (a + 1.0));
} else {
tmp = 1.0 / fma(b, fma(b, (b * 0.16666666666666666), 1.0), 2.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (exp(b) <= 1.0) tmp = Float64(1.0 / Float64(1.0 + Float64(a + 1.0))); else tmp = Float64(1.0 / fma(b, fma(b, Float64(b * 0.16666666666666666), 1.0), 2.0)); end return tmp end
code[a_, b_] := If[LessEqual[N[Exp[b], $MachinePrecision], 1.0], N[(1.0 / N[(1.0 + N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * N[(b * 0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{b} \leq 1:\\
\;\;\;\;\frac{1}{1 + \left(a + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, b \cdot 0.16666666666666666, 1\right), 2\right)}\\
\end{array}
\end{array}
if (exp.f64 b) < 1Initial program 99.5%
Taylor expanded in b around 0
Applied rewrites76.0%
Taylor expanded in a around 0
lower-+.f6475.5
Applied rewrites75.5%
Taylor expanded in a around 0
Applied rewrites53.6%
if 1 < (exp.f64 b) Initial program 98.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites73.7%
Taylor expanded in b around inf
Applied rewrites73.7%
Final simplification58.6%
(FPCore (a b) :precision binary64 (if (<= (exp b) 1.0) (/ 1.0 (+ 1.0 (+ a 1.0))) (/ 1.0 (fma b (fma b 0.5 1.0) 2.0))))
double code(double a, double b) {
double tmp;
if (exp(b) <= 1.0) {
tmp = 1.0 / (1.0 + (a + 1.0));
} else {
tmp = 1.0 / fma(b, fma(b, 0.5, 1.0), 2.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (exp(b) <= 1.0) tmp = Float64(1.0 / Float64(1.0 + Float64(a + 1.0))); else tmp = Float64(1.0 / fma(b, fma(b, 0.5, 1.0), 2.0)); end return tmp end
code[a_, b_] := If[LessEqual[N[Exp[b], $MachinePrecision], 1.0], N[(1.0 / N[(1.0 + N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * 0.5 + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{b} \leq 1:\\
\;\;\;\;\frac{1}{1 + \left(a + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), 2\right)}\\
\end{array}
\end{array}
if (exp.f64 b) < 1Initial program 99.5%
Taylor expanded in b around 0
Applied rewrites76.0%
Taylor expanded in a around 0
lower-+.f6475.5
Applied rewrites75.5%
Taylor expanded in a around 0
Applied rewrites53.6%
if 1 < (exp.f64 b) Initial program 98.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites57.2%
Final simplification54.5%
(FPCore (a b)
:precision binary64
(if (<= a -5e+133)
(/
1.0
(*
(* b b)
(*
b
(-
(/
(* (+ 0.125 (/ 1.0 (* b (* b b)))) (/ 1.0 b))
(+ 0.25 (/ (- (/ 1.0 b) 0.5) b)))
-0.16666666666666666))))
(/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
double tmp;
if (a <= -5e+133) {
tmp = 1.0 / ((b * b) * (b * ((((0.125 + (1.0 / (b * (b * b)))) * (1.0 / b)) / (0.25 + (((1.0 / b) - 0.5) / b))) - -0.16666666666666666)));
} else {
tmp = 1.0 / (exp(b) + 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 <= (-5d+133)) then
tmp = 1.0d0 / ((b * b) * (b * ((((0.125d0 + (1.0d0 / (b * (b * b)))) * (1.0d0 / b)) / (0.25d0 + (((1.0d0 / b) - 0.5d0) / b))) - (-0.16666666666666666d0))))
else
tmp = 1.0d0 / (exp(b) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -5e+133) {
tmp = 1.0 / ((b * b) * (b * ((((0.125 + (1.0 / (b * (b * b)))) * (1.0 / b)) / (0.25 + (((1.0 / b) - 0.5) / b))) - -0.16666666666666666)));
} else {
tmp = 1.0 / (Math.exp(b) + 1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -5e+133: tmp = 1.0 / ((b * b) * (b * ((((0.125 + (1.0 / (b * (b * b)))) * (1.0 / b)) / (0.25 + (((1.0 / b) - 0.5) / b))) - -0.16666666666666666))) else: tmp = 1.0 / (math.exp(b) + 1.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -5e+133) tmp = Float64(1.0 / Float64(Float64(b * b) * Float64(b * Float64(Float64(Float64(Float64(0.125 + Float64(1.0 / Float64(b * Float64(b * b)))) * Float64(1.0 / b)) / Float64(0.25 + Float64(Float64(Float64(1.0 / b) - 0.5) / b))) - -0.16666666666666666)))); else tmp = Float64(1.0 / Float64(exp(b) + 1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -5e+133) tmp = 1.0 / ((b * b) * (b * ((((0.125 + (1.0 / (b * (b * b)))) * (1.0 / b)) / (0.25 + (((1.0 / b) - 0.5) / b))) - -0.16666666666666666))); else tmp = 1.0 / (exp(b) + 1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -5e+133], N[(1.0 / N[(N[(b * b), $MachinePrecision] * N[(b * N[(N[(N[(N[(0.125 + N[(1.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / b), $MachinePrecision]), $MachinePrecision] / N[(0.25 + N[(N[(N[(1.0 / b), $MachinePrecision] - 0.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{+133}:\\
\;\;\;\;\frac{1}{\left(b \cdot b\right) \cdot \left(b \cdot \left(\frac{\left(0.125 + \frac{1}{b \cdot \left(b \cdot b\right)}\right) \cdot \frac{1}{b}}{0.25 + \frac{\frac{1}{b} - 0.5}{b}} - -0.16666666666666666\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\end{array}
if a < -4.99999999999999961e133Initial program 97.6%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6440.9
Applied rewrites40.9%
Taylor expanded in b around 0
Applied rewrites29.6%
Taylor expanded in b around -inf
Applied rewrites33.5%
Applied rewrites52.4%
if -4.99999999999999961e133 < a Initial program 99.5%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6490.8
Applied rewrites90.8%
Final simplification84.7%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma b (fma 0.16666666666666666 b 0.5) 1.0)))
(if (<= b -6.6e-206)
(/
(fma a (fma a 0.5 1.0) 1.0)
(+ 1.0 (fma a (fma a (fma a 0.16666666666666666 0.5) 1.0) 1.0)))
(if (<= b 5e+102)
(/ 1.0 (/ (fma (* b b) (* t_0 t_0) -4.0) (fma b t_0 -2.0)))
(/ 1.0 (* 0.16666666666666666 (* b (* b b))))))))
double code(double a, double b) {
double t_0 = fma(b, fma(0.16666666666666666, b, 0.5), 1.0);
double tmp;
if (b <= -6.6e-206) {
tmp = fma(a, fma(a, 0.5, 1.0), 1.0) / (1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0));
} else if (b <= 5e+102) {
tmp = 1.0 / (fma((b * b), (t_0 * t_0), -4.0) / fma(b, t_0, -2.0));
} else {
tmp = 1.0 / (0.16666666666666666 * (b * (b * b)));
}
return tmp;
}
function code(a, b) t_0 = fma(b, fma(0.16666666666666666, b, 0.5), 1.0) tmp = 0.0 if (b <= -6.6e-206) tmp = Float64(fma(a, fma(a, 0.5, 1.0), 1.0) / Float64(1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0))); elseif (b <= 5e+102) tmp = Float64(1.0 / Float64(fma(Float64(b * b), Float64(t_0 * t_0), -4.0) / fma(b, t_0, -2.0))); else tmp = Float64(1.0 / Float64(0.16666666666666666 * Float64(b * Float64(b * b)))); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(b * N[(0.16666666666666666 * b + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[b, -6.6e-206], N[(N[(a * N[(a * 0.5 + 1.0), $MachinePrecision] + 1.0), $MachinePrecision] / N[(1.0 + N[(a * N[(a * N[(a * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5e+102], N[(1.0 / N[(N[(N[(b * b), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision] + -4.0), $MachinePrecision] / N[(b * t$95$0 + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(0.16666666666666666 * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b, \mathsf{fma}\left(0.16666666666666666, b, 0.5\right), 1\right)\\
\mathbf{if}\;b \leq -6.6 \cdot 10^{-206}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5, 1\right), 1\right)}{1 + \mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.16666666666666666, 0.5\right), 1\right), 1\right)}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+102}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(b \cdot b, t\_0 \cdot t\_0, -4\right)}{\mathsf{fma}\left(b, t\_0, -2\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{0.16666666666666666 \cdot \left(b \cdot \left(b \cdot b\right)\right)}\\
\end{array}
\end{array}
if b < -6.59999999999999961e-206Initial program 99.0%
Taylor expanded in b around 0
Applied rewrites53.0%
Taylor expanded in a around 0
lower-+.f6451.9
Applied rewrites51.9%
Taylor expanded in a around 0
Applied rewrites39.9%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6443.2
Applied rewrites43.2%
if -6.59999999999999961e-206 < b < 5e102Initial program 99.1%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6472.6
Applied rewrites72.6%
Taylor expanded in b around 0
Applied rewrites57.7%
Applied rewrites66.6%
if 5e102 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites100.0%
Taylor expanded in b around inf
Applied rewrites100.0%
Taylor expanded in b around inf
Applied rewrites100.0%
Final simplification63.5%
(FPCore (a b)
:precision binary64
(if (<= b -6.6e-206)
(/
(fma a (fma a 0.5 1.0) 1.0)
(+ 1.0 (fma a (fma a (fma a 0.16666666666666666 0.5) 1.0) 1.0)))
(if (<= b 5e+153)
(/
1.0
(fma
b
(/
(fma
(fma 0.16666666666666666 b 0.5)
(* (* b b) (fma 0.16666666666666666 b 0.5))
-1.0)
(fma b (fma 0.16666666666666666 b 0.5) -1.0))
2.0))
(/ 1.0 (fma 0.5 (* b b) b)))))
double code(double a, double b) {
double tmp;
if (b <= -6.6e-206) {
tmp = fma(a, fma(a, 0.5, 1.0), 1.0) / (1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0));
} else if (b <= 5e+153) {
tmp = 1.0 / fma(b, (fma(fma(0.16666666666666666, b, 0.5), ((b * b) * fma(0.16666666666666666, b, 0.5)), -1.0) / fma(b, fma(0.16666666666666666, b, 0.5), -1.0)), 2.0);
} else {
tmp = 1.0 / fma(0.5, (b * b), b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -6.6e-206) tmp = Float64(fma(a, fma(a, 0.5, 1.0), 1.0) / Float64(1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0))); elseif (b <= 5e+153) tmp = Float64(1.0 / fma(b, Float64(fma(fma(0.16666666666666666, b, 0.5), Float64(Float64(b * b) * fma(0.16666666666666666, b, 0.5)), -1.0) / fma(b, fma(0.16666666666666666, b, 0.5), -1.0)), 2.0)); else tmp = Float64(1.0 / fma(0.5, Float64(b * b), b)); end return tmp end
code[a_, b_] := If[LessEqual[b, -6.6e-206], N[(N[(a * N[(a * 0.5 + 1.0), $MachinePrecision] + 1.0), $MachinePrecision] / N[(1.0 + N[(a * N[(a * N[(a * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5e+153], N[(1.0 / N[(b * N[(N[(N[(0.16666666666666666 * b + 0.5), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] * N[(0.16666666666666666 * b + 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / N[(b * N[(0.16666666666666666 * b + 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(0.5 * N[(b * b), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.6 \cdot 10^{-206}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5, 1\right), 1\right)}{1 + \mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.16666666666666666, 0.5\right), 1\right), 1\right)}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b, \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, b, 0.5\right), \left(b \cdot b\right) \cdot \mathsf{fma}\left(0.16666666666666666, b, 0.5\right), -1\right)}{\mathsf{fma}\left(b, \mathsf{fma}\left(0.16666666666666666, b, 0.5\right), -1\right)}, 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(0.5, b \cdot b, b\right)}\\
\end{array}
\end{array}
if b < -6.59999999999999961e-206Initial program 99.0%
Taylor expanded in b around 0
Applied rewrites53.0%
Taylor expanded in a around 0
lower-+.f6451.9
Applied rewrites51.9%
Taylor expanded in a around 0
Applied rewrites39.9%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6443.2
Applied rewrites43.2%
if -6.59999999999999961e-206 < b < 5.00000000000000018e153Initial program 99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6475.0
Applied rewrites75.0%
Taylor expanded in b around 0
Applied rewrites61.4%
Applied rewrites68.8%
if 5.00000000000000018e153 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites100.0%
Taylor expanded in b around -inf
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites100.0%
Final simplification63.1%
(FPCore (a b)
:precision binary64
(if (<= b -6.6e-206)
(/
(fma a (fma a 0.5 1.0) 1.0)
(+ 1.0 (fma a (fma a (fma a 0.16666666666666666 0.5) 1.0) 1.0)))
(/ 1.0 (fma b (fma b (fma b 0.16666666666666666 0.5) 1.0) 2.0))))
double code(double a, double b) {
double tmp;
if (b <= -6.6e-206) {
tmp = fma(a, fma(a, 0.5, 1.0), 1.0) / (1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0));
} else {
tmp = 1.0 / fma(b, fma(b, fma(b, 0.16666666666666666, 0.5), 1.0), 2.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -6.6e-206) tmp = Float64(fma(a, fma(a, 0.5, 1.0), 1.0) / Float64(1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0))); else tmp = Float64(1.0 / fma(b, fma(b, fma(b, 0.16666666666666666, 0.5), 1.0), 2.0)); end return tmp end
code[a_, b_] := If[LessEqual[b, -6.6e-206], N[(N[(a * N[(a * 0.5 + 1.0), $MachinePrecision] + 1.0), $MachinePrecision] / N[(1.0 + N[(a * N[(a * N[(a * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.6 \cdot 10^{-206}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5, 1\right), 1\right)}{1 + \mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.16666666666666666, 0.5\right), 1\right), 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), 1\right), 2\right)}\\
\end{array}
\end{array}
if b < -6.59999999999999961e-206Initial program 99.0%
Taylor expanded in b around 0
Applied rewrites53.0%
Taylor expanded in a around 0
lower-+.f6451.9
Applied rewrites51.9%
Taylor expanded in a around 0
Applied rewrites39.9%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6443.2
Applied rewrites43.2%
if -6.59999999999999961e-206 < b Initial program 99.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6480.4
Applied rewrites80.4%
Taylor expanded in b around 0
Applied rewrites69.7%
Final simplification59.6%
(FPCore (a b) :precision binary64 (if (<= b 4.1e+49) (/ 1.0 (+ 1.0 (+ a 1.0))) (/ 1.0 (* (* b b) (fma b 0.16666666666666666 0.5)))))
double code(double a, double b) {
double tmp;
if (b <= 4.1e+49) {
tmp = 1.0 / (1.0 + (a + 1.0));
} else {
tmp = 1.0 / ((b * b) * fma(b, 0.16666666666666666, 0.5));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 4.1e+49) tmp = Float64(1.0 / Float64(1.0 + Float64(a + 1.0))); else tmp = Float64(1.0 / Float64(Float64(b * b) * fma(b, 0.16666666666666666, 0.5))); end return tmp end
code[a_, b_] := If[LessEqual[b, 4.1e+49], N[(1.0 / N[(1.0 + N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(b * b), $MachinePrecision] * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.1 \cdot 10^{+49}:\\
\;\;\;\;\frac{1}{1 + \left(a + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(b \cdot b\right) \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right)}\\
\end{array}
\end{array}
if b < 4.1e49Initial program 99.5%
Taylor expanded in b around 0
Applied rewrites75.3%
Taylor expanded in a around 0
lower-+.f6474.8
Applied rewrites74.8%
Taylor expanded in a around 0
Applied rewrites51.9%
if 4.1e49 < b Initial program 98.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites82.0%
Taylor expanded in b around inf
Applied rewrites82.0%
Final simplification58.5%
(FPCore (a b) :precision binary64 (if (<= b 4.1e+49) (/ 1.0 (+ 1.0 (+ a 1.0))) (/ 1.0 (* 0.16666666666666666 (* b (* b b))))))
double code(double a, double b) {
double tmp;
if (b <= 4.1e+49) {
tmp = 1.0 / (1.0 + (a + 1.0));
} else {
tmp = 1.0 / (0.16666666666666666 * (b * (b * b)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 4.1d+49) then
tmp = 1.0d0 / (1.0d0 + (a + 1.0d0))
else
tmp = 1.0d0 / (0.16666666666666666d0 * (b * (b * b)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 4.1e+49) {
tmp = 1.0 / (1.0 + (a + 1.0));
} else {
tmp = 1.0 / (0.16666666666666666 * (b * (b * b)));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 4.1e+49: tmp = 1.0 / (1.0 + (a + 1.0)) else: tmp = 1.0 / (0.16666666666666666 * (b * (b * b))) return tmp
function code(a, b) tmp = 0.0 if (b <= 4.1e+49) tmp = Float64(1.0 / Float64(1.0 + Float64(a + 1.0))); else tmp = Float64(1.0 / Float64(0.16666666666666666 * Float64(b * Float64(b * b)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 4.1e+49) tmp = 1.0 / (1.0 + (a + 1.0)); else tmp = 1.0 / (0.16666666666666666 * (b * (b * b))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 4.1e+49], N[(1.0 / N[(1.0 + N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(0.16666666666666666 * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.1 \cdot 10^{+49}:\\
\;\;\;\;\frac{1}{1 + \left(a + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{0.16666666666666666 \cdot \left(b \cdot \left(b \cdot b\right)\right)}\\
\end{array}
\end{array}
if b < 4.1e49Initial program 99.5%
Taylor expanded in b around 0
Applied rewrites75.3%
Taylor expanded in a around 0
lower-+.f6474.8
Applied rewrites74.8%
Taylor expanded in a around 0
Applied rewrites51.9%
if 4.1e49 < b Initial program 98.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites82.0%
Taylor expanded in b around inf
Applied rewrites82.0%
Taylor expanded in b around inf
Applied rewrites82.0%
Final simplification58.5%
(FPCore (a b) :precision binary64 (if (<= b 4.1e+49) (/ 1.0 (+ 1.0 (+ a 1.0))) (/ 1.0 (fma 0.5 (* b b) b))))
double code(double a, double b) {
double tmp;
if (b <= 4.1e+49) {
tmp = 1.0 / (1.0 + (a + 1.0));
} else {
tmp = 1.0 / fma(0.5, (b * b), b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 4.1e+49) tmp = Float64(1.0 / Float64(1.0 + Float64(a + 1.0))); else tmp = Float64(1.0 / fma(0.5, Float64(b * b), b)); end return tmp end
code[a_, b_] := If[LessEqual[b, 4.1e+49], N[(1.0 / N[(1.0 + N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(0.5 * N[(b * b), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.1 \cdot 10^{+49}:\\
\;\;\;\;\frac{1}{1 + \left(a + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(0.5, b \cdot b, b\right)}\\
\end{array}
\end{array}
if b < 4.1e49Initial program 99.5%
Taylor expanded in b around 0
Applied rewrites75.3%
Taylor expanded in a around 0
lower-+.f6474.8
Applied rewrites74.8%
Taylor expanded in a around 0
Applied rewrites51.9%
if 4.1e49 < b Initial program 98.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
Applied rewrites82.0%
Taylor expanded in b around -inf
Applied rewrites82.0%
Taylor expanded in b around 0
Applied rewrites63.1%
Final simplification54.4%
(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(1.0 + Float64(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[(1.0 + N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 + \left(a + 1\right)}
\end{array}
Initial program 99.2%
Taylor expanded in b around 0
Applied rewrites66.7%
Taylor expanded in a around 0
lower-+.f6466.3
Applied rewrites66.3%
Taylor expanded in a around 0
Applied rewrites41.5%
Final simplification41.5%
(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
lower-+.f64N/A
lower-exp.f6482.8
Applied rewrites82.8%
Taylor expanded in b around 0
Applied rewrites40.8%
(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 2024238
(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))))