
(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 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.6%
(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 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 99.5%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6499.3
Applied rewrites99.3%
Final simplification99.4%
(FPCore (a b)
:precision binary64
(if (<= a -5.25e+79)
(/
(+ a 1.0)
(+ 1.0 (fma a (fma a (fma a 0.16666666666666666 0.5) 1.0) 1.0)))
(/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
double tmp;
if (a <= -5.25e+79) {
tmp = (a + 1.0) / (1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0));
} else {
tmp = 1.0 / (exp(b) + 1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -5.25e+79) tmp = Float64(Float64(a + 1.0) / Float64(1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0))); else tmp = Float64(1.0 / Float64(exp(b) + 1.0)); end return tmp end
code[a_, b_] := If[LessEqual[a, -5.25e+79], N[(N[(a + 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[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.25 \cdot 10^{+79}:\\
\;\;\;\;\frac{a + 1}{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}{e^{b} + 1}\\
\end{array}
\end{array}
if a < -5.25000000000000003e79Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
Taylor expanded in a around 0
+-commutativeN/A
lower-+.f642.1
Applied rewrites2.1%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6483.5
Applied rewrites83.5%
if -5.25000000000000003e79 < a Initial program 99.5%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6493.8
Applied rewrites93.8%
Final simplification91.9%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma b (fma b 0.16666666666666666 0.5) 1.0)))
(if (<= b -14.5)
(+ (exp b) 1.0)
(if (<= b 1.6e+30)
(/
(+ a 1.0)
(+ 1.0 (fma a (fma a (fma a 0.16666666666666666 0.5) 1.0) 1.0)))
(if (<= b 4.4e+51)
(/ (* 0.5 (* a a)) (+ 1.0 1.0))
(if (<= b 1.02e+103)
(/
1.0
(/
(fma
t_0
(* b (fma b (* b (fma b 0.16666666666666666 0.5)) b))
-4.0)
(fma b t_0 -2.0)))
(/ 1.0 (* b (* b (* b 0.16666666666666666))))))))))
double code(double a, double b) {
double t_0 = fma(b, fma(b, 0.16666666666666666, 0.5), 1.0);
double tmp;
if (b <= -14.5) {
tmp = exp(b) + 1.0;
} else if (b <= 1.6e+30) {
tmp = (a + 1.0) / (1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0));
} else if (b <= 4.4e+51) {
tmp = (0.5 * (a * a)) / (1.0 + 1.0);
} else if (b <= 1.02e+103) {
tmp = 1.0 / (fma(t_0, (b * fma(b, (b * fma(b, 0.16666666666666666, 0.5)), b)), -4.0) / fma(b, t_0, -2.0));
} else {
tmp = 1.0 / (b * (b * (b * 0.16666666666666666)));
}
return tmp;
}
function code(a, b) t_0 = fma(b, fma(b, 0.16666666666666666, 0.5), 1.0) tmp = 0.0 if (b <= -14.5) tmp = Float64(exp(b) + 1.0); elseif (b <= 1.6e+30) tmp = Float64(Float64(a + 1.0) / Float64(1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0))); elseif (b <= 4.4e+51) tmp = Float64(Float64(0.5 * Float64(a * a)) / Float64(1.0 + 1.0)); elseif (b <= 1.02e+103) tmp = Float64(1.0 / Float64(fma(t_0, Float64(b * fma(b, Float64(b * fma(b, 0.16666666666666666, 0.5)), b)), -4.0) / fma(b, t_0, -2.0))); else tmp = Float64(1.0 / Float64(b * Float64(b * Float64(b * 0.16666666666666666)))); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[b, -14.5], N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[b, 1.6e+30], N[(N[(a + 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, 4.4e+51], N[(N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision] / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.02e+103], N[(1.0 / N[(N[(t$95$0 * N[(b * N[(b * N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] + -4.0), $MachinePrecision] / N[(b * t$95$0 + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), 1\right)\\
\mathbf{if}\;b \leq -14.5:\\
\;\;\;\;e^{b} + 1\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{+30}:\\
\;\;\;\;\frac{a + 1}{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 4.4 \cdot 10^{+51}:\\
\;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\
\mathbf{elif}\;b \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(t\_0, b \cdot \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), b\right), -4\right)}{\mathsf{fma}\left(b, t\_0, -2\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot \left(b \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if b < -14.5Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
if -14.5 < b < 1.59999999999999986e30Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites97.7%
Taylor expanded in a around 0
Applied rewrites96.6%
Taylor expanded in a around 0
+-commutativeN/A
lower-+.f6461.3
Applied rewrites61.3%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6482.8
Applied rewrites82.8%
if 1.59999999999999986e30 < b < 4.39999999999999984e51Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites3.1%
Taylor expanded in a around 0
Applied rewrites3.1%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f643.1
Applied rewrites3.1%
Taylor expanded in a around inf
Applied rewrites83.9%
if 4.39999999999999984e51 < b < 1.01999999999999991e103Initial 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 rewrites6.8%
Applied rewrites100.0%
if 1.01999999999999991e103 < b Initial program 98.1%
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%
Final simplification90.9%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma b (fma b 0.16666666666666666 0.5) 1.0)))
(if (<= b 1.6e+30)
(/
(+ a 1.0)
(+ 1.0 (fma a (fma a (fma a 0.16666666666666666 0.5) 1.0) 1.0)))
(if (<= b 4.4e+51)
(/ (* 0.5 (* a a)) (+ 1.0 1.0))
(if (<= b 1.02e+103)
(/
1.0
(/
(fma t_0 (* b (fma b (* b (fma b 0.16666666666666666 0.5)) b)) -4.0)
(fma b t_0 -2.0)))
(/ 1.0 (* b (* b (* b 0.16666666666666666)))))))))
double code(double a, double b) {
double t_0 = fma(b, fma(b, 0.16666666666666666, 0.5), 1.0);
double tmp;
if (b <= 1.6e+30) {
tmp = (a + 1.0) / (1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0));
} else if (b <= 4.4e+51) {
tmp = (0.5 * (a * a)) / (1.0 + 1.0);
} else if (b <= 1.02e+103) {
tmp = 1.0 / (fma(t_0, (b * fma(b, (b * fma(b, 0.16666666666666666, 0.5)), b)), -4.0) / fma(b, t_0, -2.0));
} else {
tmp = 1.0 / (b * (b * (b * 0.16666666666666666)));
}
return tmp;
}
function code(a, b) t_0 = fma(b, fma(b, 0.16666666666666666, 0.5), 1.0) tmp = 0.0 if (b <= 1.6e+30) tmp = Float64(Float64(a + 1.0) / Float64(1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0))); elseif (b <= 4.4e+51) tmp = Float64(Float64(0.5 * Float64(a * a)) / Float64(1.0 + 1.0)); elseif (b <= 1.02e+103) tmp = Float64(1.0 / Float64(fma(t_0, Float64(b * fma(b, Float64(b * fma(b, 0.16666666666666666, 0.5)), b)), -4.0) / fma(b, t_0, -2.0))); else tmp = Float64(1.0 / Float64(b * Float64(b * Float64(b * 0.16666666666666666)))); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[b, 1.6e+30], N[(N[(a + 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, 4.4e+51], N[(N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision] / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.02e+103], N[(1.0 / N[(N[(t$95$0 * N[(b * N[(b * N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] + -4.0), $MachinePrecision] / N[(b * t$95$0 + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), 1\right)\\
\mathbf{if}\;b \leq 1.6 \cdot 10^{+30}:\\
\;\;\;\;\frac{a + 1}{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 4.4 \cdot 10^{+51}:\\
\;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\
\mathbf{elif}\;b \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(t\_0, b \cdot \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), b\right), -4\right)}{\mathsf{fma}\left(b, t\_0, -2\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot \left(b \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if b < 1.59999999999999986e30Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites74.2%
Taylor expanded in a around 0
Applied rewrites73.5%
Taylor expanded in a around 0
+-commutativeN/A
lower-+.f6448.7
Applied rewrites48.7%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6463.8
Applied rewrites63.8%
if 1.59999999999999986e30 < b < 4.39999999999999984e51Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites3.1%
Taylor expanded in a around 0
Applied rewrites3.1%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f643.1
Applied rewrites3.1%
Taylor expanded in a around inf
Applied rewrites83.9%
if 4.39999999999999984e51 < b < 1.01999999999999991e103Initial 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 rewrites6.8%
Applied rewrites100.0%
if 1.01999999999999991e103 < b Initial program 98.1%
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%
Final simplification73.4%
(FPCore (a b)
:precision binary64
(if (<= b 1.6e+30)
(/
(+ a 1.0)
(+ 1.0 (fma a (fma a (fma a 0.16666666666666666 0.5) 1.0) 1.0)))
(if (<= b 2.9e+77)
(/ (* 0.5 (* a a)) (+ 1.0 1.0))
(if (<= b 1e+154)
(/
1.0
(fma
b
(/
(fma
(fma b 0.16666666666666666 0.5)
(* b (* b (fma b 0.16666666666666666 0.5)))
-1.0)
(fma b (fma b 0.16666666666666666 0.5) -1.0))
2.0))
(/ 1.0 (fma b (fma b 0.5 1.0) 2.0))))))
double code(double a, double b) {
double tmp;
if (b <= 1.6e+30) {
tmp = (a + 1.0) / (1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0));
} else if (b <= 2.9e+77) {
tmp = (0.5 * (a * a)) / (1.0 + 1.0);
} else if (b <= 1e+154) {
tmp = 1.0 / fma(b, (fma(fma(b, 0.16666666666666666, 0.5), (b * (b * fma(b, 0.16666666666666666, 0.5))), -1.0) / fma(b, fma(b, 0.16666666666666666, 0.5), -1.0)), 2.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 (b <= 1.6e+30) tmp = Float64(Float64(a + 1.0) / Float64(1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0))); elseif (b <= 2.9e+77) tmp = Float64(Float64(0.5 * Float64(a * a)) / Float64(1.0 + 1.0)); elseif (b <= 1e+154) tmp = Float64(1.0 / fma(b, Float64(fma(fma(b, 0.16666666666666666, 0.5), Float64(b * Float64(b * fma(b, 0.16666666666666666, 0.5))), -1.0) / fma(b, fma(b, 0.16666666666666666, 0.5), -1.0)), 2.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[b, 1.6e+30], N[(N[(a + 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, 2.9e+77], N[(N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision] / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e+154], N[(1.0 / N[(b * N[(N[(N[(b * 0.16666666666666666 + 0.5), $MachinePrecision] * N[(b * N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + 2.0), $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}\;b \leq 1.6 \cdot 10^{+30}:\\
\;\;\;\;\frac{a + 1}{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 2.9 \cdot 10^{+77}:\\
\;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\
\mathbf{elif}\;b \leq 10^{+154}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b, \frac{\mathsf{fma}\left(\mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), b \cdot \left(b \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right)\right), -1\right)}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), -1\right)}, 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), 2\right)}\\
\end{array}
\end{array}
if b < 1.59999999999999986e30Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites74.2%
Taylor expanded in a around 0
Applied rewrites73.5%
Taylor expanded in a around 0
+-commutativeN/A
lower-+.f6448.7
Applied rewrites48.7%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6463.8
Applied rewrites63.8%
if 1.59999999999999986e30 < b < 2.9000000000000002e77Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites10.0%
Taylor expanded in a around 0
Applied rewrites10.0%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f643.0
Applied rewrites3.0%
Taylor expanded in a around inf
Applied rewrites52.5%
if 2.9000000000000002e77 < b < 1.00000000000000004e154Initial 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 rewrites78.2%
Applied rewrites100.0%
if 1.00000000000000004e154 < b Initial program 97.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 rewrites100.0%
Final simplification71.2%
(FPCore (a b)
:precision binary64
(if (<= b 1.6e+30)
(/
(+ a 1.0)
(+ 1.0 (fma a (fma a (fma a 0.16666666666666666 0.5) 1.0) 1.0)))
(if (<= b 4.4e+95)
(/ (* 0.5 (* a a)) (+ 1.0 1.0))
(/ 1.0 (* b (* b (fma b 0.16666666666666666 0.5)))))))
double code(double a, double b) {
double tmp;
if (b <= 1.6e+30) {
tmp = (a + 1.0) / (1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0));
} else if (b <= 4.4e+95) {
tmp = (0.5 * (a * a)) / (1.0 + 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 <= 1.6e+30) tmp = Float64(Float64(a + 1.0) / Float64(1.0 + fma(a, fma(a, fma(a, 0.16666666666666666, 0.5), 1.0), 1.0))); elseif (b <= 4.4e+95) tmp = Float64(Float64(0.5 * Float64(a * a)) / Float64(1.0 + 1.0)); else tmp = Float64(1.0 / Float64(b * Float64(b * fma(b, 0.16666666666666666, 0.5)))); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.6e+30], N[(N[(a + 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, 4.4e+95], N[(N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision] / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.6 \cdot 10^{+30}:\\
\;\;\;\;\frac{a + 1}{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 4.4 \cdot 10^{+95}:\\
\;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right)\right)}\\
\end{array}
\end{array}
if b < 1.59999999999999986e30Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites74.2%
Taylor expanded in a around 0
Applied rewrites73.5%
Taylor expanded in a around 0
+-commutativeN/A
lower-+.f6448.7
Applied rewrites48.7%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6463.8
Applied rewrites63.8%
if 1.59999999999999986e30 < b < 4.3999999999999998e95Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites15.2%
Taylor expanded in a around 0
Applied rewrites15.2%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f643.0
Applied rewrites3.0%
Taylor expanded in a around inf
Applied rewrites49.1%
if 4.3999999999999998e95 < 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 rewrites95.1%
Taylor expanded in b around inf
Applied rewrites95.1%
Final simplification69.6%
(FPCore (a b)
:precision binary64
(if (<= b 1.6e+30)
(/ (+ a 1.0) (+ 1.0 (fma a (fma a 0.5 1.0) 1.0)))
(if (<= b 4.4e+95)
(/ (* 0.5 (* a a)) (+ 1.0 1.0))
(/ 1.0 (* b (* b (fma b 0.16666666666666666 0.5)))))))
double code(double a, double b) {
double tmp;
if (b <= 1.6e+30) {
tmp = (a + 1.0) / (1.0 + fma(a, fma(a, 0.5, 1.0), 1.0));
} else if (b <= 4.4e+95) {
tmp = (0.5 * (a * a)) / (1.0 + 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 <= 1.6e+30) tmp = Float64(Float64(a + 1.0) / Float64(1.0 + fma(a, fma(a, 0.5, 1.0), 1.0))); elseif (b <= 4.4e+95) tmp = Float64(Float64(0.5 * Float64(a * a)) / Float64(1.0 + 1.0)); else tmp = Float64(1.0 / Float64(b * Float64(b * fma(b, 0.16666666666666666, 0.5)))); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.6e+30], N[(N[(a + 1.0), $MachinePrecision] / N[(1.0 + N[(a * N[(a * 0.5 + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.4e+95], N[(N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision] / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.6 \cdot 10^{+30}:\\
\;\;\;\;\frac{a + 1}{1 + \mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5, 1\right), 1\right)}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{+95}:\\
\;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right)\right)}\\
\end{array}
\end{array}
if b < 1.59999999999999986e30Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites74.2%
Taylor expanded in a around 0
Applied rewrites73.5%
Taylor expanded in a around 0
+-commutativeN/A
lower-+.f6448.7
Applied rewrites48.7%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6460.6
Applied rewrites60.6%
if 1.59999999999999986e30 < b < 4.3999999999999998e95Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites15.2%
Taylor expanded in a around 0
Applied rewrites15.2%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f643.0
Applied rewrites3.0%
Taylor expanded in a around inf
Applied rewrites49.1%
if 4.3999999999999998e95 < 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 rewrites95.1%
Taylor expanded in b around inf
Applied rewrites95.1%
Final simplification67.3%
(FPCore (a b)
:precision binary64
(if (<= b 1.95e+15)
(fma a 0.25 0.5)
(if (<= b 4.4e+95)
(/ (* 0.5 (* a a)) (+ 1.0 1.0))
(/ 1.0 (* b (* b (fma b 0.16666666666666666 0.5)))))))
double code(double a, double b) {
double tmp;
if (b <= 1.95e+15) {
tmp = fma(a, 0.25, 0.5);
} else if (b <= 4.4e+95) {
tmp = (0.5 * (a * a)) / (1.0 + 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 <= 1.95e+15) tmp = fma(a, 0.25, 0.5); elseif (b <= 4.4e+95) tmp = Float64(Float64(0.5 * Float64(a * a)) / Float64(1.0 + 1.0)); else tmp = Float64(1.0 / Float64(b * Float64(b * fma(b, 0.16666666666666666, 0.5)))); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.95e+15], N[(a * 0.25 + 0.5), $MachinePrecision], If[LessEqual[b, 4.4e+95], N[(N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision] / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.95 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(a, 0.25, 0.5\right)\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{+95}:\\
\;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right)\right)}\\
\end{array}
\end{array}
if b < 1.95e15Initial program 100.0%
Taylor expanded in b around 0
associate-*r/N/A
unpow2N/A
associate-*r*N/A
times-fracN/A
distribute-lft1-inN/A
lower-*.f64N/A
Applied rewrites70.7%
Taylor expanded in a around 0
Applied rewrites46.4%
Taylor expanded in b around 0
Applied rewrites50.5%
if 1.95e15 < b < 4.3999999999999998e95Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites22.5%
Taylor expanded in a around 0
Applied rewrites22.5%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f642.9
Applied rewrites2.9%
Taylor expanded in a around inf
Applied rewrites40.0%
if 4.3999999999999998e95 < 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 rewrites95.1%
Taylor expanded in b around inf
Applied rewrites95.1%
(FPCore (a b)
:precision binary64
(if (<= b 1.95e+15)
(fma a 0.25 0.5)
(if (<= b 4.4e+95)
(/ (* 0.5 (* a a)) (+ 1.0 1.0))
(/ 1.0 (* b (* b (* b 0.16666666666666666)))))))
double code(double a, double b) {
double tmp;
if (b <= 1.95e+15) {
tmp = fma(a, 0.25, 0.5);
} else if (b <= 4.4e+95) {
tmp = (0.5 * (a * a)) / (1.0 + 1.0);
} else {
tmp = 1.0 / (b * (b * (b * 0.16666666666666666)));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 1.95e+15) tmp = fma(a, 0.25, 0.5); elseif (b <= 4.4e+95) tmp = Float64(Float64(0.5 * Float64(a * a)) / Float64(1.0 + 1.0)); else tmp = Float64(1.0 / Float64(b * Float64(b * Float64(b * 0.16666666666666666)))); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.95e+15], N[(a * 0.25 + 0.5), $MachinePrecision], If[LessEqual[b, 4.4e+95], N[(N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision] / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.95 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(a, 0.25, 0.5\right)\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{+95}:\\
\;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot \left(b \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if b < 1.95e15Initial program 100.0%
Taylor expanded in b around 0
associate-*r/N/A
unpow2N/A
associate-*r*N/A
times-fracN/A
distribute-lft1-inN/A
lower-*.f64N/A
Applied rewrites70.7%
Taylor expanded in a around 0
Applied rewrites46.4%
Taylor expanded in b around 0
Applied rewrites50.5%
if 1.95e15 < b < 4.3999999999999998e95Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites22.5%
Taylor expanded in a around 0
Applied rewrites22.5%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f642.9
Applied rewrites2.9%
Taylor expanded in a around inf
Applied rewrites40.0%
if 4.3999999999999998e95 < 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 rewrites95.1%
Taylor expanded in b around inf
Applied rewrites95.1%
(FPCore (a b)
:precision binary64
(if (<= b 1.95e+15)
(fma a 0.25 0.5)
(if (<= b 1.9e+154)
(/ (* 0.5 (* a a)) (+ 1.0 1.0))
(/ 1.0 (fma b (fma b 0.5 1.0) 2.0)))))
double code(double a, double b) {
double tmp;
if (b <= 1.95e+15) {
tmp = fma(a, 0.25, 0.5);
} else if (b <= 1.9e+154) {
tmp = (0.5 * (a * a)) / (1.0 + 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 (b <= 1.95e+15) tmp = fma(a, 0.25, 0.5); elseif (b <= 1.9e+154) tmp = Float64(Float64(0.5 * Float64(a * a)) / Float64(1.0 + 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[b, 1.95e+15], N[(a * 0.25 + 0.5), $MachinePrecision], If[LessEqual[b, 1.9e+154], N[(N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision] / N[(1.0 + 1.0), $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}\;b \leq 1.95 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(a, 0.25, 0.5\right)\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;\frac{0.5 \cdot \left(a \cdot a\right)}{1 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), 2\right)}\\
\end{array}
\end{array}
if b < 1.95e15Initial program 100.0%
Taylor expanded in b around 0
associate-*r/N/A
unpow2N/A
associate-*r*N/A
times-fracN/A
distribute-lft1-inN/A
lower-*.f64N/A
Applied rewrites70.7%
Taylor expanded in a around 0
Applied rewrites46.4%
Taylor expanded in b around 0
Applied rewrites50.5%
if 1.95e15 < b < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites25.5%
Taylor expanded in a around 0
Applied rewrites25.5%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f642.9
Applied rewrites2.9%
Taylor expanded in a around inf
Applied rewrites35.1%
if 1.8999999999999999e154 < b Initial program 97.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 rewrites100.0%
(FPCore (a b) :precision binary64 (if (<= b -2.6e-190) (fma a 0.25 0.5) (/ 1.0 (fma b (fma b 0.5 1.0) 2.0))))
double code(double a, double b) {
double tmp;
if (b <= -2.6e-190) {
tmp = fma(a, 0.25, 0.5);
} else {
tmp = 1.0 / fma(b, fma(b, 0.5, 1.0), 2.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= -2.6e-190) tmp = fma(a, 0.25, 0.5); else tmp = Float64(1.0 / fma(b, fma(b, 0.5, 1.0), 2.0)); end return tmp end
code[a_, b_] := If[LessEqual[b, -2.6e-190], N[(a * 0.25 + 0.5), $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}\;b \leq -2.6 \cdot 10^{-190}:\\
\;\;\;\;\mathsf{fma}\left(a, 0.25, 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), 2\right)}\\
\end{array}
\end{array}
if b < -2.5999999999999998e-190Initial program 100.0%
Taylor expanded in b around 0
associate-*r/N/A
unpow2N/A
associate-*r*N/A
times-fracN/A
distribute-lft1-inN/A
lower-*.f64N/A
Applied rewrites41.5%
Taylor expanded in a around 0
Applied rewrites30.5%
Taylor expanded in b around 0
Applied rewrites38.8%
if -2.5999999999999998e-190 < b Initial program 99.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6480.2
Applied rewrites80.2%
Taylor expanded in b around 0
Applied rewrites57.1%
(FPCore (a b) :precision binary64 (fma a 0.25 0.5))
double code(double a, double b) {
return fma(a, 0.25, 0.5);
}
function code(a, b) return fma(a, 0.25, 0.5) end
code[a_, b_] := N[(a * 0.25 + 0.5), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a, 0.25, 0.5\right)
\end{array}
Initial program 99.6%
Taylor expanded in b around 0
associate-*r/N/A
unpow2N/A
associate-*r*N/A
times-fracN/A
distribute-lft1-inN/A
lower-*.f64N/A
Applied rewrites57.9%
Taylor expanded in a around 0
Applied rewrites33.5%
Taylor expanded in b around 0
Applied rewrites36.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.6%
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 rewrites36.2%
(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 2024232
(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))))