
(FPCore (x y z)
:precision binary64
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x - 0.5d0) * log(x)) - x) + 0.91893853320467d0) + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
end function
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\end{array}
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z)
:precision binary64
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x - 0.5d0) * log(x)) - x) + 0.91893853320467d0) + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
end function
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\end{array}
(FPCore (x y z)
:precision binary64
(if (<= x 5e+22)
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x))
(+
(* (- (- (- (log x))) 1.0) x)
(fma
z
(/ (- (* (+ 0.0007936500793651 y) z) 0.0027777777777778) x)
(/ 0.083333333333333 x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 5e+22) {
tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
} else {
tmp = ((-(-log(x)) - 1.0) * x) + fma(z, ((((0.0007936500793651 + y) * z) - 0.0027777777777778) / x), (0.083333333333333 / x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 5e+22) tmp = Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)); else tmp = Float64(Float64(Float64(Float64(-Float64(-log(x))) - 1.0) * x) + fma(z, Float64(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778) / x), Float64(0.083333333333333 / x))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 5e+22], N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(N[((-(-N[Log[x], $MachinePrecision])) - 1.0), $MachinePrecision] * x), $MachinePrecision] + N[(z * N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] / x), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+22}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-\left(-\log x\right)\right) - 1\right) \cdot x + \mathsf{fma}\left(z, \frac{\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778}{x}, \frac{0.083333333333333}{x}\right)\\
\end{array}
\end{array}
if x < 4.9999999999999996e22Initial program 99.6%
if 4.9999999999999996e22 < x Initial program 87.8%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites97.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
log-recN/A
lower-neg.f64N/A
lift-log.f6497.8
Applied rewrites97.8%
(FPCore (x y z) :precision binary64 (+ (- (* (- (log x) 1.0) x) (- (fma -0.5 (log x) 0.91893853320467))) (fma (/ 1.0 x) 0.083333333333333 (* (/ (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) x) z))))
double code(double x, double y, double z) {
return (((log(x) - 1.0) * x) - -fma(-0.5, log(x), 0.91893853320467)) + fma((1.0 / x), 0.083333333333333, (((((y + 0.0007936500793651) * z) - 0.0027777777777778) / x) * z));
}
function code(x, y, z) return Float64(Float64(Float64(Float64(log(x) - 1.0) * x) - Float64(-fma(-0.5, log(x), 0.91893853320467))) + fma(Float64(1.0 / x), 0.083333333333333, Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) / x) * z))) end
code[x_, y_, z_] := N[(N[(N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision] - (-N[(-0.5 * N[Log[x], $MachinePrecision] + 0.91893853320467), $MachinePrecision])), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * 0.083333333333333 + N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\log x - 1\right) \cdot x - \left(-\mathsf{fma}\left(-0.5, \log x, 0.91893853320467\right)\right)\right) + \mathsf{fma}\left(\frac{1}{x}, 0.083333333333333, \frac{\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778}{x} \cdot z\right)
\end{array}
Initial program 94.2%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites97.7%
lift-/.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
metadata-evalN/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.7%
Taylor expanded in x around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.6%
Taylor expanded in x around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-log.f6497.8
Applied rewrites97.8%
(FPCore (x y z) :precision binary64 (+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (fma z (/ (- (* (+ 0.0007936500793651 y) z) 0.0027777777777778) x) (/ 0.083333333333333 x))))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + fma(z, ((((0.0007936500793651 + y) * z) - 0.0027777777777778) / x), (0.083333333333333 / x));
}
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + fma(z, Float64(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778) / x), Float64(0.083333333333333 / x))) end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(z * N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] / x), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \mathsf{fma}\left(z, \frac{\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778}{x}, \frac{0.083333333333333}{x}\right)
\end{array}
Initial program 94.2%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites97.7%
(FPCore (x y z) :precision binary64 (+ (* (- (- (- (log x))) 1.0) x) (fma z (/ (- (* (+ 0.0007936500793651 y) z) 0.0027777777777778) x) (/ 0.083333333333333 x))))
double code(double x, double y, double z) {
return ((-(-log(x)) - 1.0) * x) + fma(z, ((((0.0007936500793651 + y) * z) - 0.0027777777777778) / x), (0.083333333333333 / x));
}
function code(x, y, z) return Float64(Float64(Float64(Float64(-Float64(-log(x))) - 1.0) * x) + fma(z, Float64(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778) / x), Float64(0.083333333333333 / x))) end
code[x_, y_, z_] := N[(N[(N[((-(-N[Log[x], $MachinePrecision])) - 1.0), $MachinePrecision] * x), $MachinePrecision] + N[(z * N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] / x), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(-\left(-\log x\right)\right) - 1\right) \cdot x + \mathsf{fma}\left(z, \frac{\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778}{x}, \frac{0.083333333333333}{x}\right)
\end{array}
Initial program 94.2%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites97.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
log-recN/A
lower-neg.f64N/A
lift-log.f6496.9
Applied rewrites96.9%
(FPCore (x y z)
:precision binary64
(if (<= x 0.0009)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(if (<= x 1.3e+221)
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/ (* (* z z) (+ 0.0007936500793651 y)) x))
(* (* (/ (- (log x) 1.0) y) y) x))))
double code(double x, double y, double z) {
double tmp;
if (x <= 0.0009) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else if (x <= 1.3e+221) {
tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + (((z * z) * (0.0007936500793651 + y)) / x);
} else {
tmp = (((log(x) - 1.0) / y) * y) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 0.0009) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); elseif (x <= 1.3e+221) tmp = Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(z * z) * Float64(0.0007936500793651 + y)) / x)); else tmp = Float64(Float64(Float64(Float64(log(x) - 1.0) / y) * y) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 0.0009], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 1.3e+221], N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(z * z), $MachinePrecision] * N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] / y), $MachinePrecision] * y), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0009:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+221}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(z \cdot z\right) \cdot \left(0.0007936500793651 + y\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\log x - 1}{y} \cdot y\right) \cdot x\\
\end{array}
\end{array}
if x < 8.9999999999999998e-4Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f6498.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.9
Applied rewrites98.9%
if 8.9999999999999998e-4 < x < 1.30000000000000002e221Initial program 91.5%
Taylor expanded in z around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f6490.5
Applied rewrites90.5%
if 1.30000000000000002e221 < x Initial program 81.7%
Taylor expanded in y around inf
Applied rewrites51.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.1%
lift--.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
lift-log.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
sub-divN/A
remove-double-negN/A
lower-/.f64N/A
lower--.f64N/A
lift-log.f6488.3
Applied rewrites88.3%
(FPCore (x y z)
:precision binary64
(if (<= x 2.4e-14)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(fma (- (* z 0.0007936500793651) 0.0027777777777778) z 0.083333333333333)
x))))
double code(double x, double y, double z) {
double tmp;
if (x <= 2.4e-14) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + (fma(((z * 0.0007936500793651) - 0.0027777777777778), z, 0.083333333333333) / x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 2.4e-14) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(fma(Float64(Float64(z * 0.0007936500793651) - 0.0027777777777778), z, 0.083333333333333) / x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 2.4e-14], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(z * 0.0007936500793651), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{-14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\mathsf{fma}\left(z \cdot 0.0007936500793651 - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\end{array}
\end{array}
if x < 2.4e-14Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f6499.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
if 2.4e-14 < x Initial program 89.1%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6479.7
Applied rewrites79.7%
(FPCore (x y z)
:precision binary64
(if (<= x 0.69)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(if (<= x 2.2e+215)
(+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (* (* z z) y) x))
(* (- (log x) 1.0) x))))
double code(double x, double y, double z) {
double tmp;
if (x <= 0.69) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else if (x <= 2.2e+215) {
tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + (((z * z) * y) / x);
} else {
tmp = (log(x) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 0.69) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); elseif (x <= 2.2e+215) tmp = Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(z * z) * y) / x)); else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 0.69], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 2.2e+215], N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.69:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+215}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(z \cdot z\right) \cdot y}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 0.68999999999999995Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f6498.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.6
Applied rewrites98.6%
if 0.68999999999999995 < x < 2.2000000000000001e215Initial program 91.5%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6482.2
Applied rewrites82.2%
if 2.2000000000000001e215 < x Initial program 82.1%
Taylor expanded in x around inf
*-commutativeN/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6488.3
Applied rewrites88.3%
(FPCore (x y z)
:precision binary64
(if (<= x 0.0009)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/ (* (* z z) 0.0007936500793651) x))))
double code(double x, double y, double z) {
double tmp;
if (x <= 0.0009) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + (((z * z) * 0.0007936500793651) / x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 0.0009) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(z * z) * 0.0007936500793651) / x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 0.0009], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(z * z), $MachinePrecision] * 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0009:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(z \cdot z\right) \cdot 0.0007936500793651}{x}\\
\end{array}
\end{array}
if x < 8.9999999999999998e-4Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f6498.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.9
Applied rewrites98.9%
if 8.9999999999999998e-4 < x Initial program 88.7%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6481.4
Applied rewrites81.4%
Taylor expanded in z around inf
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f6488.0
Applied rewrites88.0%
Taylor expanded in y around 0
Applied rewrites79.4%
(FPCore (x y z)
:precision binary64
(if (<= x 215.0)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(if (<= x 2.2e+215)
(+ (* (- (- (- (log x))) 1.0) x) (/ (* (* z z) y) x))
(* (- (log x) 1.0) x))))
double code(double x, double y, double z) {
double tmp;
if (x <= 215.0) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else if (x <= 2.2e+215) {
tmp = ((-(-log(x)) - 1.0) * x) + (((z * z) * y) / x);
} else {
tmp = (log(x) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 215.0) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); elseif (x <= 2.2e+215) tmp = Float64(Float64(Float64(Float64(-Float64(-log(x))) - 1.0) * x) + Float64(Float64(Float64(z * z) * y) / x)); else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 215.0], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 2.2e+215], N[(N[(N[((-(-N[Log[x], $MachinePrecision])) - 1.0), $MachinePrecision] * x), $MachinePrecision] + N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 215:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+215}:\\
\;\;\;\;\left(\left(-\left(-\log x\right)\right) - 1\right) \cdot x + \frac{\left(z \cdot z\right) \cdot y}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 215Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f6498.4
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.4
Applied rewrites98.4%
if 215 < x < 2.2000000000000001e215Initial program 91.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6482.7
Applied rewrites82.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
log-recN/A
lower-neg.f64N/A
lift-log.f6482.2
Applied rewrites82.2%
if 2.2000000000000001e215 < x Initial program 82.1%
Taylor expanded in x around inf
*-commutativeN/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6488.3
Applied rewrites88.3%
(FPCore (x y z)
:precision binary64
(if (<= x 1.5)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/ 0.083333333333333 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.5) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + (0.083333333333333 / x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.5) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(0.083333333333333 / x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.5], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.5:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{0.083333333333333}{x}\\
\end{array}
\end{array}
if x < 1.5Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f6498.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.6
Applied rewrites98.6%
if 1.5 < x Initial program 88.6%
Taylor expanded in z around 0
Applied rewrites70.5%
(FPCore (x y z)
:precision binary64
(if (<= x 1.5)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(- (+ (fma (log x) (- x 0.5) (/ 0.083333333333333 x)) 0.91893853320467) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.5) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = (fma(log(x), (x - 0.5), (0.083333333333333 / x)) + 0.91893853320467) - x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.5) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(Float64(fma(log(x), Float64(x - 0.5), Float64(0.083333333333333 / x)) + 0.91893853320467) - x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.5], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision] + 0.91893853320467), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.5:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\log x, x - 0.5, \frac{0.083333333333333}{x}\right) + 0.91893853320467\right) - x\\
\end{array}
\end{array}
if x < 1.5Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f6498.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.6
Applied rewrites98.6%
if 1.5 < x Initial program 88.6%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6470.5
Applied rewrites70.5%
(FPCore (x y z)
:precision binary64
(if (<= x 3000000000000.0)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(* (- (log x) 1.0) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 3000000000000.0) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = (log(x) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 3000000000000.0) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 3000000000000.0], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3000000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 3e12Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f6497.3
lift-+.f64N/A
+-commutativeN/A
lower-+.f6497.3
Applied rewrites97.3%
if 3e12 < x Initial program 88.2%
Taylor expanded in x around inf
*-commutativeN/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6471.8
Applied rewrites71.8%
(FPCore (x y z) :precision binary64 (if (<= x 1950000000000.0) (/ (* z (* (+ 0.0007936500793651 y) z)) x) (* (- (log x) 1.0) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 1950000000000.0) {
tmp = (z * ((0.0007936500793651 + y) * z)) / x;
} else {
tmp = (log(x) - 1.0) * x;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 1950000000000.0d0) then
tmp = (z * ((0.0007936500793651d0 + y) * z)) / x
else
tmp = (log(x) - 1.0d0) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 1950000000000.0) {
tmp = (z * ((0.0007936500793651 + y) * z)) / x;
} else {
tmp = (Math.log(x) - 1.0) * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1950000000000.0: tmp = (z * ((0.0007936500793651 + y) * z)) / x else: tmp = (math.log(x) - 1.0) * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1950000000000.0) tmp = Float64(Float64(z * Float64(Float64(0.0007936500793651 + y) * z)) / x); else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1950000000000.0) tmp = (z * ((0.0007936500793651 + y) * z)) / x; else tmp = (log(x) - 1.0) * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1950000000000.0], N[(N[(z * N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1950000000000:\\
\;\;\;\;\frac{z \cdot \left(\left(0.0007936500793651 + y\right) \cdot z\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 1.95e12Initial program 99.7%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites97.8%
lift-/.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
metadata-evalN/A
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.7%
Taylor expanded in z around inf
*-commutativeN/A
+-commutativeN/A
associate-*l/N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
associate-/l*N/A
+-commutativeN/A
pow2N/A
lower-/.f64N/A
Applied rewrites57.4%
if 1.95e12 < x Initial program 88.2%
Taylor expanded in x around inf
*-commutativeN/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6471.8
Applied rewrites71.8%
(FPCore (x y z) :precision binary64 (if (<= x 1950000000000.0) (* (/ (+ y 0.0007936500793651) x) (* z z)) (* (- (log x) 1.0) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 1950000000000.0) {
tmp = ((y + 0.0007936500793651) / x) * (z * z);
} else {
tmp = (log(x) - 1.0) * x;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 1950000000000.0d0) then
tmp = ((y + 0.0007936500793651d0) / x) * (z * z)
else
tmp = (log(x) - 1.0d0) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 1950000000000.0) {
tmp = ((y + 0.0007936500793651) / x) * (z * z);
} else {
tmp = (Math.log(x) - 1.0) * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1950000000000.0: tmp = ((y + 0.0007936500793651) / x) * (z * z) else: tmp = (math.log(x) - 1.0) * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1950000000000.0) tmp = Float64(Float64(Float64(y + 0.0007936500793651) / x) * Float64(z * z)); else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1950000000000.0) tmp = ((y + 0.0007936500793651) / x) * (z * z); else tmp = (log(x) - 1.0) * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1950000000000.0], N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision] * N[(z * z), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1950000000000:\\
\;\;\;\;\frac{y + 0.0007936500793651}{x} \cdot \left(z \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 1.95e12Initial program 99.7%
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
div-addN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
Applied rewrites97.8%
Taylor expanded in z around inf
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
div-addN/A
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
pow2N/A
lift-*.f6455.4
Applied rewrites55.4%
if 1.95e12 < x Initial program 88.2%
Taylor expanded in x around inf
*-commutativeN/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6471.8
Applied rewrites71.8%
(FPCore (x y z) :precision binary64 (if (<= x 115000000.0) (* y (/ (* z z) x)) (* (- (log x) 1.0) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 115000000.0) {
tmp = y * ((z * z) / x);
} else {
tmp = (log(x) - 1.0) * x;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 115000000.0d0) then
tmp = y * ((z * z) / x)
else
tmp = (log(x) - 1.0d0) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 115000000.0) {
tmp = y * ((z * z) / x);
} else {
tmp = (Math.log(x) - 1.0) * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 115000000.0: tmp = y * ((z * z) / x) else: tmp = (math.log(x) - 1.0) * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= 115000000.0) tmp = Float64(y * Float64(Float64(z * z) / x)); else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 115000000.0) tmp = y * ((z * z) / x); else tmp = (log(x) - 1.0) * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 115000000.0], N[(y * N[(N[(z * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 115000000:\\
\;\;\;\;y \cdot \frac{z \cdot z}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 1.15e8Initial program 99.7%
Taylor expanded in y around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6439.8
Applied rewrites39.8%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f6441.9
Applied rewrites41.9%
if 1.15e8 < x Initial program 88.3%
Taylor expanded in x around inf
*-commutativeN/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6471.3
Applied rewrites71.3%
(FPCore (x y z) :precision binary64 (* y (/ (* z z) x)))
double code(double x, double y, double z) {
return y * ((z * z) / x);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y * ((z * z) / x)
end function
public static double code(double x, double y, double z) {
return y * ((z * z) / x);
}
def code(x, y, z): return y * ((z * z) / x)
function code(x, y, z) return Float64(y * Float64(Float64(z * z) / x)) end
function tmp = code(x, y, z) tmp = y * ((z * z) / x); end
code[x_, y_, z_] := N[(y * N[(N[(z * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \frac{z \cdot z}{x}
\end{array}
Initial program 94.2%
Taylor expanded in y around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6430.0
Applied rewrites30.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f6431.8
Applied rewrites31.8%
(FPCore (x y z) :precision binary64 (* y (* z (/ z x))))
double code(double x, double y, double z) {
return y * (z * (z / x));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y * (z * (z / x))
end function
public static double code(double x, double y, double z) {
return y * (z * (z / x));
}
def code(x, y, z): return y * (z * (z / x))
function code(x, y, z) return Float64(y * Float64(z * Float64(z / x))) end
function tmp = code(x, y, z) tmp = y * (z * (z / x)); end
code[x_, y_, z_] := N[(y * N[(z * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(z \cdot \frac{z}{x}\right)
\end{array}
Initial program 94.2%
Taylor expanded in y around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6430.0
Applied rewrites30.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f6431.8
Applied rewrites31.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6432.0
Applied rewrites32.0%
herbie shell --seed 2025118
(FPCore (x y z)
:name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"
:precision binary64
(+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))