
(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}
Herbie found 11 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 z)))) (log (+ y x))) t))
double code(double x, double y, double z, double t, double a) {
return (fma(log(t), (a - 0.5), -(-log(z))) + log((y + x))) - t;
}
function code(x, y, z, t, a) return Float64(Float64(fma(log(t), Float64(a - 0.5), Float64(-Float64(-log(z)))) + log(Float64(y + x))) - t) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + (-(-N[Log[z], $MachinePrecision]))), $MachinePrecision] + N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(\log t, a - 0.5, -\left(-\log z\right)\right) + \log \left(y + x\right)\right) - t
\end{array}
Initial program 99.6%
Taylor expanded in z around inf
lower--.f64N/A
Applied rewrites99.6%
(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}
Initial program 99.6%
(FPCore (x y z t a) :precision binary64 (- (+ (fma (log t) (+ -0.5 a) (log (+ y x))) (log z)) t))
double code(double x, double y, double z, double t, double a) {
return (fma(log(t), (-0.5 + a), log((y + x))) + log(z)) - t;
}
function code(x, y, z, t, a) return Float64(Float64(fma(log(t), Float64(-0.5 + a), log(Float64(y + x))) + log(z)) - t) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(N[Log[t], $MachinePrecision] * N[(-0.5 + a), $MachinePrecision] + N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(\log t, -0.5 + a, \log \left(y + x\right)\right) + \log z\right) - t
\end{array}
Initial program 99.6%
Taylor expanded in a around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift-log.f64N/A
lower-+.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-log.f6499.6
Applied rewrites99.6%
(FPCore (x y z t a)
:precision binary64
(if (<= a -8.2)
(+ (- t) (* (- a 0.5) (log t)))
(if (<= a 1.75)
(- (+ (fma -0.5 (log t) (log z)) (log (+ y x))) t)
(- (+ (* a (log t)) (log y)) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -8.2) {
tmp = -t + ((a - 0.5) * log(t));
} else if (a <= 1.75) {
tmp = (fma(-0.5, log(t), log(z)) + log((y + x))) - t;
} else {
tmp = ((a * log(t)) + log(y)) - t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -8.2) tmp = Float64(Float64(-t) + Float64(Float64(a - 0.5) * log(t))); elseif (a <= 1.75) tmp = Float64(Float64(fma(-0.5, log(t), log(z)) + log(Float64(y + x))) - t); else tmp = Float64(Float64(Float64(a * log(t)) + log(y)) - t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -8.2], N[((-t) + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.75], N[(N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.2:\\
\;\;\;\;\left(-t\right) + \left(a - 0.5\right) \cdot \log t\\
\mathbf{elif}\;a \leq 1.75:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5, \log t, \log z\right) + \log \left(y + x\right)\right) - t\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot \log t + \log y\right) - t\\
\end{array}
\end{array}
if a < -8.1999999999999993Initial program 99.7%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6498.9
Applied rewrites98.9%
if -8.1999999999999993 < a < 1.75Initial program 99.5%
Taylor expanded in z around inf
lower--.f64N/A
Applied rewrites99.5%
Taylor expanded in a around inf
lower-*.f64N/A
lift-log.f6456.7
Applied rewrites56.7%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f6498.3
Applied rewrites98.3%
if 1.75 < a Initial program 99.7%
Taylor expanded in z around inf
lower--.f64N/A
Applied rewrites99.7%
Taylor expanded in a around inf
lower-*.f64N/A
lift-log.f6498.3
Applied rewrites98.3%
Taylor expanded in x around 0
+-commutative76.1
Applied rewrites76.1%
(FPCore (x y z t a)
:precision binary64
(if (<= a -8.2)
(+ (- t) (* (- a 0.5) (log t)))
(if (<= a 1.75)
(- (+ (fma -0.5 (log t) (log z)) (log y)) t)
(- (+ (* a (log t)) (log y)) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -8.2) {
tmp = -t + ((a - 0.5) * log(t));
} else if (a <= 1.75) {
tmp = (fma(-0.5, log(t), log(z)) + log(y)) - t;
} else {
tmp = ((a * log(t)) + log(y)) - t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -8.2) tmp = Float64(Float64(-t) + Float64(Float64(a - 0.5) * log(t))); elseif (a <= 1.75) tmp = Float64(Float64(fma(-0.5, log(t), log(z)) + log(y)) - t); else tmp = Float64(Float64(Float64(a * log(t)) + log(y)) - t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -8.2], N[((-t) + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.75], N[(N[(N[(-0.5 * N[Log[t], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.2:\\
\;\;\;\;\left(-t\right) + \left(a - 0.5\right) \cdot \log t\\
\mathbf{elif}\;a \leq 1.75:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5, \log t, \log z\right) + \log y\right) - t\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot \log t + \log y\right) - t\\
\end{array}
\end{array}
if a < -8.1999999999999993Initial program 99.7%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6498.9
Applied rewrites98.9%
if -8.1999999999999993 < a < 1.75Initial program 99.5%
Taylor expanded in z around inf
lower--.f64N/A
Applied rewrites99.5%
Taylor expanded in a around inf
lower-*.f64N/A
lift-log.f6456.7
Applied rewrites56.7%
Taylor expanded in x around 0
+-commutative41.9
Applied rewrites41.9%
Taylor expanded in a around 0
+-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift-log.f6463.1
Applied rewrites63.1%
if 1.75 < a Initial program 99.7%
Taylor expanded in z around inf
lower--.f64N/A
Applied rewrites99.7%
Taylor expanded in a around inf
lower-*.f64N/A
lift-log.f6498.3
Applied rewrites98.3%
Taylor expanded in x around 0
+-commutative76.1
Applied rewrites76.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))
(t_2 (- (+ (* a (log t)) (log y)) t)))
(if (<= t_1 -500.0)
t_2
(if (<= t_1 1020.0) (fma (- a 0.5) (log t) (log (* z y))) t_2))))
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 t_2 = ((a * log(t)) + log(y)) - t;
double tmp;
if (t_1 <= -500.0) {
tmp = t_2;
} else if (t_1 <= 1020.0) {
tmp = fma((a - 0.5), log(t), log((z * y)));
} else {
tmp = t_2;
}
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))) t_2 = Float64(Float64(Float64(a * log(t)) + log(y)) - t) tmp = 0.0 if (t_1 <= -500.0) tmp = t_2; elseif (t_1 <= 1020.0) tmp = fma(Float64(a - 0.5), log(t), log(Float64(z * y))); else tmp = t_2; 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]}, Block[{t$95$2 = N[(N[(N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[t$95$1, -500.0], t$95$2, If[LessEqual[t$95$1, 1020.0], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\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\\
t_2 := \left(a \cdot \log t + \log y\right) - t\\
\mathbf{if}\;t\_1 \leq -500:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 1020:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\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))) < -500 or 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.8%
Taylor expanded in z around inf
lower--.f64N/A
Applied rewrites99.8%
Taylor expanded in a around inf
lower-*.f64N/A
lift-log.f6493.6
Applied rewrites93.6%
Taylor expanded in x around 0
+-commutative70.9
Applied rewrites70.9%
if -500 < (+.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 98.9%
Taylor expanded in x around 0
lower--.f64N/A
associate-+r+N/A
sum-logN/A
*-commutativeN/A
log-pow-revN/A
sum-logN/A
lower-log.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lift--.f6444.1
Applied rewrites44.1%
Taylor expanded in t around 0
pow-to-expN/A
associate-*r*N/A
lift-pow.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-log.f6442.9
Applied rewrites42.9%
lift-log.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
*-commutativeN/A
log-prodN/A
log-pow-revN/A
sum-logN/A
lower-fma.f64N/A
lift--.f64N/A
lift-log.f64N/A
+-commutativeN/A
log-prodN/A
lift-log.f64N/A
lift-*.f6447.2
Applied rewrites47.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))
(t_2 (- (+ (* a (log t)) (log y)) t)))
(if (<= t_1 -500.0)
t_2
(if (<= t_1 1020.0) (fma 0.5 (- (log t)) (log (* z y))) t_2))))
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 t_2 = ((a * log(t)) + log(y)) - t;
double tmp;
if (t_1 <= -500.0) {
tmp = t_2;
} else if (t_1 <= 1020.0) {
tmp = fma(0.5, -log(t), log((z * y)));
} else {
tmp = t_2;
}
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))) t_2 = Float64(Float64(Float64(a * log(t)) + log(y)) - t) tmp = 0.0 if (t_1 <= -500.0) tmp = t_2; elseif (t_1 <= 1020.0) tmp = fma(0.5, Float64(-log(t)), log(Float64(z * y))); else tmp = t_2; 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]}, Block[{t$95$2 = N[(N[(N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[t$95$1, -500.0], t$95$2, If[LessEqual[t$95$1, 1020.0], N[(0.5 * (-N[Log[t], $MachinePrecision]) + N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\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\\
t_2 := \left(a \cdot \log t + \log y\right) - t\\
\mathbf{if}\;t\_1 \leq -500:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 1020:\\
\;\;\;\;\mathsf{fma}\left(0.5, -\log t, \log \left(z \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\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))) < -500 or 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.8%
Taylor expanded in z around inf
lower--.f64N/A
Applied rewrites99.8%
Taylor expanded in a around inf
lower-*.f64N/A
lift-log.f6493.6
Applied rewrites93.6%
Taylor expanded in x around 0
+-commutative70.9
Applied rewrites70.9%
if -500 < (+.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 98.9%
Taylor expanded in x around 0
lower--.f64N/A
associate-+r+N/A
sum-logN/A
*-commutativeN/A
log-pow-revN/A
sum-logN/A
lower-log.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lift--.f6444.1
Applied rewrites44.1%
Taylor expanded in t around 0
pow-to-expN/A
associate-*r*N/A
lift-pow.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-log.f6442.9
Applied rewrites42.9%
Taylor expanded in a around 0
log-prodN/A
pow1/2N/A
log-powN/A
log-recN/A
mul-1-negN/A
sum-logN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-log.f64N/A
+-commutativeN/A
log-prodN/A
lift-log.f64N/A
lift-*.f6446.1
Applied rewrites46.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))
(t_2 (- (* a (log t)) t)))
(if (<= t_1 -700.0)
t_2
(if (<= t_1 2000.0) (fma 0.5 (- (log t)) (log (* z y))) t_2))))
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 t_2 = (a * log(t)) - t;
double tmp;
if (t_1 <= -700.0) {
tmp = t_2;
} else if (t_1 <= 2000.0) {
tmp = fma(0.5, -log(t), log((z * y)));
} else {
tmp = t_2;
}
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))) t_2 = Float64(Float64(a * log(t)) - t) tmp = 0.0 if (t_1 <= -700.0) tmp = t_2; elseif (t_1 <= 2000.0) tmp = fma(0.5, Float64(-log(t)), log(Float64(z * y))); else tmp = t_2; 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]}, Block[{t$95$2 = N[(N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[t$95$1, -700.0], t$95$2, If[LessEqual[t$95$1, 2000.0], N[(0.5 * (-N[Log[t], $MachinePrecision]) + N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\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\\
t_2 := a \cdot \log t - t\\
\mathbf{if}\;t\_1 \leq -700:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2000:\\
\;\;\;\;\mathsf{fma}\left(0.5, -\log t, \log \left(z \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\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))) < -700 or 2e3 < (+.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.8%
Taylor expanded in z around inf
lower--.f64N/A
Applied rewrites99.8%
Taylor expanded in a around inf
lower-*.f64N/A
lift-log.f6497.7
Applied rewrites97.7%
if -700 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < 2e3Initial program 99.0%
Taylor expanded in x around 0
lower--.f64N/A
associate-+r+N/A
sum-logN/A
*-commutativeN/A
log-pow-revN/A
sum-logN/A
lower-log.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lift--.f6438.5
Applied rewrites38.5%
Taylor expanded in t around 0
pow-to-expN/A
associate-*r*N/A
lift-pow.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-log.f6437.4
Applied rewrites37.4%
Taylor expanded in a around 0
log-prodN/A
pow1/2N/A
log-powN/A
log-recN/A
mul-1-negN/A
sum-logN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-log.f64N/A
+-commutativeN/A
log-prodN/A
lift-log.f64N/A
lift-*.f6440.2
Applied rewrites40.2%
(FPCore (x y z t a) :precision binary64 (- (* a (log t)) t))
double code(double x, double y, double z, double t, double a) {
return (a * log(t)) - 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 = (a * log(t)) - t
end function
public static double code(double x, double y, double z, double t, double a) {
return (a * Math.log(t)) - t;
}
def code(x, y, z, t, a): return (a * math.log(t)) - t
function code(x, y, z, t, a) return Float64(Float64(a * log(t)) - t) end
function tmp = code(x, y, z, t, a) tmp = (a * log(t)) - t; end
code[x_, y_, z_, t_, a_] := N[(N[(a * N[Log[t], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
a \cdot \log t - t
\end{array}
Initial program 99.6%
Taylor expanded in z around inf
lower--.f64N/A
Applied rewrites99.6%
Taylor expanded in a around inf
lower-*.f64N/A
lift-log.f6474.6
Applied rewrites74.6%
(FPCore (x y z t a) :precision binary64 (if (<= t 1.4e+47) (* (log t) a) (- t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 1.4e+47) {
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 <= 1.4d+47) 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 <= 1.4e+47) {
tmp = Math.log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= 1.4e+47: tmp = math.log(t) * a else: tmp = -t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= 1.4e+47) 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 <= 1.4e+47) tmp = log(t) * a; else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 1.4e+47], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.4 \cdot 10^{+47}:\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < 1.39999999999999994e47Initial program 99.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6450.1
Applied rewrites50.1%
if 1.39999999999999994e47 < t Initial program 99.9%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6478.0
Applied rewrites78.0%
(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.f6438.0
Applied rewrites38.0%
herbie shell --seed 2025101
(FPCore (x y z t a)
:name "Numeric.SpecFunctions:logGammaL from math-functions-0.1.5.2"
:precision binary64
(+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))