
(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 14 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 (/ (+ (exp a) (exp b)) (exp a))))
double code(double a, double b) {
return 1.0 / ((exp(a) + exp(b)) / exp(a));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / ((exp(a) + exp(b)) / exp(a))
end function
public static double code(double a, double b) {
return 1.0 / ((Math.exp(a) + Math.exp(b)) / Math.exp(a));
}
def code(a, b): return 1.0 / ((math.exp(a) + math.exp(b)) / math.exp(a))
function code(a, b) return Float64(1.0 / Float64(Float64(exp(a) + exp(b)) / exp(a))) end
function tmp = code(a, b) tmp = 1.0 / ((exp(a) + exp(b)) / exp(a)); end
code[a_, b_] := N[(1.0 / N[(N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision] / N[Exp[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{e^{a} + e^{b}}{e^{a}}}
\end{array}
Initial program 99.6%
Applied egg-rr0
(FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (/ (exp a) 2.0) (exp (- (log1p (exp b))))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = exp(a) / 2.0;
} else {
tmp = exp(-log1p(exp(b)));
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = Math.exp(a) / 2.0;
} else {
tmp = Math.exp(-Math.log1p(Math.exp(b)));
}
return tmp;
}
def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = math.exp(a) / 2.0 else: tmp = math.exp(-math.log1p(math.exp(b))) return tmp
function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(exp(a) / 2.0); else tmp = exp(Float64(-log1p(exp(b)))); end return tmp end
code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(N[Exp[a], $MachinePrecision] / 2.0), $MachinePrecision], N[Exp[(-N[Log[1 + N[Exp[b], $MachinePrecision]], $MachinePrecision])], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{e^{a}}{2}\\
\mathbf{else}:\\
\;\;\;\;e^{-\mathsf{log1p}\left(e^{b}\right)}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 100.0%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around 0 0
Simplified0
if 0.0 < (exp.f64 a) Initial program 99.4%
Taylor expanded in a around 0 0
Simplified0
Applied egg-rr0
Applied egg-rr0
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Initial program 99.6%
(FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (/ (exp a) 2.0) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = exp(a) / 2.0;
} 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 (exp(a) <= 0.0d0) then
tmp = exp(a) / 2.0d0
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 (Math.exp(a) <= 0.0) {
tmp = Math.exp(a) / 2.0;
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = math.exp(a) / 2.0 else: tmp = 1.0 / (1.0 + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(exp(a) / 2.0); else tmp = Float64(1.0 / Float64(1.0 + exp(b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (exp(a) <= 0.0) tmp = exp(a) / 2.0; else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(N[Exp[a], $MachinePrecision] / 2.0), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{e^{a}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 100.0%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around 0 0
Simplified0
if 0.0 < (exp.f64 a) Initial program 99.4%
Taylor expanded in a around 0 0
Simplified0
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ 0.5 (* b 0.16666666666666666)))
(t_1 (* b t_0))
(t_2 (* t_1 (* (* b b) (* t_0 t_0)))))
(if (<= b 2.1e-44)
(+ 0.5 (* a 0.25))
(if (<= b 1.65e+31)
(/
1.0
(+
2.0
(/
(* (- 1.0 (* t_2 t_2)) b)
(* (- 1.0 t_2) (+ 1.0 (* b (* t_0 (+ t_1 -1.0))))))))
(/
1.0
(+
2.0
(/ (* (+ 1.0 (* t_1 (* b (* t_0 t_1)))) b) (+ 1.0 (* -0.5 b)))))))))
double code(double a, double b) {
double t_0 = 0.5 + (b * 0.16666666666666666);
double t_1 = b * t_0;
double t_2 = t_1 * ((b * b) * (t_0 * t_0));
double tmp;
if (b <= 2.1e-44) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 1.65e+31) {
tmp = 1.0 / (2.0 + (((1.0 - (t_2 * t_2)) * b) / ((1.0 - t_2) * (1.0 + (b * (t_0 * (t_1 + -1.0)))))));
} else {
tmp = 1.0 / (2.0 + (((1.0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0 + (-0.5 * b))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 0.5d0 + (b * 0.16666666666666666d0)
t_1 = b * t_0
t_2 = t_1 * ((b * b) * (t_0 * t_0))
if (b <= 2.1d-44) then
tmp = 0.5d0 + (a * 0.25d0)
else if (b <= 1.65d+31) then
tmp = 1.0d0 / (2.0d0 + (((1.0d0 - (t_2 * t_2)) * b) / ((1.0d0 - t_2) * (1.0d0 + (b * (t_0 * (t_1 + (-1.0d0))))))))
else
tmp = 1.0d0 / (2.0d0 + (((1.0d0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0d0 + ((-0.5d0) * b))))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = 0.5 + (b * 0.16666666666666666);
double t_1 = b * t_0;
double t_2 = t_1 * ((b * b) * (t_0 * t_0));
double tmp;
if (b <= 2.1e-44) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 1.65e+31) {
tmp = 1.0 / (2.0 + (((1.0 - (t_2 * t_2)) * b) / ((1.0 - t_2) * (1.0 + (b * (t_0 * (t_1 + -1.0)))))));
} else {
tmp = 1.0 / (2.0 + (((1.0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0 + (-0.5 * b))));
}
return tmp;
}
def code(a, b): t_0 = 0.5 + (b * 0.16666666666666666) t_1 = b * t_0 t_2 = t_1 * ((b * b) * (t_0 * t_0)) tmp = 0 if b <= 2.1e-44: tmp = 0.5 + (a * 0.25) elif b <= 1.65e+31: tmp = 1.0 / (2.0 + (((1.0 - (t_2 * t_2)) * b) / ((1.0 - t_2) * (1.0 + (b * (t_0 * (t_1 + -1.0))))))) else: tmp = 1.0 / (2.0 + (((1.0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0 + (-0.5 * b)))) return tmp
function code(a, b) t_0 = Float64(0.5 + Float64(b * 0.16666666666666666)) t_1 = Float64(b * t_0) t_2 = Float64(t_1 * Float64(Float64(b * b) * Float64(t_0 * t_0))) tmp = 0.0 if (b <= 2.1e-44) tmp = Float64(0.5 + Float64(a * 0.25)); elseif (b <= 1.65e+31) tmp = Float64(1.0 / Float64(2.0 + Float64(Float64(Float64(1.0 - Float64(t_2 * t_2)) * b) / Float64(Float64(1.0 - t_2) * Float64(1.0 + Float64(b * Float64(t_0 * Float64(t_1 + -1.0)))))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(Float64(Float64(1.0 + Float64(t_1 * Float64(b * Float64(t_0 * t_1)))) * b) / Float64(1.0 + Float64(-0.5 * b))))); end return tmp end
function tmp_2 = code(a, b) t_0 = 0.5 + (b * 0.16666666666666666); t_1 = b * t_0; t_2 = t_1 * ((b * b) * (t_0 * t_0)); tmp = 0.0; if (b <= 2.1e-44) tmp = 0.5 + (a * 0.25); elseif (b <= 1.65e+31) tmp = 1.0 / (2.0 + (((1.0 - (t_2 * t_2)) * b) / ((1.0 - t_2) * (1.0 + (b * (t_0 * (t_1 + -1.0))))))); else tmp = 1.0 / (2.0 + (((1.0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0 + (-0.5 * b)))); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[(b * b), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 2.1e-44], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.65e+31], N[(1.0 / N[(2.0 + N[(N[(N[(1.0 - N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] / N[(N[(1.0 - t$95$2), $MachinePrecision] * N[(1.0 + N[(b * N[(t$95$0 * N[(t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(N[(N[(1.0 + N[(t$95$1 * N[(b * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] / N[(1.0 + N[(-0.5 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + b \cdot 0.16666666666666666\\
t_1 := b \cdot t\_0\\
t_2 := t\_1 \cdot \left(\left(b \cdot b\right) \cdot \left(t\_0 \cdot t\_0\right)\right)\\
\mathbf{if}\;b \leq 2.1 \cdot 10^{-44}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{+31}:\\
\;\;\;\;\frac{1}{2 + \frac{\left(1 - t\_2 \cdot t\_2\right) \cdot b}{\left(1 - t\_2\right) \cdot \left(1 + b \cdot \left(t\_0 \cdot \left(t\_1 + -1\right)\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + \frac{\left(1 + t\_1 \cdot \left(b \cdot \left(t\_0 \cdot t\_1\right)\right)\right) \cdot b}{1 + -0.5 \cdot b}}\\
\end{array}
\end{array}
if b < 2.10000000000000001e-44Initial program 99.4%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around 0 0
Simplified0
if 2.10000000000000001e-44 < b < 1.64999999999999996e31Initial program 99.8%
Taylor expanded in a around 0 0
Simplified0
Taylor expanded in b around 0 0
Simplified0
Applied egg-rr0
Applied egg-rr0
if 1.64999999999999996e31 < b Initial program 100.0%
Taylor expanded in a around 0 0
Simplified0
Taylor expanded in b around 0 0
Simplified0
Applied egg-rr0
Taylor expanded in b around 0 0
Simplified0
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ 0.5 (* b 0.16666666666666666))) (t_1 (* b t_0)))
(if (<= b 4.1e+35)
(/ (exp a) 2.0)
(/
1.0
(+
2.0
(/ (* (+ 1.0 (* t_1 (* b (* t_0 t_1)))) b) (+ 1.0 (* -0.5 b))))))))
double code(double a, double b) {
double t_0 = 0.5 + (b * 0.16666666666666666);
double t_1 = b * t_0;
double tmp;
if (b <= 4.1e+35) {
tmp = exp(a) / 2.0;
} else {
tmp = 1.0 / (2.0 + (((1.0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0 + (-0.5 * b))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 + (b * 0.16666666666666666d0)
t_1 = b * t_0
if (b <= 4.1d+35) then
tmp = exp(a) / 2.0d0
else
tmp = 1.0d0 / (2.0d0 + (((1.0d0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0d0 + ((-0.5d0) * b))))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = 0.5 + (b * 0.16666666666666666);
double t_1 = b * t_0;
double tmp;
if (b <= 4.1e+35) {
tmp = Math.exp(a) / 2.0;
} else {
tmp = 1.0 / (2.0 + (((1.0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0 + (-0.5 * b))));
}
return tmp;
}
def code(a, b): t_0 = 0.5 + (b * 0.16666666666666666) t_1 = b * t_0 tmp = 0 if b <= 4.1e+35: tmp = math.exp(a) / 2.0 else: tmp = 1.0 / (2.0 + (((1.0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0 + (-0.5 * b)))) return tmp
function code(a, b) t_0 = Float64(0.5 + Float64(b * 0.16666666666666666)) t_1 = Float64(b * t_0) tmp = 0.0 if (b <= 4.1e+35) tmp = Float64(exp(a) / 2.0); else tmp = Float64(1.0 / Float64(2.0 + Float64(Float64(Float64(1.0 + Float64(t_1 * Float64(b * Float64(t_0 * t_1)))) * b) / Float64(1.0 + Float64(-0.5 * b))))); end return tmp end
function tmp_2 = code(a, b) t_0 = 0.5 + (b * 0.16666666666666666); t_1 = b * t_0; tmp = 0.0; if (b <= 4.1e+35) tmp = exp(a) / 2.0; else tmp = 1.0 / (2.0 + (((1.0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0 + (-0.5 * b)))); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b * t$95$0), $MachinePrecision]}, If[LessEqual[b, 4.1e+35], N[(N[Exp[a], $MachinePrecision] / 2.0), $MachinePrecision], N[(1.0 / N[(2.0 + N[(N[(N[(1.0 + N[(t$95$1 * N[(b * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] / N[(1.0 + N[(-0.5 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + b \cdot 0.16666666666666666\\
t_1 := b \cdot t\_0\\
\mathbf{if}\;b \leq 4.1 \cdot 10^{+35}:\\
\;\;\;\;\frac{e^{a}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + \frac{\left(1 + t\_1 \cdot \left(b \cdot \left(t\_0 \cdot t\_1\right)\right)\right) \cdot b}{1 + -0.5 \cdot b}}\\
\end{array}
\end{array}
if b < 4.0999999999999998e35Initial program 99.4%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around 0 0
Simplified0
if 4.0999999999999998e35 < b Initial program 100.0%
Taylor expanded in a around 0 0
Simplified0
Taylor expanded in b around 0 0
Simplified0
Applied egg-rr0
Taylor expanded in b around 0 0
Simplified0
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ 0.5 (* b 0.16666666666666666))) (t_1 (* b t_0)))
(if (<= b 3e-40)
(+ 0.5 (* a 0.25))
(if (<= b 1e+102)
(/ 1.0 (+ 2.0 (/ (* (- 1.0 (* b (* t_0 t_1))) b) (- 1.0 t_1))))
(/ 6.0 (* b (* b b)))))))
double code(double a, double b) {
double t_0 = 0.5 + (b * 0.16666666666666666);
double t_1 = b * t_0;
double tmp;
if (b <= 3e-40) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 1e+102) {
tmp = 1.0 / (2.0 + (((1.0 - (b * (t_0 * t_1))) * b) / (1.0 - t_1)));
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 + (b * 0.16666666666666666d0)
t_1 = b * t_0
if (b <= 3d-40) then
tmp = 0.5d0 + (a * 0.25d0)
else if (b <= 1d+102) then
tmp = 1.0d0 / (2.0d0 + (((1.0d0 - (b * (t_0 * t_1))) * b) / (1.0d0 - t_1)))
else
tmp = 6.0d0 / (b * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = 0.5 + (b * 0.16666666666666666);
double t_1 = b * t_0;
double tmp;
if (b <= 3e-40) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 1e+102) {
tmp = 1.0 / (2.0 + (((1.0 - (b * (t_0 * t_1))) * b) / (1.0 - t_1)));
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
def code(a, b): t_0 = 0.5 + (b * 0.16666666666666666) t_1 = b * t_0 tmp = 0 if b <= 3e-40: tmp = 0.5 + (a * 0.25) elif b <= 1e+102: tmp = 1.0 / (2.0 + (((1.0 - (b * (t_0 * t_1))) * b) / (1.0 - t_1))) else: tmp = 6.0 / (b * (b * b)) return tmp
function code(a, b) t_0 = Float64(0.5 + Float64(b * 0.16666666666666666)) t_1 = Float64(b * t_0) tmp = 0.0 if (b <= 3e-40) tmp = Float64(0.5 + Float64(a * 0.25)); elseif (b <= 1e+102) tmp = Float64(1.0 / Float64(2.0 + Float64(Float64(Float64(1.0 - Float64(b * Float64(t_0 * t_1))) * b) / Float64(1.0 - t_1)))); else tmp = Float64(6.0 / Float64(b * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) t_0 = 0.5 + (b * 0.16666666666666666); t_1 = b * t_0; tmp = 0.0; if (b <= 3e-40) tmp = 0.5 + (a * 0.25); elseif (b <= 1e+102) tmp = 1.0 / (2.0 + (((1.0 - (b * (t_0 * t_1))) * b) / (1.0 - t_1))); else tmp = 6.0 / (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b * t$95$0), $MachinePrecision]}, If[LessEqual[b, 3e-40], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e+102], N[(1.0 / N[(2.0 + N[(N[(N[(1.0 - N[(b * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] / N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + b \cdot 0.16666666666666666\\
t_1 := b \cdot t\_0\\
\mathbf{if}\;b \leq 3 \cdot 10^{-40}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{elif}\;b \leq 10^{+102}:\\
\;\;\;\;\frac{1}{2 + \frac{\left(1 - b \cdot \left(t\_0 \cdot t\_1\right)\right) \cdot b}{1 - t\_1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\
\end{array}
\end{array}
if b < 3.0000000000000002e-40Initial program 99.4%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around 0 0
Simplified0
if 3.0000000000000002e-40 < b < 9.99999999999999977e101Initial program 99.9%
Taylor expanded in a around 0 0
Simplified0
Taylor expanded in b around 0 0
Simplified0
Applied egg-rr0
if 9.99999999999999977e101 < b Initial program 100.0%
Taylor expanded in a around 0 0
Simplified0
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in b around inf 0
Simplified0
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ 0.5 (* b 0.16666666666666666))) (t_1 (* b t_0)))
(if (<= b 7e-40)
(+ 0.5 (* a 0.25))
(/
1.0
(+
2.0
(/ (* (+ 1.0 (* t_1 (* b (* t_0 t_1)))) b) (+ 1.0 (* -0.5 b))))))))
double code(double a, double b) {
double t_0 = 0.5 + (b * 0.16666666666666666);
double t_1 = b * t_0;
double tmp;
if (b <= 7e-40) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = 1.0 / (2.0 + (((1.0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0 + (-0.5 * b))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 + (b * 0.16666666666666666d0)
t_1 = b * t_0
if (b <= 7d-40) then
tmp = 0.5d0 + (a * 0.25d0)
else
tmp = 1.0d0 / (2.0d0 + (((1.0d0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0d0 + ((-0.5d0) * b))))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = 0.5 + (b * 0.16666666666666666);
double t_1 = b * t_0;
double tmp;
if (b <= 7e-40) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = 1.0 / (2.0 + (((1.0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0 + (-0.5 * b))));
}
return tmp;
}
def code(a, b): t_0 = 0.5 + (b * 0.16666666666666666) t_1 = b * t_0 tmp = 0 if b <= 7e-40: tmp = 0.5 + (a * 0.25) else: tmp = 1.0 / (2.0 + (((1.0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0 + (-0.5 * b)))) return tmp
function code(a, b) t_0 = Float64(0.5 + Float64(b * 0.16666666666666666)) t_1 = Float64(b * t_0) tmp = 0.0 if (b <= 7e-40) tmp = Float64(0.5 + Float64(a * 0.25)); else tmp = Float64(1.0 / Float64(2.0 + Float64(Float64(Float64(1.0 + Float64(t_1 * Float64(b * Float64(t_0 * t_1)))) * b) / Float64(1.0 + Float64(-0.5 * b))))); end return tmp end
function tmp_2 = code(a, b) t_0 = 0.5 + (b * 0.16666666666666666); t_1 = b * t_0; tmp = 0.0; if (b <= 7e-40) tmp = 0.5 + (a * 0.25); else tmp = 1.0 / (2.0 + (((1.0 + (t_1 * (b * (t_0 * t_1)))) * b) / (1.0 + (-0.5 * b)))); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b * t$95$0), $MachinePrecision]}, If[LessEqual[b, 7e-40], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(N[(N[(1.0 + N[(t$95$1 * N[(b * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] / N[(1.0 + N[(-0.5 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + b \cdot 0.16666666666666666\\
t_1 := b \cdot t\_0\\
\mathbf{if}\;b \leq 7 \cdot 10^{-40}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + \frac{\left(1 + t\_1 \cdot \left(b \cdot \left(t\_0 \cdot t\_1\right)\right)\right) \cdot b}{1 + -0.5 \cdot b}}\\
\end{array}
\end{array}
if b < 7.0000000000000003e-40Initial program 99.4%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around 0 0
Simplified0
if 7.0000000000000003e-40 < b Initial program 100.0%
Taylor expanded in a around 0 0
Simplified0
Taylor expanded in b around 0 0
Simplified0
Applied egg-rr0
Taylor expanded in b around 0 0
Simplified0
(FPCore (a b)
:precision binary64
(let* ((t_0 (* b (* b b))))
(if (<= b 1e-42)
(+ 0.5 (* a 0.25))
(if (<= b 1e+102)
(/
1.0
(+
2.0
(*
b
(+
1.0
(/
(* (+ 0.125 (* t_0 0.004629629629629629)) b)
(+
0.25
(*
(* b 0.16666666666666666)
(+ (* b 0.16666666666666666) -0.5))))))))
(/ 6.0 t_0)))))
double code(double a, double b) {
double t_0 = b * (b * b);
double tmp;
if (b <= 1e-42) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 1e+102) {
tmp = 1.0 / (2.0 + (b * (1.0 + (((0.125 + (t_0 * 0.004629629629629629)) * b) / (0.25 + ((b * 0.16666666666666666) * ((b * 0.16666666666666666) + -0.5)))))));
} else {
tmp = 6.0 / t_0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: tmp
t_0 = b * (b * b)
if (b <= 1d-42) then
tmp = 0.5d0 + (a * 0.25d0)
else if (b <= 1d+102) then
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (((0.125d0 + (t_0 * 0.004629629629629629d0)) * b) / (0.25d0 + ((b * 0.16666666666666666d0) * ((b * 0.16666666666666666d0) + (-0.5d0))))))))
else
tmp = 6.0d0 / t_0
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = b * (b * b);
double tmp;
if (b <= 1e-42) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 1e+102) {
tmp = 1.0 / (2.0 + (b * (1.0 + (((0.125 + (t_0 * 0.004629629629629629)) * b) / (0.25 + ((b * 0.16666666666666666) * ((b * 0.16666666666666666) + -0.5)))))));
} else {
tmp = 6.0 / t_0;
}
return tmp;
}
def code(a, b): t_0 = b * (b * b) tmp = 0 if b <= 1e-42: tmp = 0.5 + (a * 0.25) elif b <= 1e+102: tmp = 1.0 / (2.0 + (b * (1.0 + (((0.125 + (t_0 * 0.004629629629629629)) * b) / (0.25 + ((b * 0.16666666666666666) * ((b * 0.16666666666666666) + -0.5))))))) else: tmp = 6.0 / t_0 return tmp
function code(a, b) t_0 = Float64(b * Float64(b * b)) tmp = 0.0 if (b <= 1e-42) tmp = Float64(0.5 + Float64(a * 0.25)); elseif (b <= 1e+102) tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(Float64(Float64(0.125 + Float64(t_0 * 0.004629629629629629)) * b) / Float64(0.25 + Float64(Float64(b * 0.16666666666666666) * Float64(Float64(b * 0.16666666666666666) + -0.5)))))))); else tmp = Float64(6.0 / t_0); end return tmp end
function tmp_2 = code(a, b) t_0 = b * (b * b); tmp = 0.0; if (b <= 1e-42) tmp = 0.5 + (a * 0.25); elseif (b <= 1e+102) tmp = 1.0 / (2.0 + (b * (1.0 + (((0.125 + (t_0 * 0.004629629629629629)) * b) / (0.25 + ((b * 0.16666666666666666) * ((b * 0.16666666666666666) + -0.5))))))); else tmp = 6.0 / t_0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 1e-42], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1e+102], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(N[(N[(0.125 + N[(t$95$0 * 0.004629629629629629), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] / N[(0.25 + N[(N[(b * 0.16666666666666666), $MachinePrecision] * N[(N[(b * 0.16666666666666666), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(6.0 / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \left(b \cdot b\right)\\
\mathbf{if}\;b \leq 10^{-42}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{elif}\;b \leq 10^{+102}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + \frac{\left(0.125 + t\_0 \cdot 0.004629629629629629\right) \cdot b}{0.25 + \left(b \cdot 0.16666666666666666\right) \cdot \left(b \cdot 0.16666666666666666 + -0.5\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{6}{t\_0}\\
\end{array}
\end{array}
if b < 1.00000000000000004e-42Initial program 99.4%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around 0 0
Simplified0
if 1.00000000000000004e-42 < b < 9.99999999999999977e101Initial program 99.9%
Taylor expanded in a around 0 0
Simplified0
Taylor expanded in b around 0 0
Simplified0
Applied egg-rr0
if 9.99999999999999977e101 < b Initial program 100.0%
Taylor expanded in a around 0 0
Simplified0
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in b around inf 0
Simplified0
(FPCore (a b) :precision binary64 (if (<= b 7.6e-44) (+ 0.5 (* a 0.25)) (/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666)))))))))
double code(double a, double b) {
double tmp;
if (b <= 7.6e-44) {
tmp = 0.5 + (a * 0.25);
} 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 <= 7.6d-44) then
tmp = 0.5d0 + (a * 0.25d0)
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 <= 7.6e-44) {
tmp = 0.5 + (a * 0.25);
} 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 <= 7.6e-44: tmp = 0.5 + (a * 0.25) 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 <= 7.6e-44) tmp = Float64(0.5 + Float64(a * 0.25)); 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 <= 7.6e-44) tmp = 0.5 + (a * 0.25); 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, 7.6e-44], N[(0.5 + N[(a * 0.25), $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 7.6 \cdot 10^{-44}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\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 < 7.6000000000000002e-44Initial program 99.4%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around 0 0
Simplified0
if 7.6000000000000002e-44 < b Initial program 100.0%
Taylor expanded in a around 0 0
Simplified0
Taylor expanded in b around 0 0
Simplified0
(FPCore (a b) :precision binary64 (if (<= b 2.0) (+ 0.5 (* a 0.25)) (/ 6.0 (* b (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 2.0) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 2.0d0) then
tmp = 0.5d0 + (a * 0.25d0)
else
tmp = 6.0d0 / (b * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 2.0) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.0: tmp = 0.5 + (a * 0.25) else: tmp = 6.0 / (b * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (b <= 2.0) tmp = Float64(0.5 + Float64(a * 0.25)); else tmp = Float64(6.0 / Float64(b * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.0) tmp = 0.5 + (a * 0.25); else tmp = 6.0 / (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2.0], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\
\end{array}
\end{array}
if b < 2Initial program 99.4%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around 0 0
Simplified0
if 2 < b Initial program 100.0%
Taylor expanded in a around 0 0
Simplified0
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in b around inf 0
Simplified0
(FPCore (a b) :precision binary64 (if (<= a -580.0) (* 0.020833333333333332 (* b (* b b))) (+ 0.5 (* a 0.25))))
double code(double a, double b) {
double tmp;
if (a <= -580.0) {
tmp = 0.020833333333333332 * (b * (b * b));
} else {
tmp = 0.5 + (a * 0.25);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-580.0d0)) then
tmp = 0.020833333333333332d0 * (b * (b * b))
else
tmp = 0.5d0 + (a * 0.25d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -580.0) {
tmp = 0.020833333333333332 * (b * (b * b));
} else {
tmp = 0.5 + (a * 0.25);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -580.0: tmp = 0.020833333333333332 * (b * (b * b)) else: tmp = 0.5 + (a * 0.25) return tmp
function code(a, b) tmp = 0.0 if (a <= -580.0) tmp = Float64(0.020833333333333332 * Float64(b * Float64(b * b))); else tmp = Float64(0.5 + Float64(a * 0.25)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -580.0) tmp = 0.020833333333333332 * (b * (b * b)); else tmp = 0.5 + (a * 0.25); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -580.0], N[(0.020833333333333332 * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -580:\\
\;\;\;\;0.020833333333333332 \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\end{array}
\end{array}
if a < -580Initial program 100.0%
Taylor expanded in a around 0 0
Simplified0
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in b around inf 0
Simplified0
if -580 < a Initial program 99.4%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around 0 0
Simplified0
(FPCore (a b) :precision binary64 (+ 0.5 (* a 0.25)))
double code(double a, double b) {
return 0.5 + (a * 0.25);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0 + (a * 0.25d0)
end function
public static double code(double a, double b) {
return 0.5 + (a * 0.25);
}
def code(a, b): return 0.5 + (a * 0.25)
function code(a, b) return Float64(0.5 + Float64(a * 0.25)) end
function tmp = code(a, b) tmp = 0.5 + (a * 0.25); end
code[a_, b_] := N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 + a \cdot 0.25
\end{array}
Initial program 99.6%
Taylor expanded in b around 0 0
Simplified0
Taylor expanded in a around 0 0
Simplified0
(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.6%
Taylor expanded in a around 0 0
Simplified0
Taylor expanded in b around 0 0
Simplified0
(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 2024111
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:alt
(! :herbie-platform default (/ 1 (+ 1 (exp (- b a)))))
(/ (exp a) (+ (exp a) (exp b))))