
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ (- (+ (log (+ x y)) (log z)) t) (* (- a 0.5) (log t))))
double code(double x, double y, double z, double t, double a) {
return ((log((x + y)) + log(z)) - t) + ((a - 0.5) * log(t));
}
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 (+ y x)) (- (log z) t)) (* (- a 0.5) (log t))))
double code(double x, double y, double z, double t, double a) {
return (log((y + x)) + (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 + x)) + (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 + x)) + (Math.log(z) - t)) + ((a - 0.5) * Math.log(t));
}
def code(x, y, z, t, a): return (math.log((y + x)) + (math.log(z) - t)) + ((a - 0.5) * math.log(t))
function code(x, y, z, t, a) return Float64(Float64(log(Float64(y + x)) + Float64(log(z) - t)) + Float64(Float64(a - 0.5) * log(t))) end
function tmp = code(x, y, z, t, a) tmp = (log((y + x)) + (log(z) - t)) + ((a - 0.5) * log(t)); end
code[x_, y_, z_, t_, a_] := N[(N[(N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\log \left(y + x\right) + \left(\log z - t\right)\right) + \left(a - 0.5\right) \cdot \log t
\end{array}
Initial program 99.6%
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
associate--l+N/A
lower-+.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lift-log.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))))
(t_2 (* (log t) a)))
(if (<= t_1 -5e+19)
(- t_2 t)
(if (<= t_1 1000.0)
(fma -0.5 (log t) (- (log (* z y)) t))
(+ (+ (log (+ y x)) (- t)) 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 = log(t) * a;
double tmp;
if (t_1 <= -5e+19) {
tmp = t_2 - t;
} else if (t_1 <= 1000.0) {
tmp = fma(-0.5, log(t), (log((z * y)) - t));
} else {
tmp = (log((y + x)) + -t) + 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(log(t) * a) tmp = 0.0 if (t_1 <= -5e+19) tmp = Float64(t_2 - t); elseif (t_1 <= 1000.0) tmp = fma(-0.5, log(t), Float64(log(Float64(z * y)) - t)); else tmp = Float64(Float64(log(Float64(y + x)) + Float64(-t)) + 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[Log[t], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+19], N[(t$95$2 - t), $MachinePrecision], If[LessEqual[t$95$1, 1000.0], N[(-0.5 * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision] + (-t)), $MachinePrecision] + t$95$2), $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\\
t_2 := \log t \cdot a\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+19}:\\
\;\;\;\;t\_2 - t\\
\mathbf{elif}\;t\_1 \leq 1000:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log \left(z \cdot y\right) - t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\log \left(y + x\right) + \left(-t\right)\right) + 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))) < -5e19Initial program 99.8%
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.8
Applied rewrites99.8%
Taylor expanded in a around inf
*-commutativeN/A
lift-log.f64N/A
lift-*.f6499.8
Applied rewrites99.8%
if -5e19 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < 1e3Initial program 99.1%
Taylor expanded in x around 0
+-commutativeN/A
sum-logN/A
lower-log.f64N/A
lower-*.f6446.2
Applied rewrites46.2%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift-log.f6446.2
Applied rewrites46.2%
Taylor expanded in a around 0
Applied rewrites46.2%
if 1e3 < (+.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.5%
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
associate--l+N/A
lower-+.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lift-log.f6499.5
Applied rewrites99.5%
Taylor expanded in a around 0
lower-*.f64N/A
lift-log.f6420.0
Applied rewrites20.0%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f646.1
Applied rewrites6.1%
Taylor expanded in a around inf
*-commutativeN/A
lift-log.f64N/A
lift-*.f6483.2
Applied rewrites83.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 (* (log t) a)))
(if (<= t_1 -5e+19)
(- t_2 t)
(if (<= t_1 1000.0)
(fma -0.5 (log t) (- (log (* z y)) t))
(- (+ t_2 (log z)) t)))))
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 = log(t) * a;
double tmp;
if (t_1 <= -5e+19) {
tmp = t_2 - t;
} else if (t_1 <= 1000.0) {
tmp = fma(-0.5, log(t), (log((z * y)) - t));
} else {
tmp = (t_2 + log(z)) - t;
}
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(log(t) * a) tmp = 0.0 if (t_1 <= -5e+19) tmp = Float64(t_2 - t); elseif (t_1 <= 1000.0) tmp = fma(-0.5, log(t), Float64(log(Float64(z * y)) - t)); else tmp = Float64(Float64(t_2 + log(z)) - t); 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[Log[t], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+19], N[(t$95$2 - t), $MachinePrecision], If[LessEqual[t$95$1, 1000.0], N[(-0.5 * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $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\\
t_2 := \log t \cdot a\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+19}:\\
\;\;\;\;t\_2 - t\\
\mathbf{elif}\;t\_1 \leq 1000:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log t, \log \left(z \cdot y\right) - t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_2 + \log z\right) - t\\
\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))) < -5e19Initial program 99.8%
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.8
Applied rewrites99.8%
Taylor expanded in a around inf
*-commutativeN/A
lift-log.f64N/A
lift-*.f6499.8
Applied rewrites99.8%
if -5e19 < (+.f64 (-.f64 (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) t) (*.f64 (-.f64 a #s(literal 1/2 binary64)) (log.f64 t))) < 1e3Initial program 99.1%
Taylor expanded in x around 0
+-commutativeN/A
sum-logN/A
lower-log.f64N/A
lower-*.f6446.2
Applied rewrites46.2%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift-log.f6446.2
Applied rewrites46.2%
Taylor expanded in a around 0
Applied rewrites46.2%
if 1e3 < (+.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.5%
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.5
Applied rewrites99.5%
Taylor expanded in a around inf
*-commutativeN/A
lift-log.f64N/A
lift-*.f6483.0
Applied rewrites83.0%
(FPCore (x y z t a) :precision binary64 (if (<= (+ (log (+ x y)) (log z)) 705.36) (fma (- a 0.5) (log t) (- (log (* z (+ y x))) t)) (+ (+ (log (+ y x)) (- t)) (* (- a 0.5) (log t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((log((x + y)) + log(z)) <= 705.36) {
tmp = fma((a - 0.5), log(t), (log((z * (y + x))) - t));
} else {
tmp = (log((y + x)) + -t) + ((a - 0.5) * log(t));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (Float64(log(Float64(x + y)) + log(z)) <= 705.36) tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * Float64(y + x))) - t)); else tmp = Float64(Float64(log(Float64(y + x)) + Float64(-t)) + Float64(Float64(a - 0.5) * log(t))); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision], 705.36], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision] + (-t)), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\log \left(x + y\right) + \log z \leq 705.36:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot \left(y + x\right)\right) - t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\log \left(y + x\right) + \left(-t\right)\right) + \left(a - 0.5\right) \cdot \log t\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 705.360000000000014Initial program 99.5%
lift-+.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift-log.f64N/A
lower--.f64N/A
+-commutativeN/A
sum-logN/A
lower-log.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6496.8
Applied rewrites96.8%
if 705.360000000000014 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
associate--l+N/A
lower-+.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lift-log.f6499.8
Applied rewrites99.8%
Taylor expanded in t around inf
mul-1-negN/A
lift-neg.f6481.8
Applied rewrites81.8%
(FPCore (x y z t a) :precision binary64 (if (<= (+ (log (+ x y)) (log z)) 705.36) (fma (- a 0.5) (log t) (- (log (* z y)) t)) (+ (+ (log (+ y x)) (- t)) (* (- a 0.5) (log t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((log((x + y)) + log(z)) <= 705.36) {
tmp = fma((a - 0.5), log(t), (log((z * y)) - t));
} else {
tmp = (log((y + x)) + -t) + ((a - 0.5) * log(t));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (Float64(log(Float64(x + y)) + log(z)) <= 705.36) tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * y)) - t)); else tmp = Float64(Float64(log(Float64(y + x)) + Float64(-t)) + Float64(Float64(a - 0.5) * log(t))); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision], 705.36], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision] + (-t)), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\log \left(x + y\right) + \log z \leq 705.36:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot y\right) - t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\log \left(y + x\right) + \left(-t\right)\right) + \left(a - 0.5\right) \cdot \log t\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 705.360000000000014Initial program 99.5%
Taylor expanded in x around 0
+-commutativeN/A
sum-logN/A
lower-log.f64N/A
lower-*.f6461.4
Applied rewrites61.4%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift-log.f6461.4
Applied rewrites61.4%
if 705.360000000000014 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
associate--l+N/A
lower-+.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lift-log.f6499.8
Applied rewrites99.8%
Taylor expanded in t around inf
mul-1-negN/A
lift-neg.f6481.8
Applied rewrites81.8%
(FPCore (x y z t a) :precision binary64 (if (<= (+ (log (+ x y)) (log z)) 705.36) (fma (- a 0.5) (log t) (- (log (* z y)) t)) (+ (+ (log (+ y x)) (- t)) (* (log t) a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((log((x + y)) + log(z)) <= 705.36) {
tmp = fma((a - 0.5), log(t), (log((z * y)) - t));
} else {
tmp = (log((y + x)) + -t) + (log(t) * a);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (Float64(log(Float64(x + y)) + log(z)) <= 705.36) tmp = fma(Float64(a - 0.5), log(t), Float64(log(Float64(z * y)) - t)); else tmp = Float64(Float64(log(Float64(y + x)) + Float64(-t)) + Float64(log(t) * a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[Log[N[(x + y), $MachinePrecision]], $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision], 705.36], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + N[(N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(y + x), $MachinePrecision]], $MachinePrecision] + (-t)), $MachinePrecision] + N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\log \left(x + y\right) + \log z \leq 705.36:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, \log \left(z \cdot y\right) - t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\log \left(y + x\right) + \left(-t\right)\right) + \log t \cdot a\\
\end{array}
\end{array}
if (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) < 705.360000000000014Initial program 99.5%
Taylor expanded in x around 0
+-commutativeN/A
sum-logN/A
lower-log.f64N/A
lower-*.f6461.4
Applied rewrites61.4%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift-log.f6461.4
Applied rewrites61.4%
if 705.360000000000014 < (+.f64 (log.f64 (+.f64 x y)) (log.f64 z)) Initial program 99.7%
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
associate--l+N/A
lower-+.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lift-log.f6499.8
Applied rewrites99.8%
Taylor expanded in a around 0
lower-*.f64N/A
lift-log.f6470.6
Applied rewrites70.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6452.6
Applied rewrites52.6%
Taylor expanded in a around inf
*-commutativeN/A
lift-log.f64N/A
lift-*.f6481.6
Applied rewrites81.6%
(FPCore (x y z t a)
:precision binary64
(if (<= a -0.92)
(fma (- a 0.5) (log t) (- t))
(if (<= a 2.2)
(+ (+ (log y) (- (log z) t)) (* -0.5 (log t)))
(- (* (log t) a) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -0.92) {
tmp = fma((a - 0.5), log(t), -t);
} else if (a <= 2.2) {
tmp = (log(y) + (log(z) - t)) + (-0.5 * log(t));
} else {
tmp = (log(t) * a) - t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -0.92) tmp = fma(Float64(a - 0.5), log(t), Float64(-t)); elseif (a <= 2.2) tmp = Float64(Float64(log(y) + Float64(log(z) - t)) + Float64(-0.5 * log(t))); else tmp = Float64(Float64(log(t) * a) - t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -0.92], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + (-t)), $MachinePrecision], If[LessEqual[a, 2.2], N[(N[(N[Log[y], $MachinePrecision] + N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision] - t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.92:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, -t\right)\\
\mathbf{elif}\;a \leq 2.2:\\
\;\;\;\;\left(\log y + \left(\log z - t\right)\right) + -0.5 \cdot \log t\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot a - t\\
\end{array}
\end{array}
if a < -0.92000000000000004Initial program 99.6%
Taylor expanded in x around 0
+-commutativeN/A
sum-logN/A
lower-log.f64N/A
lower-*.f6460.2
Applied rewrites60.2%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift-log.f6460.3
Applied rewrites60.3%
Taylor expanded in t around inf
+-commutativeN/A
associate-+r-N/A
mul-1-negN/A
lower-neg.f6498.2
Applied rewrites98.2%
if -0.92000000000000004 < a < 2.2000000000000002Initial program 99.6%
lift--.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-log.f64N/A
lift-log.f64N/A
associate--l+N/A
lower-+.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lift-log.f6499.6
Applied rewrites99.6%
Taylor expanded in a around 0
lower-*.f64N/A
lift-log.f6498.6
Applied rewrites98.6%
Taylor expanded in x around 0
Applied rewrites65.4%
if 2.2000000000000002 < a Initial program 99.5%
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.5
Applied rewrites99.5%
Taylor expanded in a around inf
*-commutativeN/A
lift-log.f64N/A
lift-*.f6499.5
Applied rewrites99.5%
(FPCore (x y z t a)
:precision binary64
(if (<= a -0.92)
(fma (- a 0.5) (log t) (- t))
(if (<= a 2.2)
(- (+ (fma (log t) -0.5 (log y)) (log z)) t)
(- (* (log t) a) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -0.92) {
tmp = fma((a - 0.5), log(t), -t);
} else if (a <= 2.2) {
tmp = (fma(log(t), -0.5, log(y)) + log(z)) - t;
} else {
tmp = (log(t) * a) - t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -0.92) tmp = fma(Float64(a - 0.5), log(t), Float64(-t)); elseif (a <= 2.2) tmp = Float64(Float64(fma(log(t), -0.5, log(y)) + log(z)) - t); else tmp = Float64(Float64(log(t) * a) - t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -0.92], N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + (-t)), $MachinePrecision], If[LessEqual[a, 2.2], N[(N[(N[(N[Log[t], $MachinePrecision] * -0.5 + N[Log[y], $MachinePrecision]), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision] - t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.92:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, \log t, -t\right)\\
\mathbf{elif}\;a \leq 2.2:\\
\;\;\;\;\left(\mathsf{fma}\left(\log t, -0.5, \log y\right) + \log z\right) - t\\
\mathbf{else}:\\
\;\;\;\;\log t \cdot a - t\\
\end{array}
\end{array}
if a < -0.92000000000000004Initial program 99.6%
Taylor expanded in x around 0
+-commutativeN/A
sum-logN/A
lower-log.f64N/A
lower-*.f6460.2
Applied rewrites60.2%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift-log.f6460.3
Applied rewrites60.3%
Taylor expanded in t around inf
+-commutativeN/A
associate-+r-N/A
mul-1-negN/A
lower-neg.f6498.2
Applied rewrites98.2%
if -0.92000000000000004 < a < 2.2000000000000002Initial 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.5
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites65.4%
Taylor expanded in a around 0
Applied rewrites65.4%
if 2.2000000000000002 < a Initial program 99.5%
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.5
Applied rewrites99.5%
Taylor expanded in a around inf
*-commutativeN/A
lift-log.f64N/A
lift-*.f6499.5
Applied rewrites99.5%
(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.5
Applied rewrites99.5%
(FPCore (x y z t a) :precision binary64 (- (+ (fma (log t) (+ -0.5 a) (log y)) (log z)) t))
double code(double x, double y, double z, double t, double a) {
return (fma(log(t), (-0.5 + a), log(y)) + log(z)) - t;
}
function code(x, y, z, t, a) return Float64(Float64(fma(log(t), Float64(-0.5 + a), log(y)) + log(z)) - t) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(N[Log[t], $MachinePrecision] * N[(-0.5 + a), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(\log t, -0.5 + a, \log y\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.5
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites69.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= (- a 0.5) -5e+38) (not (<= (- a 0.5) 1e+16))) (* (log t) a) (- t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((a - 0.5) <= -5e+38) || !((a - 0.5) <= 1e+16)) {
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 (((a - 0.5d0) <= (-5d+38)) .or. (.not. ((a - 0.5d0) <= 1d+16))) 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 (((a - 0.5) <= -5e+38) || !((a - 0.5) <= 1e+16)) {
tmp = Math.log(t) * a;
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if ((a - 0.5) <= -5e+38) or not ((a - 0.5) <= 1e+16): tmp = math.log(t) * a else: tmp = -t return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((Float64(a - 0.5) <= -5e+38) || !(Float64(a - 0.5) <= 1e+16)) 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 (((a - 0.5) <= -5e+38) || ~(((a - 0.5) <= 1e+16))) tmp = log(t) * a; else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(a - 0.5), $MachinePrecision], -5e+38], N[Not[LessEqual[N[(a - 0.5), $MachinePrecision], 1e+16]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision], (-t)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a - 0.5 \leq -5 \cdot 10^{+38} \lor \neg \left(a - 0.5 \leq 10^{+16}\right):\\
\;\;\;\;\log t \cdot a\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if (-.f64 a #s(literal 1/2 binary64)) < -4.9999999999999997e38 or 1e16 < (-.f64 a #s(literal 1/2 binary64)) Initial program 99.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6485.8
Applied rewrites85.8%
if -4.9999999999999997e38 < (-.f64 a #s(literal 1/2 binary64)) < 1e16Initial program 99.6%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6456.4
Applied rewrites56.4%
Final simplification69.3%
(FPCore (x y z t a) :precision binary64 (fma (- a 0.5) (log t) (- t)))
double code(double x, double y, double z, double t, double a) {
return fma((a - 0.5), log(t), -t);
}
function code(x, y, z, t, a) return fma(Float64(a - 0.5), log(t), Float64(-t)) end
code[x_, y_, z_, t_, a_] := N[(N[(a - 0.5), $MachinePrecision] * N[Log[t], $MachinePrecision] + (-t)), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, \log t, -t\right)
\end{array}
Initial program 99.6%
Taylor expanded in x around 0
+-commutativeN/A
sum-logN/A
lower-log.f64N/A
lower-*.f6453.7
Applied rewrites53.7%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift-log.f6453.7
Applied rewrites53.7%
Taylor expanded in t around inf
+-commutativeN/A
associate-+r-N/A
mul-1-negN/A
lower-neg.f6478.6
Applied rewrites78.6%
(FPCore (x y z t a) :precision binary64 (- (* (log t) a) t))
double code(double x, double y, double z, double t, double a) {
return (log(t) * a) - 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(t) * a) - t
end function
public static double code(double x, double y, double z, double t, double a) {
return (Math.log(t) * a) - t;
}
def code(x, y, z, t, a): return (math.log(t) * a) - t
function code(x, y, z, t, a) return Float64(Float64(log(t) * a) - t) end
function tmp = code(x, y, z, t, a) tmp = (log(t) * a) - t; end
code[x_, y_, z_, t_, a_] := N[(N[(N[Log[t], $MachinePrecision] * a), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\log t \cdot a - 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.5
Applied rewrites99.5%
Taylor expanded in a around inf
*-commutativeN/A
lift-log.f64N/A
lift-*.f6476.1
Applied rewrites76.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.f6439.2
Applied rewrites39.2%
herbie shell --seed 2025085
(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))))