
(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 9 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 -23000.0) (/ (exp a) 2.0) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
double tmp;
if (a <= -23000.0) {
tmp = exp(a) / 2.0;
} else {
tmp = 1.0 / (exp(b) + 1.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-23000.0d0)) then
tmp = exp(a) / 2.0d0
else
tmp = 1.0d0 / (exp(b) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -23000.0) {
tmp = Math.exp(a) / 2.0;
} else {
tmp = 1.0 / (Math.exp(b) + 1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -23000.0: tmp = math.exp(a) / 2.0 else: tmp = 1.0 / (math.exp(b) + 1.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -23000.0) tmp = Float64(exp(a) / 2.0); else tmp = Float64(1.0 / Float64(exp(b) + 1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -23000.0) tmp = exp(a) / 2.0; else tmp = 1.0 / (exp(b) + 1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -23000.0], N[(N[Exp[a], $MachinePrecision] / 2.0), $MachinePrecision], N[(1.0 / N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -23000:\\
\;\;\;\;\frac{e^{a}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\end{array}
if a < -23000Initial program 100.0%
Taylor expanded in b around 0
Simplified100.0%
Taylor expanded in a around 0
Simplified100.0%
if -23000 < a Initial program 99.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6498.8%
Simplified98.8%
Final simplification99.0%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (* b b) 0.16666666666666666)) (t_1 (* b t_0)))
(if (<= b 860.0)
(/ (exp a) 2.0)
(if (<= b 2.6e+46)
(* -0.020833333333333332 (* a (* a a)))
(if (<= b 5e+101)
(/ 1.0 (/ (- (* b (* t_0 t_1)) 4.0) (- t_1 2.0)))
(/ 6.0 (* b (* b b))))))))
double code(double a, double b) {
double t_0 = (b * b) * 0.16666666666666666;
double t_1 = b * t_0;
double tmp;
if (b <= 860.0) {
tmp = exp(a) / 2.0;
} else if (b <= 2.6e+46) {
tmp = -0.020833333333333332 * (a * (a * a));
} else if (b <= 5e+101) {
tmp = 1.0 / (((b * (t_0 * t_1)) - 4.0) / (t_1 - 2.0));
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (b * b) * 0.16666666666666666d0
t_1 = b * t_0
if (b <= 860.0d0) then
tmp = exp(a) / 2.0d0
else if (b <= 2.6d+46) then
tmp = (-0.020833333333333332d0) * (a * (a * a))
else if (b <= 5d+101) then
tmp = 1.0d0 / (((b * (t_0 * t_1)) - 4.0d0) / (t_1 - 2.0d0))
else
tmp = 6.0d0 / (b * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = (b * b) * 0.16666666666666666;
double t_1 = b * t_0;
double tmp;
if (b <= 860.0) {
tmp = Math.exp(a) / 2.0;
} else if (b <= 2.6e+46) {
tmp = -0.020833333333333332 * (a * (a * a));
} else if (b <= 5e+101) {
tmp = 1.0 / (((b * (t_0 * t_1)) - 4.0) / (t_1 - 2.0));
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
def code(a, b): t_0 = (b * b) * 0.16666666666666666 t_1 = b * t_0 tmp = 0 if b <= 860.0: tmp = math.exp(a) / 2.0 elif b <= 2.6e+46: tmp = -0.020833333333333332 * (a * (a * a)) elif b <= 5e+101: tmp = 1.0 / (((b * (t_0 * t_1)) - 4.0) / (t_1 - 2.0)) else: tmp = 6.0 / (b * (b * b)) return tmp
function code(a, b) t_0 = Float64(Float64(b * b) * 0.16666666666666666) t_1 = Float64(b * t_0) tmp = 0.0 if (b <= 860.0) tmp = Float64(exp(a) / 2.0); elseif (b <= 2.6e+46) tmp = Float64(-0.020833333333333332 * Float64(a * Float64(a * a))); elseif (b <= 5e+101) tmp = Float64(1.0 / Float64(Float64(Float64(b * Float64(t_0 * t_1)) - 4.0) / Float64(t_1 - 2.0))); else tmp = Float64(6.0 / Float64(b * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) t_0 = (b * b) * 0.16666666666666666; t_1 = b * t_0; tmp = 0.0; if (b <= 860.0) tmp = exp(a) / 2.0; elseif (b <= 2.6e+46) tmp = -0.020833333333333332 * (a * (a * a)); elseif (b <= 5e+101) tmp = 1.0 / (((b * (t_0 * t_1)) - 4.0) / (t_1 - 2.0)); else tmp = 6.0 / (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]}, Block[{t$95$1 = N[(b * t$95$0), $MachinePrecision]}, If[LessEqual[b, 860.0], N[(N[Exp[a], $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[b, 2.6e+46], N[(-0.020833333333333332 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5e+101], N[(1.0 / N[(N[(N[(b * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] - 4.0), $MachinePrecision] / N[(t$95$1 - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b \cdot b\right) \cdot 0.16666666666666666\\
t_1 := b \cdot t\_0\\
\mathbf{if}\;b \leq 860:\\
\;\;\;\;\frac{e^{a}}{2}\\
\mathbf{elif}\;b \leq 2.6 \cdot 10^{+46}:\\
\;\;\;\;-0.020833333333333332 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+101}:\\
\;\;\;\;\frac{1}{\frac{b \cdot \left(t\_0 \cdot t\_1\right) - 4}{t\_1 - 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\
\end{array}
\end{array}
if b < 860Initial program 99.4%
Taylor expanded in b around 0
Simplified78.6%
Taylor expanded in a around 0
Simplified77.3%
if 860 < b < 2.60000000000000013e46Initial program 100.0%
Taylor expanded in b around 0
Simplified3.1%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
+-inversesN/A
associate--r+N/A
+-commutativeN/A
distribute-rgt-outN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
Simplified3.1%
Taylor expanded in a around inf
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6489.4%
Simplified89.4%
if 2.60000000000000013e46 < b < 4.99999999999999989e101Initial program 91.7%
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
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f647.0%
Simplified7.0%
Taylor expanded in b around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f647.0%
Simplified7.0%
+-commutativeN/A
flip-+N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
--lowering--.f64N/A
Applied egg-rr92.0%
if 4.99999999999999989e101 < 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
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64100.0%
Simplified100.0%
Taylor expanded in b around inf
/-lowering-/.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64100.0%
Simplified100.0%
(FPCore (a b) :precision binary64 (if (<= a -620.0) (/ 1.0 (* b (* b (* b (+ 0.16666666666666666 (/ (+ 0.5 (/ 1.0 b)) b)))))) (/ 1.0 (+ 2.0 (* b (+ 1.0 (/ 1.0 (/ 6.0 (* b b)))))))))
double code(double a, double b) {
double tmp;
if (a <= -620.0) {
tmp = 1.0 / (b * (b * (b * (0.16666666666666666 + ((0.5 + (1.0 / b)) / b)))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (1.0 / (6.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 (a <= (-620.0d0)) then
tmp = 1.0d0 / (b * (b * (b * (0.16666666666666666d0 + ((0.5d0 + (1.0d0 / b)) / b)))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (1.0d0 / (6.0d0 / (b * b))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -620.0) {
tmp = 1.0 / (b * (b * (b * (0.16666666666666666 + ((0.5 + (1.0 / b)) / b)))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (1.0 / (6.0 / (b * b))))));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -620.0: tmp = 1.0 / (b * (b * (b * (0.16666666666666666 + ((0.5 + (1.0 / b)) / b))))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (1.0 / (6.0 / (b * b)))))) return tmp
function code(a, b) tmp = 0.0 if (a <= -620.0) tmp = Float64(1.0 / Float64(b * Float64(b * Float64(b * Float64(0.16666666666666666 + Float64(Float64(0.5 + Float64(1.0 / b)) / b)))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(1.0 / Float64(6.0 / Float64(b * b))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -620.0) tmp = 1.0 / (b * (b * (b * (0.16666666666666666 + ((0.5 + (1.0 / b)) / b))))); else tmp = 1.0 / (2.0 + (b * (1.0 + (1.0 / (6.0 / (b * b)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -620.0], N[(1.0 / N[(b * N[(b * N[(b * N[(0.16666666666666666 + N[(N[(0.5 + N[(1.0 / b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(1.0 / N[(6.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -620:\\
\;\;\;\;\frac{1}{b \cdot \left(b \cdot \left(b \cdot \left(0.16666666666666666 + \frac{0.5 + \frac{1}{b}}{b}\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + \frac{1}{\frac{6}{b \cdot b}}\right)}\\
\end{array}
\end{array}
if a < -620Initial program 98.3%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6429.9%
Simplified29.9%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6424.9%
Simplified24.9%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
cube-multN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mul-1-negN/A
remove-double-negN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
Simplified28.6%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f6464.8%
Applied egg-rr64.8%
if -620 < a Initial program 99.5%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6498.8%
Simplified98.8%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6467.1%
Simplified67.1%
*-commutativeN/A
flip-+N/A
associate-*l/N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
*-lowering-*.f64N/A
metadata-evalN/A
--lowering--.f64N/A
swap-sqrN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-eval67.1%
Applied egg-rr67.1%
Taylor expanded in b around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6467.1%
Simplified67.1%
Final simplification66.6%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* a (* a -0.020833333333333332))))
(if (<= b 350.0)
(+ 0.5 (* a (+ 0.25 t_0)))
(if (<= b 3.6e+101) (* a t_0) (/ 6.0 (* b (* b b)))))))
double code(double a, double b) {
double t_0 = a * (a * -0.020833333333333332);
double tmp;
if (b <= 350.0) {
tmp = 0.5 + (a * (0.25 + t_0));
} else if (b <= 3.6e+101) {
tmp = a * t_0;
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: tmp
t_0 = a * (a * (-0.020833333333333332d0))
if (b <= 350.0d0) then
tmp = 0.5d0 + (a * (0.25d0 + t_0))
else if (b <= 3.6d+101) then
tmp = a * t_0
else
tmp = 6.0d0 / (b * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = a * (a * -0.020833333333333332);
double tmp;
if (b <= 350.0) {
tmp = 0.5 + (a * (0.25 + t_0));
} else if (b <= 3.6e+101) {
tmp = a * t_0;
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
def code(a, b): t_0 = a * (a * -0.020833333333333332) tmp = 0 if b <= 350.0: tmp = 0.5 + (a * (0.25 + t_0)) elif b <= 3.6e+101: tmp = a * t_0 else: tmp = 6.0 / (b * (b * b)) return tmp
function code(a, b) t_0 = Float64(a * Float64(a * -0.020833333333333332)) tmp = 0.0 if (b <= 350.0) tmp = Float64(0.5 + Float64(a * Float64(0.25 + t_0))); elseif (b <= 3.6e+101) tmp = Float64(a * t_0); else tmp = Float64(6.0 / Float64(b * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) t_0 = a * (a * -0.020833333333333332); tmp = 0.0; if (b <= 350.0) tmp = 0.5 + (a * (0.25 + t_0)); elseif (b <= 3.6e+101) tmp = a * t_0; else tmp = 6.0 / (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(a * N[(a * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 350.0], N[(0.5 + N[(a * N[(0.25 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.6e+101], N[(a * t$95$0), $MachinePrecision], N[(6.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(a \cdot -0.020833333333333332\right)\\
\mathbf{if}\;b \leq 350:\\
\;\;\;\;0.5 + a \cdot \left(0.25 + t\_0\right)\\
\mathbf{elif}\;b \leq 3.6 \cdot 10^{+101}:\\
\;\;\;\;a \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\
\end{array}
\end{array}
if b < 350Initial program 99.4%
Taylor expanded in b around 0
Simplified78.6%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
+-inversesN/A
associate--r+N/A
+-commutativeN/A
distribute-rgt-outN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
Simplified55.9%
if 350 < b < 3.60000000000000029e101Initial program 95.0%
Taylor expanded in b around 0
Simplified12.7%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
+-inversesN/A
associate--r+N/A
+-commutativeN/A
distribute-rgt-outN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
Simplified3.0%
Taylor expanded in a around inf
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6459.8%
Simplified59.8%
associate-*r*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6459.8%
Applied egg-rr59.8%
if 3.60000000000000029e101 < 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
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6498.3%
Simplified98.3%
Taylor expanded in b around inf
/-lowering-/.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6498.3%
Simplified98.3%
Final simplification64.8%
(FPCore (a b)
:precision binary64
(if (<= b 420.0)
(+ 0.5 (* a 0.25))
(if (<= b 3.6e+101)
(* a (* a (* a -0.020833333333333332)))
(/ 6.0 (* b (* b b))))))
double code(double a, double b) {
double tmp;
if (b <= 420.0) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 3.6e+101) {
tmp = a * (a * (a * -0.020833333333333332));
} else {
tmp = 6.0 / (b * (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 <= 420.0d0) then
tmp = 0.5d0 + (a * 0.25d0)
else if (b <= 3.6d+101) then
tmp = a * (a * (a * (-0.020833333333333332d0)))
else
tmp = 6.0d0 / (b * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 420.0) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 3.6e+101) {
tmp = a * (a * (a * -0.020833333333333332));
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 420.0: tmp = 0.5 + (a * 0.25) elif b <= 3.6e+101: tmp = a * (a * (a * -0.020833333333333332)) else: tmp = 6.0 / (b * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (b <= 420.0) tmp = Float64(0.5 + Float64(a * 0.25)); elseif (b <= 3.6e+101) tmp = Float64(a * Float64(a * Float64(a * -0.020833333333333332))); else tmp = Float64(6.0 / Float64(b * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 420.0) tmp = 0.5 + (a * 0.25); elseif (b <= 3.6e+101) tmp = a * (a * (a * -0.020833333333333332)); else tmp = 6.0 / (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 420.0], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.6e+101], N[(a * N[(a * N[(a * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 420:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{elif}\;b \leq 3.6 \cdot 10^{+101}:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot -0.020833333333333332\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\
\end{array}
\end{array}
if b < 420Initial program 99.4%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6477.2%
Simplified77.2%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f6455.9%
Simplified55.9%
if 420 < b < 3.60000000000000029e101Initial program 95.0%
Taylor expanded in b around 0
Simplified12.7%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
+-inversesN/A
associate--r+N/A
+-commutativeN/A
distribute-rgt-outN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
Simplified3.0%
Taylor expanded in a around inf
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6459.8%
Simplified59.8%
associate-*r*N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6459.8%
Applied egg-rr59.8%
if 3.60000000000000029e101 < 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
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6498.3%
Simplified98.3%
Taylor expanded in b around inf
/-lowering-/.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6498.3%
Simplified98.3%
Final simplification64.8%
(FPCore (a b) :precision binary64 (if (<= b 370.0) (+ 0.5 (* a 0.25)) (* -0.020833333333333332 (* a (* a a)))))
double code(double a, double b) {
double tmp;
if (b <= 370.0) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = -0.020833333333333332 * (a * (a * a));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 370.0d0) then
tmp = 0.5d0 + (a * 0.25d0)
else
tmp = (-0.020833333333333332d0) * (a * (a * a))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 370.0) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = -0.020833333333333332 * (a * (a * a));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 370.0: tmp = 0.5 + (a * 0.25) else: tmp = -0.020833333333333332 * (a * (a * a)) return tmp
function code(a, b) tmp = 0.0 if (b <= 370.0) tmp = Float64(0.5 + Float64(a * 0.25)); else tmp = Float64(-0.020833333333333332 * Float64(a * Float64(a * a))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 370.0) tmp = 0.5 + (a * 0.25); else tmp = -0.020833333333333332 * (a * (a * a)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 370.0], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], N[(-0.020833333333333332 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 370:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;-0.020833333333333332 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\end{array}
\end{array}
if b < 370Initial program 99.4%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6477.2%
Simplified77.2%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f6455.9%
Simplified55.9%
if 370 < b Initial program 98.6%
Taylor expanded in b around 0
Simplified23.3%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
+-inversesN/A
associate--r+N/A
+-commutativeN/A
distribute-rgt-outN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
distribute-rgt-outN/A
Simplified2.8%
Taylor expanded in a around inf
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6451.5%
Simplified51.5%
Final simplification54.6%
(FPCore (a b) :precision binary64 (+ 0.5 (* a 0.25)))
double code(double a, double b) {
return 0.5 + (a * 0.25);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0 + (a * 0.25d0)
end function
public static double code(double a, double b) {
return 0.5 + (a * 0.25);
}
def code(a, b): return 0.5 + (a * 0.25)
function code(a, b) return Float64(0.5 + Float64(a * 0.25)) end
function tmp = code(a, b) tmp = 0.5 + (a * 0.25); end
code[a_, b_] := N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 + a \cdot 0.25
\end{array}
Initial program 99.2%
Taylor expanded in a around 0
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6483.6%
Simplified83.6%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f6441.0%
Simplified41.0%
Final simplification41.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
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6483.2%
Simplified83.2%
Taylor expanded in b around 0
Simplified40.7%
(FPCore (a b) :precision binary64 (/ 1.0 (+ 1.0 (exp (- b a)))))
double code(double a, double b) {
return 1.0 / (1.0 + exp((b - a)));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (1.0d0 + exp((b - a)))
end function
public static double code(double a, double b) {
return 1.0 / (1.0 + Math.exp((b - a)));
}
def code(a, b): return 1.0 / (1.0 + math.exp((b - a)))
function code(a, b) return Float64(1.0 / Float64(1.0 + exp(Float64(b - a)))) end
function tmp = code(a, b) tmp = 1.0 / (1.0 + exp((b - a))); end
code[a_, b_] := N[(1.0 / N[(1.0 + N[Exp[N[(b - a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 + e^{b - a}}
\end{array}
herbie shell --seed 2024150
(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))))