
(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 17 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.1%
associate-/r/99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub69.8%
*-lft-identity69.8%
associate-*l/69.8%
lft-mult-inverse99.1%
sub-neg99.1%
distribute-frac-neg99.1%
remove-double-neg99.1%
div-exp99.9%
Simplified99.9%
add-exp-log99.9%
log-rec99.9%
log1p-define100.0%
Applied egg-rr100.0%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* a (+ -1.0 (* a (+ 0.5 (* a -0.16666666666666666)))))))
(if (<= a -1e+103)
(/ 1.0 (+ 2.0 t_0))
(if (<= a -6.8e+34)
(/ 1.0 (+ 2.0 (+ b (* b (+ t_0 (/ t_0 b))))))
(/ 1.0 (+ 1.0 (exp b)))))))
double code(double a, double b) {
double t_0 = a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))));
double tmp;
if (a <= -1e+103) {
tmp = 1.0 / (2.0 + t_0);
} else if (a <= -6.8e+34) {
tmp = 1.0 / (2.0 + (b + (b * (t_0 + (t_0 / 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) :: t_0
real(8) :: tmp
t_0 = a * ((-1.0d0) + (a * (0.5d0 + (a * (-0.16666666666666666d0)))))
if (a <= (-1d+103)) then
tmp = 1.0d0 / (2.0d0 + t_0)
else if (a <= (-6.8d+34)) then
tmp = 1.0d0 / (2.0d0 + (b + (b * (t_0 + (t_0 / b)))))
else
tmp = 1.0d0 / (1.0d0 + exp(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 (a <= -1e+103) {
tmp = 1.0 / (2.0 + t_0);
} else if (a <= -6.8e+34) {
tmp = 1.0 / (2.0 + (b + (b * (t_0 + (t_0 / b)))));
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): t_0 = a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))) tmp = 0 if a <= -1e+103: tmp = 1.0 / (2.0 + t_0) elif a <= -6.8e+34: tmp = 1.0 / (2.0 + (b + (b * (t_0 + (t_0 / b))))) else: tmp = 1.0 / (1.0 + math.exp(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 (a <= -1e+103) tmp = Float64(1.0 / Float64(2.0 + t_0)); elseif (a <= -6.8e+34) tmp = Float64(1.0 / Float64(2.0 + Float64(b + Float64(b * Float64(t_0 + Float64(t_0 / b)))))); else tmp = Float64(1.0 / Float64(1.0 + exp(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 (a <= -1e+103) tmp = 1.0 / (2.0 + t_0); elseif (a <= -6.8e+34) tmp = 1.0 / (2.0 + (b + (b * (t_0 + (t_0 / b))))); else tmp = 1.0 / (1.0 + exp(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[a, -1e+103], N[(1.0 / N[(2.0 + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -6.8e+34], N[(1.0 / N[(2.0 + N[(b + N[(b * N[(t$95$0 + N[(t$95$0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $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}\;a \leq -1 \cdot 10^{+103}:\\
\;\;\;\;\frac{1}{2 + t\_0}\\
\mathbf{elif}\;a \leq -6.8 \cdot 10^{+34}:\\
\;\;\;\;\frac{1}{2 + \left(b + b \cdot \left(t\_0 + \frac{t\_0}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -1e103Initial 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 100.0%
Taylor expanded in a around 0 100.0%
if -1e103 < a < -6.7999999999999999e34Initial 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 50.0%
distribute-rgt1-in100.0%
Simplified100.0%
Taylor expanded in a around 0 7.4%
Taylor expanded in b around inf 66.3%
if -6.7999999999999999e34 < a Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.8%
remove-double-neg98.8%
unsub-neg98.8%
div-sub93.1%
*-lft-identity93.1%
associate-*l/93.1%
lft-mult-inverse98.8%
sub-neg98.8%
distribute-frac-neg98.8%
remove-double-neg98.8%
div-exp99.9%
Simplified99.9%
Taylor expanded in a around 0 95.7%
Final simplification95.0%
(FPCore (a b) :precision binary64 (if (<= a -4.6e-14) (/ 1.0 (+ 1.0 (exp (- a)))) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (a <= -4.6e-14) {
tmp = 1.0 / (1.0 + exp(-a));
} 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 <= (-4.6d-14)) then
tmp = 1.0d0 / (1.0d0 + exp(-a))
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 <= -4.6e-14) {
tmp = 1.0 / (1.0 + Math.exp(-a));
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -4.6e-14: tmp = 1.0 / (1.0 + math.exp(-a)) else: tmp = 1.0 / (1.0 + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -4.6e-14) tmp = Float64(1.0 / Float64(1.0 + exp(Float64(-a)))); 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 <= -4.6e-14) tmp = 1.0 / (1.0 + exp(-a)); else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -4.6e-14], N[(1.0 / N[(1.0 + N[Exp[(-a)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.6 \cdot 10^{-14}:\\
\;\;\;\;\frac{1}{1 + e^{-a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -4.59999999999999996e-14Initial program 98.7%
*-lft-identity98.7%
associate-*l/98.7%
associate-/r/98.7%
remove-double-neg98.7%
unsub-neg98.7%
div-sub6.1%
*-lft-identity6.1%
associate-*l/6.1%
lft-mult-inverse98.7%
sub-neg98.7%
distribute-frac-neg98.7%
remove-double-neg98.7%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 98.7%
if -4.59999999999999996e-14 < a Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.3%
associate-/r/99.3%
remove-double-neg99.3%
unsub-neg99.3%
div-sub99.3%
*-lft-identity99.3%
associate-*l/99.3%
lft-mult-inverse99.3%
sub-neg99.3%
distribute-frac-neg99.3%
remove-double-neg99.3%
div-exp99.9%
Simplified99.9%
Taylor expanded in a around 0 99.7%
(FPCore (a b) :precision binary64 (/ 1.0 (+ -1.0 (+ (exp (- b a)) 2.0))))
double code(double a, double b) {
return 1.0 / (-1.0 + (exp((b - a)) + 2.0));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / ((-1.0d0) + (exp((b - a)) + 2.0d0))
end function
public static double code(double a, double b) {
return 1.0 / (-1.0 + (Math.exp((b - a)) + 2.0));
}
def code(a, b): return 1.0 / (-1.0 + (math.exp((b - a)) + 2.0))
function code(a, b) return Float64(1.0 / Float64(-1.0 + Float64(exp(Float64(b - a)) + 2.0))) end
function tmp = code(a, b) tmp = 1.0 / (-1.0 + (exp((b - a)) + 2.0)); end
code[a_, b_] := N[(1.0 / N[(-1.0 + N[(N[Exp[N[(b - a), $MachinePrecision]], $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{-1 + \left(e^{b - a} + 2\right)}
\end{array}
Initial program 99.2%
*-lft-identity99.2%
associate-*l/99.1%
associate-/r/99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub69.8%
*-lft-identity69.8%
associate-*l/69.8%
lft-mult-inverse99.1%
sub-neg99.1%
distribute-frac-neg99.1%
remove-double-neg99.1%
div-exp99.9%
Simplified99.9%
expm1-log1p-u99.5%
expm1-undefine99.5%
Applied egg-rr99.5%
sub-neg99.5%
metadata-eval99.5%
+-commutative99.5%
log1p-undefine99.2%
rem-exp-log99.9%
associate-+r+99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(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.1%
associate-/r/99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub69.8%
*-lft-identity69.8%
associate-*l/69.8%
lft-mult-inverse99.1%
sub-neg99.1%
distribute-frac-neg99.1%
remove-double-neg99.1%
div-exp99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(if (<= b -1.35)
1.0
(if (<= b 9.8e+97)
(/
1.0
(+
2.0
(+
b
(*
a
(+
(- -1.0 b)
(*
a
(+
(* b (* -0.16666666666666666 (+ a (/ a b))))
(* 0.5 (+ b 1.0)))))))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666))))))))))
double code(double a, double b) {
double tmp;
if (b <= -1.35) {
tmp = 1.0;
} else if (b <= 9.8e+97) {
tmp = 1.0 / (2.0 + (b + (a * ((-1.0 - b) + (a * ((b * (-0.16666666666666666 * (a + (a / b)))) + (0.5 * (b + 1.0))))))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-1.35d0)) then
tmp = 1.0d0
else if (b <= 9.8d+97) then
tmp = 1.0d0 / (2.0d0 + (b + (a * (((-1.0d0) - b) + (a * ((b * ((-0.16666666666666666d0) * (a + (a / b)))) + (0.5d0 * (b + 1.0d0))))))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (b * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -1.35) {
tmp = 1.0;
} else if (b <= 9.8e+97) {
tmp = 1.0 / (2.0 + (b + (a * ((-1.0 - b) + (a * ((b * (-0.16666666666666666 * (a + (a / b)))) + (0.5 * (b + 1.0))))))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -1.35: tmp = 1.0 elif b <= 9.8e+97: tmp = 1.0 / (2.0 + (b + (a * ((-1.0 - b) + (a * ((b * (-0.16666666666666666 * (a + (a / b)))) + (0.5 * (b + 1.0)))))))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))) return tmp
function code(a, b) tmp = 0.0 if (b <= -1.35) tmp = 1.0; elseif (b <= 9.8e+97) tmp = Float64(1.0 / Float64(2.0 + Float64(b + Float64(a * Float64(Float64(-1.0 - b) + Float64(a * Float64(Float64(b * Float64(-0.16666666666666666 * Float64(a + Float64(a / b)))) + Float64(0.5 * Float64(b + 1.0))))))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(b * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -1.35) tmp = 1.0; elseif (b <= 9.8e+97) tmp = 1.0 / (2.0 + (b + (a * ((-1.0 - b) + (a * ((b * (-0.16666666666666666 * (a + (a / b)))) + (0.5 * (b + 1.0)))))))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -1.35], 1.0, If[LessEqual[b, 9.8e+97], N[(1.0 / N[(2.0 + N[(b + N[(a * N[(N[(-1.0 - b), $MachinePrecision] + N[(a * N[(N[(b * N[(-0.16666666666666666 * N[(a + N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(b + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(b * N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.35:\\
\;\;\;\;1\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{+97}:\\
\;\;\;\;\frac{1}{2 + \left(b + a \cdot \left(\left(-1 - b\right) + a \cdot \left(b \cdot \left(-0.16666666666666666 \cdot \left(a + \frac{a}{b}\right)\right) + 0.5 \cdot \left(b + 1\right)\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(0.5 + b \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if b < -1.3500000000000001Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.7%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
Applied egg-rr100.0%
*-inverses100.0%
Simplified100.0%
if -1.3500000000000001 < b < 9.79999999999999928e97Initial program 99.2%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub65.4%
*-lft-identity65.4%
associate-*l/65.4%
lft-mult-inverse99.2%
sub-neg99.2%
distribute-frac-neg99.2%
remove-double-neg99.2%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 75.0%
distribute-rgt1-in91.2%
Simplified91.2%
Taylor expanded in a around 0 78.4%
Taylor expanded in b around inf 80.9%
distribute-lft-out80.9%
Simplified80.9%
if 9.79999999999999928e97 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub59.6%
*-lft-identity59.6%
associate-*l/59.6%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 98.4%
*-commutative98.4%
Simplified98.4%
Final simplification88.1%
(FPCore (a b)
:precision binary64
(if (<= b -6.8)
1.0
(if (<= b 9.8e+97)
(/
1.0
(+
2.0
(+
b
(*
a
(+
(- -1.0 b)
(*
a
(+ (* 0.5 (+ b 1.0)) (* -0.16666666666666666 (* a (+ b 1.0))))))))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666))))))))))
double code(double a, double b) {
double tmp;
if (b <= -6.8) {
tmp = 1.0;
} else if (b <= 9.8e+97) {
tmp = 1.0 / (2.0 + (b + (a * ((-1.0 - b) + (a * ((0.5 * (b + 1.0)) + (-0.16666666666666666 * (a * (b + 1.0)))))))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-6.8d0)) then
tmp = 1.0d0
else if (b <= 9.8d+97) then
tmp = 1.0d0 / (2.0d0 + (b + (a * (((-1.0d0) - b) + (a * ((0.5d0 * (b + 1.0d0)) + ((-0.16666666666666666d0) * (a * (b + 1.0d0)))))))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (b * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -6.8) {
tmp = 1.0;
} else if (b <= 9.8e+97) {
tmp = 1.0 / (2.0 + (b + (a * ((-1.0 - b) + (a * ((0.5 * (b + 1.0)) + (-0.16666666666666666 * (a * (b + 1.0)))))))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -6.8: tmp = 1.0 elif b <= 9.8e+97: tmp = 1.0 / (2.0 + (b + (a * ((-1.0 - b) + (a * ((0.5 * (b + 1.0)) + (-0.16666666666666666 * (a * (b + 1.0))))))))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))) return tmp
function code(a, b) tmp = 0.0 if (b <= -6.8) tmp = 1.0; elseif (b <= 9.8e+97) tmp = Float64(1.0 / Float64(2.0 + Float64(b + Float64(a * Float64(Float64(-1.0 - b) + Float64(a * Float64(Float64(0.5 * Float64(b + 1.0)) + Float64(-0.16666666666666666 * Float64(a * Float64(b + 1.0)))))))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(b * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -6.8) tmp = 1.0; elseif (b <= 9.8e+97) tmp = 1.0 / (2.0 + (b + (a * ((-1.0 - b) + (a * ((0.5 * (b + 1.0)) + (-0.16666666666666666 * (a * (b + 1.0))))))))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -6.8], 1.0, If[LessEqual[b, 9.8e+97], N[(1.0 / N[(2.0 + N[(b + N[(a * N[(N[(-1.0 - b), $MachinePrecision] + N[(a * N[(N[(0.5 * N[(b + 1.0), $MachinePrecision]), $MachinePrecision] + N[(-0.16666666666666666 * N[(a * N[(b + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(b * N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.8:\\
\;\;\;\;1\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{+97}:\\
\;\;\;\;\frac{1}{2 + \left(b + a \cdot \left(\left(-1 - b\right) + a \cdot \left(0.5 \cdot \left(b + 1\right) + -0.16666666666666666 \cdot \left(a \cdot \left(b + 1\right)\right)\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(0.5 + b \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if b < -6.79999999999999982Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.7%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
Applied egg-rr100.0%
*-inverses100.0%
Simplified100.0%
if -6.79999999999999982 < b < 9.79999999999999928e97Initial program 99.2%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub65.4%
*-lft-identity65.4%
associate-*l/65.4%
lft-mult-inverse99.2%
sub-neg99.2%
distribute-frac-neg99.2%
remove-double-neg99.2%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 75.0%
distribute-rgt1-in91.2%
Simplified91.2%
Taylor expanded in a around 0 78.4%
if 9.79999999999999928e97 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub59.6%
*-lft-identity59.6%
associate-*l/59.6%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 98.4%
*-commutative98.4%
Simplified98.4%
Final simplification86.7%
(FPCore (a b)
:precision binary64
(if (<= b -15.5)
1.0
(if (<= b 1.2e-16)
(/ 1.0 (+ 2.0 (* a (+ -1.0 (* a (+ 0.5 (* a -0.16666666666666666)))))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666))))))))))
double code(double a, double b) {
double tmp;
if (b <= -15.5) {
tmp = 1.0;
} else if (b <= 1.2e-16) {
tmp = 1.0 / (2.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-15.5d0)) then
tmp = 1.0d0
else if (b <= 1.2d-16) then
tmp = 1.0d0 / (2.0d0 + (a * ((-1.0d0) + (a * (0.5d0 + (a * (-0.16666666666666666d0)))))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (b * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -15.5) {
tmp = 1.0;
} else if (b <= 1.2e-16) {
tmp = 1.0 / (2.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -15.5: tmp = 1.0 elif b <= 1.2e-16: tmp = 1.0 / (2.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))) return tmp
function code(a, b) tmp = 0.0 if (b <= -15.5) tmp = 1.0; elseif (b <= 1.2e-16) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(-1.0 + Float64(a * Float64(0.5 + Float64(a * -0.16666666666666666))))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(b * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -15.5) tmp = 1.0; elseif (b <= 1.2e-16) tmp = 1.0 / (2.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -15.5], 1.0, If[LessEqual[b, 1.2e-16], 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], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(b * N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -15.5:\\
\;\;\;\;1\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-16}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(-1 + a \cdot \left(0.5 + a \cdot -0.16666666666666666\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(0.5 + b \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if b < -15.5Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.7%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
Applied egg-rr100.0%
*-inverses100.0%
Simplified100.0%
if -15.5 < b < 1.20000000000000002e-16Initial program 100.0%
*-lft-identity100.0%
associate-*l/99.9%
associate-/r/99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub63.1%
*-lft-identity63.1%
associate-*l/63.1%
lft-mult-inverse99.9%
sub-neg99.9%
distribute-frac-neg99.9%
remove-double-neg99.9%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 98.9%
Taylor expanded in a around 0 85.5%
if 1.20000000000000002e-16 < b Initial program 98.6%
*-lft-identity98.6%
associate-*l/98.6%
associate-/r/98.6%
remove-double-neg98.6%
unsub-neg98.6%
div-sub65.2%
*-lft-identity65.2%
associate-*l/65.2%
lft-mult-inverse98.6%
sub-neg98.6%
distribute-frac-neg98.6%
remove-double-neg98.6%
div-exp99.9%
Simplified99.9%
Taylor expanded in a around 0 99.8%
Taylor expanded in b around 0 80.4%
*-commutative80.4%
Simplified80.4%
Final simplification86.5%
(FPCore (a b)
:precision binary64
(if (<= b -4.8)
1.0
(if (<= b 1.15e+150)
(/ 1.0 (+ 2.0 (* a (+ -1.0 (* a (+ 0.5 (* a -0.16666666666666666)))))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b 0.5))))))))
double code(double a, double b) {
double tmp;
if (b <= -4.8) {
tmp = 1.0;
} else if (b <= 1.15e+150) {
tmp = 1.0 / (2.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (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 <= (-4.8d0)) then
tmp = 1.0d0
else if (b <= 1.15d+150) then
tmp = 1.0d0 / (2.0d0 + (a * ((-1.0d0) + (a * (0.5d0 + (a * (-0.16666666666666666d0)))))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * 0.5d0))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -4.8) {
tmp = 1.0;
} else if (b <= 1.15e+150) {
tmp = 1.0 / (2.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -4.8: tmp = 1.0 elif b <= 1.15e+150: tmp = 1.0 / (2.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))) return tmp
function code(a, b) tmp = 0.0 if (b <= -4.8) tmp = 1.0; elseif (b <= 1.15e+150) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(-1.0 + Float64(a * Float64(0.5 + Float64(a * -0.16666666666666666))))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * 0.5))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -4.8) tmp = 1.0; elseif (b <= 1.15e+150) tmp = 1.0 / (2.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -4.8], 1.0, If[LessEqual[b, 1.15e+150], 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], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.8:\\
\;\;\;\;1\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{+150}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(-1 + a \cdot \left(0.5 + a \cdot -0.16666666666666666\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < -4.79999999999999982Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.7%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
Applied egg-rr100.0%
*-inverses100.0%
Simplified100.0%
if -4.79999999999999982 < b < 1.15000000000000001e150Initial program 99.3%
*-lft-identity99.3%
associate-*l/99.3%
associate-/r/99.3%
remove-double-neg99.3%
unsub-neg99.3%
div-sub64.8%
*-lft-identity64.8%
associate-*l/64.8%
lft-mult-inverse99.3%
sub-neg99.3%
distribute-frac-neg99.3%
remove-double-neg99.3%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 85.6%
Taylor expanded in a around 0 73.5%
if 1.15000000000000001e150 < 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 a around 0 100.0%
Taylor expanded in b around 0 97.8%
*-commutative97.8%
Simplified97.8%
Final simplification82.0%
(FPCore (a b)
:precision binary64
(if (<= b -560.0)
1.0
(if (<= b 1.15e+150)
(/ 1.0 (+ 2.0 (* a (+ -1.0 (* a 0.5)))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b 0.5))))))))
double code(double a, double b) {
double tmp;
if (b <= -560.0) {
tmp = 1.0;
} else if (b <= 1.15e+150) {
tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (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 <= (-560.0d0)) then
tmp = 1.0d0
else if (b <= 1.15d+150) then
tmp = 1.0d0 / (2.0d0 + (a * ((-1.0d0) + (a * 0.5d0))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * 0.5d0))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -560.0) {
tmp = 1.0;
} else if (b <= 1.15e+150) {
tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -560.0: tmp = 1.0 elif b <= 1.15e+150: tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5)))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))) return tmp
function code(a, b) tmp = 0.0 if (b <= -560.0) tmp = 1.0; elseif (b <= 1.15e+150) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(-1.0 + Float64(a * 0.5))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * 0.5))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -560.0) tmp = 1.0; elseif (b <= 1.15e+150) tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5)))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -560.0], 1.0, If[LessEqual[b, 1.15e+150], N[(1.0 / N[(2.0 + N[(a * N[(-1.0 + N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -560:\\
\;\;\;\;1\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{+150}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(-1 + a \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < -560Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.7%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
Applied egg-rr100.0%
*-inverses100.0%
Simplified100.0%
if -560 < b < 1.15000000000000001e150Initial program 99.3%
*-lft-identity99.3%
associate-*l/99.3%
associate-/r/99.3%
remove-double-neg99.3%
unsub-neg99.3%
div-sub64.8%
*-lft-identity64.8%
associate-*l/64.8%
lft-mult-inverse99.3%
sub-neg99.3%
distribute-frac-neg99.3%
remove-double-neg99.3%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 85.6%
Taylor expanded in a around 0 70.1%
if 1.15000000000000001e150 < 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 a around 0 100.0%
Taylor expanded in b around 0 97.8%
*-commutative97.8%
Simplified97.8%
Final simplification79.7%
(FPCore (a b) :precision binary64 (if (<= b -6.5) 1.0 (/ 1.0 (+ 2.0 (* a (+ -1.0 (* a 0.5)))))))
double code(double a, double b) {
double tmp;
if (b <= -6.5) {
tmp = 1.0;
} else {
tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 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 <= (-6.5d0)) then
tmp = 1.0d0
else
tmp = 1.0d0 / (2.0d0 + (a * ((-1.0d0) + (a * 0.5d0))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -6.5) {
tmp = 1.0;
} else {
tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -6.5: tmp = 1.0 else: tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5)))) return tmp
function code(a, b) tmp = 0.0 if (b <= -6.5) tmp = 1.0; else tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(-1.0 + Float64(a * 0.5))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -6.5) tmp = 1.0; else tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -6.5], 1.0, N[(1.0 / N[(2.0 + N[(a * N[(-1.0 + N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.5:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(-1 + a \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < -6.5Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.7%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
Applied egg-rr100.0%
*-inverses100.0%
Simplified100.0%
if -6.5 < b Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub63.9%
*-lft-identity63.9%
associate-*l/63.9%
lft-mult-inverse99.4%
sub-neg99.4%
distribute-frac-neg99.4%
remove-double-neg99.4%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 77.3%
Taylor expanded in a around 0 60.7%
Final simplification67.6%
(FPCore (a b) :precision binary64 (if (<= b -1.4) 1.0 (/ 1.0 (- 2.0 a))))
double code(double a, double b) {
double tmp;
if (b <= -1.4) {
tmp = 1.0;
} else {
tmp = 1.0 / (2.0 - a);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-1.4d0)) then
tmp = 1.0d0
else
tmp = 1.0d0 / (2.0d0 - a)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -1.4) {
tmp = 1.0;
} else {
tmp = 1.0 / (2.0 - a);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -1.4: tmp = 1.0 else: tmp = 1.0 / (2.0 - a) return tmp
function code(a, b) tmp = 0.0 if (b <= -1.4) tmp = 1.0; else tmp = Float64(1.0 / Float64(2.0 - a)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -1.4) tmp = 1.0; else tmp = 1.0 / (2.0 - a); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -1.4], 1.0, N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.4:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - a}\\
\end{array}
\end{array}
if b < -1.3999999999999999Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.7%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
Applied egg-rr100.0%
*-inverses100.0%
Simplified100.0%
if -1.3999999999999999 < b Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub63.9%
*-lft-identity63.9%
associate-*l/63.9%
lft-mult-inverse99.4%
sub-neg99.4%
distribute-frac-neg99.4%
remove-double-neg99.4%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 77.3%
Taylor expanded in a around 0 43.6%
neg-mul-143.6%
unsub-neg43.6%
Simplified43.6%
(FPCore (a b) :precision binary64 (if (<= b -1.0) 1.0 (/ 1.0 (+ b 2.0))))
double code(double a, double b) {
double tmp;
if (b <= -1.0) {
tmp = 1.0;
} else {
tmp = 1.0 / (b + 2.0);
}
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 = 1.0d0
else
tmp = 1.0d0 / (b + 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -1.0) {
tmp = 1.0;
} else {
tmp = 1.0 / (b + 2.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -1.0: tmp = 1.0 else: tmp = 1.0 / (b + 2.0) return tmp
function code(a, b) tmp = 0.0 if (b <= -1.0) tmp = 1.0; else tmp = Float64(1.0 / Float64(b + 2.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -1.0) tmp = 1.0; else tmp = 1.0 / (b + 2.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -1.0], 1.0, N[(1.0 / N[(b + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b + 2}\\
\end{array}
\end{array}
if b < -1Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.7%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
Applied egg-rr100.0%
*-inverses100.0%
Simplified100.0%
if -1 < b Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub63.9%
*-lft-identity63.9%
associate-*l/63.9%
lft-mult-inverse99.4%
sub-neg99.4%
distribute-frac-neg99.4%
remove-double-neg99.4%
div-exp99.9%
Simplified99.9%
Taylor expanded in a around 0 76.4%
Taylor expanded in b around 0 43.2%
+-commutative43.2%
Simplified43.2%
(FPCore (a b) :precision binary64 (if (<= b -1.8) 1.0 (+ 0.5 (* b -0.25))))
double code(double a, double b) {
double tmp;
if (b <= -1.8) {
tmp = 1.0;
} else {
tmp = 0.5 + (b * -0.25);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-1.8d0)) then
tmp = 1.0d0
else
tmp = 0.5d0 + (b * (-0.25d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -1.8) {
tmp = 1.0;
} else {
tmp = 0.5 + (b * -0.25);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -1.8: tmp = 1.0 else: tmp = 0.5 + (b * -0.25) return tmp
function code(a, b) tmp = 0.0 if (b <= -1.8) tmp = 1.0; else tmp = Float64(0.5 + Float64(b * -0.25)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -1.8) tmp = 1.0; else tmp = 0.5 + (b * -0.25); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -1.8], 1.0, N[(0.5 + N[(b * -0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.8:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0.5 + b \cdot -0.25\\
\end{array}
\end{array}
if b < -1.80000000000000004Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.7%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
Applied egg-rr100.0%
*-inverses100.0%
Simplified100.0%
if -1.80000000000000004 < b Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub63.9%
*-lft-identity63.9%
associate-*l/63.9%
lft-mult-inverse99.4%
sub-neg99.4%
distribute-frac-neg99.4%
remove-double-neg99.4%
div-exp99.9%
Simplified99.9%
Taylor expanded in a around 0 76.4%
Taylor expanded in b around 0 42.6%
*-commutative42.6%
Simplified42.6%
(FPCore (a b) :precision binary64 (if (<= b -0.98) 1.0 (+ 0.5 (* a 0.25))))
double code(double a, double b) {
double tmp;
if (b <= -0.98) {
tmp = 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 (b <= (-0.98d0)) then
tmp = 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 (b <= -0.98) {
tmp = 1.0;
} else {
tmp = 0.5 + (a * 0.25);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -0.98: tmp = 1.0 else: tmp = 0.5 + (a * 0.25) return tmp
function code(a, b) tmp = 0.0 if (b <= -0.98) tmp = 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 (b <= -0.98) tmp = 1.0; else tmp = 0.5 + (a * 0.25); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -0.98], 1.0, N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.98:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\end{array}
\end{array}
if b < -0.97999999999999998Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.7%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
Applied egg-rr100.0%
*-inverses100.0%
Simplified100.0%
if -0.97999999999999998 < b Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub63.9%
*-lft-identity63.9%
associate-*l/63.9%
lft-mult-inverse99.4%
sub-neg99.4%
distribute-frac-neg99.4%
remove-double-neg99.4%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 77.3%
Taylor expanded in a around 0 42.6%
*-commutative42.6%
Simplified42.6%
(FPCore (a b) :precision binary64 (if (<= b -1.1) 1.0 0.5))
double code(double a, double b) {
double tmp;
if (b <= -1.1) {
tmp = 1.0;
} else {
tmp = 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 <= (-1.1d0)) then
tmp = 1.0d0
else
tmp = 0.5d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -1.1) {
tmp = 1.0;
} else {
tmp = 0.5;
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -1.1: tmp = 1.0 else: tmp = 0.5 return tmp
function code(a, b) tmp = 0.0 if (b <= -1.1) tmp = 1.0; else tmp = 0.5; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -1.1) tmp = 1.0; else tmp = 0.5; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -1.1], 1.0, 0.5]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.1:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if b < -1.1000000000000001Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.7%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
*-lft-identity97.8%
associate-*l/97.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
Applied egg-rr100.0%
*-inverses100.0%
Simplified100.0%
if -1.1000000000000001 < b Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub63.9%
*-lft-identity63.9%
associate-*l/63.9%
lft-mult-inverse99.4%
sub-neg99.4%
distribute-frac-neg99.4%
remove-double-neg99.4%
div-exp99.9%
Simplified99.9%
Taylor expanded in a around 0 76.4%
Taylor expanded in b around 0 41.9%
(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.1%
associate-/r/99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub69.8%
*-lft-identity69.8%
associate-*l/69.8%
lft-mult-inverse99.1%
sub-neg99.1%
distribute-frac-neg99.1%
remove-double-neg99.1%
div-exp99.9%
Simplified99.9%
Taylor expanded in a around 0 80.5%
Taylor expanded in b around 0 37.8%
(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 2024100
(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))))