
(FPCore (x y z t a) :precision binary64 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))
double code(double x, double y, double z, double t, double a) {
return ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((log((x + y)) + log(z)) - t) + ((a - 0.5d0) * log(t))
end function
public static double code(double x, double y, double z, double t, double a) {
return ((Math.log((x + y)) + Math.log(z)) - t) + ((a - 0.5) * Math.log(t));
}
def code(x, y, z, t, a): return ((math.log((x + y)) + math.log(z)) - t) + ((a - 0.5) * math.log(t))
function code(x, y, z, t, a) return Float64(Float64(Float64(log(Float64(x + y)) + log(z)) - t) + Float64(Float64(a - 0.5) * log(t))) end
function tmp = code(x, y, z, t, a) tmp = ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t)); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))
double code(double x, double y, double z, double t, double a) {
return ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((log((x + y)) + log(z)) - t) + ((a - 0.5d0) * log(t))
end function
public static double code(double x, double y, double z, double t, double a) {
return ((Math.log((x + y)) + Math.log(z)) - t) + ((a - 0.5) * Math.log(t));
}
def code(x, y, z, t, a): return ((math.log((x + y)) + math.log(z)) - t) + ((a - 0.5) * math.log(t))
function code(x, y, z, t, a) return Float64(Float64(Float64(log(Float64(x + y)) + log(z)) - t) + Float64(Float64(a - 0.5) * log(t))) end
function tmp = code(x, y, z, t, a) tmp = ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t)); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t
\end{array}
(FPCore (x y z t a) :precision binary64 (+ (log (+ x y)) (- (log z) (fma (log t) (- 0.5 a) t))))
double code(double x, double y, double z, double t, double a) {
return log((x + y)) + (log(z) - fma(log(t), (0.5 - a), t));
}
function code(x, y, z, t, a) return Float64(log(Float64(x + y)) + Float64(log(z) - fma(log(t), Float64(0.5 - a), t))) end
code[x_, y_, z_, t_, a_] := N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * N[(0.5 - a), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log \left(x + y\right) + \left(\log z - \mathsf{fma}\left(\log t, 0.5 - a, t\right)\right)
\end{array}
Initial program 99.6%
associate-+l-99.6%
associate--l+99.6%
sub-neg99.6%
+-commutative99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-udef99.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-in99.6%
metadata-eval99.6%
metadata-eval99.6%
unsub-neg99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= (log z) -660.0) (not (<= (log z) 162.8))) (- (+ (log y) (* (log t) a)) t) (- (+ (log (* z (+ x y))) (* (log t) (- a 0.5))) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((log(z) <= -660.0) || !(log(z) <= 162.8)) {
tmp = (log(y) + (log(t) * a)) - t;
} else {
tmp = (log((z * (x + y))) + (log(t) * (a - 0.5))) - t;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((log(z) <= (-660.0d0)) .or. (.not. (log(z) <= 162.8d0))) then
tmp = (log(y) + (log(t) * a)) - t
else
tmp = (log((z * (x + y))) + (log(t) * (a - 0.5d0))) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((Math.log(z) <= -660.0) || !(Math.log(z) <= 162.8)) {
tmp = (Math.log(y) + (Math.log(t) * a)) - t;
} else {
tmp = (Math.log((z * (x + y))) + (Math.log(t) * (a - 0.5))) - t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (math.log(z) <= -660.0) or not (math.log(z) <= 162.8): tmp = (math.log(y) + (math.log(t) * a)) - t else: tmp = (math.log((z * (x + y))) + (math.log(t) * (a - 0.5))) - t return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((log(z) <= -660.0) || !(log(z) <= 162.8)) tmp = Float64(Float64(log(y) + Float64(log(t) * a)) - t); else tmp = Float64(Float64(log(Float64(z * Float64(x + y))) + Float64(log(t) * Float64(a - 0.5))) - t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((log(z) <= -660.0) || ~((log(z) <= 162.8))) tmp = (log(y) + (log(t) * a)) - t; else tmp = (log((z * (x + y))) + (log(t) * (a - 0.5))) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[Log[z], $MachinePrecision], -660.0], N[Not[LessEqual[N[Log[z], $MachinePrecision], 162.8]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[Log[N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\log z \leq -660 \lor \neg \left(\log z \leq 162.8\right):\\
\;\;\;\;\left(\log y + \log t \cdot a\right) - t\\
\mathbf{else}:\\
\;\;\;\;\left(\log \left(z \cdot \left(x + y\right)\right) + \log t \cdot \left(a - 0.5\right)\right) - t\\
\end{array}
\end{array}
if (log.f64 z) < -660 or 162.80000000000001 < (log.f64 z) Initial program 99.7%
Taylor expanded in x around 0 64.0%
Taylor expanded in a around inf 54.3%
*-commutative54.3%
Simplified54.3%
if -660 < (log.f64 z) < 162.80000000000001Initial program 99.5%
associate-+l-99.5%
associate--l+99.6%
sub-neg99.6%
+-commutative99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-udef99.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-in99.6%
metadata-eval99.6%
metadata-eval99.6%
unsub-neg99.6%
Simplified99.6%
associate-+r-99.5%
fma-udef99.5%
associate--r+99.5%
+-commutative99.5%
sum-log95.4%
Applied egg-rr95.4%
Final simplification79.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -5.2) (not (<= a 0.52))) (- (+ (log y) (* (log t) a)) t) (- (+ (log y) (+ (log z) (* (log t) -0.5))) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -5.2) || !(a <= 0.52)) {
tmp = (log(y) + (log(t) * a)) - t;
} else {
tmp = (log(y) + (log(z) + (log(t) * -0.5))) - t;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((a <= (-5.2d0)) .or. (.not. (a <= 0.52d0))) then
tmp = (log(y) + (log(t) * a)) - t
else
tmp = (log(y) + (log(z) + (log(t) * (-0.5d0)))) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -5.2) || !(a <= 0.52)) {
tmp = (Math.log(y) + (Math.log(t) * a)) - t;
} else {
tmp = (Math.log(y) + (Math.log(z) + (Math.log(t) * -0.5))) - t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (a <= -5.2) or not (a <= 0.52): tmp = (math.log(y) + (math.log(t) * a)) - t else: tmp = (math.log(y) + (math.log(z) + (math.log(t) * -0.5))) - t return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -5.2) || !(a <= 0.52)) tmp = Float64(Float64(log(y) + Float64(log(t) * a)) - t); else tmp = Float64(Float64(log(y) + Float64(log(z) + Float64(log(t) * -0.5))) - t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((a <= -5.2) || ~((a <= 0.52))) tmp = (log(y) + (log(t) * a)) - t; else tmp = (log(y) + (log(z) + (log(t) * -0.5))) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -5.2], N[Not[LessEqual[a, 0.52]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] + N[(N[Log[z], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.2 \lor \neg \left(a \leq 0.52\right):\\
\;\;\;\;\left(\log y + \log t \cdot a\right) - t\\
\mathbf{else}:\\
\;\;\;\;\left(\log y + \left(\log z + \log t \cdot -0.5\right)\right) - t\\
\end{array}
\end{array}
if a < -5.20000000000000018 or 0.52000000000000002 < a Initial program 99.7%
Taylor expanded in x around 0 78.4%
Taylor expanded in a around inf 78.0%
*-commutative78.0%
Simplified78.0%
if -5.20000000000000018 < a < 0.52000000000000002Initial program 99.5%
Taylor expanded in x around 0 62.2%
Taylor expanded in a around 0 61.3%
*-commutative61.3%
Simplified61.3%
Final simplification69.5%
(FPCore (x y z t a) :precision binary64 (+ (- (+ (log (+ x y)) (log z)) t) (* (log t) (- a 0.5))))
double code(double x, double y, double z, double t, double a) {
return ((log((x + y)) + log(z)) - t) + (log(t) * (a - 0.5));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((log((x + y)) + log(z)) - t) + (log(t) * (a - 0.5d0))
end function
public static double code(double x, double y, double z, double t, double a) {
return ((Math.log((x + y)) + Math.log(z)) - t) + (Math.log(t) * (a - 0.5));
}
def code(x, y, z, t, a): return ((math.log((x + y)) + math.log(z)) - t) + (math.log(t) * (a - 0.5))
function code(x, y, z, t, a) return Float64(Float64(Float64(log(Float64(x + y)) + log(z)) - t) + Float64(log(t) * Float64(a - 0.5))) end
function tmp = code(x, y, z, t, a) tmp = ((log((x + y)) + log(z)) - t) + (log(t) * (a - 0.5)); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \log t \cdot \left(a - 0.5\right)
\end{array}
Initial program 99.6%
Final simplification99.6%
(FPCore (x y z t a) :precision binary64 (- (+ (log y) (+ (log z) (* (log t) (- a 0.5)))) t))
double code(double x, double y, double z, double t, double a) {
return (log(y) + (log(z) + (log(t) * (a - 0.5)))) - t;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = (log(y) + (log(z) + (log(t) * (a - 0.5d0)))) - t
end function
public static double code(double x, double y, double z, double t, double a) {
return (Math.log(y) + (Math.log(z) + (Math.log(t) * (a - 0.5)))) - t;
}
def code(x, y, z, t, a): return (math.log(y) + (math.log(z) + (math.log(t) * (a - 0.5)))) - t
function code(x, y, z, t, a) return Float64(Float64(log(y) + Float64(log(z) + Float64(log(t) * Float64(a - 0.5)))) - t) end
function tmp = code(x, y, z, t, a) tmp = (log(y) + (log(z) + (log(t) * (a - 0.5)))) - t; end
code[x_, y_, z_, t_, a_] := N[(N[(N[Log[y], $MachinePrecision] + N[(N[Log[z], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\log y + \left(\log z + \log t \cdot \left(a - 0.5\right)\right)\right) - t
\end{array}
Initial program 99.6%
Taylor expanded in x around 0 70.2%
Final simplification70.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= t 2.7e+29) (and (not (<= t 4.3e+101)) (<= t 3.75e+112))) (+ (log (+ x y)) (* (log t) a)) (- t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= 2.7e+29) || (!(t <= 4.3e+101) && (t <= 3.75e+112))) {
tmp = log((x + y)) + (log(t) * a);
} else {
tmp = -t;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((t <= 2.7d+29) .or. (.not. (t <= 4.3d+101)) .and. (t <= 3.75d+112)) then
tmp = log((x + y)) + (log(t) * a)
else
tmp = -t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= 2.7e+29) || (!(t <= 4.3e+101) && (t <= 3.75e+112))) {
tmp = Math.log((x + y)) + (Math.log(t) * a);
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= 2.7e+29) or (not (t <= 4.3e+101) and (t <= 3.75e+112)): tmp = math.log((x + y)) + (math.log(t) * a) else: tmp = -t return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= 2.7e+29) || (!(t <= 4.3e+101) && (t <= 3.75e+112))) tmp = Float64(log(Float64(x + y)) + Float64(log(t) * a)); else tmp = Float64(-t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= 2.7e+29) || (~((t <= 4.3e+101)) && (t <= 3.75e+112))) tmp = log((x + y)) + (log(t) * a); else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, 2.7e+29], And[N[Not[LessEqual[t, 4.3e+101]], $MachinePrecision], LessEqual[t, 3.75e+112]]], N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 2.7 \cdot 10^{+29} \lor \neg \left(t \leq 4.3 \cdot 10^{+101}\right) \land t \leq 3.75 \cdot 10^{+112}:\\
\;\;\;\;\log \left(x + y\right) + \log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < 2.7e29 or 4.3000000000000001e101 < t < 3.75e112Initial program 99.3%
associate-+l-99.3%
associate--l+99.4%
sub-neg99.4%
+-commutative99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
fma-udef99.4%
sub-neg99.4%
+-commutative99.4%
distribute-neg-in99.4%
metadata-eval99.4%
metadata-eval99.4%
unsub-neg99.4%
Simplified99.4%
Taylor expanded in a around inf 55.7%
*-commutative55.7%
Simplified55.7%
if 2.7e29 < t < 4.3000000000000001e101 or 3.75e112 < t Initial program 99.9%
associate-+l-99.9%
associate--l+99.9%
sub-neg99.9%
+-commutative99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-udef99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
metadata-eval99.9%
metadata-eval99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in t around inf 82.2%
neg-mul-182.2%
Simplified82.2%
Taylor expanded in t around inf 82.2%
neg-mul-182.2%
Simplified82.2%
Final simplification67.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -5.2) (not (<= a 1.15e-11))) (- (+ (log y) (* (log t) a)) t) (- (log (* z (+ x y))) (+ (* (log t) 0.5) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -5.2) || !(a <= 1.15e-11)) {
tmp = (log(y) + (log(t) * a)) - t;
} else {
tmp = log((z * (x + y))) - ((log(t) * 0.5) + t);
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((a <= (-5.2d0)) .or. (.not. (a <= 1.15d-11))) then
tmp = (log(y) + (log(t) * a)) - t
else
tmp = log((z * (x + y))) - ((log(t) * 0.5d0) + t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -5.2) || !(a <= 1.15e-11)) {
tmp = (Math.log(y) + (Math.log(t) * a)) - t;
} else {
tmp = Math.log((z * (x + y))) - ((Math.log(t) * 0.5) + t);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (a <= -5.2) or not (a <= 1.15e-11): tmp = (math.log(y) + (math.log(t) * a)) - t else: tmp = math.log((z * (x + y))) - ((math.log(t) * 0.5) + t) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -5.2) || !(a <= 1.15e-11)) tmp = Float64(Float64(log(y) + Float64(log(t) * a)) - t); else tmp = Float64(log(Float64(z * Float64(x + y))) - Float64(Float64(log(t) * 0.5) + t)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((a <= -5.2) || ~((a <= 1.15e-11))) tmp = (log(y) + (log(t) * a)) - t; else tmp = log((z * (x + y))) - ((log(t) * 0.5) + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -5.2], N[Not[LessEqual[a, 1.15e-11]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[Log[N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(N[(N[Log[t], $MachinePrecision] * 0.5), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.2 \lor \neg \left(a \leq 1.15 \cdot 10^{-11}\right):\\
\;\;\;\;\left(\log y + \log t \cdot a\right) - t\\
\mathbf{else}:\\
\;\;\;\;\log \left(z \cdot \left(x + y\right)\right) - \left(\log t \cdot 0.5 + t\right)\\
\end{array}
\end{array}
if a < -5.20000000000000018 or 1.15000000000000007e-11 < a Initial program 99.7%
Taylor expanded in x around 0 77.5%
Taylor expanded in a around inf 76.5%
*-commutative76.5%
Simplified76.5%
if -5.20000000000000018 < a < 1.15000000000000007e-11Initial program 99.5%
associate-+l-99.5%
associate--l+99.5%
sub-neg99.5%
+-commutative99.5%
*-commutative99.5%
distribute-rgt-neg-in99.5%
fma-udef99.5%
sub-neg99.5%
+-commutative99.5%
distribute-neg-in99.5%
metadata-eval99.5%
metadata-eval99.5%
unsub-neg99.5%
Simplified99.5%
Taylor expanded in a around 0 98.9%
log-prod76.7%
+-commutative76.7%
*-commutative76.7%
Simplified76.7%
Final simplification76.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -5.2) (not (<= a 8.2e-10))) (- (+ (log y) (* (log t) a)) t) (- (+ (* (log t) -0.5) (log (* y z))) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -5.2) || !(a <= 8.2e-10)) {
tmp = (log(y) + (log(t) * a)) - t;
} else {
tmp = ((log(t) * -0.5) + log((y * z))) - t;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((a <= (-5.2d0)) .or. (.not. (a <= 8.2d-10))) then
tmp = (log(y) + (log(t) * a)) - t
else
tmp = ((log(t) * (-0.5d0)) + log((y * z))) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -5.2) || !(a <= 8.2e-10)) {
tmp = (Math.log(y) + (Math.log(t) * a)) - t;
} else {
tmp = ((Math.log(t) * -0.5) + Math.log((y * z))) - t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (a <= -5.2) or not (a <= 8.2e-10): tmp = (math.log(y) + (math.log(t) * a)) - t else: tmp = ((math.log(t) * -0.5) + math.log((y * z))) - t return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -5.2) || !(a <= 8.2e-10)) tmp = Float64(Float64(log(y) + Float64(log(t) * a)) - t); else tmp = Float64(Float64(Float64(log(t) * -0.5) + log(Float64(y * z))) - t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((a <= -5.2) || ~((a <= 8.2e-10))) tmp = (log(y) + (log(t) * a)) - t; else tmp = ((log(t) * -0.5) + log((y * z))) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -5.2], N[Not[LessEqual[a, 8.2e-10]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[(N[Log[t], $MachinePrecision] * -0.5), $MachinePrecision] + N[Log[N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.2 \lor \neg \left(a \leq 8.2 \cdot 10^{-10}\right):\\
\;\;\;\;\left(\log y + \log t \cdot a\right) - t\\
\mathbf{else}:\\
\;\;\;\;\left(\log t \cdot -0.5 + \log \left(y \cdot z\right)\right) - t\\
\end{array}
\end{array}
if a < -5.20000000000000018 or 8.1999999999999996e-10 < a Initial program 99.7%
Taylor expanded in x around 0 77.5%
Taylor expanded in a around inf 76.5%
*-commutative76.5%
Simplified76.5%
if -5.20000000000000018 < a < 8.1999999999999996e-10Initial program 99.5%
Taylor expanded in x around 0 62.6%
Taylor expanded in a around 0 62.1%
associate-+r+62.0%
log-prod48.4%
+-commutative48.4%
*-commutative48.4%
*-commutative48.4%
Simplified48.4%
Final simplification62.7%
(FPCore (x y z t a) :precision binary64 (if (<= t 34.0) (+ (log (* y z)) (* (log t) (- a 0.5))) (- (+ (log y) (* (log t) a)) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 34.0) {
tmp = log((y * z)) + (log(t) * (a - 0.5));
} else {
tmp = (log(y) + (log(t) * a)) - t;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (t <= 34.0d0) then
tmp = log((y * z)) + (log(t) * (a - 0.5d0))
else
tmp = (log(y) + (log(t) * a)) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 34.0) {
tmp = Math.log((y * z)) + (Math.log(t) * (a - 0.5));
} else {
tmp = (Math.log(y) + (Math.log(t) * a)) - t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= 34.0: tmp = math.log((y * z)) + (math.log(t) * (a - 0.5)) else: tmp = (math.log(y) + (math.log(t) * a)) - t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= 34.0) tmp = Float64(log(Float64(y * z)) + Float64(log(t) * Float64(a - 0.5))); else tmp = Float64(Float64(log(y) + Float64(log(t) * a)) - t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= 34.0) tmp = log((y * z)) + (log(t) * (a - 0.5)); else tmp = (log(y) + (log(t) * a)) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 34.0], N[(N[Log[N[(y * z), $MachinePrecision]], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 34:\\
\;\;\;\;\log \left(y \cdot z\right) + \log t \cdot \left(a - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\log y + \log t \cdot a\right) - t\\
\end{array}
\end{array}
if t < 34Initial program 99.3%
associate-+l-99.3%
associate--l+99.4%
sub-neg99.4%
+-commutative99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
fma-udef99.4%
sub-neg99.4%
+-commutative99.4%
distribute-neg-in99.4%
metadata-eval99.4%
metadata-eval99.4%
unsub-neg99.4%
Simplified99.4%
Taylor expanded in t around 0 97.1%
log-prod71.6%
+-commutative71.6%
Simplified71.6%
Taylor expanded in y around inf 60.4%
mul-1-neg60.4%
log-rec60.4%
remove-double-neg60.4%
log-prod48.8%
Simplified48.8%
if 34 < t Initial program 99.9%
Taylor expanded in x around 0 77.7%
Taylor expanded in a around inf 76.9%
*-commutative76.9%
Simplified76.9%
Final simplification63.2%
(FPCore (x y z t a) :precision binary64 (- (+ (log y) (* (log t) a)) t))
double code(double x, double y, double z, double t, double a) {
return (log(y) + (log(t) * a)) - t;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = (log(y) + (log(t) * a)) - t
end function
public static double code(double x, double y, double z, double t, double a) {
return (Math.log(y) + (Math.log(t) * a)) - t;
}
def code(x, y, z, t, a): return (math.log(y) + (math.log(t) * a)) - t
function code(x, y, z, t, a) return Float64(Float64(log(y) + Float64(log(t) * a)) - t) end
function tmp = code(x, y, z, t, a) tmp = (log(y) + (log(t) * a)) - t; end
code[x_, y_, z_, t_, a_] := N[(N[(N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\log y + \log t \cdot a\right) - t
\end{array}
Initial program 99.6%
Taylor expanded in x around 0 70.2%
Taylor expanded in a around inf 58.0%
*-commutative58.0%
Simplified58.0%
Final simplification58.0%
(FPCore (x y z t a) :precision binary64 (- (+ (log z) (log y)) t))
double code(double x, double y, double z, double t, double a) {
return (log(z) + log(y)) - t;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = (log(z) + log(y)) - t
end function
public static double code(double x, double y, double z, double t, double a) {
return (Math.log(z) + Math.log(y)) - t;
}
def code(x, y, z, t, a): return (math.log(z) + math.log(y)) - t
function code(x, y, z, t, a) return Float64(Float64(log(z) + log(y)) - t) end
function tmp = code(x, y, z, t, a) tmp = (log(z) + log(y)) - t; end
code[x_, y_, z_, t_, a_] := N[(N[(N[Log[z], $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\log z + \log y\right) - t
\end{array}
Initial program 99.6%
associate-+l-99.6%
associate--l+99.6%
sub-neg99.6%
+-commutative99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-udef99.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-in99.6%
metadata-eval99.6%
metadata-eval99.6%
unsub-neg99.6%
Simplified99.6%
Taylor expanded in t around inf 43.0%
Taylor expanded in x around 0 31.9%
Final simplification31.9%
(FPCore (x y z t a) :precision binary64 (if (<= t 0.195) (log (+ x y)) (- t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 0.195) {
tmp = log((x + y));
} else {
tmp = -t;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (t <= 0.195d0) then
tmp = log((x + y))
else
tmp = -t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 0.195) {
tmp = Math.log((x + y));
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= 0.195: tmp = math.log((x + y)) else: tmp = -t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= 0.195) tmp = log(Float64(x + y)); else tmp = Float64(-t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= 0.195) tmp = log((x + y)); else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 0.195], N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 0.195:\\
\;\;\;\;\log \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < 0.19500000000000001Initial program 99.3%
associate-+l-99.3%
associate--l+99.4%
sub-neg99.4%
+-commutative99.4%
*-commutative99.4%
distribute-rgt-neg-in99.4%
fma-udef99.4%
sub-neg99.4%
+-commutative99.4%
distribute-neg-in99.4%
metadata-eval99.4%
metadata-eval99.4%
unsub-neg99.4%
Simplified99.4%
Taylor expanded in t around inf 9.8%
neg-mul-19.8%
Simplified9.8%
Taylor expanded in t around 0 9.8%
+-commutative9.8%
Simplified9.8%
if 0.19500000000000001 < t Initial program 99.9%
associate-+l-99.9%
associate--l+99.8%
sub-neg99.8%
+-commutative99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-udef99.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-in99.8%
metadata-eval99.8%
metadata-eval99.8%
unsub-neg99.8%
Simplified99.8%
Taylor expanded in t around inf 72.5%
neg-mul-172.5%
Simplified72.5%
Taylor expanded in t around inf 72.6%
neg-mul-172.6%
Simplified72.6%
Final simplification42.2%
(FPCore (x y z t a) :precision binary64 (- (log y) t))
double code(double x, double y, double z, double t, double a) {
return log(y) - t;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = log(y) - t
end function
public static double code(double x, double y, double z, double t, double a) {
return Math.log(y) - t;
}
def code(x, y, z, t, a): return math.log(y) - t
function code(x, y, z, t, a) return Float64(log(y) - t) end
function tmp = code(x, y, z, t, a) tmp = log(y) - t; end
code[x_, y_, z_, t_, a_] := N[(N[Log[y], $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\log y - t
\end{array}
Initial program 99.6%
associate-+l-99.6%
associate--l+99.6%
sub-neg99.6%
+-commutative99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-udef99.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-in99.6%
metadata-eval99.6%
metadata-eval99.6%
unsub-neg99.6%
Simplified99.6%
Taylor expanded in t around inf 42.1%
neg-mul-142.1%
Simplified42.1%
Taylor expanded in x around 0 31.4%
Final simplification31.4%
(FPCore (x y z t a) :precision binary64 (- t))
double code(double x, double y, double z, double t, double a) {
return -t;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = -t
end function
public static double code(double x, double y, double z, double t, double a) {
return -t;
}
def code(x, y, z, t, a): return -t
function code(x, y, z, t, a) return Float64(-t) end
function tmp = code(x, y, z, t, a) tmp = -t; end
code[x_, y_, z_, t_, a_] := (-t)
\begin{array}{l}
\\
-t
\end{array}
Initial program 99.6%
associate-+l-99.6%
associate--l+99.6%
sub-neg99.6%
+-commutative99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-udef99.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-in99.6%
metadata-eval99.6%
metadata-eval99.6%
unsub-neg99.6%
Simplified99.6%
Taylor expanded in t around inf 42.1%
neg-mul-142.1%
Simplified42.1%
Taylor expanded in t around inf 38.8%
neg-mul-138.8%
Simplified38.8%
Final simplification38.8%
(FPCore (x y z t a) :precision binary64 (+ (log (+ x y)) (+ (- (log z) t) (* (- a 0.5) (log t)))))
double code(double x, double y, double z, double t, double a) {
return log((x + y)) + ((log(z) - t) + ((a - 0.5) * log(t)));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = log((x + y)) + ((log(z) - t) + ((a - 0.5d0) * log(t)))
end function
public static double code(double x, double y, double z, double t, double a) {
return Math.log((x + y)) + ((Math.log(z) - t) + ((a - 0.5) * Math.log(t)));
}
def code(x, y, z, t, a): return math.log((x + y)) + ((math.log(z) - t) + ((a - 0.5) * math.log(t)))
function code(x, y, z, t, a) return Float64(log(Float64(x + y)) + Float64(Float64(log(z) - t) + Float64(Float64(a - 0.5) * log(t)))) end
function tmp = code(x, y, z, t, a) tmp = log((x + y)) + ((log(z) - t) + ((a - 0.5) * log(t))); end
code[x_, y_, z_, t_, a_] := N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log \left(x + y\right) + \left(\left(\log z - t\right) + \left(a - 0.5\right) \cdot \log t\right)
\end{array}
herbie shell --seed 2024021
(FPCore (x y z t a)
:name "Numeric.SpecFunctions:logGammaL from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(+ (log (+ x y)) (+ (- (log z) t) (* (- a 0.5) (log t))))
(+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))