
(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 11 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 (log (+ (exp a) (exp b)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b;
} 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
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;
} 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 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 = b; 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;
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], b, 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:\\
\;\;\;\;b\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{a} + e^{b}\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 12.6%
Taylor expanded in b around 0 8.7%
associate-+r+8.7%
+-commutative8.7%
Simplified8.7%
Taylor expanded in a around inf 8.7%
log1p-def91.9%
Simplified91.9%
Taylor expanded in b around inf 91.9%
Taylor expanded in b around 0 100.0%
if 0.0 < (exp.f64 a) Initial program 67.6%
Final simplification76.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 (+ (log1p (exp a)) (* b (+ 0.5 (* a -0.25))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b;
} else {
tmp = log1p(exp(a)) + (b * (0.5 + (a * -0.25)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b;
} else {
tmp = Math.log1p(Math.exp(a)) + (b * (0.5 + (a * -0.25)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = b else: tmp = math.log1p(math.exp(a)) + (b * (0.5 + (a * -0.25))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = b; else tmp = Float64(log1p(exp(a)) + Float64(b * Float64(0.5 + Float64(a * -0.25)))); 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], b, N[(N[Log[1 + N[Exp[a], $MachinePrecision]], $MachinePrecision] + N[(b * N[(0.5 + N[(a * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(e^{a}\right) + b \cdot \left(0.5 + a \cdot -0.25\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 12.6%
Taylor expanded in b around 0 8.7%
associate-+r+8.7%
+-commutative8.7%
Simplified8.7%
Taylor expanded in a around inf 8.7%
log1p-def91.9%
Simplified91.9%
Taylor expanded in b around inf 91.9%
Taylor expanded in b around 0 100.0%
if 0.0 < (exp.f64 a) Initial program 67.6%
Taylor expanded in b around 0 64.1%
log1p-def64.1%
Simplified64.1%
Taylor expanded in a around 0 64.1%
+-commutative64.1%
associate-*r*64.1%
distribute-rgt-out64.1%
Simplified64.1%
Final simplification73.5%
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 53.2%
Taylor expanded in b around 0 73.5%
log1p-def73.5%
Simplified73.5%
Final simplification73.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 (log (+ 1.0 (exp b)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b;
} else {
tmp = log((1.0 + 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
else
tmp = log((1.0d0 + 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;
} else {
tmp = Math.log((1.0 + Math.exp(b)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = b else: tmp = math.log((1.0 + math.exp(b))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = b; else tmp = log(Float64(1.0 + 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;
else
tmp = log((1.0 + 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], b, N[Log[N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;b\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + e^{b}\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 12.6%
Taylor expanded in b around 0 8.7%
associate-+r+8.7%
+-commutative8.7%
Simplified8.7%
Taylor expanded in a around inf 8.7%
log1p-def91.9%
Simplified91.9%
Taylor expanded in b around inf 91.9%
Taylor expanded in b around 0 100.0%
if 0.0 < (exp.f64 a) Initial program 67.6%
Taylor expanded in a around 0 65.0%
Final simplification74.2%
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 (log1p (+ (exp a) b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b;
} else {
tmp = log1p((exp(a) + b));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b;
} else {
tmp = Math.log1p((Math.exp(a) + b));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = b else: tmp = math.log1p((math.exp(a) + b)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = b; else tmp = log1p(Float64(exp(a) + 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], b, N[Log[1 + N[(N[Exp[a], $MachinePrecision] + b), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(e^{a} + b\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 12.6%
Taylor expanded in b around 0 8.7%
associate-+r+8.7%
+-commutative8.7%
Simplified8.7%
Taylor expanded in a around inf 8.7%
log1p-def91.9%
Simplified91.9%
Taylor expanded in b around inf 91.9%
Taylor expanded in b around 0 100.0%
if 0.0 < (exp.f64 a) Initial program 67.6%
Taylor expanded in b around 0 63.2%
associate-+r+63.2%
+-commutative63.2%
Simplified63.2%
Taylor expanded in a around inf 63.2%
log1p-def63.2%
Simplified63.2%
Final simplification72.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 (log1p (exp b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b;
} 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;
} 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 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 = b; 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], b, 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:\\
\;\;\;\;b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(e^{b}\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 12.6%
Taylor expanded in b around 0 8.7%
associate-+r+8.7%
+-commutative8.7%
Simplified8.7%
Taylor expanded in a around inf 8.7%
log1p-def91.9%
Simplified91.9%
Taylor expanded in b around inf 91.9%
Taylor expanded in b around 0 100.0%
if 0.0 < (exp.f64 a) Initial program 67.6%
Taylor expanded in a around 0 65.0%
log1p-def65.0%
Simplified65.0%
Final simplification74.2%
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 (log1p (+ b (+ a 1.0)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 0.0) {
tmp = b;
} else {
tmp = log1p((b + (a + 1.0)));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 0.0) {
tmp = b;
} else {
tmp = Math.log1p((b + (a + 1.0)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 0.0: tmp = b else: tmp = math.log1p((b + (a + 1.0))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 0.0) tmp = b; else tmp = log1p(Float64(b + Float64(a + 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[N[Exp[a], $MachinePrecision], 0.0], b, N[Log[1 + N[(b + N[(a + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(b + \left(a + 1\right)\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 0.0Initial program 12.6%
Taylor expanded in b around 0 8.7%
associate-+r+8.7%
+-commutative8.7%
Simplified8.7%
Taylor expanded in a around inf 8.7%
log1p-def91.9%
Simplified91.9%
Taylor expanded in b around inf 91.9%
Taylor expanded in b around 0 100.0%
if 0.0 < (exp.f64 a) Initial program 67.6%
Taylor expanded in b around 0 63.2%
associate-+r+63.2%
+-commutative63.2%
Simplified63.2%
Taylor expanded in a around inf 63.2%
log1p-def63.2%
Simplified63.2%
Taylor expanded in a around 0 62.4%
associate-+r+62.4%
Simplified62.4%
Final simplification72.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1.0) b (log (+ a 2.0))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -1.0) {
tmp = b;
} 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 <= (-1.0d0)) then
tmp = b
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 <= -1.0) {
tmp = b;
} else {
tmp = Math.log((a + 2.0));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -1.0: tmp = b else: tmp = math.log((a + 2.0)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -1.0) tmp = b; 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 <= -1.0)
tmp = b;
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, -1.0], b, N[Log[N[(a + 2.0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1:\\
\;\;\;\;b\\
\mathbf{else}:\\
\;\;\;\;\log \left(a + 2\right)\\
\end{array}
\end{array}
if a < -1Initial program 12.6%
Taylor expanded in b around 0 8.7%
associate-+r+8.7%
+-commutative8.7%
Simplified8.7%
Taylor expanded in a around inf 8.7%
log1p-def91.9%
Simplified91.9%
Taylor expanded in b around inf 91.9%
Taylor expanded in b around 0 100.0%
if -1 < a Initial program 67.6%
Taylor expanded in b around 0 63.1%
Taylor expanded in a around 0 62.3%
Final simplification72.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -15.5) b (log (+ b 2.0))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -15.5) {
tmp = b;
} 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 <= (-15.5d0)) then
tmp = b
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 <= -15.5) {
tmp = b;
} else {
tmp = Math.log((b + 2.0));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -15.5: tmp = b else: tmp = math.log((b + 2.0)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -15.5) tmp = b; 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 <= -15.5)
tmp = b;
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, -15.5], b, N[Log[N[(b + 2.0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -15.5:\\
\;\;\;\;b\\
\mathbf{else}:\\
\;\;\;\;\log \left(b + 2\right)\\
\end{array}
\end{array}
if a < -15.5Initial program 12.6%
Taylor expanded in b around 0 8.7%
associate-+r+8.7%
+-commutative8.7%
Simplified8.7%
Taylor expanded in a around inf 8.7%
log1p-def91.9%
Simplified91.9%
Taylor expanded in b around inf 91.9%
Taylor expanded in b around 0 100.0%
if -15.5 < a Initial program 67.6%
Taylor expanded in b around 0 63.2%
associate-+r+63.2%
+-commutative63.2%
Simplified63.2%
Taylor expanded in a around 0 62.1%
Final simplification72.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -17.0) b (log 2.0)))
assert(a < b);
double code(double a, double b) {
double tmp;
if (a <= -17.0) {
tmp = b;
} 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 <= (-17.0d0)) then
tmp = b
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 <= -17.0) {
tmp = b;
} else {
tmp = Math.log(2.0);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if a <= -17.0: tmp = b else: tmp = math.log(2.0) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (a <= -17.0) tmp = b; 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 <= -17.0)
tmp = b;
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, -17.0], b, N[Log[2.0], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -17:\\
\;\;\;\;b\\
\mathbf{else}:\\
\;\;\;\;\log 2\\
\end{array}
\end{array}
if a < -17Initial program 12.6%
Taylor expanded in b around 0 8.7%
associate-+r+8.7%
+-commutative8.7%
Simplified8.7%
Taylor expanded in a around inf 8.7%
log1p-def91.9%
Simplified91.9%
Taylor expanded in b around inf 91.9%
Taylor expanded in b around 0 100.0%
if -17 < a Initial program 67.6%
Taylor expanded in b around 0 63.1%
Taylor expanded in a around 0 62.1%
Final simplification72.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 b)
assert(a < b);
double code(double a, double b) {
return b;
}
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
end function
assert a < b;
public static double code(double a, double b) {
return b;
}
[a, b] = sort([a, b]) def code(a, b): return b
a, b = sort([a, b]) function code(a, b) return b end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = b;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := b
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
b
\end{array}
Initial program 53.2%
Taylor expanded in b around 0 49.0%
associate-+r+49.0%
+-commutative49.0%
Simplified49.0%
Taylor expanded in a around inf 49.0%
log1p-def70.7%
Simplified70.7%
Taylor expanded in b around inf 26.0%
Taylor expanded in b around 0 28.8%
Final simplification28.8%
herbie shell --seed 2023318
(FPCore (a b)
:name "symmetry log of sum of exp"
:precision binary64
(log (+ (exp a) (exp b))))