
(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 10 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%
Final simplification99.2%
(FPCore (a b) :precision binary64 (if (<= (exp a) 1.0) (/ (exp a) (+ (exp a) 1.0)) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 1.0) {
tmp = exp(a) / (exp(a) + 1.0);
} else {
tmp = 1.0 / (exp(b) + 1.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (exp(a) <= 1.0d0) then
tmp = exp(a) / (exp(a) + 1.0d0)
else
tmp = 1.0d0 / (exp(b) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 1.0) {
tmp = Math.exp(a) / (Math.exp(a) + 1.0);
} else {
tmp = 1.0 / (Math.exp(b) + 1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if math.exp(a) <= 1.0: tmp = math.exp(a) / (math.exp(a) + 1.0) else: tmp = 1.0 / (math.exp(b) + 1.0) return tmp
function code(a, b) tmp = 0.0 if (exp(a) <= 1.0) tmp = Float64(exp(a) / Float64(exp(a) + 1.0)); else tmp = Float64(1.0 / Float64(exp(b) + 1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (exp(a) <= 1.0) tmp = exp(a) / (exp(a) + 1.0); else tmp = 1.0 / (exp(b) + 1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 1.0], N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 1:\\
\;\;\;\;\frac{e^{a}}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\end{array}
if (exp.f64 a) < 1Initial program 100.0%
Taylor expanded in b around 0 70.0%
if 1 < (exp.f64 a) Initial program 81.7%
Taylor expanded in a around 0 67.4%
Final simplification69.8%
(FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (/ (exp a) b) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = exp(a) / b;
} 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) / b
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) / b;
} 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) / b else: tmp = 1.0 / (math.exp(b) + 1.0) return tmp
function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(exp(a) / b); 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) / b; else tmp = 1.0 / (exp(b) + 1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(N[Exp[a], $MachinePrecision] / b), $MachinePrecision], N[(1.0 / N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{e^{a}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 100.0%
Taylor expanded in b around 0 100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
if 0.0 < (exp.f64 a) Initial program 98.9%
Taylor expanded in a around 0 97.1%
Final simplification98.0%
(FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (/ (exp a) b) (/ 1.0 (+ 2.0 (+ b (* 0.5 (* b b)))))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = exp(a) / b;
} else {
tmp = 1.0 / (2.0 + (b + (0.5 * (b * b))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (exp(a) <= 0.0d0) then
tmp = exp(a) / b
else
tmp = 1.0d0 / (2.0d0 + (b + (0.5d0 * (b * b))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = Math.exp(a) / b;
} else {
tmp = 1.0 / (2.0 + (b + (0.5 * (b * b))));
}
return tmp;
}
def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = math.exp(a) / b else: tmp = 1.0 / (2.0 + (b + (0.5 * (b * b)))) return tmp
function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(exp(a) / b); else tmp = Float64(1.0 / Float64(2.0 + Float64(b + Float64(0.5 * Float64(b * b))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (exp(a) <= 0.0) tmp = exp(a) / b; else tmp = 1.0 / (2.0 + (b + (0.5 * (b * b)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(N[Exp[a], $MachinePrecision] / b), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b + N[(0.5 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{e^{a}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + \left(b + 0.5 \cdot \left(b \cdot b\right)\right)}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 100.0%
Taylor expanded in b around 0 100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
if 0.0 < (exp.f64 a) Initial program 98.9%
Taylor expanded in a around 0 97.1%
Taylor expanded in b around 0 66.0%
unpow266.0%
Simplified66.0%
Final simplification76.1%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* b (- b))))
(if (<= b 2.0)
(+ 0.5 (* a 0.25))
(if (<= b 1.35e+154) (/ (- t_0 (* b -2.0)) (* b t_0)) (/ 2.0 (* b b))))))
double code(double a, double b) {
double t_0 = b * -b;
double tmp;
if (b <= 2.0) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 1.35e+154) {
tmp = (t_0 - (b * -2.0)) / (b * t_0);
} 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) :: t_0
real(8) :: tmp
t_0 = b * -b
if (b <= 2.0d0) then
tmp = 0.5d0 + (a * 0.25d0)
else if (b <= 1.35d+154) then
tmp = (t_0 - (b * (-2.0d0))) / (b * t_0)
else
tmp = 2.0d0 / (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = b * -b;
double tmp;
if (b <= 2.0) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 1.35e+154) {
tmp = (t_0 - (b * -2.0)) / (b * t_0);
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
def code(a, b): t_0 = b * -b tmp = 0 if b <= 2.0: tmp = 0.5 + (a * 0.25) elif b <= 1.35e+154: tmp = (t_0 - (b * -2.0)) / (b * t_0) else: tmp = 2.0 / (b * b) return tmp
function code(a, b) t_0 = Float64(b * Float64(-b)) tmp = 0.0 if (b <= 2.0) tmp = Float64(0.5 + Float64(a * 0.25)); elseif (b <= 1.35e+154) tmp = Float64(Float64(t_0 - Float64(b * -2.0)) / Float64(b * t_0)); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) t_0 = b * -b; tmp = 0.0; if (b <= 2.0) tmp = 0.5 + (a * 0.25); elseif (b <= 1.35e+154) tmp = (t_0 - (b * -2.0)) / (b * t_0); else tmp = 2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(b * (-b)), $MachinePrecision]}, If[LessEqual[b, 2.0], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e+154], N[(N[(t$95$0 - N[(b * -2.0), $MachinePrecision]), $MachinePrecision] / N[(b * t$95$0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \left(-b\right)\\
\mathbf{if}\;b \leq 2:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{t_0 - b \cdot -2}{b \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 2Initial program 99.4%
Taylor expanded in b around 0 81.4%
Taylor expanded in a around 0 52.9%
*-commutative52.9%
Simplified52.9%
if 2 < b < 1.35000000000000003e154Initial program 96.8%
Taylor expanded in a around 0 93.8%
Taylor expanded in b around 0 4.1%
+-commutative4.1%
Simplified4.1%
Taylor expanded in b around inf 4.1%
associate-*r/4.1%
metadata-eval4.1%
unpow24.1%
Simplified4.1%
frac-2neg4.1%
frac-sub22.6%
*-un-lft-identity22.6%
distribute-rgt-neg-in22.6%
metadata-eval22.6%
distribute-rgt-neg-in22.6%
Applied egg-rr22.6%
if 1.35000000000000003e154 < b Initial program 100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification55.8%
(FPCore (a b) :precision binary64 (if (<= b 7.6e-80) (+ 0.5 (* a 0.25)) (/ 1.0 (+ 2.0 (+ b (* 0.5 (* b b)))))))
double code(double a, double b) {
double tmp;
if (b <= 7.6e-80) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = 1.0 / (2.0 + (b + (0.5 * (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 <= 7.6d-80) then
tmp = 0.5d0 + (a * 0.25d0)
else
tmp = 1.0d0 / (2.0d0 + (b + (0.5d0 * (b * b))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 7.6e-80) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = 1.0 / (2.0 + (b + (0.5 * (b * b))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 7.6e-80: tmp = 0.5 + (a * 0.25) else: tmp = 1.0 / (2.0 + (b + (0.5 * (b * b)))) return tmp
function code(a, b) tmp = 0.0 if (b <= 7.6e-80) tmp = Float64(0.5 + Float64(a * 0.25)); else tmp = Float64(1.0 / Float64(2.0 + Float64(b + Float64(0.5 * Float64(b * b))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 7.6e-80) tmp = 0.5 + (a * 0.25); else tmp = 1.0 / (2.0 + (b + (0.5 * (b * b)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 7.6e-80], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b + N[(0.5 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.6 \cdot 10^{-80}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + \left(b + 0.5 \cdot \left(b \cdot b\right)\right)}\\
\end{array}
\end{array}
if b < 7.59999999999999933e-80Initial program 99.4%
Taylor expanded in b around 0 80.9%
Taylor expanded in a around 0 51.7%
*-commutative51.7%
Simplified51.7%
if 7.59999999999999933e-80 < b Initial program 98.7%
Taylor expanded in a around 0 95.0%
Taylor expanded in b around 0 59.3%
unpow259.3%
Simplified59.3%
Final simplification54.0%
(FPCore (a b) :precision binary64 (if (<= b 7e-80) (+ 0.5 (* a 0.25)) (/ 1.0 (+ 2.0 (* b (* b 0.5))))))
double code(double a, double b) {
double tmp;
if (b <= 7e-80) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = 1.0 / (2.0 + (b * (b * 0.5)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 7d-80) then
tmp = 0.5d0 + (a * 0.25d0)
else
tmp = 1.0d0 / (2.0d0 + (b * (b * 0.5d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 7e-80) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = 1.0 / (2.0 + (b * (b * 0.5)));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 7e-80: tmp = 0.5 + (a * 0.25) else: tmp = 1.0 / (2.0 + (b * (b * 0.5))) return tmp
function code(a, b) tmp = 0.0 if (b <= 7e-80) tmp = Float64(0.5 + Float64(a * 0.25)); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(b * 0.5)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 7e-80) tmp = 0.5 + (a * 0.25); else tmp = 1.0 / (2.0 + (b * (b * 0.5))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 7e-80], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b * N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7 \cdot 10^{-80}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < 7.00000000000000029e-80Initial program 99.4%
Taylor expanded in b around 0 80.9%
Taylor expanded in a around 0 51.7%
*-commutative51.7%
Simplified51.7%
if 7.00000000000000029e-80 < b Initial program 98.7%
Taylor expanded in a around 0 95.0%
Taylor expanded in b around 0 59.3%
unpow259.3%
Simplified59.3%
Taylor expanded in b around inf 58.5%
unpow258.5%
associate-*r*58.5%
*-commutative58.5%
Simplified58.5%
Final simplification53.7%
(FPCore (a b) :precision binary64 (if (<= b 1.55) (+ 0.5 (* a 0.25)) (/ 2.0 (* b b))))
double code(double a, double b) {
double tmp;
if (b <= 1.55) {
tmp = 0.5 + (a * 0.25);
} 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 <= 1.55d0) then
tmp = 0.5d0 + (a * 0.25d0)
else
tmp = 2.0d0 / (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.55) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.55: tmp = 0.5 + (a * 0.25) else: tmp = 2.0 / (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.55) tmp = Float64(0.5 + Float64(a * 0.25)); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.55) tmp = 0.5 + (a * 0.25); else tmp = 2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.55], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.55:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 1.55000000000000004Initial program 99.4%
Taylor expanded in b around 0 81.4%
Taylor expanded in a around 0 52.9%
*-commutative52.9%
Simplified52.9%
if 1.55000000000000004 < b Initial program 98.5%
Taylor expanded in a around 0 97.1%
Taylor expanded in b around 0 56.2%
unpow256.2%
Simplified56.2%
Taylor expanded in b around inf 56.2%
unpow256.2%
Simplified56.2%
Final simplification53.7%
(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 b around 0 69.3%
Taylor expanded in a around 0 39.8%
*-commutative39.8%
Simplified39.8%
Final simplification39.8%
(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 76.8%
Taylor expanded in b around 0 39.0%
Final simplification39.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 2023227
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:herbie-target
(/ 1.0 (+ 1.0 (exp (- b a))))
(/ (exp a) (+ (exp a) (exp b))))