
(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 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
(FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (* (exp a) 0.5) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = exp(a) * 0.5;
} else {
tmp = 1.0 / (1.0 + exp(b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (exp(a) <= 0.0d0) then
tmp = exp(a) * 0.5d0
else
tmp = 1.0d0 / (1.0d0 + exp(b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = Math.exp(a) * 0.5;
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = math.exp(a) * 0.5 else: tmp = 1.0 / (1.0 + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(exp(a) * 0.5); else tmp = Float64(1.0 / Float64(1.0 + exp(b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (exp(a) <= 0.0) tmp = exp(a) * 0.5; else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(N[Exp[a], $MachinePrecision] * 0.5), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;e^{a} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 98.6%
Taylor expanded in b around 0
Simplified100.0%
Taylor expanded in a around 0
Simplified100.0%
div-invN/A
metadata-evalN/A
*-lowering-*.f64N/A
exp-lowering-exp.f64100.0
Applied egg-rr100.0%
if 0.0 < (exp.f64 a) Initial program 98.9%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6498.4
Simplified98.4%
(FPCore (a b) :precision binary64 (/ 1.0 (* (+ (exp a) (exp b)) (exp (- a)))))
double code(double a, double b) {
return 1.0 / ((exp(a) + exp(b)) * exp(-a));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / ((exp(a) + exp(b)) * exp(-a))
end function
public static double code(double a, double b) {
return 1.0 / ((Math.exp(a) + Math.exp(b)) * Math.exp(-a));
}
def code(a, b): return 1.0 / ((math.exp(a) + math.exp(b)) * math.exp(-a))
function code(a, b) return Float64(1.0 / Float64(Float64(exp(a) + exp(b)) * exp(Float64(-a)))) end
function tmp = code(a, b) tmp = 1.0 / ((exp(a) + exp(b)) * exp(-a)); end
code[a_, b_] := N[(1.0 / N[(N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision] * N[Exp[(-a)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(e^{a} + e^{b}\right) \cdot e^{-a}}
\end{array}
Initial program 98.8%
clear-numN/A
/-lowering-/.f64N/A
div-invN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64N/A
rec-expN/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f6498.8
Applied egg-rr98.8%
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Initial program 98.8%
(FPCore (a b)
:precision binary64
(if (<= b 3.6e+53)
(* (exp a) 0.5)
(if (<= b 1.35e+154)
(* (/ (+ b -2.0) (fma b (* b (* b b)) -16.0)) (fma b b 4.0))
(/ 2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 3.6e+53) {
tmp = exp(a) * 0.5;
} else if (b <= 1.35e+154) {
tmp = ((b + -2.0) / fma(b, (b * (b * b)), -16.0)) * fma(b, b, 4.0);
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 3.6e+53) tmp = Float64(exp(a) * 0.5); elseif (b <= 1.35e+154) tmp = Float64(Float64(Float64(b + -2.0) / fma(b, Float64(b * Float64(b * b)), -16.0)) * fma(b, b, 4.0)); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
code[a_, b_] := If[LessEqual[b, 3.6e+53], N[(N[Exp[a], $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[b, 1.35e+154], N[(N[(N[(b + -2.0), $MachinePrecision] / N[(b * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision] + -16.0), $MachinePrecision]), $MachinePrecision] * N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.6 \cdot 10^{+53}:\\
\;\;\;\;e^{a} \cdot 0.5\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{b + -2}{\mathsf{fma}\left(b, b \cdot \left(b \cdot b\right), -16\right)} \cdot \mathsf{fma}\left(b, b, 4\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 3.6e53Initial program 98.4%
Taylor expanded in b around 0
Simplified80.8%
Taylor expanded in a around 0
Simplified80.2%
div-invN/A
metadata-evalN/A
*-lowering-*.f64N/A
exp-lowering-exp.f6480.2
Applied egg-rr80.2%
if 3.6e53 < b < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
+-lowering-+.f644.1
Simplified4.1%
flip-+N/A
clear-numN/A
flip--N/A
associate-/r/N/A
*-lowering-*.f64N/A
Applied egg-rr89.3%
if 1.35000000000000003e154 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64100.0
Simplified100.0%
Taylor expanded in b around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64100.0
Simplified100.0%
(FPCore (a b)
:precision binary64
(if (<= b 1.75e+46)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.0))
(if (<= b 1.35e+154)
(* (/ (+ b -2.0) (fma b (* b (* b b)) -16.0)) (fma b b 4.0))
(/ 2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 1.75e+46) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0);
} else if (b <= 1.35e+154) {
tmp = ((b + -2.0) / fma(b, (b * (b * b)), -16.0)) * fma(b, b, 4.0);
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 1.75e+46) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); elseif (b <= 1.35e+154) tmp = Float64(Float64(Float64(b + -2.0) / fma(b, Float64(b * Float64(b * b)), -16.0)) * fma(b, b, 4.0)); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.75e+46], 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.35e+154], N[(N[(N[(b + -2.0), $MachinePrecision] / N[(b * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision] + -16.0), $MachinePrecision]), $MachinePrecision] * N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.75 \cdot 10^{+46}:\\
\;\;\;\;\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.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{b + -2}{\mathsf{fma}\left(b, b \cdot \left(b \cdot b\right), -16\right)} \cdot \mathsf{fma}\left(b, b, 4\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 1.74999999999999992e46Initial program 98.4%
clear-numN/A
/-lowering-/.f64N/A
div-invN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64N/A
rec-expN/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f6498.4
Applied egg-rr98.4%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
neg-mul-1N/A
exp-lowering-exp.f64N/A
neg-mul-1N/A
neg-lowering-neg.f6481.8
Simplified81.8%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f6471.4
Simplified71.4%
if 1.74999999999999992e46 < b < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
+-lowering-+.f644.1
Simplified4.1%
flip-+N/A
clear-numN/A
flip--N/A
associate-/r/N/A
*-lowering-*.f64N/A
Applied egg-rr89.3%
if 1.35000000000000003e154 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64100.0
Simplified100.0%
Taylor expanded in b around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64100.0
Simplified100.0%
(FPCore (a b)
:precision binary64
(if (<= b 700.0)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.0))
(if (<= b 2.05e+99)
(* a (* a (* a -0.020833333333333332)))
(/ 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 <= 700.0) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0);
} else if (b <= 2.05e+99) {
tmp = a * (a * (a * -0.020833333333333332));
} 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 <= 700.0) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); elseif (b <= 2.05e+99) tmp = Float64(a * Float64(a * Float64(a * -0.020833333333333332))); 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, 700.0], N[(1.0 / N[(a * N[(a * N[(a * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.05e+99], N[(a * N[(a * N[(a * -0.020833333333333332), $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 700:\\
\;\;\;\;\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 2.05 \cdot 10^{+99}:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot -0.020833333333333332\right)\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 < 700Initial program 98.3%
clear-numN/A
/-lowering-/.f64N/A
div-invN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64N/A
rec-expN/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f6498.3
Applied egg-rr98.3%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
neg-mul-1N/A
exp-lowering-exp.f64N/A
neg-mul-1N/A
neg-lowering-neg.f6484.5
Simplified84.5%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f6474.0
Simplified74.0%
if 700 < b < 2.0499999999999999e99Initial program 100.0%
Taylor expanded in b around 0
Simplified25.9%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f642.8
Simplified2.8%
Taylor expanded in a around inf
unpow3N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6454.5
Simplified54.5%
if 2.0499999999999999e99 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f6495.3
Simplified95.3%
(FPCore (a b)
:precision binary64
(if (<= b 720.0)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.0))
(if (<= b 1.35e+154)
(* a (* a (* a -0.020833333333333332)))
(/ 2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 720.0) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0);
} else if (b <= 1.35e+154) {
tmp = a * (a * (a * -0.020833333333333332));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 720.0) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); elseif (b <= 1.35e+154) tmp = Float64(a * Float64(a * Float64(a * -0.020833333333333332))); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
code[a_, b_] := If[LessEqual[b, 720.0], 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.35e+154], N[(a * N[(a * N[(a * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 720:\\
\;\;\;\;\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.35 \cdot 10^{+154}:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot -0.020833333333333332\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 720Initial program 98.3%
clear-numN/A
/-lowering-/.f64N/A
div-invN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64N/A
rec-expN/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f6498.3
Applied egg-rr98.3%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
neg-mul-1N/A
exp-lowering-exp.f64N/A
neg-mul-1N/A
neg-lowering-neg.f6484.5
Simplified84.5%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f6474.0
Simplified74.0%
if 720 < b < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in b around 0
Simplified37.7%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f642.7
Simplified2.7%
Taylor expanded in a around inf
unpow3N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6444.5
Simplified44.5%
if 1.35000000000000003e154 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64100.0
Simplified100.0%
Taylor expanded in b around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64100.0
Simplified100.0%
(FPCore (a b)
:precision binary64
(if (<= b 950.0)
(/ 1.0 (fma a (fma 0.5 a -1.0) 2.0))
(if (<= b 1.35e+154)
(* a (* a (* a -0.020833333333333332)))
(/ 2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 950.0) {
tmp = 1.0 / fma(a, fma(0.5, a, -1.0), 2.0);
} else if (b <= 1.35e+154) {
tmp = a * (a * (a * -0.020833333333333332));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 950.0) tmp = Float64(1.0 / fma(a, fma(0.5, a, -1.0), 2.0)); elseif (b <= 1.35e+154) tmp = Float64(a * Float64(a * Float64(a * -0.020833333333333332))); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
code[a_, b_] := If[LessEqual[b, 950.0], N[(1.0 / N[(a * N[(0.5 * a + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e+154], N[(a * N[(a * N[(a * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 950:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(a, \mathsf{fma}\left(0.5, a, -1\right), 2\right)}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot -0.020833333333333332\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 950Initial program 98.3%
clear-numN/A
/-lowering-/.f64N/A
div-invN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64N/A
rec-expN/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f6498.3
Applied egg-rr98.3%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
neg-mul-1N/A
exp-lowering-exp.f64N/A
neg-mul-1N/A
neg-lowering-neg.f6484.5
Simplified84.5%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f6471.3
Simplified71.3%
if 950 < b < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in b around 0
Simplified37.7%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f642.7
Simplified2.7%
Taylor expanded in a around inf
unpow3N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6444.5
Simplified44.5%
if 1.35000000000000003e154 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64100.0
Simplified100.0%
Taylor expanded in b around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64100.0
Simplified100.0%
(FPCore (a b)
:precision binary64
(if (<= b 540.0)
(/ 1.0 (- 2.0 a))
(if (<= b 1.35e+154)
(* a (* a (* a -0.020833333333333332)))
(/ 2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 540.0) {
tmp = 1.0 / (2.0 - a);
} else if (b <= 1.35e+154) {
tmp = a * (a * (a * -0.020833333333333332));
} else {
tmp = 2.0 / (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 <= 540.0d0) then
tmp = 1.0d0 / (2.0d0 - a)
else if (b <= 1.35d+154) then
tmp = a * (a * (a * (-0.020833333333333332d0)))
else
tmp = 2.0d0 / (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 540.0) {
tmp = 1.0 / (2.0 - a);
} else if (b <= 1.35e+154) {
tmp = a * (a * (a * -0.020833333333333332));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 540.0: tmp = 1.0 / (2.0 - a) elif b <= 1.35e+154: tmp = a * (a * (a * -0.020833333333333332)) else: tmp = 2.0 / (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= 540.0) tmp = Float64(1.0 / Float64(2.0 - a)); elseif (b <= 1.35e+154) tmp = Float64(a * Float64(a * Float64(a * -0.020833333333333332))); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 540.0) tmp = 1.0 / (2.0 - a); elseif (b <= 1.35e+154) tmp = a * (a * (a * -0.020833333333333332)); else tmp = 2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 540.0], N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e+154], N[(a * N[(a * N[(a * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 540:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot -0.020833333333333332\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 540Initial program 98.3%
clear-numN/A
/-lowering-/.f64N/A
div-invN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64N/A
rec-expN/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f6498.3
Applied egg-rr98.3%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
neg-mul-1N/A
exp-lowering-exp.f64N/A
neg-mul-1N/A
neg-lowering-neg.f6484.5
Simplified84.5%
Taylor expanded in a around 0
neg-mul-1N/A
unsub-negN/A
--lowering--.f6459.9
Simplified59.9%
if 540 < b < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in b around 0
Simplified37.7%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f642.7
Simplified2.7%
Taylor expanded in a around inf
unpow3N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6444.5
Simplified44.5%
if 1.35000000000000003e154 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64100.0
Simplified100.0%
Taylor expanded in b around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64100.0
Simplified100.0%
(FPCore (a b) :precision binary64 (if (<= b 450.0) (/ 1.0 (- 2.0 a)) (* a (* a (* a -0.020833333333333332)))))
double code(double a, double b) {
double tmp;
if (b <= 450.0) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = a * (a * (a * -0.020833333333333332));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 450.0d0) then
tmp = 1.0d0 / (2.0d0 - a)
else
tmp = a * (a * (a * (-0.020833333333333332d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 450.0) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = a * (a * (a * -0.020833333333333332));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 450.0: tmp = 1.0 / (2.0 - a) else: tmp = a * (a * (a * -0.020833333333333332)) return tmp
function code(a, b) tmp = 0.0 if (b <= 450.0) tmp = Float64(1.0 / Float64(2.0 - a)); else tmp = Float64(a * Float64(a * Float64(a * -0.020833333333333332))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 450.0) tmp = 1.0 / (2.0 - a); else tmp = a * (a * (a * -0.020833333333333332)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 450.0], N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision], N[(a * N[(a * N[(a * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 450:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot -0.020833333333333332\right)\right)\\
\end{array}
\end{array}
if b < 450Initial program 98.3%
clear-numN/A
/-lowering-/.f64N/A
div-invN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64N/A
rec-expN/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f6498.3
Applied egg-rr98.3%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
neg-mul-1N/A
exp-lowering-exp.f64N/A
neg-mul-1N/A
neg-lowering-neg.f6484.5
Simplified84.5%
Taylor expanded in a around 0
neg-mul-1N/A
unsub-negN/A
--lowering--.f6459.9
Simplified59.9%
if 450 < b Initial program 100.0%
Taylor expanded in b around 0
Simplified36.3%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-commutativeN/A
*-lowering-*.f642.7
Simplified2.7%
Taylor expanded in a around inf
unpow3N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6443.0
Simplified43.0%
(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%
clear-numN/A
/-lowering-/.f64N/A
div-invN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64N/A
rec-expN/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f6498.8
Applied egg-rr98.8%
Taylor expanded in b around 0
+-commutativeN/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
neg-mul-1N/A
exp-lowering-exp.f64N/A
neg-mul-1N/A
neg-lowering-neg.f6470.8
Simplified70.8%
Taylor expanded in a around 0
neg-mul-1N/A
unsub-negN/A
--lowering--.f6443.9
Simplified43.9%
(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
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6481.8
Simplified81.8%
Taylor expanded in b around 0
Simplified43.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 2024199
(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))))