
(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 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Initial program 99.2%
(FPCore (a b) :precision binary64 (if (<= a -6000000.0) (* (exp a) 0.5) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
double tmp;
if (a <= -6000000.0) {
tmp = exp(a) * 0.5;
} else {
tmp = 1.0 / (exp(b) + 1.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-6000000.0d0)) then
tmp = exp(a) * 0.5d0
else
tmp = 1.0d0 / (exp(b) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -6000000.0) {
tmp = Math.exp(a) * 0.5;
} else {
tmp = 1.0 / (Math.exp(b) + 1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -6000000.0: tmp = math.exp(a) * 0.5 else: tmp = 1.0 / (math.exp(b) + 1.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -6000000.0) tmp = Float64(exp(a) * 0.5); else tmp = Float64(1.0 / Float64(exp(b) + 1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -6000000.0) tmp = exp(a) * 0.5; else tmp = 1.0 / (exp(b) + 1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -6000000.0], N[(N[Exp[a], $MachinePrecision] * 0.5), $MachinePrecision], N[(1.0 / N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6000000:\\
\;\;\;\;e^{a} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\end{array}
if a < -6e6Initial program 100.0%
Taylor expanded in b around 0
Simplified100.0%
Taylor expanded in a around 0
Simplified100.0%
lift-exp.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64100.0
Applied egg-rr100.0%
if -6e6 < a Initial program 98.9%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6498.1
Simplified98.1%
Final simplification98.6%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma (fma b 0.5 1.0) (* b (fma 0.5 (* b b) b)) -4.0)))
(if (<= b -14.6)
(+ (exp b) 1.0)
(if (<= b 5.8e+50)
(* (exp a) 0.5)
(if (<= b 1.6e+77)
(/ t_0 (* t_0 (fma b (fma b 0.5 1.0) 2.0)))
(if (<= b 2e+154)
(/ (fma b (fma b 0.5 1.0) -2.0) t_0)
(/ 2.0 (* b b))))))))
double code(double a, double b) {
double t_0 = fma(fma(b, 0.5, 1.0), (b * fma(0.5, (b * b), b)), -4.0);
double tmp;
if (b <= -14.6) {
tmp = exp(b) + 1.0;
} else if (b <= 5.8e+50) {
tmp = exp(a) * 0.5;
} else if (b <= 1.6e+77) {
tmp = t_0 / (t_0 * fma(b, fma(b, 0.5, 1.0), 2.0));
} else if (b <= 2e+154) {
tmp = fma(b, fma(b, 0.5, 1.0), -2.0) / t_0;
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
function code(a, b) t_0 = fma(fma(b, 0.5, 1.0), Float64(b * fma(0.5, Float64(b * b), b)), -4.0) tmp = 0.0 if (b <= -14.6) tmp = Float64(exp(b) + 1.0); elseif (b <= 5.8e+50) tmp = Float64(exp(a) * 0.5); elseif (b <= 1.6e+77) tmp = Float64(t_0 / Float64(t_0 * fma(b, fma(b, 0.5, 1.0), 2.0))); elseif (b <= 2e+154) tmp = Float64(fma(b, fma(b, 0.5, 1.0), -2.0) / t_0); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * 0.5 + 1.0), $MachinePrecision] * N[(b * N[(0.5 * N[(b * b), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] + -4.0), $MachinePrecision]}, If[LessEqual[b, -14.6], N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[b, 5.8e+50], N[(N[Exp[a], $MachinePrecision] * 0.5), $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], If[LessEqual[b, 2e+154], N[(N[(b * N[(b * 0.5 + 1.0), $MachinePrecision] + -2.0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(2.0 / N[(b * b), $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(0.5, b \cdot b, b\right), -4\right)\\
\mathbf{if}\;b \leq -14.6:\\
\;\;\;\;e^{b} + 1\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{+50}:\\
\;\;\;\;e^{a} \cdot 0.5\\
\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{elif}\;b \leq 2 \cdot 10^{+154}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), -2\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < -14.5999999999999996Initial program 96.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Applied egg-rr100.0%
if -14.5999999999999996 < b < 5.8e50Initial program 100.0%
Taylor expanded in b around 0
Simplified96.9%
Taylor expanded in a around 0
Simplified95.1%
lift-exp.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6495.1
Applied egg-rr95.1%
if 5.8e50 < b < 1.6000000000000001e77Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f644.3
Simplified4.3%
lift-fma.f64N/A
flip-+N/A
associate-/r/N/A
flip--N/A
lift-fma.f64N/A
frac-timesN/A
lower-/.f64N/A
Applied egg-rr91.3%
if 1.6000000000000001e77 < b < 2.00000000000000007e154Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f646.1
Simplified6.1%
lift-fma.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
sub-negN/A
lower-fma.f64N/A
metadata-evalN/A
sub-negN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied egg-rr100.0%
if 2.00000000000000007e154 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64100.0
Simplified100.0%
Taylor expanded in b around inf
lower-/.f64N/A
unpow2N/A
lower-*.f64100.0
Simplified100.0%
Final simplification96.9%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma (fma b 0.5 1.0) (* b (fma 0.5 (* b b) b)) -4.0)))
(if (<= b -1.6)
(+ (exp b) 1.0)
(if (<= b 1.6e+77)
(/ t_0 (* t_0 (fma b (fma b 0.5 1.0) 2.0)))
(if (<= b 2e+154)
(/ (fma b (fma b 0.5 1.0) -2.0) t_0)
(/ 2.0 (* b b)))))))
double code(double a, double b) {
double t_0 = fma(fma(b, 0.5, 1.0), (b * fma(0.5, (b * b), b)), -4.0);
double tmp;
if (b <= -1.6) {
tmp = exp(b) + 1.0;
} else if (b <= 1.6e+77) {
tmp = t_0 / (t_0 * fma(b, fma(b, 0.5, 1.0), 2.0));
} else if (b <= 2e+154) {
tmp = fma(b, fma(b, 0.5, 1.0), -2.0) / t_0;
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
function code(a, b) t_0 = fma(fma(b, 0.5, 1.0), Float64(b * fma(0.5, Float64(b * b), b)), -4.0) tmp = 0.0 if (b <= -1.6) tmp = Float64(exp(b) + 1.0); elseif (b <= 1.6e+77) tmp = Float64(t_0 / Float64(t_0 * fma(b, fma(b, 0.5, 1.0), 2.0))); elseif (b <= 2e+154) tmp = Float64(fma(b, fma(b, 0.5, 1.0), -2.0) / t_0); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * 0.5 + 1.0), $MachinePrecision] * N[(b * N[(0.5 * N[(b * b), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] + -4.0), $MachinePrecision]}, If[LessEqual[b, -1.6], N[(N[Exp[b], $MachinePrecision] + 1.0), $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], If[LessEqual[b, 2e+154], N[(N[(b * N[(b * 0.5 + 1.0), $MachinePrecision] + -2.0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(2.0 / N[(b * b), $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(0.5, b \cdot b, b\right), -4\right)\\
\mathbf{if}\;b \leq -1.6:\\
\;\;\;\;e^{b} + 1\\
\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{elif}\;b \leq 2 \cdot 10^{+154}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), -2\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < -1.6000000000000001Initial program 96.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Applied egg-rr100.0%
if -1.6000000000000001 < b < 1.6000000000000001e77Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6467.7
Simplified67.7%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6456.5
Simplified56.5%
lift-fma.f64N/A
flip-+N/A
associate-/r/N/A
flip--N/A
lift-fma.f64N/A
frac-timesN/A
lower-/.f64N/A
Applied egg-rr62.7%
if 1.6000000000000001e77 < b < 2.00000000000000007e154Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f646.1
Simplified6.1%
lift-fma.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
sub-negN/A
lower-fma.f64N/A
metadata-evalN/A
sub-negN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied egg-rr100.0%
if 2.00000000000000007e154 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64100.0
Simplified100.0%
Taylor expanded in b around inf
lower-/.f64N/A
unpow2N/A
lower-*.f64100.0
Simplified100.0%
Final simplification77.4%
(FPCore (a b)
:precision binary64
(let* ((t_0 (fma (fma b 0.5 1.0) (* b (fma 0.5 (* b b) b)) -4.0)))
(if (<= b 9.6e-65)
(fma
a
(fma
(* a a)
(fma a (* a 0.0020833333333333333) -0.020833333333333332)
0.25)
0.5)
(if (<= b 1.6e+77)
(/ t_0 (* t_0 (fma b (fma b 0.5 1.0) 2.0)))
(if (<= b 2e+154)
(/ (fma b (fma b 0.5 1.0) -2.0) t_0)
(/ 2.0 (* b b)))))))
double code(double a, double b) {
double t_0 = fma(fma(b, 0.5, 1.0), (b * fma(0.5, (b * b), b)), -4.0);
double tmp;
if (b <= 9.6e-65) {
tmp = fma(a, fma((a * a), fma(a, (a * 0.0020833333333333333), -0.020833333333333332), 0.25), 0.5);
} else if (b <= 1.6e+77) {
tmp = t_0 / (t_0 * fma(b, fma(b, 0.5, 1.0), 2.0));
} else if (b <= 2e+154) {
tmp = fma(b, fma(b, 0.5, 1.0), -2.0) / t_0;
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
function code(a, b) t_0 = fma(fma(b, 0.5, 1.0), Float64(b * fma(0.5, Float64(b * b), b)), -4.0) tmp = 0.0 if (b <= 9.6e-65) tmp = fma(a, fma(Float64(a * a), fma(a, Float64(a * 0.0020833333333333333), -0.020833333333333332), 0.25), 0.5); elseif (b <= 1.6e+77) tmp = Float64(t_0 / Float64(t_0 * fma(b, fma(b, 0.5, 1.0), 2.0))); elseif (b <= 2e+154) tmp = Float64(fma(b, fma(b, 0.5, 1.0), -2.0) / t_0); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * 0.5 + 1.0), $MachinePrecision] * N[(b * N[(0.5 * N[(b * b), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] + -4.0), $MachinePrecision]}, If[LessEqual[b, 9.6e-65], N[(a * N[(N[(a * a), $MachinePrecision] * N[(a * N[(a * 0.0020833333333333333), $MachinePrecision] + -0.020833333333333332), $MachinePrecision] + 0.25), $MachinePrecision] + 0.5), $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], If[LessEqual[b, 2e+154], N[(N[(b * N[(b * 0.5 + 1.0), $MachinePrecision] + -2.0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(2.0 / N[(b * b), $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(0.5, b \cdot b, b\right), -4\right)\\
\mathbf{if}\;b \leq 9.6 \cdot 10^{-65}:\\
\;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(a \cdot a, \mathsf{fma}\left(a, a \cdot 0.0020833333333333333, -0.020833333333333332\right), 0.25\right), 0.5\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{elif}\;b \leq 2 \cdot 10^{+154}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \mathsf{fma}\left(b, 0.5, 1\right), -2\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 9.6000000000000006e-65Initial program 98.9%
Taylor expanded in b around 0
Simplified74.3%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6452.3
Simplified52.3%
if 9.6000000000000006e-65 < b < 1.6000000000000001e77Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6472.8
Simplified72.8%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6418.8
Simplified18.8%
lift-fma.f64N/A
flip-+N/A
associate-/r/N/A
flip--N/A
lift-fma.f64N/A
frac-timesN/A
lower-/.f64N/A
Applied egg-rr48.7%
if 1.6000000000000001e77 < b < 2.00000000000000007e154Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f646.1
Simplified6.1%
lift-fma.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
sub-negN/A
lower-fma.f64N/A
metadata-evalN/A
sub-negN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied egg-rr100.0%
if 2.00000000000000007e154 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64100.0
Simplified100.0%
Taylor expanded in b around inf
lower-/.f64N/A
unpow2N/A
lower-*.f64100.0
Simplified100.0%
Final simplification60.4%
(FPCore (a b)
:precision binary64
(if (<= b 1.1e-9)
(fma
a
(fma
(* a a)
(fma a (* a 0.0020833333333333333) -0.020833333333333332)
0.25)
0.5)
(if (<= b 1.65e+94)
(* -0.020833333333333332 (* a (* a a)))
(/ 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 <= 1.1e-9) {
tmp = fma(a, fma((a * a), fma(a, (a * 0.0020833333333333333), -0.020833333333333332), 0.25), 0.5);
} else if (b <= 1.65e+94) {
tmp = -0.020833333333333332 * (a * (a * a));
} 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 <= 1.1e-9) tmp = fma(a, fma(Float64(a * a), fma(a, Float64(a * 0.0020833333333333333), -0.020833333333333332), 0.25), 0.5); elseif (b <= 1.65e+94) tmp = Float64(-0.020833333333333332 * Float64(a * Float64(a * a))); 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, 1.1e-9], N[(a * N[(N[(a * a), $MachinePrecision] * N[(a * N[(a * 0.0020833333333333333), $MachinePrecision] + -0.020833333333333332), $MachinePrecision] + 0.25), $MachinePrecision] + 0.5), $MachinePrecision], If[LessEqual[b, 1.65e+94], N[(-0.020833333333333332 * N[(a * N[(a * a), $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 1.1 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(a \cdot a, \mathsf{fma}\left(a, a \cdot 0.0020833333333333333, -0.020833333333333332\right), 0.25\right), 0.5\right)\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{+94}:\\
\;\;\;\;-0.020833333333333332 \cdot \left(a \cdot \left(a \cdot a\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 < 1.0999999999999999e-9Initial program 98.9%
Taylor expanded in b around 0
Simplified75.8%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6452.0
Simplified52.0%
if 1.0999999999999999e-9 < b < 1.65e94Initial program 100.0%
Taylor expanded in b around 0
Simplified44.1%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f642.6
Simplified2.6%
Taylor expanded in a around inf
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6440.1
Simplified40.1%
if 1.65e94 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6497.8
Simplified97.8%
(FPCore (a b)
:precision binary64
(if (<= b 1.1e-9)
(fma
a
(fma
(* a a)
(fma a (* a 0.0020833333333333333) -0.020833333333333332)
0.25)
0.5)
(if (<= b 5.5e+102)
(* -0.020833333333333332 (* a (* a a)))
(/ (fma 2.0 b -4.0) (* b (* b b))))))
double code(double a, double b) {
double tmp;
if (b <= 1.1e-9) {
tmp = fma(a, fma((a * a), fma(a, (a * 0.0020833333333333333), -0.020833333333333332), 0.25), 0.5);
} else if (b <= 5.5e+102) {
tmp = -0.020833333333333332 * (a * (a * a));
} else {
tmp = fma(2.0, b, -4.0) / (b * (b * b));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 1.1e-9) tmp = fma(a, fma(Float64(a * a), fma(a, Float64(a * 0.0020833333333333333), -0.020833333333333332), 0.25), 0.5); elseif (b <= 5.5e+102) tmp = Float64(-0.020833333333333332 * Float64(a * Float64(a * a))); else tmp = Float64(fma(2.0, b, -4.0) / Float64(b * Float64(b * b))); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.1e-9], N[(a * N[(N[(a * a), $MachinePrecision] * N[(a * N[(a * 0.0020833333333333333), $MachinePrecision] + -0.020833333333333332), $MachinePrecision] + 0.25), $MachinePrecision] + 0.5), $MachinePrecision], If[LessEqual[b, 5.5e+102], N[(-0.020833333333333332 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * b + -4.0), $MachinePrecision] / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.1 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(a \cdot a, \mathsf{fma}\left(a, a \cdot 0.0020833333333333333, -0.020833333333333332\right), 0.25\right), 0.5\right)\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;-0.020833333333333332 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(2, b, -4\right)}{b \cdot \left(b \cdot b\right)}\\
\end{array}
\end{array}
if b < 1.0999999999999999e-9Initial program 98.9%
Taylor expanded in b around 0
Simplified75.8%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6452.0
Simplified52.0%
if 1.0999999999999999e-9 < b < 5.49999999999999981e102Initial program 100.0%
Taylor expanded in b around 0
Simplified42.6%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f642.6
Simplified2.6%
Taylor expanded in a around inf
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6438.9
Simplified38.9%
if 5.49999999999999981e102 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6483.7
Simplified83.7%
Taylor expanded in b around inf
unpow2N/A
associate-/r*N/A
*-lft-identityN/A
lft-mult-inverseN/A
associate-*r*N/A
unpow2N/A
associate-/r*N/A
associate-/l/N/A
unpow2N/A
cube-multN/A
lower-/.f64N/A
div-subN/A
associate-/l*N/A
*-inversesN/A
metadata-evalN/A
sub-negN/A
associate-/r/N/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
cube-multN/A
Simplified100.0%
(FPCore (a b)
:precision binary64
(if (<= b 1.1e-9)
(fma a (fma -0.020833333333333332 (* a a) 0.25) 0.5)
(if (<= b 5.5e+102)
(* -0.020833333333333332 (* a (* a a)))
(/ (fma 2.0 b -4.0) (* b (* b b))))))
double code(double a, double b) {
double tmp;
if (b <= 1.1e-9) {
tmp = fma(a, fma(-0.020833333333333332, (a * a), 0.25), 0.5);
} else if (b <= 5.5e+102) {
tmp = -0.020833333333333332 * (a * (a * a));
} else {
tmp = fma(2.0, b, -4.0) / (b * (b * b));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 1.1e-9) tmp = fma(a, fma(-0.020833333333333332, Float64(a * a), 0.25), 0.5); elseif (b <= 5.5e+102) tmp = Float64(-0.020833333333333332 * Float64(a * Float64(a * a))); else tmp = Float64(fma(2.0, b, -4.0) / Float64(b * Float64(b * b))); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.1e-9], N[(a * N[(-0.020833333333333332 * N[(a * a), $MachinePrecision] + 0.25), $MachinePrecision] + 0.5), $MachinePrecision], If[LessEqual[b, 5.5e+102], N[(-0.020833333333333332 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * b + -4.0), $MachinePrecision] / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.1 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(-0.020833333333333332, a \cdot a, 0.25\right), 0.5\right)\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{+102}:\\
\;\;\;\;-0.020833333333333332 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(2, b, -4\right)}{b \cdot \left(b \cdot b\right)}\\
\end{array}
\end{array}
if b < 1.0999999999999999e-9Initial program 98.9%
Taylor expanded in b around 0
Simplified75.8%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6451.9
Simplified51.9%
if 1.0999999999999999e-9 < b < 5.49999999999999981e102Initial program 100.0%
Taylor expanded in b around 0
Simplified42.6%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f642.6
Simplified2.6%
Taylor expanded in a around inf
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6438.9
Simplified38.9%
if 5.49999999999999981e102 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6483.7
Simplified83.7%
Taylor expanded in b around inf
unpow2N/A
associate-/r*N/A
*-lft-identityN/A
lft-mult-inverseN/A
associate-*r*N/A
unpow2N/A
associate-/r*N/A
associate-/l/N/A
unpow2N/A
cube-multN/A
lower-/.f64N/A
div-subN/A
associate-/l*N/A
*-inversesN/A
metadata-evalN/A
sub-negN/A
associate-/r/N/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
cube-multN/A
Simplified100.0%
(FPCore (a b) :precision binary64 (if (<= a -8.5e+34) (* b (* (* b b) 0.020833333333333332)) (/ 1.0 (fma b (fma b 0.5 1.0) 2.0))))
double code(double a, double b) {
double tmp;
if (a <= -8.5e+34) {
tmp = b * ((b * b) * 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 (a <= -8.5e+34) tmp = Float64(b * Float64(Float64(b * b) * 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[a, -8.5e+34], N[(b * N[(N[(b * b), $MachinePrecision] * 0.020833333333333332), $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 -8.5 \cdot 10^{+34}:\\
\;\;\;\;b \cdot \left(\left(b \cdot b\right) \cdot 0.020833333333333332\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 < -8.5000000000000003e34Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6433.5
Simplified33.5%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f642.7
Simplified2.7%
Taylor expanded in b around inf
unpow3N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6445.0
Simplified45.0%
if -8.5000000000000003e34 < a Initial program 98.9%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6497.1
Simplified97.1%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6458.6
Simplified58.6%
(FPCore (a b)
:precision binary64
(if (<= b 1.1e-9)
(fma a (fma -0.020833333333333332 (* a a) 0.25) 0.5)
(if (<= b 1.15e+113)
(* -0.020833333333333332 (* a (* a a)))
(/ 2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 1.1e-9) {
tmp = fma(a, fma(-0.020833333333333332, (a * a), 0.25), 0.5);
} else if (b <= 1.15e+113) {
tmp = -0.020833333333333332 * (a * (a * a));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 1.1e-9) tmp = fma(a, fma(-0.020833333333333332, Float64(a * a), 0.25), 0.5); elseif (b <= 1.15e+113) tmp = Float64(-0.020833333333333332 * Float64(a * Float64(a * a))); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
code[a_, b_] := If[LessEqual[b, 1.1e-9], N[(a * N[(-0.020833333333333332 * N[(a * a), $MachinePrecision] + 0.25), $MachinePrecision] + 0.5), $MachinePrecision], If[LessEqual[b, 1.15e+113], N[(-0.020833333333333332 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.1 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(a, \mathsf{fma}\left(-0.020833333333333332, a \cdot a, 0.25\right), 0.5\right)\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{+113}:\\
\;\;\;\;-0.020833333333333332 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 1.0999999999999999e-9Initial program 98.9%
Taylor expanded in b around 0
Simplified75.8%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6451.9
Simplified51.9%
if 1.0999999999999999e-9 < b < 1.14999999999999998e113Initial program 100.0%
Taylor expanded in b around 0
Simplified42.6%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f642.6
Simplified2.6%
Taylor expanded in a around inf
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6438.9
Simplified38.9%
if 1.14999999999999998e113 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6483.7
Simplified83.7%
Taylor expanded in b around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6483.7
Simplified83.7%
(FPCore (a b)
:precision binary64
(if (<= b 340.0)
(fma a 0.25 0.5)
(if (<= b 1.15e+113)
(* -0.020833333333333332 (* a (* a a)))
(/ 2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 340.0) {
tmp = fma(a, 0.25, 0.5);
} else if (b <= 1.15e+113) {
tmp = -0.020833333333333332 * (a * (a * a));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 340.0) tmp = fma(a, 0.25, 0.5); elseif (b <= 1.15e+113) tmp = Float64(-0.020833333333333332 * Float64(a * Float64(a * a))); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
code[a_, b_] := If[LessEqual[b, 340.0], N[(a * 0.25 + 0.5), $MachinePrecision], If[LessEqual[b, 1.15e+113], N[(-0.020833333333333332 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 340:\\
\;\;\;\;\mathsf{fma}\left(a, 0.25, 0.5\right)\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{+113}:\\
\;\;\;\;-0.020833333333333332 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 340Initial program 98.9%
Taylor expanded in b around 0
Simplified76.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6451.0
Simplified51.0%
if 340 < b < 1.14999999999999998e113Initial program 100.0%
Taylor expanded in b around 0
Simplified35.4%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f642.7
Simplified2.7%
Taylor expanded in a around inf
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6443.5
Simplified43.5%
if 1.14999999999999998e113 < b Initial program 100.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64100.0
Simplified100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6483.7
Simplified83.7%
Taylor expanded in b around inf
lower-/.f64N/A
unpow2N/A
lower-*.f6483.7
Simplified83.7%
(FPCore (a b) :precision binary64 (if (<= a -2.0) (* b (* (* b b) 0.020833333333333332)) (fma a 0.25 0.5)))
double code(double a, double b) {
double tmp;
if (a <= -2.0) {
tmp = b * ((b * b) * 0.020833333333333332);
} else {
tmp = fma(a, 0.25, 0.5);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= -2.0) tmp = Float64(b * Float64(Float64(b * b) * 0.020833333333333332)); else tmp = fma(a, 0.25, 0.5); end return tmp end
code[a_, b_] := If[LessEqual[a, -2.0], N[(b * N[(N[(b * b), $MachinePrecision] * 0.020833333333333332), $MachinePrecision]), $MachinePrecision], N[(a * 0.25 + 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2:\\
\;\;\;\;b \cdot \left(\left(b \cdot b\right) \cdot 0.020833333333333332\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, 0.25, 0.5\right)\\
\end{array}
\end{array}
if a < -2Initial program 98.6%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6435.9
Simplified35.9%
Taylor expanded in b around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f642.7
Simplified2.7%
Taylor expanded in b around inf
unpow3N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6441.0
Simplified41.0%
if -2 < a Initial program 99.4%
Taylor expanded in b around 0
Simplified54.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6453.9
Simplified53.9%
(FPCore (a b) :precision binary64 (if (<= b 340.0) (fma a 0.25 0.5) (* -0.020833333333333332 (* a (* a a)))))
double code(double a, double b) {
double tmp;
if (b <= 340.0) {
tmp = fma(a, 0.25, 0.5);
} else {
tmp = -0.020833333333333332 * (a * (a * a));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 340.0) tmp = fma(a, 0.25, 0.5); else tmp = Float64(-0.020833333333333332 * Float64(a * Float64(a * a))); end return tmp end
code[a_, b_] := If[LessEqual[b, 340.0], N[(a * 0.25 + 0.5), $MachinePrecision], N[(-0.020833333333333332 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 340:\\
\;\;\;\;\mathsf{fma}\left(a, 0.25, 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;-0.020833333333333332 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\end{array}
\end{array}
if b < 340Initial program 98.9%
Taylor expanded in b around 0
Simplified76.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6451.0
Simplified51.0%
if 340 < b Initial program 100.0%
Taylor expanded in b around 0
Simplified39.5%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f642.6
Simplified2.6%
Taylor expanded in a around inf
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6440.0
Simplified40.0%
(FPCore (a b) :precision binary64 (fma a 0.25 0.5))
double code(double a, double b) {
return fma(a, 0.25, 0.5);
}
function code(a, b) return fma(a, 0.25, 0.5) end
code[a_, b_] := N[(a * 0.25 + 0.5), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a, 0.25, 0.5\right)
\end{array}
Initial program 99.2%
Taylor expanded in b around 0
Simplified67.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6439.0
Simplified39.0%
(FPCore (a b) :precision binary64 0.5)
double code(double a, double b) {
return 0.5;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0
end function
public static double code(double a, double b) {
return 0.5;
}
def code(a, b): return 0.5
function code(a, b) return 0.5 end
function tmp = code(a, b) tmp = 0.5; end
code[a_, b_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f6480.5
Simplified80.5%
Taylor expanded in b around 0
Simplified38.6%
(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 2024215
(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))))