
(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 (- (log1p (exp (- b a))))))
double code(double a, double b) {
return exp(-log1p(exp((b - a))));
}
public static double code(double a, double b) {
return Math.exp(-Math.log1p(Math.exp((b - a))));
}
def code(a, b): return math.exp(-math.log1p(math.exp((b - a))))
function code(a, b) return exp(Float64(-log1p(exp(Float64(b - a))))) end
code[a_, b_] := N[Exp[(-N[Log[1 + N[Exp[N[(b - a), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])], $MachinePrecision]
\begin{array}{l}
\\
e^{-\mathsf{log1p}\left(e^{b - a}\right)}
\end{array}
Initial program 99.2%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub71.8%
*-lft-identity71.8%
associate-*l/71.8%
lft-mult-inverse99.6%
sub-neg99.6%
distribute-frac-neg99.6%
remove-double-neg99.6%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
(FPCore (a b) :precision binary64 (if (<= a -720000000.0) (/ (exp a) b) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (a <= -720000000.0) {
tmp = exp(a) / b;
} else {
tmp = 1.0 / (1.0 + exp(b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-720000000.0d0)) then
tmp = exp(a) / b
else
tmp = 1.0d0 / (1.0d0 + exp(b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -720000000.0) {
tmp = Math.exp(a) / b;
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -720000000.0: tmp = math.exp(a) / b else: tmp = 1.0 / (1.0 + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -720000000.0) tmp = Float64(exp(a) / b); else tmp = Float64(1.0 / Float64(1.0 + exp(b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -720000000.0) tmp = exp(a) / b; else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -720000000.0], N[(N[Exp[a], $MachinePrecision] / b), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -720000000:\\
\;\;\;\;\frac{e^{a}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -7.2e8Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub0.0%
*-lft-identity0.0%
associate-*l/0.0%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 67.1%
distribute-rgt1-in100.0%
rec-exp100.0%
associate-*r/100.0%
*-rgt-identity100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
if -7.2e8 < a Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub98.9%
*-lft-identity98.9%
associate-*l/98.9%
lft-mult-inverse99.4%
sub-neg99.4%
distribute-frac-neg99.4%
remove-double-neg99.4%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 98.2%
(FPCore (a b)
:precision binary64
(if (<= a -720000000.0)
(/ (exp a) b)
(/
1.0
(-
2.0
(-
(*
a
(+
(+ b 1.0)
(*
a
(+
(- (* b 0.5) b)
(-
(*
a
(+
0.16666666666666666
(/
(* (* b -0.8333333333333334) (* b -0.16666666666666666))
(* b -0.16666666666666666))))
0.5)))))
b)))))
double code(double a, double b) {
double tmp;
if (a <= -720000000.0) {
tmp = exp(a) / b;
} else {
tmp = 1.0 / (2.0 - ((a * ((b + 1.0) + (a * (((b * 0.5) - b) + ((a * (0.16666666666666666 + (((b * -0.8333333333333334) * (b * -0.16666666666666666)) / (b * -0.16666666666666666)))) - 0.5))))) - b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-720000000.0d0)) then
tmp = exp(a) / b
else
tmp = 1.0d0 / (2.0d0 - ((a * ((b + 1.0d0) + (a * (((b * 0.5d0) - b) + ((a * (0.16666666666666666d0 + (((b * (-0.8333333333333334d0)) * (b * (-0.16666666666666666d0))) / (b * (-0.16666666666666666d0))))) - 0.5d0))))) - b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -720000000.0) {
tmp = Math.exp(a) / b;
} else {
tmp = 1.0 / (2.0 - ((a * ((b + 1.0) + (a * (((b * 0.5) - b) + ((a * (0.16666666666666666 + (((b * -0.8333333333333334) * (b * -0.16666666666666666)) / (b * -0.16666666666666666)))) - 0.5))))) - b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -720000000.0: tmp = math.exp(a) / b else: tmp = 1.0 / (2.0 - ((a * ((b + 1.0) + (a * (((b * 0.5) - b) + ((a * (0.16666666666666666 + (((b * -0.8333333333333334) * (b * -0.16666666666666666)) / (b * -0.16666666666666666)))) - 0.5))))) - b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -720000000.0) tmp = Float64(exp(a) / b); else tmp = Float64(1.0 / Float64(2.0 - Float64(Float64(a * Float64(Float64(b + 1.0) + Float64(a * Float64(Float64(Float64(b * 0.5) - b) + Float64(Float64(a * Float64(0.16666666666666666 + Float64(Float64(Float64(b * -0.8333333333333334) * Float64(b * -0.16666666666666666)) / Float64(b * -0.16666666666666666)))) - 0.5))))) - b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -720000000.0) tmp = exp(a) / b; else tmp = 1.0 / (2.0 - ((a * ((b + 1.0) + (a * (((b * 0.5) - b) + ((a * (0.16666666666666666 + (((b * -0.8333333333333334) * (b * -0.16666666666666666)) / (b * -0.16666666666666666)))) - 0.5))))) - b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -720000000.0], N[(N[Exp[a], $MachinePrecision] / b), $MachinePrecision], N[(1.0 / N[(2.0 - N[(N[(a * N[(N[(b + 1.0), $MachinePrecision] + N[(a * N[(N[(N[(b * 0.5), $MachinePrecision] - b), $MachinePrecision] + N[(N[(a * N[(0.16666666666666666 + N[(N[(N[(b * -0.8333333333333334), $MachinePrecision] * N[(b * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] / N[(b * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -720000000:\\
\;\;\;\;\frac{e^{a}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \left(a \cdot \left(\left(b + 1\right) + a \cdot \left(\left(b \cdot 0.5 - b\right) + \left(a \cdot \left(0.16666666666666666 + \frac{\left(b \cdot -0.8333333333333334\right) \cdot \left(b \cdot -0.16666666666666666\right)}{b \cdot -0.16666666666666666}\right) - 0.5\right)\right)\right) - b\right)}\\
\end{array}
\end{array}
if a < -7.2e8Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub0.0%
*-lft-identity0.0%
associate-*l/0.0%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 67.1%
distribute-rgt1-in100.0%
rec-exp100.0%
associate-*r/100.0%
*-rgt-identity100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
if -7.2e8 < a Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub98.9%
*-lft-identity98.9%
associate-*l/98.9%
lft-mult-inverse99.4%
sub-neg99.4%
distribute-frac-neg99.4%
remove-double-neg99.4%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 51.9%
distribute-rgt1-in51.9%
rec-exp51.9%
associate-*r/51.9%
*-rgt-identity51.9%
+-commutative51.9%
Simplified51.9%
Taylor expanded in a around 0 50.8%
flip-+49.7%
mul-1-neg49.7%
distribute-rgt-out49.7%
metadata-eval49.7%
*-commutative49.7%
mul-1-neg49.7%
distribute-rgt-out49.7%
metadata-eval49.7%
*-commutative49.7%
sqr-neg49.7%
Applied egg-rr49.7%
div-sub49.7%
unpow249.7%
unpow249.7%
difference-of-squares62.4%
+-commutative62.4%
distribute-lft-out62.4%
metadata-eval62.4%
distribute-lft-out--62.4%
metadata-eval62.4%
*-commutative62.4%
distribute-lft-out--62.4%
metadata-eval62.4%
*-commutative62.4%
Simplified62.4%
Final simplification72.7%
(FPCore (a b) :precision binary64 (/ 1.0 (+ (exp (- b a)) 1.0)))
double code(double a, double b) {
return 1.0 / (exp((b - a)) + 1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (exp((b - a)) + 1.0d0)
end function
public static double code(double a, double b) {
return 1.0 / (Math.exp((b - a)) + 1.0);
}
def code(a, b): return 1.0 / (math.exp((b - a)) + 1.0)
function code(a, b) return Float64(1.0 / Float64(exp(Float64(b - a)) + 1.0)) end
function tmp = code(a, b) tmp = 1.0 / (exp((b - a)) + 1.0); end
code[a_, b_] := N[(1.0 / N[(N[Exp[N[(b - a), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{e^{b - a} + 1}
\end{array}
Initial program 99.2%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub71.8%
*-lft-identity71.8%
associate-*l/71.8%
lft-mult-inverse99.6%
sub-neg99.6%
distribute-frac-neg99.6%
remove-double-neg99.6%
div-exp100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a b)
:precision binary64
(if (<= b -1.65)
0.5
(/
1.0
(-
2.0
(-
(*
a
(+
(+ b 1.0)
(*
a
(+
(- (* b 0.5) b)
(-
(*
a
(+
0.16666666666666666
(/
(* (* b -0.8333333333333334) (* b -0.16666666666666666))
(* b -0.16666666666666666))))
0.5)))))
b)))))
double code(double a, double b) {
double tmp;
if (b <= -1.65) {
tmp = 0.5;
} else {
tmp = 1.0 / (2.0 - ((a * ((b + 1.0) + (a * (((b * 0.5) - b) + ((a * (0.16666666666666666 + (((b * -0.8333333333333334) * (b * -0.16666666666666666)) / (b * -0.16666666666666666)))) - 0.5))))) - 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.65d0)) then
tmp = 0.5d0
else
tmp = 1.0d0 / (2.0d0 - ((a * ((b + 1.0d0) + (a * (((b * 0.5d0) - b) + ((a * (0.16666666666666666d0 + (((b * (-0.8333333333333334d0)) * (b * (-0.16666666666666666d0))) / (b * (-0.16666666666666666d0))))) - 0.5d0))))) - b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -1.65) {
tmp = 0.5;
} else {
tmp = 1.0 / (2.0 - ((a * ((b + 1.0) + (a * (((b * 0.5) - b) + ((a * (0.16666666666666666 + (((b * -0.8333333333333334) * (b * -0.16666666666666666)) / (b * -0.16666666666666666)))) - 0.5))))) - b));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -1.65: tmp = 0.5 else: tmp = 1.0 / (2.0 - ((a * ((b + 1.0) + (a * (((b * 0.5) - b) + ((a * (0.16666666666666666 + (((b * -0.8333333333333334) * (b * -0.16666666666666666)) / (b * -0.16666666666666666)))) - 0.5))))) - b)) return tmp
function code(a, b) tmp = 0.0 if (b <= -1.65) tmp = 0.5; else tmp = Float64(1.0 / Float64(2.0 - Float64(Float64(a * Float64(Float64(b + 1.0) + Float64(a * Float64(Float64(Float64(b * 0.5) - b) + Float64(Float64(a * Float64(0.16666666666666666 + Float64(Float64(Float64(b * -0.8333333333333334) * Float64(b * -0.16666666666666666)) / Float64(b * -0.16666666666666666)))) - 0.5))))) - b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -1.65) tmp = 0.5; else tmp = 1.0 / (2.0 - ((a * ((b + 1.0) + (a * (((b * 0.5) - b) + ((a * (0.16666666666666666 + (((b * -0.8333333333333334) * (b * -0.16666666666666666)) / (b * -0.16666666666666666)))) - 0.5))))) - b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -1.65], 0.5, N[(1.0 / N[(2.0 - N[(N[(a * N[(N[(b + 1.0), $MachinePrecision] + N[(a * N[(N[(N[(b * 0.5), $MachinePrecision] - b), $MachinePrecision] + N[(N[(a * N[(0.16666666666666666 + N[(N[(N[(b * -0.8333333333333334), $MachinePrecision] * N[(b * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] / N[(b * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.65:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \left(a \cdot \left(\left(b + 1\right) + a \cdot \left(\left(b \cdot 0.5 - b\right) + \left(a \cdot \left(0.16666666666666666 + \frac{\left(b \cdot -0.8333333333333334\right) \cdot \left(b \cdot -0.16666666666666666\right)}{b \cdot -0.16666666666666666}\right) - 0.5\right)\right)\right) - b\right)}\\
\end{array}
\end{array}
if b < -1.6499999999999999Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.8%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.8%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 99.0%
Taylor expanded in b around 0 18.8%
if -1.6499999999999999 < b Initial program 99.5%
*-lft-identity99.5%
associate-*l/99.5%
associate-/r/99.5%
remove-double-neg99.5%
unsub-neg99.5%
div-sub66.2%
*-lft-identity66.2%
associate-*l/66.2%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 67.8%
distribute-rgt1-in78.7%
rec-exp78.7%
associate-*r/78.7%
*-rgt-identity78.7%
+-commutative78.7%
Simplified78.7%
Taylor expanded in a around 0 68.4%
flip-+61.5%
mul-1-neg61.5%
distribute-rgt-out61.5%
metadata-eval61.5%
*-commutative61.5%
mul-1-neg61.5%
distribute-rgt-out61.5%
metadata-eval61.5%
*-commutative61.5%
sqr-neg61.5%
Applied egg-rr61.5%
div-sub61.5%
unpow261.5%
unpow261.5%
difference-of-squares78.6%
+-commutative78.6%
distribute-lft-out78.6%
metadata-eval78.6%
distribute-lft-out--78.6%
metadata-eval78.6%
*-commutative78.6%
distribute-lft-out--78.6%
metadata-eval78.6%
*-commutative78.6%
Simplified78.6%
Final simplification67.9%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* a (+ -1.0 (* a (+ 0.5 (* a -0.16666666666666666)))))))
(if (<= b -1.12e-296)
(/ 1.0 (+ 2.0 t_0))
(/ 1.0 (+ 2.0 (+ b (* b (+ t_0 (/ (* a (+ -1.0 (* a 0.5))) b)))))))))
double code(double a, double b) {
double t_0 = a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))));
double tmp;
if (b <= -1.12e-296) {
tmp = 1.0 / (2.0 + t_0);
} else {
tmp = 1.0 / (2.0 + (b + (b * (t_0 + ((a * (-1.0 + (a * 0.5))) / 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 * ((-1.0d0) + (a * (0.5d0 + (a * (-0.16666666666666666d0)))))
if (b <= (-1.12d-296)) then
tmp = 1.0d0 / (2.0d0 + t_0)
else
tmp = 1.0d0 / (2.0d0 + (b + (b * (t_0 + ((a * ((-1.0d0) + (a * 0.5d0))) / b)))))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))));
double tmp;
if (b <= -1.12e-296) {
tmp = 1.0 / (2.0 + t_0);
} else {
tmp = 1.0 / (2.0 + (b + (b * (t_0 + ((a * (-1.0 + (a * 0.5))) / b)))));
}
return tmp;
}
def code(a, b): t_0 = a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))) tmp = 0 if b <= -1.12e-296: tmp = 1.0 / (2.0 + t_0) else: tmp = 1.0 / (2.0 + (b + (b * (t_0 + ((a * (-1.0 + (a * 0.5))) / b))))) return tmp
function code(a, b) t_0 = Float64(a * Float64(-1.0 + Float64(a * Float64(0.5 + Float64(a * -0.16666666666666666))))) tmp = 0.0 if (b <= -1.12e-296) tmp = Float64(1.0 / Float64(2.0 + t_0)); else tmp = Float64(1.0 / Float64(2.0 + Float64(b + Float64(b * Float64(t_0 + Float64(Float64(a * Float64(-1.0 + Float64(a * 0.5))) / b)))))); end return tmp end
function tmp_2 = code(a, b) t_0 = a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))); tmp = 0.0; if (b <= -1.12e-296) tmp = 1.0 / (2.0 + t_0); else tmp = 1.0 / (2.0 + (b + (b * (t_0 + ((a * (-1.0 + (a * 0.5))) / b))))); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(a * N[(-1.0 + N[(a * N[(0.5 + N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.12e-296], N[(1.0 / N[(2.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b + N[(b * N[(t$95$0 + N[(N[(a * N[(-1.0 + N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(-1 + a \cdot \left(0.5 + a \cdot -0.16666666666666666\right)\right)\\
\mathbf{if}\;b \leq -1.12 \cdot 10^{-296}:\\
\;\;\;\;\frac{1}{2 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + \left(b + b \cdot \left(t\_0 + \frac{a \cdot \left(-1 + a \cdot 0.5\right)}{b}\right)\right)}\\
\end{array}
\end{array}
if b < -1.11999999999999994e-296Initial program 98.3%
*-lft-identity98.3%
associate-*l/98.3%
associate-/r/98.2%
remove-double-neg98.2%
unsub-neg98.2%
div-sub79.6%
*-lft-identity79.6%
associate-*l/79.6%
lft-mult-inverse99.1%
sub-neg99.1%
distribute-frac-neg99.1%
remove-double-neg99.1%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 67.9%
Taylor expanded in a around 0 63.1%
if -1.11999999999999994e-296 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub65.2%
*-lft-identity65.2%
associate-*l/65.2%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 66.9%
distribute-rgt1-in67.6%
rec-exp67.6%
associate-*r/67.6%
*-rgt-identity67.6%
+-commutative67.6%
Simplified67.6%
Taylor expanded in a around 0 56.1%
Taylor expanded in b around inf 53.3%
Taylor expanded in b around inf 58.8%
Final simplification60.7%
(FPCore (a b) :precision binary64 (if (<= b -1.0) 0.5 (/ 1.0 (- (+ b 2.0) (* b (+ a (/ a b)))))))
double code(double a, double b) {
double tmp;
if (b <= -1.0) {
tmp = 0.5;
} else {
tmp = 1.0 / ((b + 2.0) - (b * (a + (a / 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.0d0)) then
tmp = 0.5d0
else
tmp = 1.0d0 / ((b + 2.0d0) - (b * (a + (a / b))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -1.0) {
tmp = 0.5;
} else {
tmp = 1.0 / ((b + 2.0) - (b * (a + (a / b))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -1.0: tmp = 0.5 else: tmp = 1.0 / ((b + 2.0) - (b * (a + (a / b)))) return tmp
function code(a, b) tmp = 0.0 if (b <= -1.0) tmp = 0.5; else tmp = Float64(1.0 / Float64(Float64(b + 2.0) - Float64(b * Float64(a + Float64(a / b))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -1.0) tmp = 0.5; else tmp = 1.0 / ((b + 2.0) - (b * (a + (a / b)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -1.0], 0.5, N[(1.0 / N[(N[(b + 2.0), $MachinePrecision] - N[(b * N[(a + N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(b + 2\right) - b \cdot \left(a + \frac{a}{b}\right)}\\
\end{array}
\end{array}
if b < -1Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.8%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.8%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 99.0%
Taylor expanded in b around 0 18.8%
if -1 < b Initial program 99.5%
*-lft-identity99.5%
associate-*l/99.5%
associate-/r/99.5%
remove-double-neg99.5%
unsub-neg99.5%
div-sub66.2%
*-lft-identity66.2%
associate-*l/66.2%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 67.8%
distribute-rgt1-in78.7%
rec-exp78.7%
associate-*r/78.7%
*-rgt-identity78.7%
+-commutative78.7%
Simplified78.7%
Taylor expanded in a around 0 51.2%
associate-+r+51.2%
+-commutative51.2%
mul-1-neg51.2%
distribute-rgt-neg-in51.2%
neg-sub051.2%
associate--r+51.2%
metadata-eval51.2%
Simplified51.2%
Taylor expanded in b around inf 62.4%
mul-1-neg62.4%
unsub-neg62.4%
mul-1-neg62.4%
Simplified62.4%
Final simplification54.6%
(FPCore (a b) :precision binary64 (/ 1.0 (+ 2.0 (* a (+ -1.0 (* a (+ 0.5 (* a -0.16666666666666666))))))))
double code(double a, double b) {
return 1.0 / (2.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (2.0d0 + (a * ((-1.0d0) + (a * (0.5d0 + (a * (-0.16666666666666666d0)))))))
end function
public static double code(double a, double b) {
return 1.0 / (2.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))));
}
def code(a, b): return 1.0 / (2.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))))
function code(a, b) return Float64(1.0 / Float64(2.0 + Float64(a * Float64(-1.0 + Float64(a * Float64(0.5 + Float64(a * -0.16666666666666666))))))) end
function tmp = code(a, b) tmp = 1.0 / (2.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))); end
code[a_, b_] := N[(1.0 / N[(2.0 + N[(a * N[(-1.0 + N[(a * N[(0.5 + N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{2 + a \cdot \left(-1 + a \cdot \left(0.5 + a \cdot -0.16666666666666666\right)\right)}
\end{array}
Initial program 99.2%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub71.8%
*-lft-identity71.8%
associate-*l/71.8%
lft-mult-inverse99.6%
sub-neg99.6%
distribute-frac-neg99.6%
remove-double-neg99.6%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 67.0%
Taylor expanded in a around 0 57.8%
Final simplification57.8%
(FPCore (a b) :precision binary64 (if (<= a -1.1e-6) (/ -1.0 (* b (+ a (/ a b)))) (+ 0.5 (* a 0.25))))
double code(double a, double b) {
double tmp;
if (a <= -1.1e-6) {
tmp = -1.0 / (b * (a + (a / b)));
} else {
tmp = 0.5 + (a * 0.25);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-1.1d-6)) then
tmp = (-1.0d0) / (b * (a + (a / b)))
else
tmp = 0.5d0 + (a * 0.25d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.1e-6) {
tmp = -1.0 / (b * (a + (a / b)));
} else {
tmp = 0.5 + (a * 0.25);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.1e-6: tmp = -1.0 / (b * (a + (a / b))) else: tmp = 0.5 + (a * 0.25) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.1e-6) tmp = Float64(-1.0 / Float64(b * Float64(a + Float64(a / b)))); else tmp = Float64(0.5 + Float64(a * 0.25)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.1e-6) tmp = -1.0 / (b * (a + (a / b))); else tmp = 0.5 + (a * 0.25); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.1e-6], N[(-1.0 / N[(b * N[(a + N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.1 \cdot 10^{-6}:\\
\;\;\;\;\frac{-1}{b \cdot \left(a + \frac{a}{b}\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\end{array}
\end{array}
if a < -1.1000000000000001e-6Initial program 98.7%
*-lft-identity98.7%
associate-*l/98.7%
associate-/r/98.7%
remove-double-neg98.7%
unsub-neg98.7%
div-sub5.3%
*-lft-identity5.3%
associate-*l/5.3%
lft-mult-inverse98.7%
sub-neg98.7%
distribute-frac-neg98.7%
remove-double-neg98.7%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 63.1%
distribute-rgt1-in93.8%
rec-exp93.8%
associate-*r/93.8%
*-rgt-identity93.8%
+-commutative93.8%
Simplified93.8%
Taylor expanded in a around 0 19.4%
associate-+r+19.4%
+-commutative19.4%
mul-1-neg19.4%
distribute-rgt-neg-in19.4%
neg-sub019.4%
associate--r+19.4%
metadata-eval19.4%
Simplified19.4%
Taylor expanded in a around inf 19.4%
Taylor expanded in b around inf 50.7%
if -1.1000000000000001e-6 < a Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub99.4%
*-lft-identity99.4%
associate-*l/99.4%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 56.0%
Taylor expanded in a around 0 55.1%
*-commutative55.1%
Simplified55.1%
(FPCore (a b) :precision binary64 (if (<= b 2.0) (/ 1.0 (- 2.0 a)) (/ -1.0 (* b (+ a -1.0)))))
double code(double a, double b) {
double tmp;
if (b <= 2.0) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = -1.0 / (b * (a + -1.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 2.0d0) then
tmp = 1.0d0 / (2.0d0 - a)
else
tmp = (-1.0d0) / (b * (a + (-1.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 2.0) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = -1.0 / (b * (a + -1.0));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.0: tmp = 1.0 / (2.0 - a) else: tmp = -1.0 / (b * (a + -1.0)) return tmp
function code(a, b) tmp = 0.0 if (b <= 2.0) tmp = Float64(1.0 / Float64(2.0 - a)); else tmp = Float64(-1.0 / Float64(b * Float64(a + -1.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.0) tmp = 1.0 / (2.0 - a); else tmp = -1.0 / (b * (a + -1.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2.0], N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(b * N[(a + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{b \cdot \left(a + -1\right)}\\
\end{array}
\end{array}
if b < 2Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub74.6%
*-lft-identity74.6%
associate-*l/74.6%
lft-mult-inverse99.4%
sub-neg99.4%
distribute-frac-neg99.4%
remove-double-neg99.4%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 78.4%
Taylor expanded in a around 0 54.3%
neg-mul-154.3%
unsub-neg54.3%
Simplified54.3%
if 2 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub64.8%
*-lft-identity64.8%
associate-*l/64.8%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 38.7%
distribute-rgt1-in38.7%
rec-exp38.7%
associate-*r/38.7%
*-rgt-identity38.7%
+-commutative38.7%
Simplified38.7%
Taylor expanded in a around 0 20.2%
associate-+r+20.2%
+-commutative20.2%
mul-1-neg20.2%
distribute-rgt-neg-in20.2%
neg-sub020.2%
associate--r+20.2%
metadata-eval20.2%
Simplified20.2%
Taylor expanded in b around inf 20.2%
mul-1-neg20.2%
unsub-neg20.2%
Simplified20.2%
Final simplification44.9%
(FPCore (a b) :precision binary64 (if (<= a -1.1e-6) (/ -1.0 (* a (+ b 1.0))) (+ 0.5 (* a 0.25))))
double code(double a, double b) {
double tmp;
if (a <= -1.1e-6) {
tmp = -1.0 / (a * (b + 1.0));
} else {
tmp = 0.5 + (a * 0.25);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-1.1d-6)) then
tmp = (-1.0d0) / (a * (b + 1.0d0))
else
tmp = 0.5d0 + (a * 0.25d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.1e-6) {
tmp = -1.0 / (a * (b + 1.0));
} else {
tmp = 0.5 + (a * 0.25);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.1e-6: tmp = -1.0 / (a * (b + 1.0)) else: tmp = 0.5 + (a * 0.25) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.1e-6) tmp = Float64(-1.0 / Float64(a * Float64(b + 1.0))); else tmp = Float64(0.5 + Float64(a * 0.25)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.1e-6) tmp = -1.0 / (a * (b + 1.0)); else tmp = 0.5 + (a * 0.25); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.1e-6], N[(-1.0 / N[(a * N[(b + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.1 \cdot 10^{-6}:\\
\;\;\;\;\frac{-1}{a \cdot \left(b + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\end{array}
\end{array}
if a < -1.1000000000000001e-6Initial program 98.7%
*-lft-identity98.7%
associate-*l/98.7%
associate-/r/98.7%
remove-double-neg98.7%
unsub-neg98.7%
div-sub5.3%
*-lft-identity5.3%
associate-*l/5.3%
lft-mult-inverse98.7%
sub-neg98.7%
distribute-frac-neg98.7%
remove-double-neg98.7%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 63.1%
distribute-rgt1-in93.8%
rec-exp93.8%
associate-*r/93.8%
*-rgt-identity93.8%
+-commutative93.8%
Simplified93.8%
Taylor expanded in a around 0 19.4%
associate-+r+19.4%
+-commutative19.4%
mul-1-neg19.4%
distribute-rgt-neg-in19.4%
neg-sub019.4%
associate--r+19.4%
metadata-eval19.4%
Simplified19.4%
Taylor expanded in a around inf 19.4%
if -1.1000000000000001e-6 < a Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub99.4%
*-lft-identity99.4%
associate-*l/99.4%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 56.0%
Taylor expanded in a around 0 55.1%
*-commutative55.1%
Simplified55.1%
Final simplification44.6%
(FPCore (a b) :precision binary64 (if (<= b 6e+87) (/ 1.0 (- 2.0 a)) (/ -1.0 (* b a))))
double code(double a, double b) {
double tmp;
if (b <= 6e+87) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = -1.0 / (b * a);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 6d+87) then
tmp = 1.0d0 / (2.0d0 - a)
else
tmp = (-1.0d0) / (b * a)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 6e+87) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = -1.0 / (b * a);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 6e+87: tmp = 1.0 / (2.0 - a) else: tmp = -1.0 / (b * a) return tmp
function code(a, b) tmp = 0.0 if (b <= 6e+87) tmp = Float64(1.0 / Float64(2.0 - a)); else tmp = Float64(-1.0 / Float64(b * a)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 6e+87) tmp = 1.0 / (2.0 - a); else tmp = -1.0 / (b * a); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 6e+87], N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(b * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6 \cdot 10^{+87}:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{b \cdot a}\\
\end{array}
\end{array}
if b < 5.9999999999999998e87Initial program 99.0%
*-lft-identity99.0%
associate-*l/99.0%
associate-/r/99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub74.7%
*-lft-identity74.7%
associate-*l/74.7%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 73.1%
Taylor expanded in a around 0 49.1%
neg-mul-149.1%
unsub-neg49.1%
Simplified49.1%
if 5.9999999999999998e87 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub60.0%
*-lft-identity60.0%
associate-*l/60.0%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 43.7%
distribute-rgt1-in43.7%
rec-exp43.7%
associate-*r/43.7%
*-rgt-identity43.7%
+-commutative43.7%
Simplified43.7%
Taylor expanded in a around 0 27.1%
associate-+r+27.1%
+-commutative27.1%
mul-1-neg27.1%
distribute-rgt-neg-in27.1%
neg-sub027.1%
associate--r+27.1%
metadata-eval27.1%
Simplified27.1%
Taylor expanded in a around inf 25.8%
Taylor expanded in b around inf 25.8%
*-commutative25.8%
Simplified25.8%
(FPCore (a b) :precision binary64 (if (<= a -1.1e-6) (/ -1.0 (* b a)) (+ 0.5 (* a 0.25))))
double code(double a, double b) {
double tmp;
if (a <= -1.1e-6) {
tmp = -1.0 / (b * a);
} else {
tmp = 0.5 + (a * 0.25);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-1.1d-6)) then
tmp = (-1.0d0) / (b * a)
else
tmp = 0.5d0 + (a * 0.25d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.1e-6) {
tmp = -1.0 / (b * a);
} else {
tmp = 0.5 + (a * 0.25);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.1e-6: tmp = -1.0 / (b * a) else: tmp = 0.5 + (a * 0.25) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.1e-6) tmp = Float64(-1.0 / Float64(b * a)); else tmp = Float64(0.5 + Float64(a * 0.25)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.1e-6) tmp = -1.0 / (b * a); else tmp = 0.5 + (a * 0.25); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.1e-6], N[(-1.0 / N[(b * a), $MachinePrecision]), $MachinePrecision], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.1 \cdot 10^{-6}:\\
\;\;\;\;\frac{-1}{b \cdot a}\\
\mathbf{else}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\end{array}
\end{array}
if a < -1.1000000000000001e-6Initial program 98.7%
*-lft-identity98.7%
associate-*l/98.7%
associate-/r/98.7%
remove-double-neg98.7%
unsub-neg98.7%
div-sub5.3%
*-lft-identity5.3%
associate-*l/5.3%
lft-mult-inverse98.7%
sub-neg98.7%
distribute-frac-neg98.7%
remove-double-neg98.7%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 63.1%
distribute-rgt1-in93.8%
rec-exp93.8%
associate-*r/93.8%
*-rgt-identity93.8%
+-commutative93.8%
Simplified93.8%
Taylor expanded in a around 0 19.4%
associate-+r+19.4%
+-commutative19.4%
mul-1-neg19.4%
distribute-rgt-neg-in19.4%
neg-sub019.4%
associate--r+19.4%
metadata-eval19.4%
Simplified19.4%
Taylor expanded in a around inf 19.4%
Taylor expanded in b around inf 18.2%
*-commutative18.2%
Simplified18.2%
if -1.1000000000000001e-6 < a Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub99.4%
*-lft-identity99.4%
associate-*l/99.4%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 56.0%
Taylor expanded in a around 0 55.1%
*-commutative55.1%
Simplified55.1%
(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%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub71.8%
*-lft-identity71.8%
associate-*l/71.8%
lft-mult-inverse99.6%
sub-neg99.6%
distribute-frac-neg99.6%
remove-double-neg99.6%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 67.0%
Taylor expanded in a around 0 39.6%
*-commutative39.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 99.2%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub71.8%
*-lft-identity71.8%
associate-*l/71.8%
lft-mult-inverse99.6%
sub-neg99.6%
distribute-frac-neg99.6%
remove-double-neg99.6%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 81.7%
Taylor expanded in b around 0 39.5%
(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 2024088
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:alt
(/ 1.0 (+ 1.0 (exp (- b a))))
(/ (exp a) (+ (exp a) (exp b))))