
(FPCore (a b) :precision binary64 (log (+ (exp a) (exp b))))
double code(double a, double b) {
return log((exp(a) + exp(b)));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = log((exp(a) + exp(b)))
end function
public static double code(double a, double b) {
return Math.log((Math.exp(a) + Math.exp(b)));
}
def code(a, b): return math.log((math.exp(a) + math.exp(b)))
function code(a, b) return log(Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = log((exp(a) + exp(b))); end
code[a_, b_] := N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(e^{a} + e^{b}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (log (+ (exp a) (exp b))))
double code(double a, double b) {
return log((exp(a) + exp(b)));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = log((exp(a) + exp(b)))
end function
public static double code(double a, double b) {
return Math.log((Math.exp(a) + Math.exp(b)));
}
def code(a, b): return math.log((math.exp(a) + math.exp(b)))
function code(a, b) return log(Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = log((exp(a) + exp(b))); end
code[a_, b_] := N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(e^{a} + e^{b}\right)
\end{array}
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (/ b (+ (exp a) 1.0)) (if (<= (exp a) 0.99999995) (log1p (exp a)) (log1p (+ a (exp b))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b / (exp(a) + 1.0);
} else if (exp(a) <= 0.99999995) {
tmp = log1p(exp(a));
} else {
tmp = log1p((a + exp(b)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b / (Math.exp(a) + 1.0);
} else if (Math.exp(a) <= 0.99999995) {
tmp = Math.log1p(Math.exp(a));
} else {
tmp = Math.log1p((a + Math.exp(b)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = b / (math.exp(a) + 1.0) elif math.exp(a) <= 0.99999995: tmp = math.log1p(math.exp(a)) else: tmp = math.log1p((a + math.exp(b))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(b / Float64(exp(a) + 1.0)); elseif (exp(a) <= 0.99999995) tmp = log1p(exp(a)); else tmp = log1p(Float64(a + exp(b))); end return tmp end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[a], $MachinePrecision], 0.99999995], N[Log[1 + N[Exp[a], $MachinePrecision]], $MachinePrecision], N[Log[1 + N[(a + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{elif}\;e^{a} \leq 0.99999995:\\
\;\;\;\;\mathsf{log1p}\left(e^{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(a + e^{b}\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 7.7%
Taylor expanded in b around 0 98.4%
log1p-define98.4%
Simplified98.4%
Taylor expanded in b around inf 98.4%
if 0.0 < (exp.f64 a) < 0.999999949999999971Initial program 85.6%
Taylor expanded in b around 0 85.6%
log1p-define99.7%
Simplified99.7%
if 0.999999949999999971 < (exp.f64 a) Initial program 63.9%
Taylor expanded in a around 0 62.6%
+-commutative62.6%
Simplified62.6%
log1p-define97.9%
Applied egg-rr97.9%
Final simplification98.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (/ b (+ (exp a) 1.0)) (if (<= (exp a) 0.99999995) (log1p (exp a)) (log1p (exp b)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b / (exp(a) + 1.0);
} else if (exp(a) <= 0.99999995) {
tmp = log1p(exp(a));
} else {
tmp = log1p(exp(b));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b / (Math.exp(a) + 1.0);
} else if (Math.exp(a) <= 0.99999995) {
tmp = Math.log1p(Math.exp(a));
} else {
tmp = Math.log1p(Math.exp(b));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = b / (math.exp(a) + 1.0) elif math.exp(a) <= 0.99999995: tmp = math.log1p(math.exp(a)) else: tmp = math.log1p(math.exp(b)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(b / Float64(exp(a) + 1.0)); elseif (exp(a) <= 0.99999995) tmp = log1p(exp(a)); else tmp = log1p(exp(b)); end return tmp end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[a], $MachinePrecision], 0.99999995], N[Log[1 + N[Exp[a], $MachinePrecision]], $MachinePrecision], N[Log[1 + N[Exp[b], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{elif}\;e^{a} \leq 0.99999995:\\
\;\;\;\;\mathsf{log1p}\left(e^{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(e^{b}\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 7.7%
Taylor expanded in b around 0 98.4%
log1p-define98.4%
Simplified98.4%
Taylor expanded in b around inf 98.4%
if 0.0 < (exp.f64 a) < 0.999999949999999971Initial program 85.6%
Taylor expanded in b around 0 85.6%
log1p-define99.7%
Simplified99.7%
if 0.999999949999999971 < (exp.f64 a) Initial program 63.9%
Taylor expanded in a around 0 60.8%
log1p-define61.3%
Simplified61.3%
Final simplification70.5%
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b)
:precision binary64
(if (<= (exp a) 0.0)
(/ b (+ (exp a) 1.0))
(if (<= (exp a) 0.99999999)
(log1p (exp a))
(+ (log 2.0) (* b (+ 0.5 (* b 0.125)))))))assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b / (exp(a) + 1.0);
} else if (exp(a) <= 0.99999999) {
tmp = log1p(exp(a));
} else {
tmp = log(2.0) + (b * (0.5 + (b * 0.125)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b / (Math.exp(a) + 1.0);
} else if (Math.exp(a) <= 0.99999999) {
tmp = Math.log1p(Math.exp(a));
} else {
tmp = Math.log(2.0) + (b * (0.5 + (b * 0.125)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = b / (math.exp(a) + 1.0) elif math.exp(a) <= 0.99999999: tmp = math.log1p(math.exp(a)) else: tmp = math.log(2.0) + (b * (0.5 + (b * 0.125))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(b / Float64(exp(a) + 1.0)); elseif (exp(a) <= 0.99999999) tmp = log1p(exp(a)); else tmp = Float64(log(2.0) + Float64(b * Float64(0.5 + Float64(b * 0.125)))); end return tmp end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[a], $MachinePrecision], 0.99999999], N[Log[1 + N[Exp[a], $MachinePrecision]], $MachinePrecision], N[(N[Log[2.0], $MachinePrecision] + N[(b * N[(0.5 + N[(b * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{elif}\;e^{a} \leq 0.99999999:\\
\;\;\;\;\mathsf{log1p}\left(e^{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\log 2 + b \cdot \left(0.5 + b \cdot 0.125\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 7.7%
Taylor expanded in b around 0 98.4%
log1p-define98.4%
Simplified98.4%
Taylor expanded in b around inf 98.4%
if 0.0 < (exp.f64 a) < 0.99999998999999995Initial program 85.6%
Taylor expanded in b around 0 85.6%
log1p-define99.7%
Simplified99.7%
if 0.99999998999999995 < (exp.f64 a) Initial program 63.9%
Taylor expanded in a around 0 60.8%
Taylor expanded in b around 0 59.0%
Final simplification68.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (/ b (+ (exp a) 1.0)) (log (+ (exp a) (exp b)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b / (exp(a) + 1.0);
} else {
tmp = log((exp(a) + exp(b)));
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
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 = b / (exp(a) + 1.0d0)
else
tmp = log((exp(a) + exp(b)))
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b / (Math.exp(a) + 1.0);
} else {
tmp = Math.log((Math.exp(a) + Math.exp(b)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = b / (math.exp(a) + 1.0) else: tmp = math.log((math.exp(a) + math.exp(b))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(b / Float64(exp(a) + 1.0)); else tmp = log(Float64(exp(a) + exp(b))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (exp(a) <= 0.0)
tmp = b / (exp(a) + 1.0);
else
tmp = log((exp(a) + exp(b)));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{a} + e^{b}\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 7.7%
Taylor expanded in b around 0 98.4%
log1p-define98.4%
Simplified98.4%
Taylor expanded in b around inf 98.4%
if 0.0 < (exp.f64 a) Initial program 64.4%
Final simplification72.1%
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ (exp a) 1.0)))
(if (<= (exp a) 0.0)
(/ b t_0)
(log (+ t_0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666))))))))))assert(a < b);
double code(double a, double b) {
double t_0 = exp(a) + 1.0;
double tmp;
if (exp(a) <= 0.0) {
tmp = b / t_0;
} else {
tmp = log((t_0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))));
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
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 = exp(a) + 1.0d0
if (exp(a) <= 0.0d0) then
tmp = b / t_0
else
tmp = log((t_0 + (b * (1.0d0 + (b * (0.5d0 + (b * 0.16666666666666666d0)))))))
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double t_0 = Math.exp(a) + 1.0;
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b / t_0;
} else {
tmp = Math.log((t_0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): t_0 = math.exp(a) + 1.0 tmp = 0 if math.exp(a) <= 0.0: tmp = b / t_0 else: tmp = math.log((t_0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))))) return tmp
a, b = sort([a, b]) function code(a, b) t_0 = Float64(exp(a) + 1.0) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(b / t_0); else tmp = log(Float64(t_0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(b * 0.16666666666666666))))))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
t_0 = exp(a) + 1.0;
tmp = 0.0;
if (exp(a) <= 0.0)
tmp = b / t_0;
else
tmp = log((t_0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := Block[{t$95$0 = N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(b / t$95$0), $MachinePrecision], N[Log[N[(t$95$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}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_0 := e^{a} + 1\\
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\log \left(t\_0 + b \cdot \left(1 + b \cdot \left(0.5 + b \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 7.7%
Taylor expanded in b around 0 98.4%
log1p-define98.4%
Simplified98.4%
Taylor expanded in b around inf 98.4%
if 0.0 < (exp.f64 a) Initial program 64.4%
Taylor expanded in b around 0 60.9%
associate-+r+60.9%
*-commutative60.9%
Simplified60.9%
Final simplification69.4%
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b)
:precision binary64
(if (<= (exp a) 0.0)
(/ b (+ (exp a) 1.0))
(if (<= (exp a) 0.99999999)
(+ (log 2.0) (* a (+ 0.5 (* a 0.125))))
(+ (log 2.0) (* b (+ 0.5 (* b 0.125)))))))assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b / (exp(a) + 1.0);
} else if (exp(a) <= 0.99999999) {
tmp = log(2.0) + (a * (0.5 + (a * 0.125)));
} else {
tmp = log(2.0) + (b * (0.5 + (b * 0.125)));
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
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 = b / (exp(a) + 1.0d0)
else if (exp(a) <= 0.99999999d0) then
tmp = log(2.0d0) + (a * (0.5d0 + (a * 0.125d0)))
else
tmp = log(2.0d0) + (b * (0.5d0 + (b * 0.125d0)))
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b / (Math.exp(a) + 1.0);
} else if (Math.exp(a) <= 0.99999999) {
tmp = Math.log(2.0) + (a * (0.5 + (a * 0.125)));
} else {
tmp = Math.log(2.0) + (b * (0.5 + (b * 0.125)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = b / (math.exp(a) + 1.0) elif math.exp(a) <= 0.99999999: tmp = math.log(2.0) + (a * (0.5 + (a * 0.125))) else: tmp = math.log(2.0) + (b * (0.5 + (b * 0.125))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(b / Float64(exp(a) + 1.0)); elseif (exp(a) <= 0.99999999) tmp = Float64(log(2.0) + Float64(a * Float64(0.5 + Float64(a * 0.125)))); else tmp = Float64(log(2.0) + Float64(b * Float64(0.5 + Float64(b * 0.125)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (exp(a) <= 0.0)
tmp = b / (exp(a) + 1.0);
elseif (exp(a) <= 0.99999999)
tmp = log(2.0) + (a * (0.5 + (a * 0.125)));
else
tmp = log(2.0) + (b * (0.5 + (b * 0.125)));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[a], $MachinePrecision], 0.99999999], N[(N[Log[2.0], $MachinePrecision] + N[(a * N[(0.5 + N[(a * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Log[2.0], $MachinePrecision] + N[(b * N[(0.5 + N[(b * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{elif}\;e^{a} \leq 0.99999999:\\
\;\;\;\;\log 2 + a \cdot \left(0.5 + a \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;\log 2 + b \cdot \left(0.5 + b \cdot 0.125\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 7.7%
Taylor expanded in b around 0 98.4%
log1p-define98.4%
Simplified98.4%
Taylor expanded in b around inf 98.4%
if 0.0 < (exp.f64 a) < 0.99999998999999995Initial program 85.6%
Taylor expanded in b around 0 85.6%
log1p-define99.7%
Simplified99.7%
Taylor expanded in a around 0 67.2%
*-commutative67.2%
Simplified67.2%
if 0.99999998999999995 < (exp.f64 a) Initial program 63.9%
Taylor expanded in a around 0 60.8%
Taylor expanded in b around 0 59.0%
Final simplification68.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (let* ((t_0 (+ (exp a) 1.0))) (if (<= (exp a) 0.0) (/ b t_0) (log (+ t_0 (* b (+ 1.0 (* b 0.5))))))))
assert(a < b);
double code(double a, double b) {
double t_0 = exp(a) + 1.0;
double tmp;
if (exp(a) <= 0.0) {
tmp = b / t_0;
} else {
tmp = log((t_0 + (b * (1.0 + (b * 0.5)))));
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
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 = exp(a) + 1.0d0
if (exp(a) <= 0.0d0) then
tmp = b / t_0
else
tmp = log((t_0 + (b * (1.0d0 + (b * 0.5d0)))))
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double t_0 = Math.exp(a) + 1.0;
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b / t_0;
} else {
tmp = Math.log((t_0 + (b * (1.0 + (b * 0.5)))));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): t_0 = math.exp(a) + 1.0 tmp = 0 if math.exp(a) <= 0.0: tmp = b / t_0 else: tmp = math.log((t_0 + (b * (1.0 + (b * 0.5))))) return tmp
a, b = sort([a, b]) function code(a, b) t_0 = Float64(exp(a) + 1.0) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(b / t_0); else tmp = log(Float64(t_0 + Float64(b * Float64(1.0 + Float64(b * 0.5))))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
t_0 = exp(a) + 1.0;
tmp = 0.0;
if (exp(a) <= 0.0)
tmp = b / t_0;
else
tmp = log((t_0 + (b * (1.0 + (b * 0.5)))));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := Block[{t$95$0 = N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(b / t$95$0), $MachinePrecision], N[Log[N[(t$95$0 + N[(b * N[(1.0 + N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_0 := e^{a} + 1\\
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\log \left(t\_0 + b \cdot \left(1 + b \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 7.7%
Taylor expanded in b around 0 98.4%
log1p-define98.4%
Simplified98.4%
Taylor expanded in b around inf 98.4%
if 0.0 < (exp.f64 a) Initial program 64.4%
Taylor expanded in b around 0 61.6%
associate-+r+61.6%
*-commutative61.6%
Simplified61.6%
Final simplification69.9%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (+ (log1p (exp a)) (/ b (+ (exp a) 1.0))))
assert(a < b);
double code(double a, double b) {
return log1p(exp(a)) + (b / (exp(a) + 1.0));
}
assert a < b;
public static double code(double a, double b) {
return Math.log1p(Math.exp(a)) + (b / (Math.exp(a) + 1.0));
}
[a, b] = sort([a, b]) def code(a, b): return math.log1p(math.exp(a)) + (b / (math.exp(a) + 1.0))
a, b = sort([a, b]) function code(a, b) return Float64(log1p(exp(a)) + Float64(b / Float64(exp(a) + 1.0))) end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[Log[1 + N[Exp[a], $MachinePrecision]], $MachinePrecision] + N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\mathsf{log1p}\left(e^{a}\right) + \frac{b}{e^{a} + 1}
\end{array}
Initial program 51.6%
Taylor expanded in b around 0 69.6%
log1p-define69.9%
Simplified69.9%
Final simplification69.9%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (/ b (+ (exp a) 1.0)) (log (+ (+ b 2.0) (* a (+ 1.0 (* a (+ 0.5 (* a 0.16666666666666666)))))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b / (exp(a) + 1.0);
} else {
tmp = log(((b + 2.0) + (a * (1.0 + (a * (0.5 + (a * 0.16666666666666666)))))));
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
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 = b / (exp(a) + 1.0d0)
else
tmp = log(((b + 2.0d0) + (a * (1.0d0 + (a * (0.5d0 + (a * 0.16666666666666666d0)))))))
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b / (Math.exp(a) + 1.0);
} else {
tmp = Math.log(((b + 2.0) + (a * (1.0 + (a * (0.5 + (a * 0.16666666666666666)))))));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = b / (math.exp(a) + 1.0) else: tmp = math.log(((b + 2.0) + (a * (1.0 + (a * (0.5 + (a * 0.16666666666666666))))))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(b / Float64(exp(a) + 1.0)); else tmp = log(Float64(Float64(b + 2.0) + Float64(a * Float64(1.0 + Float64(a * Float64(0.5 + Float64(a * 0.16666666666666666))))))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (exp(a) <= 0.0)
tmp = b / (exp(a) + 1.0);
else
tmp = log(((b + 2.0) + (a * (1.0 + (a * (0.5 + (a * 0.16666666666666666)))))));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[Log[N[(N[(b + 2.0), $MachinePrecision] + N[(a * N[(1.0 + N[(a * N[(0.5 + N[(a * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;\log \left(\left(b + 2\right) + a \cdot \left(1 + a \cdot \left(0.5 + a \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 7.7%
Taylor expanded in b around 0 98.4%
log1p-define98.4%
Simplified98.4%
Taylor expanded in b around inf 98.4%
if 0.0 < (exp.f64 a) Initial program 64.4%
Taylor expanded in b around 0 60.2%
associate-+r+60.2%
+-commutative60.2%
Simplified60.2%
Taylor expanded in a around 0 59.3%
associate-+r+59.3%
*-commutative59.3%
Simplified59.3%
Final simplification68.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (/ b (+ (exp a) 1.0)) (+ (log 2.0) (* a (+ 0.5 (* a 0.125))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b / (exp(a) + 1.0);
} else {
tmp = log(2.0) + (a * (0.5 + (a * 0.125)));
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
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 = b / (exp(a) + 1.0d0)
else
tmp = log(2.0d0) + (a * (0.5d0 + (a * 0.125d0)))
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b / (Math.exp(a) + 1.0);
} else {
tmp = Math.log(2.0) + (a * (0.5 + (a * 0.125)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = b / (math.exp(a) + 1.0) else: tmp = math.log(2.0) + (a * (0.5 + (a * 0.125))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(b / Float64(exp(a) + 1.0)); else tmp = Float64(log(2.0) + Float64(a * Float64(0.5 + Float64(a * 0.125)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (exp(a) <= 0.0)
tmp = b / (exp(a) + 1.0);
else
tmp = log(2.0) + (a * (0.5 + (a * 0.125)));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Log[2.0], $MachinePrecision] + N[(a * N[(0.5 + N[(a * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;\log 2 + a \cdot \left(0.5 + a \cdot 0.125\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 7.7%
Taylor expanded in b around 0 98.4%
log1p-define98.4%
Simplified98.4%
Taylor expanded in b around inf 98.4%
if 0.0 < (exp.f64 a) Initial program 64.4%
Taylor expanded in b around 0 60.3%
log1p-define60.7%
Simplified60.7%
Taylor expanded in a around 0 59.7%
*-commutative59.7%
Simplified59.7%
Final simplification68.5%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= (exp a) 0.0) (/ b (+ (exp a) 1.0)) (+ (* b 0.5) (log 2.0))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b / (exp(a) + 1.0);
} else {
tmp = (b * 0.5) + log(2.0);
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
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 = b / (exp(a) + 1.0d0)
else
tmp = (b * 0.5d0) + log(2.0d0)
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b / (Math.exp(a) + 1.0);
} else {
tmp = (b * 0.5) + Math.log(2.0);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = b / (math.exp(a) + 1.0) else: tmp = (b * 0.5) + math.log(2.0) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = Float64(b / Float64(exp(a) + 1.0)); else tmp = Float64(Float64(b * 0.5) + log(2.0)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (exp(a) <= 0.0)
tmp = b / (exp(a) + 1.0);
else
tmp = (b * 0.5) + log(2.0);
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 0.0], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(b * 0.5), $MachinePrecision] + N[Log[2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;b \cdot 0.5 + \log 2\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 7.7%
Taylor expanded in b around 0 98.4%
log1p-define98.4%
Simplified98.4%
Taylor expanded in b around inf 98.4%
if 0.0 < (exp.f64 a) Initial program 64.4%
Taylor expanded in b around 0 61.2%
log1p-define61.6%
Simplified61.6%
Taylor expanded in a around 0 57.9%
Final simplification67.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -2e+14) (* b 0.5) (if (<= a -9e-8) (+ (log 2.0) (* a 0.5)) (+ (* b 0.5) (log 2.0)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -2e+14) {
tmp = b * 0.5;
} else if (a <= -9e-8) {
tmp = log(2.0) + (a * 0.5);
} else {
tmp = (b * 0.5) + log(2.0);
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-2d+14)) then
tmp = b * 0.5d0
else if (a <= (-9d-8)) then
tmp = log(2.0d0) + (a * 0.5d0)
else
tmp = (b * 0.5d0) + log(2.0d0)
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -2e+14) {
tmp = b * 0.5;
} else if (a <= -9e-8) {
tmp = Math.log(2.0) + (a * 0.5);
} else {
tmp = (b * 0.5) + Math.log(2.0);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -2e+14: tmp = b * 0.5 elif a <= -9e-8: tmp = math.log(2.0) + (a * 0.5) else: tmp = (b * 0.5) + math.log(2.0) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -2e+14) tmp = Float64(b * 0.5); elseif (a <= -9e-8) tmp = Float64(log(2.0) + Float64(a * 0.5)); else tmp = Float64(Float64(b * 0.5) + log(2.0)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -2e+14)
tmp = b * 0.5;
elseif (a <= -9e-8)
tmp = log(2.0) + (a * 0.5);
else
tmp = (b * 0.5) + log(2.0);
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -2e+14], N[(b * 0.5), $MachinePrecision], If[LessEqual[a, -9e-8], N[(N[Log[2.0], $MachinePrecision] + N[(a * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(b * 0.5), $MachinePrecision] + N[Log[2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2 \cdot 10^{+14}:\\
\;\;\;\;b \cdot 0.5\\
\mathbf{elif}\;a \leq -9 \cdot 10^{-8}:\\
\;\;\;\;\log 2 + a \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;b \cdot 0.5 + \log 2\\
\end{array}
\end{array}
if a < -2e14Initial program 8.0%
Taylor expanded in b around 0 100.0%
log1p-define100.0%
Simplified100.0%
Taylor expanded in a around 0 4.2%
Taylor expanded in b around inf 18.8%
*-commutative18.8%
Simplified18.8%
if -2e14 < a < -8.99999999999999986e-8Initial program 43.3%
Taylor expanded in b around 0 43.3%
log1p-define51.9%
Simplified51.9%
Taylor expanded in a around 0 22.3%
+-commutative22.3%
*-commutative22.3%
Simplified22.3%
if -8.99999999999999986e-8 < a Initial program 64.1%
Taylor expanded in b around 0 60.7%
log1p-define60.8%
Simplified60.8%
Taylor expanded in a around 0 58.5%
Final simplification49.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -3700000000.0) (* b 0.5) (if (<= a -9e-8) (log (+ a 2.0)) (+ (* b 0.5) (log 2.0)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -3700000000.0) {
tmp = b * 0.5;
} else if (a <= -9e-8) {
tmp = log((a + 2.0));
} else {
tmp = (b * 0.5) + log(2.0);
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-3700000000.0d0)) then
tmp = b * 0.5d0
else if (a <= (-9d-8)) then
tmp = log((a + 2.0d0))
else
tmp = (b * 0.5d0) + log(2.0d0)
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -3700000000.0) {
tmp = b * 0.5;
} else if (a <= -9e-8) {
tmp = Math.log((a + 2.0));
} else {
tmp = (b * 0.5) + Math.log(2.0);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -3700000000.0: tmp = b * 0.5 elif a <= -9e-8: tmp = math.log((a + 2.0)) else: tmp = (b * 0.5) + math.log(2.0) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -3700000000.0) tmp = Float64(b * 0.5); elseif (a <= -9e-8) tmp = log(Float64(a + 2.0)); else tmp = Float64(Float64(b * 0.5) + log(2.0)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -3700000000.0)
tmp = b * 0.5;
elseif (a <= -9e-8)
tmp = log((a + 2.0));
else
tmp = (b * 0.5) + log(2.0);
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -3700000000.0], N[(b * 0.5), $MachinePrecision], If[LessEqual[a, -9e-8], N[Log[N[(a + 2.0), $MachinePrecision]], $MachinePrecision], N[(N[(b * 0.5), $MachinePrecision] + N[Log[2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3700000000:\\
\;\;\;\;b \cdot 0.5\\
\mathbf{elif}\;a \leq -9 \cdot 10^{-8}:\\
\;\;\;\;\log \left(a + 2\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot 0.5 + \log 2\\
\end{array}
\end{array}
if a < -3.7e9Initial program 7.9%
Taylor expanded in b around 0 100.0%
log1p-define100.0%
Simplified100.0%
Taylor expanded in a around 0 4.2%
Taylor expanded in b around inf 18.8%
*-commutative18.8%
Simplified18.8%
if -3.7e9 < a < -8.99999999999999986e-8Initial program 48.8%
Taylor expanded in a around 0 20.7%
+-commutative20.7%
Simplified20.7%
Taylor expanded in b around 0 20.7%
if -8.99999999999999986e-8 < a Initial program 64.1%
Taylor expanded in b around 0 60.7%
log1p-define60.8%
Simplified60.8%
Taylor expanded in a around 0 58.5%
Final simplification49.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -3700000000.0) (* b 0.5) (if (<= a -9e-8) (log (+ a 2.0)) (log1p (+ b 1.0)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -3700000000.0) {
tmp = b * 0.5;
} else if (a <= -9e-8) {
tmp = log((a + 2.0));
} else {
tmp = log1p((b + 1.0));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -3700000000.0) {
tmp = b * 0.5;
} else if (a <= -9e-8) {
tmp = Math.log((a + 2.0));
} else {
tmp = Math.log1p((b + 1.0));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -3700000000.0: tmp = b * 0.5 elif a <= -9e-8: tmp = math.log((a + 2.0)) else: tmp = math.log1p((b + 1.0)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -3700000000.0) tmp = Float64(b * 0.5); elseif (a <= -9e-8) tmp = log(Float64(a + 2.0)); else tmp = log1p(Float64(b + 1.0)); end return tmp end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -3700000000.0], N[(b * 0.5), $MachinePrecision], If[LessEqual[a, -9e-8], N[Log[N[(a + 2.0), $MachinePrecision]], $MachinePrecision], N[Log[1 + N[(b + 1.0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3700000000:\\
\;\;\;\;b \cdot 0.5\\
\mathbf{elif}\;a \leq -9 \cdot 10^{-8}:\\
\;\;\;\;\log \left(a + 2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(b + 1\right)\\
\end{array}
\end{array}
if a < -3.7e9Initial program 7.9%
Taylor expanded in b around 0 100.0%
log1p-define100.0%
Simplified100.0%
Taylor expanded in a around 0 4.2%
Taylor expanded in b around inf 18.8%
*-commutative18.8%
Simplified18.8%
if -3.7e9 < a < -8.99999999999999986e-8Initial program 48.8%
Taylor expanded in a around 0 20.7%
+-commutative20.7%
Simplified20.7%
Taylor expanded in b around 0 20.7%
if -8.99999999999999986e-8 < a Initial program 64.1%
Taylor expanded in b around 0 59.7%
associate-+r+59.7%
+-commutative59.7%
Simplified59.7%
Taylor expanded in a around 0 59.3%
associate-+r+59.3%
*-commutative59.3%
Simplified59.3%
Taylor expanded in a around 0 57.5%
+-commutative57.5%
Simplified57.5%
log1p-expm1-u57.5%
expm1-undefine57.5%
add-exp-log57.5%
Applied egg-rr57.5%
associate--l+57.5%
metadata-eval57.5%
Simplified57.5%
Final simplification48.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -3700000000.0) (* b 0.5) (if (<= a -9e-8) (log (+ a 2.0)) (log (+ b 2.0)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -3700000000.0) {
tmp = b * 0.5;
} else if (a <= -9e-8) {
tmp = log((a + 2.0));
} else {
tmp = log((b + 2.0));
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-3700000000.0d0)) then
tmp = b * 0.5d0
else if (a <= (-9d-8)) then
tmp = log((a + 2.0d0))
else
tmp = log((b + 2.0d0))
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -3700000000.0) {
tmp = b * 0.5;
} else if (a <= -9e-8) {
tmp = Math.log((a + 2.0));
} else {
tmp = Math.log((b + 2.0));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -3700000000.0: tmp = b * 0.5 elif a <= -9e-8: tmp = math.log((a + 2.0)) else: tmp = math.log((b + 2.0)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -3700000000.0) tmp = Float64(b * 0.5); elseif (a <= -9e-8) tmp = log(Float64(a + 2.0)); else tmp = log(Float64(b + 2.0)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -3700000000.0)
tmp = b * 0.5;
elseif (a <= -9e-8)
tmp = log((a + 2.0));
else
tmp = log((b + 2.0));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -3700000000.0], N[(b * 0.5), $MachinePrecision], If[LessEqual[a, -9e-8], N[Log[N[(a + 2.0), $MachinePrecision]], $MachinePrecision], N[Log[N[(b + 2.0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3700000000:\\
\;\;\;\;b \cdot 0.5\\
\mathbf{elif}\;a \leq -9 \cdot 10^{-8}:\\
\;\;\;\;\log \left(a + 2\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(b + 2\right)\\
\end{array}
\end{array}
if a < -3.7e9Initial program 7.9%
Taylor expanded in b around 0 100.0%
log1p-define100.0%
Simplified100.0%
Taylor expanded in a around 0 4.2%
Taylor expanded in b around inf 18.8%
*-commutative18.8%
Simplified18.8%
if -3.7e9 < a < -8.99999999999999986e-8Initial program 48.8%
Taylor expanded in a around 0 20.7%
+-commutative20.7%
Simplified20.7%
Taylor expanded in b around 0 20.7%
if -8.99999999999999986e-8 < a Initial program 64.1%
Taylor expanded in a around 0 60.8%
Taylor expanded in b around 0 57.5%
Final simplification48.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -2.9e+30) (* b 0.5) (log (+ a 2.0))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -2.9e+30) {
tmp = b * 0.5;
} else {
tmp = log((a + 2.0));
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-2.9d+30)) then
tmp = b * 0.5d0
else
tmp = log((a + 2.0d0))
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -2.9e+30) {
tmp = b * 0.5;
} else {
tmp = Math.log((a + 2.0));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -2.9e+30: tmp = b * 0.5 else: tmp = math.log((a + 2.0)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -2.9e+30) tmp = Float64(b * 0.5); else tmp = log(Float64(a + 2.0)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -2.9e+30)
tmp = b * 0.5;
else
tmp = log((a + 2.0));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -2.9e+30], N[(b * 0.5), $MachinePrecision], N[Log[N[(a + 2.0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.9 \cdot 10^{+30}:\\
\;\;\;\;b \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\log \left(a + 2\right)\\
\end{array}
\end{array}
if a < -2.8999999999999998e30Initial program 8.1%
Taylor expanded in b around 0 100.0%
log1p-define100.0%
Simplified100.0%
Taylor expanded in a around 0 4.3%
Taylor expanded in b around inf 18.8%
*-commutative18.8%
Simplified18.8%
if -2.8999999999999998e30 < a Initial program 62.4%
Taylor expanded in a around 0 60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in b around 0 56.6%
Final simplification49.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1.8e+66) (* b 0.5) (log 2.0)))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1.8e+66) {
tmp = b * 0.5;
} else {
tmp = log(2.0);
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-1.8d+66)) then
tmp = b * 0.5d0
else
tmp = log(2.0d0)
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (a <= -1.8e+66) {
tmp = b * 0.5;
} else {
tmp = Math.log(2.0);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -1.8e+66: tmp = b * 0.5 else: tmp = math.log(2.0) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -1.8e+66) tmp = Float64(b * 0.5); else tmp = log(2.0); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (a <= -1.8e+66)
tmp = b * 0.5;
else
tmp = log(2.0);
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[a, -1.8e+66], N[(b * 0.5), $MachinePrecision], N[Log[2.0], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.8 \cdot 10^{+66}:\\
\;\;\;\;b \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\log 2\\
\end{array}
\end{array}
if a < -1.8e66Initial program 8.5%
Taylor expanded in b around 0 100.0%
log1p-define100.0%
Simplified100.0%
Taylor expanded in a around 0 4.1%
Taylor expanded in b around inf 18.8%
*-commutative18.8%
Simplified18.8%
if -1.8e66 < a Initial program 61.3%
Taylor expanded in b around 0 57.4%
log1p-define57.7%
Simplified57.7%
Taylor expanded in a around 0 54.4%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* b 0.5))
assert(a < b);
double code(double a, double b) {
return b * 0.5;
}
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = b * 0.5d0
end function
assert a < b;
public static double code(double a, double b) {
return b * 0.5;
}
[a, b] = sort([a, b]) def code(a, b): return b * 0.5
a, b = sort([a, b]) function code(a, b) return Float64(b * 0.5) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = b * 0.5;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(b * 0.5), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
b \cdot 0.5
\end{array}
Initial program 51.6%
Taylor expanded in b around 0 69.6%
log1p-define69.9%
Simplified69.9%
Taylor expanded in a around 0 45.8%
Taylor expanded in b around inf 6.6%
*-commutative6.6%
Simplified6.6%
herbie shell --seed 2024107
(FPCore (a b)
:name "symmetry log of sum of exp"
:precision binary64
(log (+ (exp a) (exp b))))