
(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 16 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 (/ 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}
Initial program 98.4%
*-lft-identity98.4%
associate-*l/98.4%
associate-/r/98.4%
remove-double-neg98.4%
unsub-neg98.4%
div-sub69.9%
*-lft-identity69.9%
associate-*l/69.9%
lft-mult-inverse99.2%
sub-neg99.2%
distribute-frac-neg99.2%
remove-double-neg99.2%
div-exp100.0%
Simplified100.0%
(FPCore (a b) :precision binary64 (if (<= a -30500.0) (/ (exp a) b) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (a <= -30500.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 <= (-30500.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 <= -30500.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 <= -30500.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 <= -30500.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 <= -30500.0) tmp = exp(a) / b; else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -30500.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 -30500:\\
\;\;\;\;\frac{e^{a}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -30500Initial 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 68.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 -30500 < a Initial program 97.8%
*-lft-identity97.8%
associate-*l/97.8%
associate-/r/97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.3%
*-lft-identity97.3%
associate-*l/97.3%
lft-mult-inverse98.9%
sub-neg98.9%
distribute-frac-neg98.9%
remove-double-neg98.9%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 97.7%
(FPCore (a b) :precision binary64 (if (<= a -550.0) (/ (exp a) b) (/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666)))))))))
double code(double a, double b) {
double tmp;
if (a <= -550.0) {
tmp = exp(a) / b;
} 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 (a <= (-550.0d0)) then
tmp = exp(a) / b
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 (a <= -550.0) {
tmp = Math.exp(a) / b;
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -550.0: tmp = math.exp(a) / b 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 (a <= -550.0) tmp = Float64(exp(a) / b); 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 (a <= -550.0) tmp = exp(a) / b; 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[a, -550.0], N[(N[Exp[a], $MachinePrecision] / b), $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}\;a \leq -550:\\
\;\;\;\;\frac{e^{a}}{b}\\
\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 a < -550Initial program 97.3%
*-lft-identity97.3%
associate-*l/97.3%
associate-/r/97.3%
remove-double-neg97.3%
unsub-neg97.3%
div-sub0.0%
*-lft-identity0.0%
associate-*l/0.0%
lft-mult-inverse97.3%
sub-neg97.3%
distribute-frac-neg97.3%
remove-double-neg97.3%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 65.3%
distribute-rgt1-in97.4%
rec-exp97.4%
associate-*r/97.4%
*-rgt-identity97.4%
+-commutative97.4%
Simplified97.4%
Taylor expanded in b around inf 97.4%
if -550 < 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-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 98.2%
Taylor expanded in b around 0 65.5%
*-commutative65.5%
Simplified65.5%
(FPCore (a b)
:precision binary64
(if (<= b -400.0)
0.5
(if (<= b 1.05e+103)
(/
1.0
(+
2.0
(+
b
(*
a
(+
(*
a
(+
(- 0.5 (* b (* 0.16666666666666666 (+ a (/ a b)))))
(- b (* b 0.5))))
(- -1.0 b))))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666))))))))))
double code(double a, double b) {
double tmp;
if (b <= -400.0) {
tmp = 0.5;
} else if (b <= 1.05e+103) {
tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (b * (0.16666666666666666 * (a + (a / b))))) + (b - (b * 0.5)))) + (-1.0 - b)))));
} 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 <= (-400.0d0)) then
tmp = 0.5d0
else if (b <= 1.05d+103) then
tmp = 1.0d0 / (2.0d0 + (b + (a * ((a * ((0.5d0 - (b * (0.16666666666666666d0 * (a + (a / b))))) + (b - (b * 0.5d0)))) + ((-1.0d0) - b)))))
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 <= -400.0) {
tmp = 0.5;
} else if (b <= 1.05e+103) {
tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (b * (0.16666666666666666 * (a + (a / b))))) + (b - (b * 0.5)))) + (-1.0 - b)))));
} 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 <= -400.0: tmp = 0.5 elif b <= 1.05e+103: tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (b * (0.16666666666666666 * (a + (a / b))))) + (b - (b * 0.5)))) + (-1.0 - b))))) 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 <= -400.0) tmp = 0.5; elseif (b <= 1.05e+103) tmp = Float64(1.0 / Float64(2.0 + Float64(b + Float64(a * Float64(Float64(a * Float64(Float64(0.5 - Float64(b * Float64(0.16666666666666666 * Float64(a + Float64(a / b))))) + Float64(b - Float64(b * 0.5)))) + Float64(-1.0 - b)))))); 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 <= -400.0) tmp = 0.5; elseif (b <= 1.05e+103) tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (b * (0.16666666666666666 * (a + (a / b))))) + (b - (b * 0.5)))) + (-1.0 - b))))); 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, -400.0], 0.5, If[LessEqual[b, 1.05e+103], N[(1.0 / N[(2.0 + N[(b + N[(a * N[(N[(a * N[(N[(0.5 - N[(b * N[(0.16666666666666666 * N[(a + N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b - N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 - b), $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 -400:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;\frac{1}{2 + \left(b + a \cdot \left(a \cdot \left(\left(0.5 - b \cdot \left(0.16666666666666666 \cdot \left(a + \frac{a}{b}\right)\right)\right) + \left(b - b \cdot 0.5\right)\right) + \left(-1 - b\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 < -400Initial program 92.7%
*-lft-identity92.7%
associate-*l/92.7%
associate-/r/92.7%
remove-double-neg92.7%
unsub-neg92.7%
div-sub92.7%
*-lft-identity92.7%
associate-*l/92.7%
lft-mult-inverse96.4%
sub-neg96.4%
distribute-frac-neg96.4%
remove-double-neg96.4%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 18.8%
if -400 < b < 1.0500000000000001e103Initial program 99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub64.7%
*-lft-identity64.7%
associate-*l/64.7%
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 79.4%
distribute-rgt1-in94.8%
rec-exp94.8%
associate-*r/94.8%
*-rgt-identity94.8%
+-commutative94.8%
Simplified94.8%
Taylor expanded in a around 0 83.5%
Taylor expanded in b around inf 84.7%
distribute-lft-out84.7%
Simplified84.7%
if 1.0500000000000001e103 < 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 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification73.2%
(FPCore (a b)
:precision binary64
(if (<= b -4100.0)
0.5
(if (<= b 5.2e+102)
(/
1.0
(+
2.0
(+
b
(*
a
(+
(*
a
(+ (- 0.5 (* b (* 0.16666666666666666 (/ a b)))) (- b (* b 0.5))))
(- -1.0 b))))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666))))))))))
double code(double a, double b) {
double tmp;
if (b <= -4100.0) {
tmp = 0.5;
} else if (b <= 5.2e+102) {
tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (b * (0.16666666666666666 * (a / b)))) + (b - (b * 0.5)))) + (-1.0 - b)))));
} 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 <= (-4100.0d0)) then
tmp = 0.5d0
else if (b <= 5.2d+102) then
tmp = 1.0d0 / (2.0d0 + (b + (a * ((a * ((0.5d0 - (b * (0.16666666666666666d0 * (a / b)))) + (b - (b * 0.5d0)))) + ((-1.0d0) - b)))))
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 <= -4100.0) {
tmp = 0.5;
} else if (b <= 5.2e+102) {
tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (b * (0.16666666666666666 * (a / b)))) + (b - (b * 0.5)))) + (-1.0 - b)))));
} 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 <= -4100.0: tmp = 0.5 elif b <= 5.2e+102: tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (b * (0.16666666666666666 * (a / b)))) + (b - (b * 0.5)))) + (-1.0 - b))))) 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 <= -4100.0) tmp = 0.5; elseif (b <= 5.2e+102) tmp = Float64(1.0 / Float64(2.0 + Float64(b + Float64(a * Float64(Float64(a * Float64(Float64(0.5 - Float64(b * Float64(0.16666666666666666 * Float64(a / b)))) + Float64(b - Float64(b * 0.5)))) + Float64(-1.0 - b)))))); 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 <= -4100.0) tmp = 0.5; elseif (b <= 5.2e+102) tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (b * (0.16666666666666666 * (a / b)))) + (b - (b * 0.5)))) + (-1.0 - b))))); 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, -4100.0], 0.5, If[LessEqual[b, 5.2e+102], N[(1.0 / N[(2.0 + N[(b + N[(a * N[(N[(a * N[(N[(0.5 - N[(b * N[(0.16666666666666666 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b - N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 - b), $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 -4100:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{+102}:\\
\;\;\;\;\frac{1}{2 + \left(b + a \cdot \left(a \cdot \left(\left(0.5 - b \cdot \left(0.16666666666666666 \cdot \frac{a}{b}\right)\right) + \left(b - b \cdot 0.5\right)\right) + \left(-1 - b\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 < -4100Initial program 92.7%
*-lft-identity92.7%
associate-*l/92.7%
associate-/r/92.7%
remove-double-neg92.7%
unsub-neg92.7%
div-sub92.7%
*-lft-identity92.7%
associate-*l/92.7%
lft-mult-inverse96.4%
sub-neg96.4%
distribute-frac-neg96.4%
remove-double-neg96.4%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 18.8%
if -4100 < b < 5.20000000000000013e102Initial program 99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub64.7%
*-lft-identity64.7%
associate-*l/64.7%
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 79.4%
distribute-rgt1-in94.8%
rec-exp94.8%
associate-*r/94.8%
*-rgt-identity94.8%
+-commutative94.8%
Simplified94.8%
Taylor expanded in a around 0 83.5%
Taylor expanded in b around inf 84.7%
distribute-lft-out84.7%
Simplified84.7%
Taylor expanded in b around 0 84.7%
if 5.20000000000000013e102 < 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 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification73.2%
(FPCore (a b)
:precision binary64
(if (<= b -60.0)
0.5
(if (<= b 1e+103)
(/
1.0
(+
2.0
(+
b
(*
a
(+
(*
a
(+
(- 0.5 (* a (+ 0.16666666666666666 (* b -0.8333333333333334))))
(- b (* b 0.5))))
(- -1.0 b))))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666))))))))))
double code(double a, double b) {
double tmp;
if (b <= -60.0) {
tmp = 0.5;
} else if (b <= 1e+103) {
tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (a * (0.16666666666666666 + (b * -0.8333333333333334)))) + (b - (b * 0.5)))) + (-1.0 - b)))));
} 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 <= (-60.0d0)) then
tmp = 0.5d0
else if (b <= 1d+103) then
tmp = 1.0d0 / (2.0d0 + (b + (a * ((a * ((0.5d0 - (a * (0.16666666666666666d0 + (b * (-0.8333333333333334d0))))) + (b - (b * 0.5d0)))) + ((-1.0d0) - b)))))
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 <= -60.0) {
tmp = 0.5;
} else if (b <= 1e+103) {
tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (a * (0.16666666666666666 + (b * -0.8333333333333334)))) + (b - (b * 0.5)))) + (-1.0 - b)))));
} 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 <= -60.0: tmp = 0.5 elif b <= 1e+103: tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (a * (0.16666666666666666 + (b * -0.8333333333333334)))) + (b - (b * 0.5)))) + (-1.0 - b))))) 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 <= -60.0) tmp = 0.5; elseif (b <= 1e+103) tmp = Float64(1.0 / Float64(2.0 + Float64(b + Float64(a * Float64(Float64(a * Float64(Float64(0.5 - Float64(a * Float64(0.16666666666666666 + Float64(b * -0.8333333333333334)))) + Float64(b - Float64(b * 0.5)))) + Float64(-1.0 - b)))))); 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 <= -60.0) tmp = 0.5; elseif (b <= 1e+103) tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (a * (0.16666666666666666 + (b * -0.8333333333333334)))) + (b - (b * 0.5)))) + (-1.0 - b))))); 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, -60.0], 0.5, If[LessEqual[b, 1e+103], N[(1.0 / N[(2.0 + N[(b + N[(a * N[(N[(a * N[(N[(0.5 - N[(a * N[(0.16666666666666666 + N[(b * -0.8333333333333334), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b - N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 - b), $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 -60:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq 10^{+103}:\\
\;\;\;\;\frac{1}{2 + \left(b + a \cdot \left(a \cdot \left(\left(0.5 - a \cdot \left(0.16666666666666666 + b \cdot -0.8333333333333334\right)\right) + \left(b - b \cdot 0.5\right)\right) + \left(-1 - b\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 < -60Initial program 92.7%
*-lft-identity92.7%
associate-*l/92.7%
associate-/r/92.7%
remove-double-neg92.7%
unsub-neg92.7%
div-sub92.7%
*-lft-identity92.7%
associate-*l/92.7%
lft-mult-inverse96.4%
sub-neg96.4%
distribute-frac-neg96.4%
remove-double-neg96.4%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 18.8%
if -60 < b < 1e103Initial program 99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub64.7%
*-lft-identity64.7%
associate-*l/64.7%
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 79.4%
distribute-rgt1-in94.8%
rec-exp94.8%
associate-*r/94.8%
*-rgt-identity94.8%
+-commutative94.8%
Simplified94.8%
Taylor expanded in a around 0 83.5%
*-un-lft-identity83.5%
+-commutative83.5%
distribute-rgt-out83.5%
fma-define83.5%
metadata-eval83.5%
add-sqr-sqrt45.9%
sqrt-unprod83.5%
mul-1-neg83.5%
mul-1-neg83.5%
sqr-neg83.5%
sqrt-unprod37.6%
add-sqr-sqrt83.5%
distribute-rgt-out83.5%
metadata-eval83.5%
Applied egg-rr83.5%
*-lft-identity83.5%
fma-undefine83.5%
distribute-lft-out83.5%
metadata-eval83.5%
Simplified83.5%
if 1e103 < 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 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification72.5%
(FPCore (a b)
:precision binary64
(if (<= b -35.0)
0.5
(if (<= b 3.3e+102)
(/
1.0
(+
2.0
(+
b
(*
a
(+
(* a (+ (- 0.5 (* a 0.16666666666666666)) (- b (* b 0.5))))
(- -1.0 b))))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666))))))))))
double code(double a, double b) {
double tmp;
if (b <= -35.0) {
tmp = 0.5;
} else if (b <= 3.3e+102) {
tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (a * 0.16666666666666666)) + (b - (b * 0.5)))) + (-1.0 - b)))));
} 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 <= (-35.0d0)) then
tmp = 0.5d0
else if (b <= 3.3d+102) then
tmp = 1.0d0 / (2.0d0 + (b + (a * ((a * ((0.5d0 - (a * 0.16666666666666666d0)) + (b - (b * 0.5d0)))) + ((-1.0d0) - b)))))
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 <= -35.0) {
tmp = 0.5;
} else if (b <= 3.3e+102) {
tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (a * 0.16666666666666666)) + (b - (b * 0.5)))) + (-1.0 - b)))));
} 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 <= -35.0: tmp = 0.5 elif b <= 3.3e+102: tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (a * 0.16666666666666666)) + (b - (b * 0.5)))) + (-1.0 - b))))) 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 <= -35.0) tmp = 0.5; elseif (b <= 3.3e+102) tmp = Float64(1.0 / Float64(2.0 + Float64(b + Float64(a * Float64(Float64(a * Float64(Float64(0.5 - Float64(a * 0.16666666666666666)) + Float64(b - Float64(b * 0.5)))) + Float64(-1.0 - b)))))); 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 <= -35.0) tmp = 0.5; elseif (b <= 3.3e+102) tmp = 1.0 / (2.0 + (b + (a * ((a * ((0.5 - (a * 0.16666666666666666)) + (b - (b * 0.5)))) + (-1.0 - b))))); 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, -35.0], 0.5, If[LessEqual[b, 3.3e+102], N[(1.0 / N[(2.0 + N[(b + N[(a * N[(N[(a * N[(N[(0.5 - N[(a * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] + N[(b - N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 - b), $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 -35:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq 3.3 \cdot 10^{+102}:\\
\;\;\;\;\frac{1}{2 + \left(b + a \cdot \left(a \cdot \left(\left(0.5 - a \cdot 0.16666666666666666\right) + \left(b - b \cdot 0.5\right)\right) + \left(-1 - b\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 < -35Initial program 92.7%
*-lft-identity92.7%
associate-*l/92.7%
associate-/r/92.7%
remove-double-neg92.7%
unsub-neg92.7%
div-sub92.7%
*-lft-identity92.7%
associate-*l/92.7%
lft-mult-inverse96.4%
sub-neg96.4%
distribute-frac-neg96.4%
remove-double-neg96.4%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 18.8%
if -35 < b < 3.29999999999999999e102Initial program 99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub64.7%
*-lft-identity64.7%
associate-*l/64.7%
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 79.4%
distribute-rgt1-in94.8%
rec-exp94.8%
associate-*r/94.8%
*-rgt-identity94.8%
+-commutative94.8%
Simplified94.8%
Taylor expanded in a around 0 83.5%
Taylor expanded in b around 0 83.5%
if 3.29999999999999999e102 < 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 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification72.5%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* a (+ -1.0 (* a 0.5)))))
(if (<= b -4.8e-178)
(/ 1.0 (+ 2.0 t_0))
(if (<= b 2.1e-186)
(/ 1.0 (+ b (- 2.0 (* b (+ a (/ a b))))))
(if (<= b 4e+102)
(/ 1.0 (+ 2.0 (+ b t_0)))
(/
1.0
(+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666))))))))))))
double code(double a, double b) {
double t_0 = a * (-1.0 + (a * 0.5));
double tmp;
if (b <= -4.8e-178) {
tmp = 1.0 / (2.0 + t_0);
} else if (b <= 2.1e-186) {
tmp = 1.0 / (b + (2.0 - (b * (a + (a / b)))));
} else if (b <= 4e+102) {
tmp = 1.0 / (2.0 + (b + t_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) :: t_0
real(8) :: tmp
t_0 = a * ((-1.0d0) + (a * 0.5d0))
if (b <= (-4.8d-178)) then
tmp = 1.0d0 / (2.0d0 + t_0)
else if (b <= 2.1d-186) then
tmp = 1.0d0 / (b + (2.0d0 - (b * (a + (a / b)))))
else if (b <= 4d+102) then
tmp = 1.0d0 / (2.0d0 + (b + t_0))
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 t_0 = a * (-1.0 + (a * 0.5));
double tmp;
if (b <= -4.8e-178) {
tmp = 1.0 / (2.0 + t_0);
} else if (b <= 2.1e-186) {
tmp = 1.0 / (b + (2.0 - (b * (a + (a / b)))));
} else if (b <= 4e+102) {
tmp = 1.0 / (2.0 + (b + t_0));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
def code(a, b): t_0 = a * (-1.0 + (a * 0.5)) tmp = 0 if b <= -4.8e-178: tmp = 1.0 / (2.0 + t_0) elif b <= 2.1e-186: tmp = 1.0 / (b + (2.0 - (b * (a + (a / b))))) elif b <= 4e+102: tmp = 1.0 / (2.0 + (b + t_0)) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))) return tmp
function code(a, b) t_0 = Float64(a * Float64(-1.0 + Float64(a * 0.5))) tmp = 0.0 if (b <= -4.8e-178) tmp = Float64(1.0 / Float64(2.0 + t_0)); elseif (b <= 2.1e-186) tmp = Float64(1.0 / Float64(b + Float64(2.0 - Float64(b * Float64(a + Float64(a / b)))))); elseif (b <= 4e+102) tmp = Float64(1.0 / Float64(2.0 + Float64(b + t_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) t_0 = a * (-1.0 + (a * 0.5)); tmp = 0.0; if (b <= -4.8e-178) tmp = 1.0 / (2.0 + t_0); elseif (b <= 2.1e-186) tmp = 1.0 / (b + (2.0 - (b * (a + (a / b))))); elseif (b <= 4e+102) tmp = 1.0 / (2.0 + (b + t_0)); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(a * N[(-1.0 + N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4.8e-178], N[(1.0 / N[(2.0 + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.1e-186], N[(1.0 / N[(b + N[(2.0 - N[(b * N[(a + N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e+102], N[(1.0 / N[(2.0 + N[(b + t$95$0), $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}
t_0 := a \cdot \left(-1 + a \cdot 0.5\right)\\
\mathbf{if}\;b \leq -4.8 \cdot 10^{-178}:\\
\;\;\;\;\frac{1}{2 + t\_0}\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{-186}:\\
\;\;\;\;\frac{1}{b + \left(2 - b \cdot \left(a + \frac{a}{b}\right)\right)}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{+102}:\\
\;\;\;\;\frac{1}{2 + \left(b + t\_0\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 < -4.8000000000000001e-178Initial program 95.7%
*-lft-identity95.7%
associate-*l/95.7%
associate-/r/95.7%
remove-double-neg95.7%
unsub-neg95.7%
div-sub81.7%
*-lft-identity81.7%
associate-*l/81.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 29.9%
distribute-rgt1-in43.9%
rec-exp43.9%
associate-*r/43.9%
*-rgt-identity43.9%
+-commutative43.9%
Simplified43.9%
Taylor expanded in a around 0 35.0%
Taylor expanded in b around 0 43.7%
if -4.8000000000000001e-178 < b < 2.1000000000000002e-186Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub66.0%
*-lft-identity66.0%
associate-*l/66.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 78.0%
distribute-rgt1-in100.0%
rec-exp100.0%
associate-*r/100.0%
*-rgt-identity100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 67.9%
associate-+r+67.9%
+-commutative67.9%
associate-+l+67.9%
mul-1-neg67.9%
distribute-rgt-neg-in67.9%
distribute-neg-in67.9%
metadata-eval67.9%
unsub-neg67.9%
Simplified67.9%
Taylor expanded in b around inf 96.1%
mul-1-neg96.1%
unsub-neg96.1%
mul-1-neg96.1%
Simplified96.1%
if 2.1000000000000002e-186 < b < 3.99999999999999991e102Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub63.2%
*-lft-identity63.2%
associate-*l/63.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 88.6%
distribute-rgt1-in88.6%
rec-exp88.6%
associate-*r/88.6%
*-rgt-identity88.6%
+-commutative88.6%
Simplified88.6%
Taylor expanded in a around 0 66.3%
Taylor expanded in b around 0 66.2%
if 3.99999999999999991e102 < 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 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification69.8%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* a (+ -1.0 (* a 0.5)))))
(if (<= b -1.9e-179)
(/ 1.0 (+ 2.0 t_0))
(if (<= b 6.4e-192)
(/ 1.0 (+ b (- 2.0 (* b (+ a (/ a b))))))
(if (<= b 5.1e+147)
(/ 1.0 (+ 2.0 (+ b t_0)))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b 0.5))))))))))
double code(double a, double b) {
double t_0 = a * (-1.0 + (a * 0.5));
double tmp;
if (b <= -1.9e-179) {
tmp = 1.0 / (2.0 + t_0);
} else if (b <= 6.4e-192) {
tmp = 1.0 / (b + (2.0 - (b * (a + (a / b)))));
} else if (b <= 5.1e+147) {
tmp = 1.0 / (2.0 + (b + t_0));
} 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) :: t_0
real(8) :: tmp
t_0 = a * ((-1.0d0) + (a * 0.5d0))
if (b <= (-1.9d-179)) then
tmp = 1.0d0 / (2.0d0 + t_0)
else if (b <= 6.4d-192) then
tmp = 1.0d0 / (b + (2.0d0 - (b * (a + (a / b)))))
else if (b <= 5.1d+147) then
tmp = 1.0d0 / (2.0d0 + (b + t_0))
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 t_0 = a * (-1.0 + (a * 0.5));
double tmp;
if (b <= -1.9e-179) {
tmp = 1.0 / (2.0 + t_0);
} else if (b <= 6.4e-192) {
tmp = 1.0 / (b + (2.0 - (b * (a + (a / b)))));
} else if (b <= 5.1e+147) {
tmp = 1.0 / (2.0 + (b + t_0));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5))));
}
return tmp;
}
def code(a, b): t_0 = a * (-1.0 + (a * 0.5)) tmp = 0 if b <= -1.9e-179: tmp = 1.0 / (2.0 + t_0) elif b <= 6.4e-192: tmp = 1.0 / (b + (2.0 - (b * (a + (a / b))))) elif b <= 5.1e+147: tmp = 1.0 / (2.0 + (b + t_0)) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))) return tmp
function code(a, b) t_0 = Float64(a * Float64(-1.0 + Float64(a * 0.5))) tmp = 0.0 if (b <= -1.9e-179) tmp = Float64(1.0 / Float64(2.0 + t_0)); elseif (b <= 6.4e-192) tmp = Float64(1.0 / Float64(b + Float64(2.0 - Float64(b * Float64(a + Float64(a / b)))))); elseif (b <= 5.1e+147) tmp = Float64(1.0 / Float64(2.0 + Float64(b + t_0))); 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) t_0 = a * (-1.0 + (a * 0.5)); tmp = 0.0; if (b <= -1.9e-179) tmp = 1.0 / (2.0 + t_0); elseif (b <= 6.4e-192) tmp = 1.0 / (b + (2.0 - (b * (a + (a / b))))); elseif (b <= 5.1e+147) tmp = 1.0 / (2.0 + (b + t_0)); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(a * N[(-1.0 + N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.9e-179], N[(1.0 / N[(2.0 + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.4e-192], N[(1.0 / N[(b + N[(2.0 - N[(b * N[(a + N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.1e+147], N[(1.0 / N[(2.0 + N[(b + t$95$0), $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}
t_0 := a \cdot \left(-1 + a \cdot 0.5\right)\\
\mathbf{if}\;b \leq -1.9 \cdot 10^{-179}:\\
\;\;\;\;\frac{1}{2 + t\_0}\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{-192}:\\
\;\;\;\;\frac{1}{b + \left(2 - b \cdot \left(a + \frac{a}{b}\right)\right)}\\
\mathbf{elif}\;b \leq 5.1 \cdot 10^{+147}:\\
\;\;\;\;\frac{1}{2 + \left(b + t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < -1.89999999999999987e-179Initial program 95.7%
*-lft-identity95.7%
associate-*l/95.7%
associate-/r/95.7%
remove-double-neg95.7%
unsub-neg95.7%
div-sub81.7%
*-lft-identity81.7%
associate-*l/81.7%
lft-mult-inverse97.8%
sub-neg97.8%
distribute-frac-neg97.8%
remove-double-neg97.8%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 29.9%
distribute-rgt1-in43.9%
rec-exp43.9%
associate-*r/43.9%
*-rgt-identity43.9%
+-commutative43.9%
Simplified43.9%
Taylor expanded in a around 0 35.0%
Taylor expanded in b around 0 43.7%
if -1.89999999999999987e-179 < b < 6.4000000000000003e-192Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub66.0%
*-lft-identity66.0%
associate-*l/66.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 78.0%
distribute-rgt1-in100.0%
rec-exp100.0%
associate-*r/100.0%
*-rgt-identity100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 67.9%
associate-+r+67.9%
+-commutative67.9%
associate-+l+67.9%
mul-1-neg67.9%
distribute-rgt-neg-in67.9%
distribute-neg-in67.9%
metadata-eval67.9%
unsub-neg67.9%
Simplified67.9%
Taylor expanded in b around inf 96.1%
mul-1-neg96.1%
unsub-neg96.1%
mul-1-neg96.1%
Simplified96.1%
if 6.4000000000000003e-192 < b < 5.09999999999999999e147Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub61.8%
*-lft-identity61.8%
associate-*l/61.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 84.8%
distribute-rgt1-in84.8%
rec-exp84.8%
associate-*r/84.8%
*-rgt-identity84.8%
+-commutative84.8%
Simplified84.8%
Taylor expanded in a around 0 63.5%
Taylor expanded in b around 0 62.2%
if 5.09999999999999999e147 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub62.2%
*-lft-identity62.2%
associate-*l/62.2%
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.6%
Final simplification67.2%
(FPCore (a b)
:precision binary64
(if (<= b -53.0)
0.5
(if (<= b 6.5e+102)
(/
1.0
(+ 2.0 (+ b (* 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 <= -53.0) {
tmp = 0.5;
} else if (b <= 6.5e+102) {
tmp = 1.0 / (2.0 + (b + (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 <= (-53.0d0)) then
tmp = 0.5d0
else if (b <= 6.5d+102) then
tmp = 1.0d0 / (2.0d0 + (b + (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 <= -53.0) {
tmp = 0.5;
} else if (b <= 6.5e+102) {
tmp = 1.0 / (2.0 + (b + (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 <= -53.0: tmp = 0.5 elif b <= 6.5e+102: tmp = 1.0 / (2.0 + (b + (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 <= -53.0) tmp = 0.5; elseif (b <= 6.5e+102) tmp = Float64(1.0 / Float64(2.0 + Float64(b + 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 <= -53.0) tmp = 0.5; elseif (b <= 6.5e+102) tmp = 1.0 / (2.0 + (b + (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, -53.0], 0.5, If[LessEqual[b, 6.5e+102], N[(1.0 / N[(2.0 + N[(b + N[(a * N[(-1.0 + N[(a * N[(0.5 + N[(a * -0.16666666666666666), $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 -53:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{+102}:\\
\;\;\;\;\frac{1}{2 + \left(b + a \cdot \left(-1 + a \cdot \left(0.5 + a \cdot -0.16666666666666666\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 < -53Initial program 92.7%
*-lft-identity92.7%
associate-*l/92.7%
associate-/r/92.7%
remove-double-neg92.7%
unsub-neg92.7%
div-sub92.7%
*-lft-identity92.7%
associate-*l/92.7%
lft-mult-inverse96.4%
sub-neg96.4%
distribute-frac-neg96.4%
remove-double-neg96.4%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 18.8%
if -53 < b < 6.5000000000000004e102Initial program 99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub64.7%
*-lft-identity64.7%
associate-*l/64.7%
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 79.4%
distribute-rgt1-in94.8%
rec-exp94.8%
associate-*r/94.8%
*-rgt-identity94.8%
+-commutative94.8%
Simplified94.8%
Taylor expanded in a around 0 83.5%
Taylor expanded in b around inf 84.7%
distribute-lft-out84.7%
Simplified84.7%
Taylor expanded in b around 0 83.5%
if 6.5000000000000004e102 < 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 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification72.5%
(FPCore (a b) :precision binary64 (if (<= b 8e+146) (/ 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 <= 8e+146) {
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 <= 8d+146) 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 <= 8e+146) {
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 <= 8e+146: 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 <= 8e+146) 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 <= 8e+146) 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, 8e+146], 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 8 \cdot 10^{+146}:\\
\;\;\;\;\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 < 7.99999999999999947e146Initial program 98.1%
*-lft-identity98.1%
associate-*l/98.1%
associate-/r/98.2%
remove-double-neg98.2%
unsub-neg98.2%
div-sub71.2%
*-lft-identity71.2%
associate-*l/71.2%
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 59.9%
distribute-rgt1-in70.9%
rec-exp70.9%
associate-*r/70.9%
*-rgt-identity70.9%
+-commutative70.9%
Simplified70.9%
Taylor expanded in a around 0 55.9%
Taylor expanded in b around 0 58.9%
if 7.99999999999999947e146 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub62.2%
*-lft-identity62.2%
associate-*l/62.2%
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.6%
Final simplification64.5%
(FPCore (a b) :precision binary64 (if (<= b 3.2e-60) (/ 1.0 (- 2.0 a)) (/ 1.0 (+ b (- 2.0 (* b a))))))
double code(double a, double b) {
double tmp;
if (b <= 3.2e-60) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = 1.0 / (b + (2.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 <= 3.2d-60) then
tmp = 1.0d0 / (2.0d0 - a)
else
tmp = 1.0d0 / (b + (2.0d0 - (b * a)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 3.2e-60) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = 1.0 / (b + (2.0 - (b * a)));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.2e-60: tmp = 1.0 / (2.0 - a) else: tmp = 1.0 / (b + (2.0 - (b * a))) return tmp
function code(a, b) tmp = 0.0 if (b <= 3.2e-60) tmp = Float64(1.0 / Float64(2.0 - a)); else tmp = Float64(1.0 / Float64(b + Float64(2.0 - Float64(b * a)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 3.2e-60) tmp = 1.0 / (2.0 - a); else tmp = 1.0 / (b + (2.0 - (b * a))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.2e-60], N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b + N[(2.0 - N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{-60}:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b + \left(2 - b \cdot a\right)}\\
\end{array}
\end{array}
if b < 3.2000000000000001e-60Initial program 97.7%
*-lft-identity97.7%
associate-*l/97.7%
associate-/r/97.7%
remove-double-neg97.7%
unsub-neg97.7%
div-sub75.8%
*-lft-identity75.8%
associate-*l/75.8%
lft-mult-inverse98.9%
sub-neg98.9%
distribute-frac-neg98.9%
remove-double-neg98.9%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 57.2%
distribute-rgt1-in70.7%
rec-exp70.7%
associate-*r/70.7%
*-rgt-identity70.7%
+-commutative70.7%
Simplified70.7%
Taylor expanded in a around 0 48.2%
associate-+r+48.2%
+-commutative48.2%
associate-+l+48.2%
mul-1-neg48.2%
distribute-rgt-neg-in48.2%
distribute-neg-in48.2%
metadata-eval48.2%
unsub-neg48.2%
Simplified48.2%
Taylor expanded in b around 0 52.7%
mul-1-neg52.7%
unsub-neg52.7%
Simplified52.7%
if 3.2000000000000001e-60 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub56.4%
*-lft-identity56.4%
associate-*l/56.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 57.8%
distribute-rgt1-in57.8%
rec-exp57.8%
associate-*r/57.8%
*-rgt-identity57.8%
+-commutative57.8%
Simplified57.8%
Taylor expanded in a around 0 33.4%
associate-+r+33.4%
+-commutative33.4%
associate-+l+33.4%
mul-1-neg33.4%
distribute-rgt-neg-in33.4%
distribute-neg-in33.4%
metadata-eval33.4%
unsub-neg33.4%
Simplified33.4%
Taylor expanded in b around inf 33.1%
associate-*r*33.1%
mul-1-neg33.1%
Simplified33.1%
Final simplification46.7%
(FPCore (a b) :precision binary64 (if (<= b 2.75e-9) (/ 1.0 (- 2.0 a)) (/ -1.0 (* a (+ 1.0 b)))))
double code(double a, double b) {
double tmp;
if (b <= 2.75e-9) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = -1.0 / (a * (1.0 + b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 2.75d-9) then
tmp = 1.0d0 / (2.0d0 - a)
else
tmp = (-1.0d0) / (a * (1.0d0 + b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 2.75e-9) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = -1.0 / (a * (1.0 + b));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.75e-9: tmp = 1.0 / (2.0 - a) else: tmp = -1.0 / (a * (1.0 + b)) return tmp
function code(a, b) tmp = 0.0 if (b <= 2.75e-9) tmp = Float64(1.0 / Float64(2.0 - a)); else tmp = Float64(-1.0 / Float64(a * Float64(1.0 + b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.75e-9) tmp = 1.0 / (2.0 - a); else tmp = -1.0 / (a * (1.0 + b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2.75e-9], N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(a * N[(1.0 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.75 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{a \cdot \left(1 + b\right)}\\
\end{array}
\end{array}
if b < 2.7499999999999998e-9Initial program 97.9%
*-lft-identity97.9%
associate-*l/97.9%
associate-/r/97.9%
remove-double-neg97.9%
unsub-neg97.9%
div-sub74.2%
*-lft-identity74.2%
associate-*l/74.2%
lft-mult-inverse99.0%
sub-neg99.0%
distribute-frac-neg99.0%
remove-double-neg99.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 60.7%
distribute-rgt1-in73.1%
rec-exp73.1%
associate-*r/73.1%
*-rgt-identity73.1%
+-commutative73.1%
Simplified73.1%
Taylor expanded in a around 0 48.5%
associate-+r+48.5%
+-commutative48.5%
associate-+l+48.5%
mul-1-neg48.5%
distribute-rgt-neg-in48.5%
distribute-neg-in48.5%
metadata-eval48.5%
unsub-neg48.5%
Simplified48.5%
Taylor expanded in b around 0 52.4%
mul-1-neg52.4%
unsub-neg52.4%
Simplified52.4%
if 2.7499999999999998e-9 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub56.5%
*-lft-identity56.5%
associate-*l/56.5%
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 47.0%
distribute-rgt1-in47.0%
rec-exp47.0%
associate-*r/47.0%
*-rgt-identity47.0%
+-commutative47.0%
Simplified47.0%
Taylor expanded in a around 0 28.7%
associate-+r+28.7%
+-commutative28.7%
associate-+l+28.7%
mul-1-neg28.7%
distribute-rgt-neg-in28.7%
distribute-neg-in28.7%
metadata-eval28.7%
unsub-neg28.7%
Simplified28.7%
Taylor expanded in a around inf 27.4%
+-commutative27.4%
Simplified27.4%
Final simplification46.4%
(FPCore (a b) :precision binary64 (/ 1.0 (+ 2.0 (* a (+ -1.0 (* a 0.5))))))
double code(double a, double b) {
return 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))));
}
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))))
end function
public static double code(double a, double b) {
return 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))));
}
def code(a, b): return 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))))
function code(a, b) return Float64(1.0 / Float64(2.0 + Float64(a * Float64(-1.0 + Float64(a * 0.5))))) end
function tmp = code(a, b) tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5)))); end
code[a_, b_] := N[(1.0 / N[(2.0 + N[(a * N[(-1.0 + N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{2 + a \cdot \left(-1 + a \cdot 0.5\right)}
\end{array}
Initial program 98.4%
*-lft-identity98.4%
associate-*l/98.4%
associate-/r/98.4%
remove-double-neg98.4%
unsub-neg98.4%
div-sub69.9%
*-lft-identity69.9%
associate-*l/69.9%
lft-mult-inverse99.2%
sub-neg99.2%
distribute-frac-neg99.2%
remove-double-neg99.2%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 57.4%
distribute-rgt1-in66.8%
rec-exp66.8%
associate-*r/66.8%
*-rgt-identity66.8%
+-commutative66.8%
Simplified66.8%
Taylor expanded in a around 0 53.9%
Taylor expanded in b around 0 54.0%
Final simplification54.0%
(FPCore (a b) :precision binary64 (/ 1.0 (- 2.0 a)))
double code(double a, double b) {
return 1.0 / (2.0 - a);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (2.0d0 - a)
end function
public static double code(double a, double b) {
return 1.0 / (2.0 - a);
}
def code(a, b): return 1.0 / (2.0 - a)
function code(a, b) return Float64(1.0 / Float64(2.0 - a)) end
function tmp = code(a, b) tmp = 1.0 / (2.0 - a); end
code[a_, b_] := N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{2 - a}
\end{array}
Initial program 98.4%
*-lft-identity98.4%
associate-*l/98.4%
associate-/r/98.4%
remove-double-neg98.4%
unsub-neg98.4%
div-sub69.9%
*-lft-identity69.9%
associate-*l/69.9%
lft-mult-inverse99.2%
sub-neg99.2%
distribute-frac-neg99.2%
remove-double-neg99.2%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 57.4%
distribute-rgt1-in66.8%
rec-exp66.8%
associate-*r/66.8%
*-rgt-identity66.8%
+-commutative66.8%
Simplified66.8%
Taylor expanded in a around 0 43.7%
associate-+r+43.7%
+-commutative43.7%
associate-+l+43.7%
mul-1-neg43.7%
distribute-rgt-neg-in43.7%
distribute-neg-in43.7%
metadata-eval43.7%
unsub-neg43.7%
Simplified43.7%
Taylor expanded in b around 0 40.8%
mul-1-neg40.8%
unsub-neg40.8%
Simplified40.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 98.4%
*-lft-identity98.4%
associate-*l/98.4%
associate-/r/98.4%
remove-double-neg98.4%
unsub-neg98.4%
div-sub69.9%
*-lft-identity69.9%
associate-*l/69.9%
lft-mult-inverse99.2%
sub-neg99.2%
distribute-frac-neg99.2%
remove-double-neg99.2%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 80.9%
Taylor expanded in b around 0 40.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 2024089
(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))))