
(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 16 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 100.0%
(FPCore (a b) :precision binary64 (if (<= (exp a) 0.9999999998) (/ 1.0 (+ 1.0 (exp (- a)))) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.9999999998) {
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.9999999998d0) 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.9999999998) {
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.9999999998: 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.9999999998) 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.9999999998) 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.9999999998], 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.9999999998:\\
\;\;\;\;\frac{1}{1 + e^{-a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.9999999998Initial program 100.0%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64100.0
Applied egg-rr100.0%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
exp-diffN/A
remove-double-divN/A
exp-negN/A
rem-exp-logN/A
associate-/r*N/A
/-lowering-/.f64N/A
+-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.f6498.7
Simplified98.7%
if 0.9999999998 < (exp.f64 a) Initial program 99.9%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6498.9
Simplified98.9%
Final simplification98.9%
(FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (exp a) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = 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.0d0) then
tmp = 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.0) {
tmp = 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.0: tmp = 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.0) tmp = exp(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.0) tmp = 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.0], N[Exp[a], $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:\\
\;\;\;\;e^{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 100.0%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64100.0
Applied egg-rr100.0%
Taylor expanded in a around inf
Simplified100.0%
if 0.0 < (exp.f64 a) Initial program 99.9%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6498.1
Simplified98.1%
Final simplification98.7%
(FPCore (a b) :precision binary64 (/ 1.0 (+ 1.0 (/ 1.0 (exp (- a b))))))
double code(double a, double b) {
return 1.0 / (1.0 + (1.0 / exp((a - b))));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (1.0d0 + (1.0d0 / exp((a - b))))
end function
public static double code(double a, double b) {
return 1.0 / (1.0 + (1.0 / Math.exp((a - b))));
}
def code(a, b): return 1.0 / (1.0 + (1.0 / math.exp((a - b))))
function code(a, b) return Float64(1.0 / Float64(1.0 + Float64(1.0 / exp(Float64(a - b))))) end
function tmp = code(a, b) tmp = 1.0 / (1.0 + (1.0 / exp((a - b)))); end
code[a_, b_] := N[(1.0 / N[(1.0 + N[(1.0 / N[Exp[N[(a - b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 + \frac{1}{e^{a - b}}}
\end{array}
Initial program 100.0%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64100.0
Applied egg-rr100.0%
Taylor expanded in a around inf
mul-1-negN/A
unsub-negN/A
exp-diffN/A
rem-exp-logN/A
remove-double-divN/A
exp-negN/A
associate-/r*N/A
/-lowering-/.f64N/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
+-lowering-+.f64N/A
*-commutativeN/A
neg-mul-1N/A
prod-expN/A
exp-lowering-exp.f64N/A
neg-mul-1N/A
unsub-negN/A
--lowering--.f6499.9
Simplified99.9%
exp-diffN/A
clear-numN/A
/-lowering-/.f64N/A
div-expN/A
exp-lowering-exp.f64N/A
--lowering--.f64100.0
Applied egg-rr100.0%
(FPCore (a b) :precision binary64 (if (<= (exp b) 5000.0) (/ 1.0 (- 2.0 a)) (* a (* a (* a -0.020833333333333332)))))
double code(double a, double b) {
double tmp;
if (exp(b) <= 5000.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 (exp(b) <= 5000.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 (Math.exp(b) <= 5000.0) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = a * (a * (a * -0.020833333333333332));
}
return tmp;
}
def code(a, b): tmp = 0 if math.exp(b) <= 5000.0: tmp = 1.0 / (2.0 - a) else: tmp = a * (a * (a * -0.020833333333333332)) return tmp
function code(a, b) tmp = 0.0 if (exp(b) <= 5000.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 (exp(b) <= 5000.0) tmp = 1.0 / (2.0 - a); else tmp = a * (a * (a * -0.020833333333333332)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[Exp[b], $MachinePrecision], 5000.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}\;e^{b} \leq 5000:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot -0.020833333333333332\right)\right)\\
\end{array}
\end{array}
if (exp.f64 b) < 5e3Initial program 99.9%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f6499.9
Applied egg-rr99.9%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
exp-diffN/A
remove-double-divN/A
exp-negN/A
rem-exp-logN/A
associate-/r*N/A
/-lowering-/.f64N/A
+-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.f6479.4
Simplified79.4%
Taylor expanded in a around 0
neg-mul-1N/A
unsub-negN/A
--lowering--.f6454.8
Simplified54.8%
if 5e3 < (exp.f64 b) Initial program 100.0%
Taylor expanded in b around 0
Simplified40.3%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f642.6
Simplified2.6%
Taylor expanded in a around inf
unpow3N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6449.3
Simplified49.3%
(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}
Initial program 100.0%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64100.0
Applied egg-rr100.0%
Taylor expanded in a around inf
mul-1-negN/A
unsub-negN/A
exp-diffN/A
rem-exp-logN/A
remove-double-divN/A
exp-negN/A
associate-/r*N/A
/-lowering-/.f64N/A
distribute-lft-inN/A
exp-negN/A
lft-mult-inverseN/A
+-lowering-+.f64N/A
*-commutativeN/A
neg-mul-1N/A
prod-expN/A
exp-lowering-exp.f64N/A
neg-mul-1N/A
unsub-negN/A
--lowering--.f6499.9
Simplified99.9%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma (fma b 0.5 1.0) (* b (fma b (* b 0.5) b)) -4.0)))
(if (<= b -2.4e-40)
(exp a)
(if (<= b 3.3e+51)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.0))
(if (<= b 1.6e+77)
(/ t_0 (* t_0 (fma b (fma b 0.5 1.0) 2.0)))
(/ 1.0 (fma b (fma b (fma b 0.16666666666666666 0.5) 1.0) 2.0)))))))
double code(double a, double b) {
double t_0 = fma(fma(b, 0.5, 1.0), (b * fma(b, (b * 0.5), b)), -4.0);
double tmp;
if (b <= -2.4e-40) {
tmp = exp(a);
} else if (b <= 3.3e+51) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0);
} else if (b <= 1.6e+77) {
tmp = t_0 / (t_0 * fma(b, fma(b, 0.5, 1.0), 2.0));
} else {
tmp = 1.0 / fma(b, fma(b, fma(b, 0.16666666666666666, 0.5), 1.0), 2.0);
}
return tmp;
}
function code(a, b) t_0 = fma(fma(b, 0.5, 1.0), Float64(b * fma(b, Float64(b * 0.5), b)), -4.0) tmp = 0.0 if (b <= -2.4e-40) tmp = exp(a); elseif (b <= 3.3e+51) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); elseif (b <= 1.6e+77) tmp = Float64(t_0 / Float64(t_0 * fma(b, fma(b, 0.5, 1.0), 2.0))); else tmp = Float64(1.0 / fma(b, fma(b, fma(b, 0.16666666666666666, 0.5), 1.0), 2.0)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * 0.5 + 1.0), $MachinePrecision] * N[(b * N[(b * N[(b * 0.5), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] + -4.0), $MachinePrecision]}, If[LessEqual[b, -2.4e-40], N[Exp[a], $MachinePrecision], If[LessEqual[b, 3.3e+51], 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.6e+77], N[(t$95$0 / N[(t$95$0 * N[(b * N[(b * 0.5 + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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)\\
\mathbf{if}\;b \leq -2.4 \cdot 10^{-40}:\\
\;\;\;\;e^{a}\\
\mathbf{elif}\;b \leq 3.3 \cdot 10^{+51}:\\
\;\;\;\;\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.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{t\_0}{t\_0 \cdot \mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), 2\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 < -2.39999999999999991e-40Initial program 100.0%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64100.0
Applied egg-rr100.0%
Taylor expanded in a around inf
Simplified95.5%
if -2.39999999999999991e-40 < b < 3.2999999999999997e51Initial program 99.9%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f6499.9
Applied egg-rr99.9%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
exp-diffN/A
remove-double-divN/A
exp-negN/A
rem-exp-logN/A
associate-/r*N/A
/-lowering-/.f64N/A
+-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.f6494.0
Simplified94.0%
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.f6485.0
Simplified85.0%
if 3.2999999999999997e51 < b < 1.6000000000000001e77Initial 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.f644.3
Simplified4.3%
flip-+N/A
associate-/r/N/A
flip--N/A
frac-timesN/A
/-lowering-/.f64N/A
Applied egg-rr100.0%
if 1.6000000000000001e77 < 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.f6493.4
Simplified93.4%
Final simplification89.3%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma (fma b 0.5 1.0) (* b (fma b (* b 0.5) b)) -4.0)))
(if (<= b 3.2e+51)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.0))
(if (<= b 1.6e+77)
(/ t_0 (* t_0 (fma b (fma b 0.5 1.0) 2.0)))
(/ 1.0 (fma b (fma b (fma b 0.16666666666666666 0.5) 1.0) 2.0))))))
double code(double a, double b) {
double t_0 = fma(fma(b, 0.5, 1.0), (b * fma(b, (b * 0.5), b)), -4.0);
double tmp;
if (b <= 3.2e+51) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0);
} else if (b <= 1.6e+77) {
tmp = t_0 / (t_0 * fma(b, fma(b, 0.5, 1.0), 2.0));
} else {
tmp = 1.0 / fma(b, fma(b, fma(b, 0.16666666666666666, 0.5), 1.0), 2.0);
}
return tmp;
}
function code(a, b) t_0 = fma(fma(b, 0.5, 1.0), Float64(b * fma(b, Float64(b * 0.5), b)), -4.0) tmp = 0.0 if (b <= 3.2e+51) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); elseif (b <= 1.6e+77) tmp = Float64(t_0 / Float64(t_0 * fma(b, fma(b, 0.5, 1.0), 2.0))); else tmp = Float64(1.0 / fma(b, fma(b, fma(b, 0.16666666666666666, 0.5), 1.0), 2.0)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * 0.5 + 1.0), $MachinePrecision] * N[(b * N[(b * N[(b * 0.5), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] + -4.0), $MachinePrecision]}, If[LessEqual[b, 3.2e+51], 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.6e+77], N[(t$95$0 / N[(t$95$0 * N[(b * N[(b * 0.5 + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b * N[(b * 0.16666666666666666 + 0.5), $MachinePrecision] + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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)\\
\mathbf{if}\;b \leq 3.2 \cdot 10^{+51}:\\
\;\;\;\;\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.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{t\_0}{t\_0 \cdot \mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), 2\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 < 3.2000000000000002e51Initial program 99.9%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f6499.9
Applied egg-rr99.9%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
exp-diffN/A
remove-double-divN/A
exp-negN/A
rem-exp-logN/A
associate-/r*N/A
/-lowering-/.f64N/A
+-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.f6477.7
Simplified77.7%
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.f6469.6
Simplified69.6%
if 3.2000000000000002e51 < b < 1.6000000000000001e77Initial 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.f644.3
Simplified4.3%
flip-+N/A
associate-/r/N/A
flip--N/A
frac-timesN/A
/-lowering-/.f64N/A
Applied egg-rr100.0%
if 1.6000000000000001e77 < 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.f6493.4
Simplified93.4%
Final simplification75.4%
(FPCore (a b)
:precision binary64
(if (<= b 8e+39)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.0))
(if (<= b 1.05e+103)
(* 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 <= 8e+39) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0);
} else if (b <= 1.05e+103) {
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 <= 8e+39) 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(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, 8e+39], 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[(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 8 \cdot 10^{+39}:\\
\;\;\;\;\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}:\\
\;\;\;\;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 < 7.99999999999999952e39Initial program 99.9%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f6499.9
Applied egg-rr99.9%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
exp-diffN/A
remove-double-divN/A
exp-negN/A
rem-exp-logN/A
associate-/r*N/A
/-lowering-/.f64N/A
+-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.f6478.6
Simplified78.6%
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.f6470.3
Simplified70.3%
if 7.99999999999999952e39 < b < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in b around 0
Simplified29.0%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6454.5
Simplified54.5%
if 1.0500000000000001e103 < 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.f64100.0
Simplified100.0%
(FPCore (a b)
:precision binary64
(if (<= b 1.65e+39)
(/ 1.0 (fma a (fma a (fma a -0.16666666666666666 0.5) -1.0) 2.0))
(if (<= b 2.75e+153)
(* a (* a (* a -0.020833333333333332)))
(/ 1.0 (fma b (fma b 0.5 1.0) 2.0)))))
double code(double a, double b) {
double tmp;
if (b <= 1.65e+39) {
tmp = 1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0);
} else if (b <= 2.75e+153) {
tmp = a * (a * (a * -0.020833333333333332));
} 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.65e+39) tmp = Float64(1.0 / fma(a, fma(a, fma(a, -0.16666666666666666, 0.5), -1.0), 2.0)); elseif (b <= 2.75e+153) tmp = Float64(a * Float64(a * Float64(a * -0.020833333333333332))); 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.65e+39], 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.75e+153], N[(a * N[(a * N[(a * -0.020833333333333332), $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}\;b \leq 1.65 \cdot 10^{+39}:\\
\;\;\;\;\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.75 \cdot 10^{+153}:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot -0.020833333333333332\right)\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.6500000000000001e39Initial program 99.9%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f6499.9
Applied egg-rr99.9%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
exp-diffN/A
remove-double-divN/A
exp-negN/A
rem-exp-logN/A
associate-/r*N/A
/-lowering-/.f64N/A
+-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.f6478.6
Simplified78.6%
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.f6470.3
Simplified70.3%
if 1.6500000000000001e39 < b < 2.7500000000000001e153Initial program 100.0%
Taylor expanded in b around 0
Simplified24.7%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6460.7
Simplified60.7%
if 2.7500000000000001e153 < 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.f6497.8
Simplified97.8%
(FPCore (a b)
:precision binary64
(if (<= b 940000.0)
(/ 1.0 (fma a (fma a 0.5 -1.0) 2.0))
(if (<= b 2.75e+153)
(* a (* a (* a -0.020833333333333332)))
(/ 1.0 (fma b (fma b 0.5 1.0) 2.0)))))
double code(double a, double b) {
double tmp;
if (b <= 940000.0) {
tmp = 1.0 / fma(a, fma(a, 0.5, -1.0), 2.0);
} else if (b <= 2.75e+153) {
tmp = a * (a * (a * -0.020833333333333332));
} 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 <= 940000.0) tmp = Float64(1.0 / fma(a, fma(a, 0.5, -1.0), 2.0)); elseif (b <= 2.75e+153) tmp = Float64(a * Float64(a * Float64(a * -0.020833333333333332))); 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, 940000.0], N[(1.0 / N[(a * N[(a * 0.5 + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.75e+153], N[(a * N[(a * N[(a * -0.020833333333333332), $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}\;b \leq 940000:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5, -1\right), 2\right)}\\
\mathbf{elif}\;b \leq 2.75 \cdot 10^{+153}:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot -0.020833333333333332\right)\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 < 9.4e5Initial program 99.9%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f6499.9
Applied egg-rr99.9%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
exp-diffN/A
remove-double-divN/A
exp-negN/A
rem-exp-logN/A
associate-/r*N/A
/-lowering-/.f64N/A
+-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.f6479.4
Simplified79.4%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
accelerator-lowering-fma.f6467.4
Simplified67.4%
if 9.4e5 < b < 2.7500000000000001e153Initial program 100.0%
Taylor expanded in b around 0
Simplified31.6%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6457.2
Simplified57.2%
if 2.7500000000000001e153 < 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.f6497.8
Simplified97.8%
(FPCore (a b)
:precision binary64
(if (<= b 700.0)
(/ 1.0 (fma a (fma a 0.5 -1.0) 2.0))
(if (<= b 2.75e+153)
(* a (* a (* a -0.020833333333333332)))
(/ 2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 700.0) {
tmp = 1.0 / fma(a, fma(a, 0.5, -1.0), 2.0);
} else if (b <= 2.75e+153) {
tmp = a * (a * (a * -0.020833333333333332));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 700.0) tmp = Float64(1.0 / fma(a, fma(a, 0.5, -1.0), 2.0)); elseif (b <= 2.75e+153) 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, 700.0], N[(1.0 / N[(a * N[(a * 0.5 + -1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.75e+153], 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 700:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(a, \mathsf{fma}\left(a, 0.5, -1\right), 2\right)}\\
\mathbf{elif}\;b \leq 2.75 \cdot 10^{+153}:\\
\;\;\;\;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 < 700Initial program 99.9%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f6499.9
Applied egg-rr99.9%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
exp-diffN/A
remove-double-divN/A
exp-negN/A
rem-exp-logN/A
associate-/r*N/A
/-lowering-/.f64N/A
+-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.f6479.4
Simplified79.4%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
accelerator-lowering-fma.f6467.4
Simplified67.4%
if 700 < b < 2.7500000000000001e153Initial program 100.0%
Taylor expanded in b around 0
Simplified31.6%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6457.2
Simplified57.2%
if 2.7500000000000001e153 < 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.f6497.8
Simplified97.8%
Taylor expanded in b around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6497.8
Simplified97.8%
(FPCore (a b)
:precision binary64
(if (<= b 550.0)
(/ 1.0 (- 2.0 a))
(if (<= b 2.75e+153)
(* a (* a (* a -0.020833333333333332)))
(/ 2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 550.0) {
tmp = 1.0 / (2.0 - a);
} else if (b <= 2.75e+153) {
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 <= 550.0d0) then
tmp = 1.0d0 / (2.0d0 - a)
else if (b <= 2.75d+153) 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 <= 550.0) {
tmp = 1.0 / (2.0 - a);
} else if (b <= 2.75e+153) {
tmp = a * (a * (a * -0.020833333333333332));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 550.0: tmp = 1.0 / (2.0 - a) elif b <= 2.75e+153: tmp = a * (a * (a * -0.020833333333333332)) else: tmp = 2.0 / (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= 550.0) tmp = Float64(1.0 / Float64(2.0 - a)); elseif (b <= 2.75e+153) 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 <= 550.0) tmp = 1.0 / (2.0 - a); elseif (b <= 2.75e+153) tmp = a * (a * (a * -0.020833333333333332)); else tmp = 2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 550.0], N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.75e+153], 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 550:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{elif}\;b \leq 2.75 \cdot 10^{+153}:\\
\;\;\;\;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 < 550Initial program 99.9%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f6499.9
Applied egg-rr99.9%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
exp-diffN/A
remove-double-divN/A
exp-negN/A
rem-exp-logN/A
associate-/r*N/A
/-lowering-/.f64N/A
+-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.f6479.4
Simplified79.4%
Taylor expanded in a around 0
neg-mul-1N/A
unsub-negN/A
--lowering--.f6454.8
Simplified54.8%
if 550 < b < 2.7500000000000001e153Initial program 100.0%
Taylor expanded in b around 0
Simplified31.6%
Taylor expanded in a around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6457.2
Simplified57.2%
if 2.7500000000000001e153 < 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.f6497.8
Simplified97.8%
Taylor expanded in b around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6497.8
Simplified97.8%
(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 100.0%
clear-numN/A
associate-/r/N/A
inv-powN/A
pow-to-expN/A
prod-expN/A
exp-lowering-exp.f64N/A
accelerator-lowering-fma.f64N/A
log-lowering-log.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
exp-lowering-exp.f64100.0
Applied egg-rr100.0%
Taylor expanded in b around 0
mul-1-negN/A
unsub-negN/A
exp-diffN/A
remove-double-divN/A
exp-negN/A
rem-exp-logN/A
associate-/r*N/A
/-lowering-/.f64N/A
+-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.f6468.2
Simplified68.2%
Taylor expanded in a around 0
neg-mul-1N/A
unsub-negN/A
--lowering--.f6440.3
Simplified40.3%
(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 100.0%
Taylor expanded in b around 0
Simplified68.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f6439.6
Simplified39.6%
(FPCore (a b) :precision binary64 0.5)
double code(double a, double b) {
return 0.5;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0
end function
public static double code(double a, double b) {
return 0.5;
}
def code(a, b): return 0.5
function code(a, b) return 0.5 end
function tmp = code(a, b) tmp = 0.5; end
code[a_, b_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6481.3
Simplified81.3%
Taylor expanded in b around 0
Simplified39.0%
(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 2024198
(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))))