
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 20 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Initial program 98.8%
(FPCore (a b) :precision binary64 (if (<= (exp a) 0.001) (/ 1.0 (+ 1.0 (exp (- a)))) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.001) {
tmp = 1.0 / (1.0 + exp(-a));
} 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.001d0) then
tmp = 1.0d0 / (1.0d0 + exp(-a))
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.001) {
tmp = 1.0 / (1.0 + Math.exp(-a));
} else {
tmp = 1.0 / (Math.exp(b) + 1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if math.exp(a) <= 0.001: tmp = 1.0 / (1.0 + math.exp(-a)) else: tmp = 1.0 / (math.exp(b) + 1.0) return tmp
function code(a, b) tmp = 0.0 if (exp(a) <= 0.001) tmp = Float64(1.0 / Float64(1.0 + exp(Float64(-a)))); 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.001) tmp = 1.0 / (1.0 + exp(-a)); else tmp = 1.0 / (exp(b) + 1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.001], N[(1.0 / N[(1.0 + N[Exp[(-a)], $MachinePrecision]), $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.001:\\
\;\;\;\;\frac{1}{1 + e^{-a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\end{array}
if (exp.f64 a) < 1e-3Initial program 98.7%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval98.7
Applied rewrites98.7%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6498.7
Applied rewrites98.7%
if 1e-3 < (exp.f64 a) Initial program 98.9%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6498.0
Applied rewrites98.0%
Final simplification98.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.7%
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 98.9%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6497.1
Applied rewrites97.1%
Final simplification97.9%
(FPCore (a b)
:precision binary64
(if (<= a -2e+154)
(/ 1.0 (* 0.5 (* a a)))
(if (<= a -4.2e+36)
(/
1.0
(/
(fma a (* (fma a 0.5 -1.0) (* a (fma a 0.5 -1.0))) -4.0)
(fma a (fma a 0.5 -1.0) -2.0)))
(/ 1.0 (+ (exp b) 1.0)))))
double code(double a, double b) {
double tmp;
if (a <= -2e+154) {
tmp = 1.0 / (0.5 * (a * a));
} else if (a <= -4.2e+36) {
tmp = 1.0 / (fma(a, (fma(a, 0.5, -1.0) * (a * fma(a, 0.5, -1.0))), -4.0) / fma(a, fma(a, 0.5, -1.0), -2.0));
} else {
tmp = 1.0 / (exp(b) + 1.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -2e+154) tmp = Float64(1.0 / Float64(0.5 * Float64(a * a))); elseif (a <= -4.2e+36) tmp = Float64(1.0 / Float64(fma(a, Float64(fma(a, 0.5, -1.0) * Float64(a * fma(a, 0.5, -1.0))), -4.0) / fma(a, fma(a, 0.5, -1.0), -2.0))); else tmp = Float64(1.0 / Float64(exp(b) + 1.0)); end return tmp end
code[a_, b_] := If[LessEqual[a, -2e+154], N[(1.0 / N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -4.2e+36], N[(1.0 / N[(N[(a * N[(N[(a * 0.5 + -1.0), $MachinePrecision] * N[(a * N[(a * 0.5 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -4.0), $MachinePrecision] / N[(a * N[(a * 0.5 + -1.0), $MachinePrecision] + -2.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 -2 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{0.5 \cdot \left(a \cdot a\right)}\\
\mathbf{elif}\;a \leq -4.2 \cdot 10^{+36}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5, -1\right) \cdot \left(a \cdot \mathsf{fma}\left(a, 0.5, -1\right)\right), -4\right)}{\mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5, -1\right), -2\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\end{array}
if a < -2.00000000000000007e154Initial program 100.0%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
Taylor expanded in a around inf
Applied rewrites100.0%
if -2.00000000000000007e154 < a < -4.20000000000000009e36Initial program 96.0%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval96.0
Applied rewrites96.0%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites5.9%
Applied rewrites77.0%
if -4.20000000000000009e36 < a Initial program 98.9%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6494.2
Applied rewrites94.2%
Final simplification93.4%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma b (fma b 0.16666666666666666 0.5) 1.0)))
(if (<= b 1.55e-26)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.0))
(if (<= b 1.05e+103)
(/ 1.0 (/ (fma (* b b) (* t_0 t_0) -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.55e-26) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0);
} else if (b <= 1.05e+103) {
tmp = 1.0 / (fma((b * b), (t_0 * t_0), -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.55e-26) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); elseif (b <= 1.05e+103) 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(b * Float64(Float64(b * 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.55e-26], N[(1.0 / N[(a * N[(a * N[(a * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e+103], 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[(b * N[(N[(b * b), $MachinePrecision] * 0.16666666666666666), $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.55 \cdot 10^{-26}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, -0.16666666666666666, 0.5\right), -1\right), 2\right)}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;\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}{b \cdot \left(\left(b \cdot b\right) \cdot 0.16666666666666666\right)}\\
\end{array}
\end{array}
if b < 1.54999999999999992e-26Initial program 98.4%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval97.7
Applied rewrites97.7%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6480.7
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites69.5%
if 1.54999999999999992e-26 < b < 1.0500000000000001e103Initial program 99.9%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6496.4
Applied rewrites96.4%
Taylor expanded in b around 0
Applied rewrites19.8%
Applied rewrites82.4%
if 1.0500000000000001e103 < 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%
Final simplification75.3%
(FPCore (a b)
:precision binary64
(if (<= b 6.1e+57)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.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))
(/ 1.0 (fma b (fma b 0.16666666666666666 0.5) -1.0))
2.0))
(/ 1.0 (* b (* b 0.5))))))
double code(double a, double b) {
double tmp;
if (b <= 6.1e+57) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.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)), (1.0 / fma(b, fma(b, 0.16666666666666666, 0.5), -1.0)), 2.0);
} else {
tmp = 1.0 / (b * (b * 0.5));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 6.1e+57) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); elseif (b <= 1e+154) tmp = Float64(1.0 / fma(Float64(b * fma(fma(b, 0.16666666666666666, 0.5), Float64(Float64(b * b) * fma(b, 0.16666666666666666, 0.5)), -1.0)), Float64(1.0 / fma(b, fma(b, 0.16666666666666666, 0.5), -1.0)), 2.0)); else tmp = Float64(1.0 / Float64(b * Float64(b * 0.5))); end return tmp end
code[a_, b_] := If[LessEqual[b, 6.1e+57], N[(1.0 / N[(a * N[(a * N[(a * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e+154], N[(1.0 / N[(N[(b * N[(N[(b * 0.16666666666666666 + 0.5), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / 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), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.1 \cdot 10^{+57}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, -0.16666666666666666, 0.5\right), -1\right), 2\right)}\\
\mathbf{elif}\;b \leq 10^{+154}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b \cdot \mathsf{fma}\left(\mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), \left(b \cdot b\right) \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), -1\right), \frac{1}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), -1\right)}, 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < 6.09999999999999975e57Initial program 98.5%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval97.8
Applied rewrites97.8%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6478.6
Applied rewrites78.6%
Taylor expanded in a around 0
Applied rewrites67.7%
if 6.09999999999999975e57 < 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 rewrites38.9%
Applied rewrites96.0%
if 1.00000000000000004e154 < 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%
Final simplification74.0%
(FPCore (a b)
:precision binary64
(if (<= b 6.1e+57)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.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 (* b (* b 0.5))))))
double code(double a, double b) {
double tmp;
if (b <= 6.1e+57) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.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 / (b * (b * 0.5));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 6.1e+57) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); elseif (b <= 1e+154) tmp = Float64(1.0 / fma(b, Float64(fma(fma(b, 0.16666666666666666, 0.5), Float64(Float64(b * 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 / Float64(b * Float64(b * 0.5))); end return tmp end
code[a_, b_] := If[LessEqual[b, 6.1e+57], N[(1.0 / N[(a * N[(a * N[(a * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e+154], N[(1.0 / N[(b * N[(N[(N[(b * 0.16666666666666666 + 0.5), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] * N[(b * 0.16666666666666666 + 0.5), $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), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.1 \cdot 10^{+57}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, -0.16666666666666666, 0.5\right), -1\right), 2\right)}\\
\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), \left(b \cdot b\right) \cdot \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), -1\right)}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.16666666666666666, 0.5\right), -1\right)}, 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < 6.09999999999999975e57Initial program 98.5%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval97.8
Applied rewrites97.8%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6478.6
Applied rewrites78.6%
Taylor expanded in a around 0
Applied rewrites67.7%
if 6.09999999999999975e57 < 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 rewrites38.9%
Applied rewrites88.2%
if 1.00000000000000004e154 < 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%
Final simplification73.2%
(FPCore (a b)
:precision binary64
(if (<= b 6.1e+57)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.0))
(if (<= b 1.9e+154)
(/
1.0
(/
(fma (fma b 0.5 1.0) (* b (fma b (* b 0.5) b)) -4.0)
(fma b (fma b 0.5 1.0) -2.0)))
(/ 1.0 (* b (* b 0.5))))))
double code(double a, double b) {
double tmp;
if (b <= 6.1e+57) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0);
} else if (b <= 1.9e+154) {
tmp = 1.0 / (fma(fma(b, 0.5, 1.0), (b * fma(b, (b * 0.5), b)), -4.0) / fma(b, fma(b, 0.5, 1.0), -2.0));
} else {
tmp = 1.0 / (b * (b * 0.5));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 6.1e+57) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); elseif (b <= 1.9e+154) tmp = Float64(1.0 / Float64(fma(fma(b, 0.5, 1.0), Float64(b * fma(b, Float64(b * 0.5), b)), -4.0) / fma(b, fma(b, 0.5, 1.0), -2.0))); else tmp = Float64(1.0 / Float64(b * Float64(b * 0.5))); end return tmp end
code[a_, b_] := If[LessEqual[b, 6.1e+57], N[(1.0 / N[(a * N[(a * N[(a * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9e+154], N[(1.0 / N[(N[(N[(b * 0.5 + 1.0), $MachinePrecision] * N[(b * N[(b * N[(b * 0.5), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] + -4.0), $MachinePrecision] / N[(b * N[(b * 0.5 + 1.0), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.1 \cdot 10^{+57}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, -0.16666666666666666, 0.5\right), -1\right), 2\right)}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(b, 0.5, 1\right), b \cdot \mathsf{fma}\left(b, b \cdot 0.5, b\right), -4\right)}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), -2\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < 6.09999999999999975e57Initial program 98.5%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval97.8
Applied rewrites97.8%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6478.6
Applied rewrites78.6%
Taylor expanded in a around 0
Applied rewrites67.7%
if 6.09999999999999975e57 < b < 1.8999999999999999e154Initial 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 rewrites5.7%
Applied rewrites88.1%
if 1.8999999999999999e154 < 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%
(FPCore (a b)
:precision binary64
(if (<= b 6.1e+57)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.0))
(if (<= b 1.9e+154)
(/ 1.0 (/ (* 0.25 (* (* b b) (* b b))) (fma b (fma b 0.5 1.0) -2.0)))
(/ 1.0 (* b (* b 0.5))))))
double code(double a, double b) {
double tmp;
if (b <= 6.1e+57) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0);
} else if (b <= 1.9e+154) {
tmp = 1.0 / ((0.25 * ((b * b) * (b * b))) / fma(b, fma(b, 0.5, 1.0), -2.0));
} else {
tmp = 1.0 / (b * (b * 0.5));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 6.1e+57) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); elseif (b <= 1.9e+154) tmp = Float64(1.0 / Float64(Float64(0.25 * Float64(Float64(b * b) * Float64(b * b))) / fma(b, fma(b, 0.5, 1.0), -2.0))); else tmp = Float64(1.0 / Float64(b * Float64(b * 0.5))); end return tmp end
code[a_, b_] := If[LessEqual[b, 6.1e+57], N[(1.0 / N[(a * N[(a * N[(a * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9e+154], N[(1.0 / N[(N[(0.25 * N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b * N[(b * 0.5 + 1.0), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.1 \cdot 10^{+57}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, -0.16666666666666666, 0.5\right), -1\right), 2\right)}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\frac{0.25 \cdot \left(\left(b \cdot b\right) \cdot \left(b \cdot b\right)\right)}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), -2\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < 6.09999999999999975e57Initial program 98.5%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval97.8
Applied rewrites97.8%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6478.6
Applied rewrites78.6%
Taylor expanded in a around 0
Applied rewrites67.7%
if 6.09999999999999975e57 < b < 1.8999999999999999e154Initial 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 rewrites5.7%
Applied rewrites88.1%
Taylor expanded in b around inf
Applied rewrites88.1%
if 1.8999999999999999e154 < 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%
(FPCore (a b)
:precision binary64
(if (<= b 1.02e+93)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.0))
(/
1.0
(fma (* b (* b b)) 0.16666666666666666 (fma b (fma b 0.5 1.0) 2.0)))))
double code(double a, double b) {
double tmp;
if (b <= 1.02e+93) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0);
} else {
tmp = 1.0 / fma((b * (b * b)), 0.16666666666666666, fma(b, fma(b, 0.5, 1.0), 2.0));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 1.02e+93) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); else tmp = Float64(1.0 / fma(Float64(b * Float64(b * b)), 0.16666666666666666, fma(b, fma(b, 0.5, 1.0), 2.0))); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.02e+93], N[(1.0 / N[(a * N[(a * N[(a * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision] * 0.16666666666666666 + N[(b * N[(b * 0.5 + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.02 \cdot 10^{+93}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, -0.16666666666666666, 0.5\right), -1\right), 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b \cdot \left(b \cdot b\right), 0.16666666666666666, \mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), 2\right)\right)}\\
\end{array}
\end{array}
if b < 1.0200000000000001e93Initial program 98.6%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval97.9
Applied rewrites97.9%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6475.8
Applied rewrites75.8%
Taylor expanded in a around 0
Applied rewrites65.0%
if 1.0200000000000001e93 < 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 rewrites91.5%
Applied rewrites91.5%
Applied rewrites93.5%
(FPCore (a b) :precision binary64 (if (<= b 9.5e+102) (/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.0)) (/ 1.0 (* b (* (* b b) 0.16666666666666666)))))
double code(double a, double b) {
double tmp;
if (b <= 9.5e+102) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0);
} else {
tmp = 1.0 / (b * ((b * b) * 0.16666666666666666));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 9.5e+102) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); else tmp = Float64(1.0 / Float64(b * Float64(Float64(b * b) * 0.16666666666666666))); end return tmp end
code[a_, b_] := If[LessEqual[b, 9.5e+102], N[(1.0 / N[(a * N[(a * N[(a * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(N[(b * b), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.5 \cdot 10^{+102}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(a, \mathsf{fma}\left(a, \mathsf{fma}\left(a, -0.16666666666666666, 0.5\right), -1\right), 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(\left(b \cdot b\right) \cdot 0.16666666666666666\right)}\\
\end{array}
\end{array}
if b < 9.4999999999999992e102Initial program 98.6%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval98.0
Applied rewrites98.0%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6474.9
Applied rewrites74.9%
Taylor expanded in a around 0
Applied rewrites64.3%
if 9.4999999999999992e102 < 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%
Final simplification69.4%
(FPCore (a b)
:precision binary64
(if (<= a -1.8e+120)
(/ 1.0 (* 0.5 (* a a)))
(if (<= a -19.0)
(/ 1.0 (fma b (* b 0.5) b))
(fma a (fma a (* a -0.020833333333333332) 0.25) 0.5))))
double code(double a, double b) {
double tmp;
if (a <= -1.8e+120) {
tmp = 1.0 / (0.5 * (a * a));
} else if (a <= -19.0) {
tmp = 1.0 / fma(b, (b * 0.5), b);
} else {
tmp = fma(a, fma(a, (a * -0.020833333333333332), 0.25), 0.5);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -1.8e+120) tmp = Float64(1.0 / Float64(0.5 * Float64(a * a))); elseif (a <= -19.0) tmp = Float64(1.0 / fma(b, Float64(b * 0.5), b)); else tmp = fma(a, fma(a, Float64(a * -0.020833333333333332), 0.25), 0.5); end return tmp end
code[a_, b_] := If[LessEqual[a, -1.8e+120], N[(1.0 / N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -19.0], N[(1.0 / N[(b * N[(b * 0.5), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision], N[(a * N[(a * N[(a * -0.020833333333333332), $MachinePrecision] + 0.25), $MachinePrecision] + 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{+120}:\\
\;\;\;\;\frac{1}{0.5 \cdot \left(a \cdot a\right)}\\
\mathbf{elif}\;a \leq -19:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b, b \cdot 0.5, b\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(a, a \cdot -0.020833333333333332, 0.25\right), 0.5\right)\\
\end{array}
\end{array}
if a < -1.80000000000000008e120Initial program 100.0%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites86.3%
Taylor expanded in a around inf
Applied rewrites86.3%
if -1.80000000000000008e120 < a < -19Initial program 96.6%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6436.5
Applied rewrites36.5%
Taylor expanded in b around 0
Applied rewrites26.7%
Taylor expanded in b around inf
Applied rewrites26.1%
if -19 < a Initial program 98.9%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval98.1
Applied rewrites98.1%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6461.3
Applied rewrites61.3%
Taylor expanded in a around 0
Applied rewrites58.6%
(FPCore (a b)
:precision binary64
(if (<= a -1.8e+120)
(/ 1.0 (* 0.5 (* a a)))
(if (<= a -18.0)
(/ 1.0 (* b (* b 0.5)))
(fma a (fma a (* a -0.020833333333333332) 0.25) 0.5))))
double code(double a, double b) {
double tmp;
if (a <= -1.8e+120) {
tmp = 1.0 / (0.5 * (a * a));
} else if (a <= -18.0) {
tmp = 1.0 / (b * (b * 0.5));
} else {
tmp = fma(a, fma(a, (a * -0.020833333333333332), 0.25), 0.5);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -1.8e+120) tmp = Float64(1.0 / Float64(0.5 * Float64(a * a))); elseif (a <= -18.0) tmp = Float64(1.0 / Float64(b * Float64(b * 0.5))); else tmp = fma(a, fma(a, Float64(a * -0.020833333333333332), 0.25), 0.5); end return tmp end
code[a_, b_] := If[LessEqual[a, -1.8e+120], N[(1.0 / N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -18.0], N[(1.0 / N[(b * N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[(a * N[(a * -0.020833333333333332), $MachinePrecision] + 0.25), $MachinePrecision] + 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{+120}:\\
\;\;\;\;\frac{1}{0.5 \cdot \left(a \cdot a\right)}\\
\mathbf{elif}\;a \leq -18:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(a, a \cdot -0.020833333333333332, 0.25\right), 0.5\right)\\
\end{array}
\end{array}
if a < -1.80000000000000008e120Initial program 100.0%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites86.3%
Taylor expanded in a around inf
Applied rewrites86.3%
if -1.80000000000000008e120 < a < -18Initial program 96.6%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6436.5
Applied rewrites36.5%
Taylor expanded in b around 0
Applied rewrites26.7%
Taylor expanded in b around inf
Applied rewrites25.9%
if -18 < a Initial program 98.9%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval98.1
Applied rewrites98.1%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6461.3
Applied rewrites61.3%
Taylor expanded in a around 0
Applied rewrites58.6%
(FPCore (a b) :precision binary64 (if (<= b 8.2e+102) (/ 1.0 (fma a (fma a 0.5 -1.0) 2.0)) (/ 1.0 (* b (* (* b b) 0.16666666666666666)))))
double code(double a, double b) {
double tmp;
if (b <= 8.2e+102) {
tmp = 1.0 / fma(a, fma(a, 0.5, -1.0), 2.0);
} else {
tmp = 1.0 / (b * ((b * b) * 0.16666666666666666));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 8.2e+102) tmp = Float64(1.0 / fma(a, fma(a, 0.5, -1.0), 2.0)); else tmp = Float64(1.0 / Float64(b * Float64(Float64(b * b) * 0.16666666666666666))); end return tmp end
code[a_, b_] := If[LessEqual[b, 8.2e+102], N[(1.0 / N[(a * N[(a * 0.5 + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(N[(b * b), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8.2 \cdot 10^{+102}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5, -1\right), 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(\left(b \cdot b\right) \cdot 0.16666666666666666\right)}\\
\end{array}
\end{array}
if b < 8.1999999999999999e102Initial program 98.6%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval98.0
Applied rewrites98.0%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6474.9
Applied rewrites74.9%
Taylor expanded in a around 0
Applied rewrites59.9%
if 8.1999999999999999e102 < 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%
Final simplification65.7%
(FPCore (a b) :precision binary64 (if (<= b 1.55e+151) (/ 1.0 (fma a (fma a 0.5 -1.0) 2.0)) (/ 1.0 (* b (* b 0.5)))))
double code(double a, double b) {
double tmp;
if (b <= 1.55e+151) {
tmp = 1.0 / fma(a, fma(a, 0.5, -1.0), 2.0);
} else {
tmp = 1.0 / (b * (b * 0.5));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 1.55e+151) tmp = Float64(1.0 / fma(a, fma(a, 0.5, -1.0), 2.0)); else tmp = Float64(1.0 / Float64(b * Float64(b * 0.5))); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.55e+151], N[(1.0 / N[(a * N[(a * 0.5 + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.55 \cdot 10^{+151}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5, -1\right), 2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < 1.5500000000000001e151Initial program 98.7%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval98.0
Applied rewrites98.0%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6473.2
Applied rewrites73.2%
Taylor expanded in a around 0
Applied rewrites58.8%
if 1.5500000000000001e151 < 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%
(FPCore (a b) :precision binary64 (if (<= a -1.8e+120) (/ 1.0 (* 0.5 (* a a))) (/ 1.0 (fma b (fma b 0.5 1.0) 2.0))))
double code(double a, double b) {
double tmp;
if (a <= -1.8e+120) {
tmp = 1.0 / (0.5 * (a * a));
} else {
tmp = 1.0 / fma(b, fma(b, 0.5, 1.0), 2.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -1.8e+120) tmp = Float64(1.0 / Float64(0.5 * Float64(a * a))); else tmp = Float64(1.0 / fma(b, fma(b, 0.5, 1.0), 2.0)); end return tmp end
code[a_, b_] := If[LessEqual[a, -1.8e+120], N[(1.0 / N[(0.5 * N[(a * a), $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}\;a \leq -1.8 \cdot 10^{+120}:\\
\;\;\;\;\frac{1}{0.5 \cdot \left(a \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), 2\right)}\\
\end{array}
\end{array}
if a < -1.80000000000000008e120Initial program 100.0%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites86.3%
Taylor expanded in a around inf
Applied rewrites86.3%
if -1.80000000000000008e120 < a Initial program 98.5%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6488.7
Applied rewrites88.7%
Taylor expanded in b around 0
Applied rewrites55.5%
(FPCore (a b) :precision binary64 (if (<= b 1.95) (/ 1.0 (- 2.0 a)) (/ 1.0 (* b (* b 0.5)))))
double code(double a, double b) {
double tmp;
if (b <= 1.95) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = 1.0 / (b * (b * 0.5));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.95d0) then
tmp = 1.0d0 / (2.0d0 - a)
else
tmp = 1.0d0 / (b * (b * 0.5d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.95) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = 1.0 / (b * (b * 0.5));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.95: tmp = 1.0 / (2.0 - a) else: tmp = 1.0 / (b * (b * 0.5)) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.95) tmp = Float64(1.0 / Float64(2.0 - a)); else tmp = Float64(1.0 / Float64(b * Float64(b * 0.5))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.95) tmp = 1.0 / (2.0 - a); else tmp = 1.0 / (b * (b * 0.5)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.95], N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.95:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < 1.94999999999999996Initial program 98.4%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval97.7
Applied rewrites97.7%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6480.3
Applied rewrites80.3%
Taylor expanded in a around 0
Applied rewrites54.2%
if 1.94999999999999996 < 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 rewrites51.1%
Taylor expanded in b around inf
Applied rewrites51.1%
(FPCore (a b) :precision binary64 (/ 1.0 (- 2.0 a)))
double code(double a, double b) {
return 1.0 / (2.0 - a);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (2.0d0 - a)
end function
public static double code(double a, double b) {
return 1.0 / (2.0 - a);
}
def code(a, b): return 1.0 / (2.0 - a)
function code(a, b) return Float64(1.0 / Float64(2.0 - a)) end
function tmp = code(a, b) tmp = 1.0 / (2.0 - a); end
code[a_, b_] := N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{2 - a}
\end{array}
Initial program 98.8%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval98.2
Applied rewrites98.2%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6472.4
Applied rewrites72.4%
Taylor expanded in a around 0
Applied rewrites42.5%
(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 98.8%
lift-/.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
div-invN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f64N/A
metadata-eval98.2
Applied rewrites98.2%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6472.4
Applied rewrites72.4%
Taylor expanded in a around 0
Applied rewrites41.7%
(FPCore (a b) :precision binary64 0.5)
double code(double a, double b) {
return 0.5;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0
end function
public static double code(double a, double b) {
return 0.5;
}
def code(a, b): return 0.5
function code(a, b) return 0.5 end
function tmp = code(a, b) tmp = 0.5; end
code[a_, b_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 98.8%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6479.8
Applied rewrites79.8%
Taylor expanded in b around 0
Applied rewrites41.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 2024234
(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))))