
(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 (+ (- (+ (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
(let* ((t_1 (+ (log (+ x y)) (log z)))
(t_2 (+ (fma (log t) (- a 0.5) (log z)) (log y))))
(if (<= t_1 -750.0)
t_2
(if (<= t_1 710.0)
(fma (- a 0.5) (log t) (- (log (* z (+ y x))) t))
(if (<= t_1 950.0)
(+ (- (+ (log y) (log z)) t) (* -0.5 (log t)))
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(log(t), (a - 0.5), log(z)) + log(y);
double tmp;
if (t_1 <= -750.0) {
tmp = t_2;
} else if (t_1 <= 710.0) {
tmp = fma((a - 0.5), log(t), (log((z * (y + x))) - t));
} else if (t_1 <= 950.0) {
tmp = ((log(y) + log(z)) - t) + (-0.5 * log(t));
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) t_2 = Float64(fma(log(t), Float64(a - 0.5), log(z)) + log(y)) tmp = 0.0 if (t_1 <= -750.0) tmp = t_2; elseif (t_1 <= 710.0) tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * Float64(y + x))) - t)); elseif (t_1 <= 950.0) tmp = Float64(Float64(Float64(log(y) + log(z)) - t) + Float64(-0.5 * log(t))); 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[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -750.0], t$95$2, If[LessEqual[t$95$1, 710.0], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 950.0], N[(N[(N[(N[Log[y], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] + N[(-0.5 * N[Log[t], $MachinePrecision]), $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(\log t, a - 0.5, \log z\right) + \log y\\
\mathbf{if}\;t\_1 \leq -750:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 710:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot \left(y + x\right)\right) - t\right)\\
\mathbf{elif}\;t\_1 \leq 950:\\
\;\;\;\;\left(\left(\log y + \log z\right) - t\right) + -0.5 \cdot \log t\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -750 or 950 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) 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.f6474.7
Applied rewrites74.7%
Taylor expanded in t around 0
Applied rewrites50.3%
if -750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 710Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/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)) < 950Initial program 99.9%
Taylor expanded in x around 0
lower-log.f6472.3
Applied rewrites72.3%
Taylor expanded in a around 0
Applied rewrites54.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z)))
(t_2 (+ (fma (log t) (- a 0.5) (log z)) (log y))))
(if (<= t_1 -750.0)
t_2
(if (<= t_1 710.0)
(fma (- a 0.5) (log t) (- (log (* z (+ y x))) t))
(if (<= t_1 950.0) (+ (log z) (fma -0.5 (log t) (- (log y) t))) 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(log(t), (a - 0.5), log(z)) + log(y);
double tmp;
if (t_1 <= -750.0) {
tmp = t_2;
} else if (t_1 <= 710.0) {
tmp = fma((a - 0.5), log(t), (log((z * (y + x))) - t));
} else if (t_1 <= 950.0) {
tmp = log(z) + fma(-0.5, log(t), (log(y) - t));
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) t_2 = Float64(fma(log(t), Float64(a - 0.5), log(z)) + log(y)) tmp = 0.0 if (t_1 <= -750.0) tmp = t_2; elseif (t_1 <= 710.0) tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * Float64(y + x))) - t)); elseif (t_1 <= 950.0) tmp = Float64(log(z) + fma(-0.5, log(t), Float64(log(y) - t))); 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[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -750.0], t$95$2, If[LessEqual[t$95$1, 710.0], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 950.0], N[(N[Log[z], $MachinePrecision] + N[(-0.5 * N[Log[t], $MachinePrecision] + N[(N[Log[y], $MachinePrecision] - t), $MachinePrecision]), $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(\log t, a - 0.5, \log z\right) + \log y\\
\mathbf{if}\;t\_1 \leq -750:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 710:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot \left(y + x\right)\right) - t\right)\\
\mathbf{elif}\;t\_1 \leq 950:\\
\;\;\;\;\log z + \mathsf{fma}\left(-0.5, \log t, \log y - t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < -750 or 950 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) 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.f6474.7
Applied rewrites74.7%
Taylor expanded in t around 0
Applied rewrites50.3%
if -750 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 710Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/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)) < 950Initial program 99.9%
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.f6472.3
Applied rewrites72.3%
Taylor expanded in a around 0
Applied rewrites54.4%
Applied rewrites54.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (<= t_1 722.0)
(fma (- a 0.5) (log t) (- (log (* z (+ y x))) t))
(if (<= t_1 950.0) (- t) (+ (log (+ y x)) (* (log t) a))))))
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 <= 722.0) {
tmp = fma((a - 0.5), log(t), (log((z * (y + x))) - t));
} else if (t_1 <= 950.0) {
tmp = -t;
} else {
tmp = log((y + x)) + (log(t) * a);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) tmp = 0.0 if (t_1 <= 722.0) tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * Float64(y + x))) - t)); elseif (t_1 <= 950.0) tmp = Float64(-t); else tmp = Float64(log(Float64(y + x)) + Float64(log(t) * a)); 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, 722.0], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 950.0], (-t), N[(N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_1 \leq 722:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot \left(y + x\right)\right) - t\right)\\
\mathbf{elif}\;t\_1 \leq 950:\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;\log \left(y + x\right) + \log t \cdot a\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 722Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/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-*.f6493.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.6
Applied rewrites93.6%
if 722 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 950Initial program 99.9%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6459.5
Applied rewrites59.5%
if 950 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.6%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lift-+.f64N/A
associate--l+N/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower--.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6453.1
Applied rewrites53.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (log (+ x y)) (log z))))
(if (<= t_1 722.0)
(fma (+ -0.5 a) (log t) (- (log (* z y)) t))
(if (<= t_1 950.0) (- t) (+ (log (+ y x)) (* (log t) a))))))
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 <= 722.0) {
tmp = fma((-0.5 + a), log(t), (log((z * y)) - t));
} else if (t_1 <= 950.0) {
tmp = -t;
} else {
tmp = log((y + x)) + (log(t) * a);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(log(Float64(x + y)) + log(z)) tmp = 0.0 if (t_1 <= 722.0) tmp = fma(Float64(-0.5 + a), log(t), Float64(log(Float64(z * y)) - t)); elseif (t_1 <= 950.0) tmp = Float64(-t); else tmp = Float64(log(Float64(y + x)) + Float64(log(t) * a)); 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, 722.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, 950.0], (-t), N[(N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log \left(x + y\right) + \log z\\
\mathbf{if}\;t\_1 \leq 722:\\
\;\;\;\;\mathsf{fma}\left(-0.5 + a, \log t, \log \left(z \cdot y\right) - t\right)\\
\mathbf{elif}\;t\_1 \leq 950:\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;\log \left(y + x\right) + \log t \cdot a\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 722Initial 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.f6471.7
Applied rewrites71.7%
Applied rewrites63.0%
if 722 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 950Initial program 99.9%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6459.5
Applied rewrites59.5%
if 950 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.6%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lift-+.f64N/A
associate--l+N/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower--.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6453.1
Applied rewrites53.1%
(FPCore (x y z t a) :precision binary64 (+ (log (+ y x)) (- (log z) (- t (* (log t) (- a 0.5))))))
double code(double x, double y, double z, double t, double a) {
return log((y + x)) + (log(z) - (t - (log(t) * (a - 0.5))));
}
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((y + x)) + (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((y + x)) + (Math.log(z) - (t - (Math.log(t) * (a - 0.5))));
}
def code(x, y, z, t, a): return math.log((y + x)) + (math.log(z) - (t - (math.log(t) * (a - 0.5))))
function code(x, y, z, t, a) return Float64(log(Float64(y + x)) + Float64(log(z) - Float64(t - Float64(log(t) * Float64(a - 0.5))))) end
function tmp = code(x, y, z, t, a) tmp = log((y + x)) + (log(z) - (t - (log(t) * (a - 0.5)))); end
code[x_, y_, z_, t_, a_] := N[(N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - N[(t - N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log \left(y + x\right) + \left(\log z - \left(t - \log t \cdot \left(a - 0.5\right)\right)\right)
\end{array}
Initial program 99.6%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lift-+.f64N/A
associate--l+N/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower--.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
(FPCore (x y z t a) :precision binary64 (if (<= t 43000.0) (+ (fma (log t) (- a 0.5) (log z)) (log y)) (if (<= t 2.5e+68) (fma (+ -0.5 a) (log t) (- (log (* z y)) t)) (- t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 43000.0) {
tmp = fma(log(t), (a - 0.5), log(z)) + log(y);
} else if (t <= 2.5e+68) {
tmp = fma((-0.5 + a), log(t), (log((z * y)) - t));
} else {
tmp = -t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= 43000.0) tmp = Float64(fma(log(t), Float64(a - 0.5), log(z)) + log(y)); elseif (t <= 2.5e+68) tmp = fma(Float64(-0.5 + a), log(t), Float64(log(Float64(z * y)) - t)); else tmp = Float64(-t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 43000.0], N[(N[(N[Log[t], $MachinePrecision] * N[(a - 0.5), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 2.5e+68], N[(N[(-0.5 + a), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], (-t)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 43000:\\
\;\;\;\;\mathsf{fma}\left(\log t, a - 0.5, \log z\right) + \log y\\
\mathbf{elif}\;t \leq 2.5 \cdot 10^{+68}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 + a, \log t, \log \left(z \cdot y\right) - t\right)\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < 43000Initial 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.f6467.9
Applied rewrites67.9%
Taylor expanded in t around 0
Applied rewrites67.0%
if 43000 < t < 2.5000000000000002e68Initial 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.f6485.2
Applied rewrites85.2%
Applied rewrites76.0%
if 2.5000000000000002e68 < t Initial program 99.8%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6484.5
Applied rewrites84.5%
(FPCore (x y z t a) :precision binary64 (+ (- (+ (log y) (log z)) t) (* (- a 0.5) (log t))))
double code(double x, double y, double z, double t, double a) {
return ((log(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(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(y) + Math.log(z)) - t) + ((a - 0.5) * Math.log(t));
}
def code(x, y, z, t, a): return ((math.log(y) + math.log(z)) - t) + ((a - 0.5) * math.log(t))
function code(x, y, z, t, a) return Float64(Float64(Float64(log(y) + log(z)) - t) + Float64(Float64(a - 0.5) * log(t))) end
function tmp = code(x, y, z, t, a) tmp = ((log(y) + log(z)) - t) + ((a - 0.5) * log(t)); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(N[Log[y], $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 y + \log z\right) - t\right) + \left(a - 0.5\right) \cdot \log t
\end{array}
Initial program 99.6%
Taylor expanded in x around 0
lower-log.f6471.7
Applied rewrites71.7%
(FPCore (x y z t a) :precision binary64 (fma (- a 0.5) (log t) (+ (- (log z) t) (log y))))
double code(double x, double y, double z, double t, double a) {
return fma((a - 0.5), log(t), ((log(z) - t) + log(y)));
}
function code(x, y, z, t, a) return fma(Float64(a - 0.5), log(t), Float64(Float64(log(z) - t) + log(y))) end
code[x_, y_, z_, t_, a_] := N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, \log t, \left(\log z - t\right) + \log y\right)
\end{array}
Initial program 99.6%
Taylor expanded in x around 0
lower-log.f6471.7
Applied rewrites71.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6471.7
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
+-commutativeN/A
lower-+.f6471.6
Applied rewrites71.6%
(FPCore (x y z t a) :precision binary64 (+ (log z) (fma (+ -0.5 a) (log t) (- (log y) t))))
double code(double x, double y, double z, double t, double a) {
return log(z) + fma((-0.5 + a), log(t), (log(y) - t));
}
function code(x, y, z, t, a) return Float64(log(z) + fma(Float64(-0.5 + a), log(t), Float64(log(y) - t))) end
code[x_, y_, z_, t_, a_] := N[(N[Log[z], $MachinePrecision] + N[(N[(-0.5 + a), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[y], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log z + \mathsf{fma}\left(-0.5 + a, \log t, \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.f6471.6
Applied rewrites71.6%
Applied rewrites71.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -165.0) (not (<= a 4.9e+18))) (* (log t) a) (fma -0.5 (log t) (- (log (* z y)) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -165.0) || !(a <= 4.9e+18)) {
tmp = log(t) * a;
} else {
tmp = fma(-0.5, log(t), (log((z * y)) - t));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -165.0) || !(a <= 4.9e+18)) tmp = Float64(log(t) * a); else tmp = fma(-0.5, log(t), Float64(log(Float64(z * y)) - t)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -165.0], N[Not[LessEqual[a, 4.9e+18]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], N[(-0.5 * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -165 \lor \neg \left(a \leq 4.9 \cdot 10^{+18}\right):\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log \left(z \cdot y\right) - t\right)\\
\end{array}
\end{array}
if a < -165 or 4.9e18 < a Initial program 99.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6478.8
Applied rewrites78.8%
if -165 < a < 4.9e18Initial program 99.6%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lift-+.f64N/A
associate--l+N/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower--.f6499.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
lift-+.f64N/A
lift--.f64N/A
associate-+r-N/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lift--.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.6
Applied rewrites71.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f6448.2
Applied rewrites48.2%
Taylor expanded in a around 0
Applied rewrites47.0%
Final simplification62.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -165.0) (not (<= a 9e+18))) (* (log t) a) (- (log (* (* (pow t -0.5) z) y)) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -165.0) || !(a <= 9e+18)) {
tmp = log(t) * a;
} else {
tmp = log(((pow(t, -0.5) * z) * y)) - 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 ((a <= (-165.0d0)) .or. (.not. (a <= 9d+18))) then
tmp = log(t) * a
else
tmp = log((((t ** (-0.5d0)) * z) * y)) - 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 <= -165.0) || !(a <= 9e+18)) {
tmp = Math.log(t) * a;
} else {
tmp = Math.log(((Math.pow(t, -0.5) * z) * y)) - t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (a <= -165.0) or not (a <= 9e+18): tmp = math.log(t) * a else: tmp = math.log(((math.pow(t, -0.5) * z) * y)) - t return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -165.0) || !(a <= 9e+18)) tmp = Float64(log(t) * a); else tmp = Float64(log(Float64(Float64((t ^ -0.5) * z) * y)) - t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((a <= -165.0) || ~((a <= 9e+18))) tmp = log(t) * a; else tmp = log((((t ^ -0.5) * z) * y)) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -165.0], N[Not[LessEqual[a, 9e+18]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], N[(N[Log[N[(N[(N[Power[t, -0.5], $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -165 \lor \neg \left(a \leq 9 \cdot 10^{+18}\right):\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;\log \left(\left({t}^{-0.5} \cdot z\right) \cdot y\right) - t\\
\end{array}
\end{array}
if a < -165 or 9e18 < a Initial program 99.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6478.8
Applied rewrites78.8%
if -165 < a < 9e18Initial 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.f6467.3
Applied rewrites67.3%
Taylor expanded in a around 0
Applied rewrites65.1%
Applied rewrites47.2%
Final simplification62.3%
(FPCore (x y z t a) :precision binary64 (if (<= t 3.8e+28) (+ (log (+ y x)) (* (log t) a)) (- t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 3.8e+28) {
tmp = log((y + x)) + (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 <= 3.8d+28) then
tmp = log((y + x)) + (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 <= 3.8e+28) {
tmp = Math.log((y + x)) + (Math.log(t) * a);
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= 3.8e+28: tmp = math.log((y + x)) + (math.log(t) * a) else: tmp = -t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= 3.8e+28) tmp = Float64(log(Float64(y + x)) + 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 <= 3.8e+28) tmp = log((y + x)) + (log(t) * a); else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 3.8e+28], N[(N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 3.8 \cdot 10^{+28}:\\
\;\;\;\;\log \left(y + x\right) + \log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < 3.7999999999999999e28Initial program 99.5%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lift-+.f64N/A
associate--l+N/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower--.f6499.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.4
Applied rewrites99.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6461.5
Applied rewrites61.5%
if 3.7999999999999999e28 < t Initial program 99.8%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6481.1
Applied rewrites81.1%
(FPCore (x y z t a) :precision binary64 (if (<= t 5.2e+28) (* (log t) a) (- t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 5.2e+28) {
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 <= 5.2d+28) 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 <= 5.2e+28) {
tmp = Math.log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= 5.2e+28: tmp = math.log(t) * a else: tmp = -t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= 5.2e+28) 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 <= 5.2e+28) tmp = log(t) * a; else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 5.2e+28], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 5.2 \cdot 10^{+28}:\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < 5.2000000000000004e28Initial program 99.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6456.1
Applied rewrites56.1%
if 5.2000000000000004e28 < t Initial program 99.8%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6481.1
Applied rewrites81.1%
(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.5
Applied rewrites38.5%
(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 2024364
(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))))