
(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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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 15 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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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 (+ (fma (log t) (- a 0.5) (log (+ y x))) (- (log z) t)))
double code(double x, double y, double z, double t, double a) {
return fma(log(t), (a - 0.5), log((y + x))) + (log(z) - t);
}
function code(x, y, z, t, a) return Float64(fma(log(t), Float64(a - 0.5), log(Float64(y + x))) + Float64(log(z) - t)) end
code[x_, y_, z_, t_, a_] := N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log t, a - 0.5, \log \left(y + x\right)\right) + \left(\log z - t\right)
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6499.6
Applied rewrites99.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t)))))
(if (<= t_1 -200000000000.0)
(- t)
(if (<= t_1 644.5)
(* (- (/ (log (* (sqrt (pow t -1.0)) (* z (+ x y)))) t) 1.0) t)
(if (<= t_1 1020.0) (fma -0.5 (log t) (log (* z y))) (* (log t) a))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t));
double tmp;
if (t_1 <= -200000000000.0) {
tmp = -t;
} else if (t_1 <= 644.5) {
tmp = ((log((sqrt(pow(t, -1.0)) * (z * (x + y)))) / t) - 1.0) * t;
} else if (t_1 <= 1020.0) {
tmp = fma(-0.5, log(t), log((z * y)));
} else {
tmp = log(t) * a;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(log(Float64(x + y)) + log(z)) - t) + Float64(Float64(a - 0.5) * log(t))) tmp = 0.0 if (t_1 <= -200000000000.0) tmp = Float64(-t); elseif (t_1 <= 644.5) tmp = Float64(Float64(Float64(log(Float64(sqrt((t ^ -1.0)) * Float64(z * Float64(x + y)))) / t) - 1.0) * t); elseif (t_1 <= 1020.0) tmp = fma(-0.5, log(t), log(Float64(z * y))); else tmp = Float64(log(t) * a); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, -200000000000.0], (-t), If[LessEqual[t$95$1, 644.5], N[(N[(N[(N[Log[N[(N[Sqrt[N[Power[t, -1.0], $MachinePrecision]], $MachinePrecision] * N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision] - 1.0), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[t$95$1, 1020.0], N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(\log \left(x + y\right) + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t\\
\mathbf{if}\;t\_1 \leq -200000000000:\\
\;\;\;\;-t\\
\mathbf{elif}\;t\_1 \leq 644.5:\\
\;\;\;\;\left(\frac{\log \left(\sqrt{{t}^{-1}} \cdot \left(z \cdot \left(x + y\right)\right)\right)}{t} - 1\right) \cdot t\\
\mathbf{elif}\;t\_1 \leq 1020:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log \left(z \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot a\\
\end{array}
\end{array}
if (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < -2e11Initial program 99.9%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6466.0
Applied rewrites66.0%
if -2e11 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < 644.5Initial program 98.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
Applied rewrites92.3%
Taylor expanded in a around 0
Applied rewrites89.3%
if 644.5 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < 1020Initial program 99.5%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6442.7
Applied rewrites42.7%
Applied rewrites37.5%
Taylor expanded in a around 0
Applied rewrites37.5%
Taylor expanded in t around 0
Applied rewrites37.5%
if 1020 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) Initial program 99.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6472.9
Applied rewrites72.9%
Final simplification69.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z)))
(t_2 (fma -0.5 (log t) (- (+ (log z) (log y)) t))))
(if (<= t_1 -740.0)
t_2
(if (<= t_1 710.0)
(- (fma (log t) (- a 0.5) (log (* z (+ y x)))) t)
(if (<= t_1 939.0) (+ (fma (+ -0.5 a) (log t) (log z)) (log y)) t_2)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y)) + log(z);
double t_2 = fma(-0.5, log(t), ((log(z) + log(y)) - t));
double tmp;
if (t_1 <= -740.0) {
tmp = t_2;
} else if (t_1 <= 710.0) {
tmp = fma(log(t), (a - 0.5), log((z * (y + x)))) - t;
} else if (t_1 <= 939.0) {
tmp = fma((-0.5 + a), log(t), log(z)) + log(y);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) t_2 = fma(-0.5, log(t), Float64(Float64(log(z) + log(y)) - t)) tmp = 0.0 if (t_1 <= -740.0) tmp = t_2; elseif (t_1 <= 710.0) tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(z * Float64(y + x)))) - t); elseif (t_1 <= 939.0) tmp = Float64(fma(Float64(-0.5 + a), log(t), log(z)) + log(y)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-0.5 * N[Log[t], $MachinePrecision] + N[(N[(N[Log[z], $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -740.0], t$95$2, If[LessEqual[t$95$1, 710.0], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t$95$1, 939.0], N[(N[(N[(-0.5 + a), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
t_2 := \mathsf{fma}\left(-0.5, \log t, \left(\log z + \log y\right) - t\right)\\
\mathbf{if}\;t\_1 \leq -740:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 710:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(z \cdot \left(y + x\right)\right)\right) - t\\
\mathbf{elif}\;t\_1 \leq 939:\\
\;\;\;\;\mathsf{fma}\left(-0.5 + a, \log t, \log z\right) + \log y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -740 or 939 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.8%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6470.6
Applied rewrites70.6%
Applied rewrites17.0%
Applied rewrites70.7%
Taylor expanded in a around 0
Applied rewrites50.0%
if -740 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 710Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.6
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
sum-logN/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
if 710 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 939Initial program 99.6%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6456.9
Applied rewrites56.9%
Taylor expanded in t around 0
Applied rewrites52.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z)))
(t_2 (+ (fma (+ -0.5 a) (log t) (log z)) (log y))))
(if (<= t_1 -740.0)
t_2
(if (<= t_1 710.0)
(- (fma (log t) (- a 0.5) (log (* z (+ y x)))) t)
(if (<= t_1 939.0) t_2 (+ (fma -0.5 (log t) (log z)) (- (log y) t)))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y)) + log(z);
double t_2 = fma((-0.5 + a), log(t), log(z)) + log(y);
double tmp;
if (t_1 <= -740.0) {
tmp = t_2;
} else if (t_1 <= 710.0) {
tmp = fma(log(t), (a - 0.5), log((z * (y + x)))) - t;
} else if (t_1 <= 939.0) {
tmp = t_2;
} else {
tmp = fma(-0.5, log(t), log(z)) + (log(y) - t);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) t_2 = Float64(fma(Float64(-0.5 + a), log(t), log(z)) + log(y)) tmp = 0.0 if (t_1 <= -740.0) tmp = t_2; elseif (t_1 <= 710.0) tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(z * Float64(y + x)))) - t); elseif (t_1 <= 939.0) tmp = t_2; else tmp = Float64(fma(-0.5, log(t), log(z)) + Float64(log(y) - t)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(-0.5 + a), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -740.0], t$95$2, If[LessEqual[t$95$1, 710.0], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t$95$1, 939.0], t$95$2, N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
t_2 := \mathsf{fma}\left(-0.5 + a, \log t, \log z\right) + \log y\\
\mathbf{if}\;t\_1 \leq -740:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 710:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(z \cdot \left(y + x\right)\right)\right) - t\\
\mathbf{elif}\;t\_1 \leq 939:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log z\right) + \left(\log y - t\right)\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -740 or 710 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 939Initial program 99.7%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6464.5
Applied rewrites64.5%
Taylor expanded in t around 0
Applied rewrites54.7%
if -740 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 710Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.6
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
sum-logN/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
if 939 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6466.5
Applied rewrites66.5%
Taylor expanded in a around 0
Applied rewrites47.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (<= t_1 -740.0)
(- (log (/ z (sqrt t))) (- t (log y)))
(if (<= t_1 700.0)
(- (fma (log t) (- a 0.5) (log (* z (+ y x)))) t)
(+ (fma -0.5 (log t) (log z)) (- (log y) t))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y)) + log(z);
double tmp;
if (t_1 <= -740.0) {
tmp = log((z / sqrt(t))) - (t - log(y));
} else if (t_1 <= 700.0) {
tmp = fma(log(t), (a - 0.5), log((z * (y + x)))) - t;
} else {
tmp = fma(-0.5, log(t), log(z)) + (log(y) - t);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) tmp = 0.0 if (t_1 <= -740.0) tmp = Float64(log(Float64(z / sqrt(t))) - Float64(t - log(y))); elseif (t_1 <= 700.0) tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(z * Float64(y + x)))) - t); else tmp = Float64(fma(-0.5, log(t), log(z)) + Float64(log(y) - t)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -740.0], N[(N[Log[N[(z / N[Sqrt[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(t - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 700.0], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_1 \leq -740:\\
\;\;\;\;\log \left(\frac{z}{\sqrt{t}}\right) - \left(t - \log y\right)\\
\mathbf{elif}\;t\_1 \leq 700:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(z \cdot \left(y + x\right)\right)\right) - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log z\right) + \left(\log y - t\right)\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -740Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6488.4
Applied rewrites88.4%
Applied rewrites3.5%
Taylor expanded in a around 0
Applied rewrites3.5%
Applied rewrites61.7%
if -740 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 700Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.6
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
sum-logN/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
if 700 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6463.2
Applied rewrites63.2%
Taylor expanded in a around 0
Applied rewrites39.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (or (<= t_1 -740.0) (not (<= t_1 700.0)))
(- (log (/ z (sqrt t))) (- t (log y)))
(- (fma (log t) (- a 0.5) (log (* z (+ y x)))) t))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y)) + log(z);
double tmp;
if ((t_1 <= -740.0) || !(t_1 <= 700.0)) {
tmp = log((z / sqrt(t))) - (t - log(y));
} else {
tmp = fma(log(t), (a - 0.5), log((z * (y + x)))) - t;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) tmp = 0.0 if ((t_1 <= -740.0) || !(t_1 <= 700.0)) tmp = Float64(log(Float64(z / sqrt(t))) - Float64(t - log(y))); else tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(z * Float64(y + x)))) - t); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -740.0], N[Not[LessEqual[t$95$1, 700.0]], $MachinePrecision]], N[(N[Log[N[(z / N[Sqrt[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(t - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_1 \leq -740 \lor \neg \left(t\_1 \leq 700\right):\\
\;\;\;\;\log \left(\frac{z}{\sqrt{t}}\right) - \left(t - \log y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(z \cdot \left(y + x\right)\right)\right) - t\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -740 or 700 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6466.1
Applied rewrites66.1%
Applied rewrites15.3%
Taylor expanded in a around 0
Applied rewrites10.5%
Applied rewrites38.3%
if -740 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 700Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.6
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
sum-logN/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
Final simplification85.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (<= t_1 710.0)
(- (fma (log t) (- a 0.5) (log (* z (+ y x)))) t)
(if (<= t_1 940.0) (* (log t) a) (- t)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y)) + log(z);
double tmp;
if (t_1 <= 710.0) {
tmp = fma(log(t), (a - 0.5), log((z * (y + x)))) - t;
} else if (t_1 <= 940.0) {
tmp = log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) tmp = 0.0 if (t_1 <= 710.0) tmp = Float64(fma(log(t), Float64(a - 0.5), log(Float64(z * Float64(y + x)))) - t); elseif (t_1 <= 940.0) tmp = Float64(log(t) * a); else tmp = Float64(-t); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 710.0], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t$95$1, 940.0], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], (-t)]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_1 \leq 710:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log \left(z \cdot \left(y + x\right)\right)\right) - t\\
\mathbf{elif}\;t\_1 \leq 940:\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 710Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.6
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
sum-logN/A
lower-log.f64N/A
*-commutativeN/A
lower-*.f6496.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6496.4
Applied rewrites96.4%
if 710 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 940Initial program 99.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6432.9
Applied rewrites32.9%
if 940 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6451.8
Applied rewrites51.8%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (<= t_1 710.0)
(fma (+ -0.5 a) (log t) (- (log (* z y)) t))
(if (<= t_1 940.0) (* (log t) a) (- t)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log((x + y)) + log(z);
double tmp;
if (t_1 <= 710.0) {
tmp = fma((-0.5 + a), log(t), (log((z * y)) - t));
} else if (t_1 <= 940.0) {
tmp = log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) tmp = 0.0 if (t_1 <= 710.0) tmp = fma(Float64(-0.5 + a), log(t), Float64(log(Float64(z * y)) - t)); elseif (t_1 <= 940.0) tmp = Float64(log(t) * a); else tmp = Float64(-t); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 710.0], N[(N[(-0.5 + a), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 940.0], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], (-t)]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_1 \leq 710:\\
\;\;\;\;\mathsf{fma}\left(-0.5 + a, \log t, \log \left(z \cdot y\right) - t\right)\\
\mathbf{elif}\;t\_1 \leq 940:\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 710Initial program 99.6%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6476.2
Applied rewrites76.2%
Applied rewrites70.8%
if 710 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 940Initial program 99.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6432.9
Applied rewrites32.9%
if 940 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6451.8
Applied rewrites51.8%
(FPCore (x y z t a) :precision binary64 (+ (fma (+ -0.5 a) (log t) (log z)) (- (log y) t)))
double code(double x, double y, double z, double t, double a) {
return fma((-0.5 + a), log(t), log(z)) + (log(y) - t);
}
function code(x, y, z, t, a) return Float64(fma(Float64(-0.5 + a), log(t), log(z)) + Float64(log(y) - t)) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(-0.5 + a), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.5 + a, \log t, \log z\right) + \left(\log y - t\right)
\end{array}
Initial program 99.6%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6473.4
Applied rewrites73.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (log t) a)))
(if (<= a -6.6e+40)
t_1
(if (<= a 1.4e-38)
(* (- (/ (log (* (sqrt (pow t -1.0)) (* z (+ x y)))) t) 1.0) t)
(if (<= a 8.6e+67) (- t) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log(t) * a;
double tmp;
if (a <= -6.6e+40) {
tmp = t_1;
} else if (a <= 1.4e-38) {
tmp = ((log((sqrt(pow(t, -1.0)) * (z * (x + y)))) / t) - 1.0) * t;
} else if (a <= 8.6e+67) {
tmp = -t;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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) :: t_1
real(8) :: tmp
t_1 = log(t) * a
if (a <= (-6.6d+40)) then
tmp = t_1
else if (a <= 1.4d-38) then
tmp = ((log((sqrt((t ** (-1.0d0))) * (z * (x + y)))) / t) - 1.0d0) * t
else if (a <= 8.6d+67) then
tmp = -t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = Math.log(t) * a;
double tmp;
if (a <= -6.6e+40) {
tmp = t_1;
} else if (a <= 1.4e-38) {
tmp = ((Math.log((Math.sqrt(Math.pow(t, -1.0)) * (z * (x + y)))) / t) - 1.0) * t;
} else if (a <= 8.6e+67) {
tmp = -t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = math.log(t) * a tmp = 0 if a <= -6.6e+40: tmp = t_1 elif a <= 1.4e-38: tmp = ((math.log((math.sqrt(math.pow(t, -1.0)) * (z * (x + y)))) / t) - 1.0) * t elif a <= 8.6e+67: tmp = -t else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(log(t) * a) tmp = 0.0 if (a <= -6.6e+40) tmp = t_1; elseif (a <= 1.4e-38) tmp = Float64(Float64(Float64(log(Float64(sqrt((t ^ -1.0)) * Float64(z * Float64(x + y)))) / t) - 1.0) * t); elseif (a <= 8.6e+67) tmp = Float64(-t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = log(t) * a; tmp = 0.0; if (a <= -6.6e+40) tmp = t_1; elseif (a <= 1.4e-38) tmp = ((log((sqrt((t ^ -1.0)) * (z * (x + y)))) / t) - 1.0) * t; elseif (a <= 8.6e+67) tmp = -t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[a, -6.6e+40], t$95$1, If[LessEqual[a, 1.4e-38], N[(N[(N[(N[Log[N[(N[Sqrt[N[Power[t, -1.0], $MachinePrecision]], $MachinePrecision] * N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision] - 1.0), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[a, 8.6e+67], (-t), t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log t \cdot a\\
\mathbf{if}\;a \leq -6.6 \cdot 10^{+40}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.4 \cdot 10^{-38}:\\
\;\;\;\;\left(\frac{\log \left(\sqrt{{t}^{-1}} \cdot \left(z \cdot \left(x + y\right)\right)\right)}{t} - 1\right) \cdot t\\
\mathbf{elif}\;a \leq 8.6 \cdot 10^{+67}:\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -6.5999999999999997e40 or 8.6000000000000002e67 < a Initial program 99.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6478.6
Applied rewrites78.6%
if -6.5999999999999997e40 < a < 1.4e-38Initial program 99.4%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
Applied rewrites64.1%
Taylor expanded in a around 0
Applied rewrites66.4%
if 1.4e-38 < a < 8.6000000000000002e67Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6459.4
Applied rewrites59.4%
Final simplification70.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -2.3e+41) (not (<= a 8.6e+67))) (* (log t) a) (- (log (* y z)) (fma (log t) 0.5 t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -2.3e+41) || !(a <= 8.6e+67)) {
tmp = log(t) * a;
} else {
tmp = log((y * z)) - fma(log(t), 0.5, t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -2.3e+41) || !(a <= 8.6e+67)) tmp = Float64(log(t) * a); else tmp = Float64(log(Float64(y * z)) - fma(log(t), 0.5, t)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -2.3e+41], N[Not[LessEqual[a, 8.6e+67]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], N[(N[Log[N[(y * z), $MachinePrecision]], $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * 0.5 + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.3 \cdot 10^{+41} \lor \neg \left(a \leq 8.6 \cdot 10^{+67}\right):\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;\log \left(y \cdot z\right) - \mathsf{fma}\left(\log t, 0.5, t\right)\\
\end{array}
\end{array}
if a < -2.2999999999999998e41 or 8.6000000000000002e67 < a Initial program 99.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6478.6
Applied rewrites78.6%
if -2.2999999999999998e41 < a < 8.6000000000000002e67Initial program 99.5%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6469.0
Applied rewrites69.0%
Applied rewrites57.6%
Taylor expanded in a around 0
Applied rewrites53.1%
Final simplification62.6%
(FPCore (x y z t a) :precision binary64 (if (<= t 3.15e+16) (fma (+ -0.5 a) (log t) (log (* y z))) (- t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 3.15e+16) {
tmp = fma((-0.5 + a), log(t), log((y * z)));
} else {
tmp = -t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= 3.15e+16) tmp = fma(Float64(-0.5 + a), log(t), log(Float64(y * z))); else tmp = Float64(-t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 3.15e+16], N[(N[(-0.5 + a), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[Log[N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 3.15 \cdot 10^{+16}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 + a, \log t, \log \left(y \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < 3.15e16Initial program 99.3%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6467.8
Applied rewrites67.8%
Applied rewrites56.6%
Taylor expanded in t around 0
Applied rewrites53.3%
if 3.15e16 < t Initial program 99.9%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6481.7
Applied rewrites81.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (log t) a)))
(if (<= a -6.6e+40)
t_1
(if (<= a 1.4e-38)
(- (log (/ (* z y) (sqrt t))) t)
(if (<= a 8.6e+67) (- t) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = log(t) * a;
double tmp;
if (a <= -6.6e+40) {
tmp = t_1;
} else if (a <= 1.4e-38) {
tmp = log(((z * y) / sqrt(t))) - t;
} else if (a <= 8.6e+67) {
tmp = -t;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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) :: t_1
real(8) :: tmp
t_1 = log(t) * a
if (a <= (-6.6d+40)) then
tmp = t_1
else if (a <= 1.4d-38) then
tmp = log(((z * y) / sqrt(t))) - t
else if (a <= 8.6d+67) then
tmp = -t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = Math.log(t) * a;
double tmp;
if (a <= -6.6e+40) {
tmp = t_1;
} else if (a <= 1.4e-38) {
tmp = Math.log(((z * y) / Math.sqrt(t))) - t;
} else if (a <= 8.6e+67) {
tmp = -t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = math.log(t) * a tmp = 0 if a <= -6.6e+40: tmp = t_1 elif a <= 1.4e-38: tmp = math.log(((z * y) / math.sqrt(t))) - t elif a <= 8.6e+67: tmp = -t else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(log(t) * a) tmp = 0.0 if (a <= -6.6e+40) tmp = t_1; elseif (a <= 1.4e-38) tmp = Float64(log(Float64(Float64(z * y) / sqrt(t))) - t); elseif (a <= 8.6e+67) tmp = Float64(-t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = log(t) * a; tmp = 0.0; if (a <= -6.6e+40) tmp = t_1; elseif (a <= 1.4e-38) tmp = log(((z * y) / sqrt(t))) - t; elseif (a <= 8.6e+67) tmp = -t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[a, -6.6e+40], t$95$1, If[LessEqual[a, 1.4e-38], N[(N[Log[N[(N[(z * y), $MachinePrecision] / N[Sqrt[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision], If[LessEqual[a, 8.6e+67], (-t), t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log t \cdot a\\
\mathbf{if}\;a \leq -6.6 \cdot 10^{+40}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.4 \cdot 10^{-38}:\\
\;\;\;\;\log \left(\frac{z \cdot y}{\sqrt{t}}\right) - t\\
\mathbf{elif}\;a \leq 8.6 \cdot 10^{+67}:\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -6.5999999999999997e40 or 8.6000000000000002e67 < a Initial program 99.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6478.6
Applied rewrites78.6%
if -6.5999999999999997e40 < a < 1.4e-38Initial program 99.4%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-log.f64N/A
lower--.f64N/A
lower-log.f6466.6
Applied rewrites66.6%
Applied rewrites55.1%
Taylor expanded in a around 0
Applied rewrites53.8%
Applied rewrites48.1%
if 1.4e-38 < a < 8.6000000000000002e67Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6459.4
Applied rewrites59.4%
(FPCore (x y z t a) :precision binary64 (if (<= t 8e+17) (* (log t) a) (- t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 8e+17) {
tmp = log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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 <= 8d+17) then
tmp = 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 <= 8e+17) {
tmp = Math.log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= 8e+17: tmp = math.log(t) * a else: tmp = -t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= 8e+17) tmp = 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 <= 8e+17) tmp = log(t) * a; else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 8e+17], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 8 \cdot 10^{+17}:\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < 8e17Initial program 99.3%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6445.1
Applied rewrites45.1%
if 8e17 < t Initial program 99.9%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6481.7
Applied rewrites81.7%
(FPCore (x y z t a) :precision binary64 (- t))
double code(double x, double y, double z, double t, double a) {
return -t;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6437.4
Applied rewrites37.4%
(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)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
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 2024352
(FPCore (x y z t a)
:name "Numeric.SpecFunctions:logGammaL from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (+ (log (+ x y)) (+ (- (log z) t) (* (- a 1/2) (log t)))))
(+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))