
(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 14 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+35)
(+
(+ (- (* (- 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 (* (/ (+ y 0.0007936500793651) x) z) (/ 0.083333333333333 x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 5e+35) {
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, (((y + 0.0007936500793651) / x) * z), (0.083333333333333 / x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 5e+35) 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(log(x) - 1.0) * x) + fma(z, Float64(Float64(Float64(y + 0.0007936500793651) / x) * z), Float64(0.083333333333333 / x))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 5e+35], 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[(y + 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+35}:\\
\;\;\;\;\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(\log x - 1\right) \cdot x + \mathsf{fma}\left(z, \frac{y + 0.0007936500793651}{x} \cdot z, \frac{0.083333333333333}{x}\right)\\
\end{array}
\end{array}
if x < 5.00000000000000021e35Initial program 99.4%
if 5.00000000000000021e35 < x Initial program 85.4%
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.5%
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
unpow1N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
log-pow-revN/A
lower--.f64N/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lift-log.f6497.5
Applied rewrites97.5%
Taylor expanded in z around inf
associate-/l*N/A
div-addN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
(FPCore (x y z)
:precision binary64
(if (<= x 1.0)
(+
(fma -0.5 (log x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x))
(+
(* (- (log x) 1.0) x)
(fma z (* (/ (+ y 0.0007936500793651) x) z) (/ 0.083333333333333 x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.0) {
tmp = fma(-0.5, log(x), 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
} else {
tmp = ((log(x) - 1.0) * x) + fma(z, (((y + 0.0007936500793651) / x) * z), (0.083333333333333 / x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.0) tmp = Float64(fma(-0.5, log(x), 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)); else tmp = Float64(Float64(Float64(log(x) - 1.0) * x) + fma(z, Float64(Float64(Float64(y + 0.0007936500793651) / x) * z), Float64(0.083333333333333 / x))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.0], N[(N[(-0.5 * N[Log[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[(y + 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log x, 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x + \mathsf{fma}\left(z, \frac{y + 0.0007936500793651}{x} \cdot z, \frac{0.083333333333333}{x}\right)\\
\end{array}
\end{array}
if x < 1Initial program 99.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
lift-log.f6499.2
Applied rewrites99.2%
if 1 < x Initial program 86.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.7%
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
unpow1N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
log-pow-revN/A
lower--.f64N/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lift-log.f6496.8
Applied rewrites96.8%
Taylor expanded in z around inf
associate-/l*N/A
div-addN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6498.7
Applied rewrites98.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (+ y 0.0007936500793651) z)))
(if (<= x 1.0)
(+
(fma -0.5 (log x) 0.91893853320467)
(/ (+ (* (- t_0 0.0027777777777778) z) 0.083333333333333) x))
(+ (* (- (log x) 1.0) x) (* (/ t_0 x) z)))))
double code(double x, double y, double z) {
double t_0 = (y + 0.0007936500793651) * z;
double tmp;
if (x <= 1.0) {
tmp = fma(-0.5, log(x), 0.91893853320467) + ((((t_0 - 0.0027777777777778) * z) + 0.083333333333333) / x);
} else {
tmp = ((log(x) - 1.0) * x) + ((t_0 / x) * z);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(y + 0.0007936500793651) * z) tmp = 0.0 if (x <= 1.0) tmp = Float64(fma(-0.5, log(x), 0.91893853320467) + Float64(Float64(Float64(Float64(t_0 - 0.0027777777777778) * z) + 0.083333333333333) / x)); else tmp = Float64(Float64(Float64(log(x) - 1.0) * x) + Float64(Float64(t_0 / x) * z)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[x, 1.0], N[(N[(-0.5 * N[Log[x], $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(t$95$0 - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision] + N[(N[(t$95$0 / x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y + 0.0007936500793651\right) \cdot z\\
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log x, 0.91893853320467\right) + \frac{\left(t\_0 - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x + \frac{t\_0}{x} \cdot z\\
\end{array}
\end{array}
if x < 1Initial program 99.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
lift-log.f6499.2
Applied rewrites99.2%
if 1 < x Initial program 86.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.7%
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
unpow1N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
log-pow-revN/A
lower--.f64N/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lift-log.f6496.8
Applied rewrites96.8%
Taylor expanded in z around inf
associate-/l*N/A
div-addN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6498.7
Applied rewrites98.7%
Taylor expanded in z around inf
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
div-addN/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
associate-/l*N/A
*-commutativeN/A
+-commutativeN/A
associate-*l/N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites96.8%
(FPCore (x y z)
:precision binary64
(if (<= x 1.0)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(+ (* (- (log x) 1.0) x) (* (/ (* (+ y 0.0007936500793651) z) x) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.0) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = ((log(x) - 1.0) * x) + ((((y + 0.0007936500793651) * z) / x) * z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.0) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(Float64(Float64(log(x) - 1.0) * x) + Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) / x) * z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.0], 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] - 1.0), $MachinePrecision] * x), $MachinePrecision] + N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\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 + \frac{\left(y + 0.0007936500793651\right) \cdot z}{x} \cdot z\\
\end{array}
\end{array}
if x < 1Initial 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.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.7
Applied rewrites98.7%
if 1 < x Initial program 86.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.7%
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
unpow1N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
log-pow-revN/A
lower--.f64N/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lift-log.f6496.8
Applied rewrites96.8%
Taylor expanded in z around inf
associate-/l*N/A
div-addN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6498.7
Applied rewrites98.7%
Taylor expanded in z around inf
associate-*r/N/A
+-commutativeN/A
*-commutativeN/A
div-addN/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
associate-/l*N/A
*-commutativeN/A
+-commutativeN/A
associate-*l/N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites96.8%
(FPCore (x y z)
:precision binary64
(if (<= x 1.0)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(if (<= x 4e+223)
(+ (* (- (log x) 1.0) x) (* (/ (+ y 0.0007936500793651) x) (* z z)))
(-
(+ (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.0) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else if (x <= 4e+223) {
tmp = ((log(x) - 1.0) * x) + (((y + 0.0007936500793651) / x) * (z * z));
} 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.0) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); elseif (x <= 4e+223) tmp = Float64(Float64(Float64(log(x) - 1.0) * x) + Float64(Float64(Float64(y + 0.0007936500793651) / x) * Float64(z * z))); 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.0], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 4e+223], N[(N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision] + N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision] * N[(z * z), $MachinePrecision]), $MachinePrecision]), $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:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+223}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x + \frac{y + 0.0007936500793651}{x} \cdot \left(z \cdot z\right)\\
\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 < 1Initial 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.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.7
Applied rewrites98.7%
if 1 < x < 4.00000000000000019e223Initial program 89.6%
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 rewrites98.7%
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
unpow1N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
log-pow-revN/A
lower--.f64N/A
log-pow-revN/A
inv-powN/A
pow-powN/A
metadata-evalN/A
unpow1N/A
lift-log.f6497.5
Applied rewrites97.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
unpow2N/A
lower-*.f6491.6
Applied rewrites91.6%
if 4.00000000000000019e223 < x Initial program 79.3%
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-/.f6487.8
Applied rewrites87.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (+ y 0.0007936500793651) z))
(t_1
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/ (+ (* (- t_0 0.0027777777777778) z) 0.083333333333333) x))))
(if (<= t_1 -5e+65)
(* y (/ (* z z) x))
(if (<= t_1 1e+306)
(-
(+ (fma (log x) (- x 0.5) (/ 0.083333333333333 x)) 0.91893853320467)
x)
(* (/ t_0 x) z)))))
double code(double x, double y, double z) {
double t_0 = (y + 0.0007936500793651) * z;
double t_1 = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((t_0 - 0.0027777777777778) * z) + 0.083333333333333) / x);
double tmp;
if (t_1 <= -5e+65) {
tmp = y * ((z * z) / x);
} else if (t_1 <= 1e+306) {
tmp = (fma(log(x), (x - 0.5), (0.083333333333333 / x)) + 0.91893853320467) - x;
} else {
tmp = (t_0 / x) * z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(y + 0.0007936500793651) * z) t_1 = Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(t_0 - 0.0027777777777778) * z) + 0.083333333333333) / x)) tmp = 0.0 if (t_1 <= -5e+65) tmp = Float64(y * Float64(Float64(z * z) / x)); elseif (t_1 <= 1e+306) tmp = Float64(Float64(fma(log(x), Float64(x - 0.5), Float64(0.083333333333333 / x)) + 0.91893853320467) - x); else tmp = Float64(Float64(t_0 / x) * z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(t$95$0 - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+65], N[(y * N[(N[(z * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+306], N[(N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision] + 0.91893853320467), $MachinePrecision] - x), $MachinePrecision], N[(N[(t$95$0 / x), $MachinePrecision] * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y + 0.0007936500793651\right) \cdot z\\
t_1 := \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(t\_0 - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+65}:\\
\;\;\;\;y \cdot \frac{z \cdot z}{x}\\
\mathbf{elif}\;t\_1 \leq 10^{+306}:\\
\;\;\;\;\left(\mathsf{fma}\left(\log x, x - 0.5, \frac{0.083333333333333}{x}\right) + 0.91893853320467\right) - x\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{x} \cdot z\\
\end{array}
\end{array}
if (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) < -4.99999999999999973e65Initial program 88.8%
Taylor expanded in y around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.7
Applied rewrites87.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6491.0
Applied rewrites91.0%
if -4.99999999999999973e65 < (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) < 1.00000000000000002e306Initial program 99.5%
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-/.f6486.8
Applied rewrites86.8%
if 1.00000000000000002e306 < (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) Initial program 81.5%
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 rewrites98.1%
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
lower-+.f64N/A
pow2N/A
lift-*.f6481.4
Applied rewrites81.4%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
+-commutativeN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f6487.2
Applied rewrites87.2%
(FPCore (x y z)
:precision binary64
(if (<= x 3.4e+23)
(/
(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 <= 3.4e+23) {
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 <= 3.4e+23) 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, 3.4e+23], 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 3.4 \cdot 10^{+23}:\\
\;\;\;\;\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 < 3.39999999999999992e23Initial 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--.f6495.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6495.9
Applied rewrites95.9%
if 3.39999999999999992e23 < x Initial program 85.8%
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.1
Applied rewrites71.1%
(FPCore (x y z)
:precision binary64
(if (<= x 3.6e-176)
(/ (* (* z z) (+ y 0.0007936500793651)) x)
(if (<= x 1.35e-137)
(/ 0.083333333333333 x)
(if (<= x 3.4e+23)
(* (/ (* (+ y 0.0007936500793651) z) x) z)
(* (- (log x) 1.0) x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 3.6e-176) {
tmp = ((z * z) * (y + 0.0007936500793651)) / x;
} else if (x <= 1.35e-137) {
tmp = 0.083333333333333 / x;
} else if (x <= 3.4e+23) {
tmp = (((y + 0.0007936500793651) * z) / x) * 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 <= 3.6d-176) then
tmp = ((z * z) * (y + 0.0007936500793651d0)) / x
else if (x <= 1.35d-137) then
tmp = 0.083333333333333d0 / x
else if (x <= 3.4d+23) then
tmp = (((y + 0.0007936500793651d0) * z) / x) * 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 <= 3.6e-176) {
tmp = ((z * z) * (y + 0.0007936500793651)) / x;
} else if (x <= 1.35e-137) {
tmp = 0.083333333333333 / x;
} else if (x <= 3.4e+23) {
tmp = (((y + 0.0007936500793651) * z) / x) * z;
} else {
tmp = (Math.log(x) - 1.0) * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 3.6e-176: tmp = ((z * z) * (y + 0.0007936500793651)) / x elif x <= 1.35e-137: tmp = 0.083333333333333 / x elif x <= 3.4e+23: tmp = (((y + 0.0007936500793651) * z) / x) * z else: tmp = (math.log(x) - 1.0) * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= 3.6e-176) tmp = Float64(Float64(Float64(z * z) * Float64(y + 0.0007936500793651)) / x); elseif (x <= 1.35e-137) tmp = Float64(0.083333333333333 / x); elseif (x <= 3.4e+23) tmp = Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) / x) * 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 <= 3.6e-176) tmp = ((z * z) * (y + 0.0007936500793651)) / x; elseif (x <= 1.35e-137) tmp = 0.083333333333333 / x; elseif (x <= 3.4e+23) tmp = (((y + 0.0007936500793651) * z) / x) * z; else tmp = (log(x) - 1.0) * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 3.6e-176], N[(N[(N[(z * z), $MachinePrecision] * N[(y + 0.0007936500793651), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 1.35e-137], N[(0.083333333333333 / x), $MachinePrecision], If[LessEqual[x, 3.4e+23], N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.6 \cdot 10^{-176}:\\
\;\;\;\;\frac{\left(z \cdot z\right) \cdot \left(y + 0.0007936500793651\right)}{x}\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-137}:\\
\;\;\;\;\frac{0.083333333333333}{x}\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+23}:\\
\;\;\;\;\frac{\left(y + 0.0007936500793651\right) \cdot z}{x} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 3.6000000000000003e-176Initial 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 rewrites95.9%
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
lower-+.f64N/A
pow2N/A
lift-*.f6456.0
Applied rewrites56.0%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l/N/A
+-commutativeN/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f6457.7
Applied rewrites57.7%
if 3.6000000000000003e-176 < x < 1.34999999999999996e-137Initial program 99.7%
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-/.f6443.5
Applied rewrites43.5%
Taylor expanded in x around 0
lift-/.f6443.5
Applied rewrites43.5%
if 1.34999999999999996e-137 < x < 3.39999999999999992e23Initial program 99.6%
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 rewrites99.4%
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
lower-+.f64N/A
pow2N/A
lift-*.f6456.3
Applied rewrites56.3%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
+-commutativeN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f6457.3
Applied rewrites57.3%
if 3.39999999999999992e23 < x Initial program 85.8%
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.1
Applied rewrites71.1%
(FPCore (x y z)
:precision binary64
(if (<= x 3.5e-176)
(* (/ (+ y 0.0007936500793651) x) (* z z))
(if (<= x 1.35e-137)
(/ 0.083333333333333 x)
(if (<= x 3.4e+23)
(* (/ (* (+ y 0.0007936500793651) z) x) z)
(* (- (log x) 1.0) x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 3.5e-176) {
tmp = ((y + 0.0007936500793651) / x) * (z * z);
} else if (x <= 1.35e-137) {
tmp = 0.083333333333333 / x;
} else if (x <= 3.4e+23) {
tmp = (((y + 0.0007936500793651) * z) / x) * 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 <= 3.5d-176) then
tmp = ((y + 0.0007936500793651d0) / x) * (z * z)
else if (x <= 1.35d-137) then
tmp = 0.083333333333333d0 / x
else if (x <= 3.4d+23) then
tmp = (((y + 0.0007936500793651d0) * z) / x) * 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 <= 3.5e-176) {
tmp = ((y + 0.0007936500793651) / x) * (z * z);
} else if (x <= 1.35e-137) {
tmp = 0.083333333333333 / x;
} else if (x <= 3.4e+23) {
tmp = (((y + 0.0007936500793651) * z) / x) * z;
} else {
tmp = (Math.log(x) - 1.0) * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 3.5e-176: tmp = ((y + 0.0007936500793651) / x) * (z * z) elif x <= 1.35e-137: tmp = 0.083333333333333 / x elif x <= 3.4e+23: tmp = (((y + 0.0007936500793651) * z) / x) * z else: tmp = (math.log(x) - 1.0) * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= 3.5e-176) tmp = Float64(Float64(Float64(y + 0.0007936500793651) / x) * Float64(z * z)); elseif (x <= 1.35e-137) tmp = Float64(0.083333333333333 / x); elseif (x <= 3.4e+23) tmp = Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) / x) * 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 <= 3.5e-176) tmp = ((y + 0.0007936500793651) / x) * (z * z); elseif (x <= 1.35e-137) tmp = 0.083333333333333 / x; elseif (x <= 3.4e+23) tmp = (((y + 0.0007936500793651) * z) / x) * z; else tmp = (log(x) - 1.0) * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 3.5e-176], N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision] * N[(z * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.35e-137], N[(0.083333333333333 / x), $MachinePrecision], If[LessEqual[x, 3.4e+23], N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{-176}:\\
\;\;\;\;\frac{y + 0.0007936500793651}{x} \cdot \left(z \cdot z\right)\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-137}:\\
\;\;\;\;\frac{0.083333333333333}{x}\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+23}:\\
\;\;\;\;\frac{\left(y + 0.0007936500793651\right) \cdot z}{x} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 3.5e-176Initial 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 rewrites95.9%
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
lower-+.f64N/A
pow2N/A
lift-*.f6456.0
Applied rewrites56.0%
if 3.5e-176 < x < 1.34999999999999996e-137Initial program 99.7%
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-/.f6443.5
Applied rewrites43.5%
Taylor expanded in x around 0
lift-/.f6443.5
Applied rewrites43.5%
if 1.34999999999999996e-137 < x < 3.39999999999999992e23Initial program 99.6%
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 rewrites99.4%
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
lower-+.f64N/A
pow2N/A
lift-*.f6456.3
Applied rewrites56.3%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
+-commutativeN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f6457.3
Applied rewrites57.3%
if 3.39999999999999992e23 < x Initial program 85.8%
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.1
Applied rewrites71.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (* (+ y 0.0007936500793651) z) x) z)))
(if (<= x 3.5e-176)
t_0
(if (<= x 1.35e-137)
(/ 0.083333333333333 x)
(if (<= x 3.4e+23) t_0 (* (- (log x) 1.0) x))))))
double code(double x, double y, double z) {
double t_0 = (((y + 0.0007936500793651) * z) / x) * z;
double tmp;
if (x <= 3.5e-176) {
tmp = t_0;
} else if (x <= 1.35e-137) {
tmp = 0.083333333333333 / x;
} else if (x <= 3.4e+23) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (((y + 0.0007936500793651d0) * z) / x) * z
if (x <= 3.5d-176) then
tmp = t_0
else if (x <= 1.35d-137) then
tmp = 0.083333333333333d0 / x
else if (x <= 3.4d+23) then
tmp = t_0
else
tmp = (log(x) - 1.0d0) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (((y + 0.0007936500793651) * z) / x) * z;
double tmp;
if (x <= 3.5e-176) {
tmp = t_0;
} else if (x <= 1.35e-137) {
tmp = 0.083333333333333 / x;
} else if (x <= 3.4e+23) {
tmp = t_0;
} else {
tmp = (Math.log(x) - 1.0) * x;
}
return tmp;
}
def code(x, y, z): t_0 = (((y + 0.0007936500793651) * z) / x) * z tmp = 0 if x <= 3.5e-176: tmp = t_0 elif x <= 1.35e-137: tmp = 0.083333333333333 / x elif x <= 3.4e+23: tmp = t_0 else: tmp = (math.log(x) - 1.0) * x return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) / x) * z) tmp = 0.0 if (x <= 3.5e-176) tmp = t_0; elseif (x <= 1.35e-137) tmp = Float64(0.083333333333333 / x); elseif (x <= 3.4e+23) tmp = t_0; else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (((y + 0.0007936500793651) * z) / x) * z; tmp = 0.0; if (x <= 3.5e-176) tmp = t_0; elseif (x <= 1.35e-137) tmp = 0.083333333333333 / x; elseif (x <= 3.4e+23) tmp = t_0; else tmp = (log(x) - 1.0) * x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[x, 3.5e-176], t$95$0, If[LessEqual[x, 1.35e-137], N[(0.083333333333333 / x), $MachinePrecision], If[LessEqual[x, 3.4e+23], t$95$0, N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(y + 0.0007936500793651\right) \cdot z}{x} \cdot z\\
\mathbf{if}\;x \leq 3.5 \cdot 10^{-176}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-137}:\\
\;\;\;\;\frac{0.083333333333333}{x}\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+23}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 3.5e-176 or 1.34999999999999996e-137 < x < 3.39999999999999992e23Initial 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
lower-+.f64N/A
pow2N/A
lift-*.f6456.2
Applied rewrites56.2%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
+-commutativeN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f6457.0
Applied rewrites57.0%
if 3.5e-176 < x < 1.34999999999999996e-137Initial program 99.7%
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-/.f6443.5
Applied rewrites43.5%
Taylor expanded in x around 0
lift-/.f6443.5
Applied rewrites43.5%
if 3.39999999999999992e23 < x Initial program 85.8%
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.1
Applied rewrites71.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))
(t_1 (/ (* z z) x)))
(if (<= t_0 5.0)
(* y t_1)
(if (<= t_0 1e+306) (* (- (log x) 1.0) x) (* t_1 0.0007936500793651)))))
double code(double x, double y, double z) {
double t_0 = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
double t_1 = (z * z) / x;
double tmp;
if (t_0 <= 5.0) {
tmp = y * t_1;
} else if (t_0 <= 1e+306) {
tmp = (log(x) - 1.0) * x;
} else {
tmp = t_1 * 0.0007936500793651;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((((x - 0.5d0) * log(x)) - x) + 0.91893853320467d0) + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
t_1 = (z * z) / x
if (t_0 <= 5.0d0) then
tmp = y * t_1
else if (t_0 <= 1d+306) then
tmp = (log(x) - 1.0d0) * x
else
tmp = t_1 * 0.0007936500793651d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((((x - 0.5) * Math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
double t_1 = (z * z) / x;
double tmp;
if (t_0 <= 5.0) {
tmp = y * t_1;
} else if (t_0 <= 1e+306) {
tmp = (Math.log(x) - 1.0) * x;
} else {
tmp = t_1 * 0.0007936500793651;
}
return tmp;
}
def code(x, y, z): t_0 = ((((x - 0.5) * math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x) t_1 = (z * z) / x tmp = 0 if t_0 <= 5.0: tmp = y * t_1 elif t_0 <= 1e+306: tmp = (math.log(x) - 1.0) * x else: tmp = t_1 * 0.0007936500793651 return tmp
function code(x, y, z) t_0 = 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)) t_1 = Float64(Float64(z * z) / x) tmp = 0.0 if (t_0 <= 5.0) tmp = Float64(y * t_1); elseif (t_0 <= 1e+306) tmp = Float64(Float64(log(x) - 1.0) * x); else tmp = Float64(t_1 * 0.0007936500793651); end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); t_1 = (z * z) / x; tmp = 0.0; if (t_0 <= 5.0) tmp = y * t_1; elseif (t_0 <= 1e+306) tmp = (log(x) - 1.0) * x; else tmp = t_1 * 0.0007936500793651; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, 5.0], N[(y * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 1e+306], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision], N[(t$95$1 * 0.0007936500793651), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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}\\
t_1 := \frac{z \cdot z}{x}\\
\mathbf{if}\;t\_0 \leq 5:\\
\;\;\;\;y \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{+306}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot 0.0007936500793651\\
\end{array}
\end{array}
if (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) < 5Initial program 89.1%
Taylor expanded in y around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6486.7
Applied rewrites86.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6489.9
Applied rewrites89.9%
if 5 < (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) < 1.00000000000000002e306Initial program 99.5%
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.f6452.0
Applied rewrites52.0%
if 1.00000000000000002e306 < (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) Initial program 81.5%
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 rewrites98.1%
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
lower-+.f64N/A
pow2N/A
lift-*.f6481.4
Applied rewrites81.4%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6471.5
Applied rewrites71.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z))
(t_1 (/ (* z z) x)))
(if (<= t_0 -50000000000.0)
(* y t_1)
(if (<= t_0 2e+46) (/ 0.083333333333333 x) (* t_1 0.0007936500793651)))))
double code(double x, double y, double z) {
double t_0 = (((y + 0.0007936500793651) * z) - 0.0027777777777778) * z;
double t_1 = (z * z) / x;
double tmp;
if (t_0 <= -50000000000.0) {
tmp = y * t_1;
} else if (t_0 <= 2e+46) {
tmp = 0.083333333333333 / x;
} else {
tmp = t_1 * 0.0007936500793651;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z
t_1 = (z * z) / x
if (t_0 <= (-50000000000.0d0)) then
tmp = y * t_1
else if (t_0 <= 2d+46) then
tmp = 0.083333333333333d0 / x
else
tmp = t_1 * 0.0007936500793651d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (((y + 0.0007936500793651) * z) - 0.0027777777777778) * z;
double t_1 = (z * z) / x;
double tmp;
if (t_0 <= -50000000000.0) {
tmp = y * t_1;
} else if (t_0 <= 2e+46) {
tmp = 0.083333333333333 / x;
} else {
tmp = t_1 * 0.0007936500793651;
}
return tmp;
}
def code(x, y, z): t_0 = (((y + 0.0007936500793651) * z) - 0.0027777777777778) * z t_1 = (z * z) / x tmp = 0 if t_0 <= -50000000000.0: tmp = y * t_1 elif t_0 <= 2e+46: tmp = 0.083333333333333 / x else: tmp = t_1 * 0.0007936500793651 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) t_1 = Float64(Float64(z * z) / x) tmp = 0.0 if (t_0 <= -50000000000.0) tmp = Float64(y * t_1); elseif (t_0 <= 2e+46) tmp = Float64(0.083333333333333 / x); else tmp = Float64(t_1 * 0.0007936500793651); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (((y + 0.0007936500793651) * z) - 0.0027777777777778) * z; t_1 = (z * z) / x; tmp = 0.0; if (t_0 <= -50000000000.0) tmp = y * t_1; elseif (t_0 <= 2e+46) tmp = 0.083333333333333 / x; else tmp = t_1 * 0.0007936500793651; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, -50000000000.0], N[(y * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 2e+46], N[(0.083333333333333 / x), $MachinePrecision], N[(t$95$1 * 0.0007936500793651), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z\\
t_1 := \frac{z \cdot z}{x}\\
\mathbf{if}\;t\_0 \leq -50000000000:\\
\;\;\;\;y \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+46}:\\
\;\;\;\;\frac{0.083333333333333}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot 0.0007936500793651\\
\end{array}
\end{array}
if (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) < -5e10Initial program 90.3%
Taylor expanded in y around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6475.0
Applied rewrites75.0%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6477.7
Applied rewrites77.7%
if -5e10 < (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) < 2e46Initial program 99.5%
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-/.f6495.2
Applied rewrites95.2%
Taylor expanded in x around 0
lift-/.f6445.6
Applied rewrites45.6%
if 2e46 < (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) Initial program 86.6%
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 rewrites98.1%
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
lower-+.f64N/A
pow2N/A
lift-*.f6472.8
Applied rewrites72.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6461.9
Applied rewrites61.9%
(FPCore (x y z)
:precision binary64
(if (<=
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
2e+46)
(/ 0.083333333333333 x)
(* (/ (* z z) x) 0.0007936500793651)))
double code(double x, double y, double z) {
double tmp;
if ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) <= 2e+46) {
tmp = 0.083333333333333 / x;
} else {
tmp = ((z * z) / x) * 0.0007936500793651;
}
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 ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) <= 2d+46) then
tmp = 0.083333333333333d0 / x
else
tmp = ((z * z) / x) * 0.0007936500793651d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) <= 2e+46) {
tmp = 0.083333333333333 / x;
} else {
tmp = ((z * z) / x) * 0.0007936500793651;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) <= 2e+46: tmp = 0.083333333333333 / x else: tmp = ((z * z) / x) * 0.0007936500793651 return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) <= 2e+46) tmp = Float64(0.083333333333333 / x); else tmp = Float64(Float64(Float64(z * z) / x) * 0.0007936500793651); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) <= 2e+46) tmp = 0.083333333333333 / x; else tmp = ((z * z) / x) * 0.0007936500793651; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision], 2e+46], N[(0.083333333333333 / x), $MachinePrecision], N[(N[(N[(z * z), $MachinePrecision] / x), $MachinePrecision] * 0.0007936500793651), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333 \leq 2 \cdot 10^{+46}:\\
\;\;\;\;\frac{0.083333333333333}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot z}{x} \cdot 0.0007936500793651\\
\end{array}
\end{array}
if (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) < 2e46Initial program 97.2%
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-/.f6476.7
Applied rewrites76.7%
Taylor expanded in x around 0
lift-/.f6434.6
Applied rewrites34.6%
if 2e46 < (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) Initial program 86.6%
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 rewrites98.1%
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
lower-+.f64N/A
pow2N/A
lift-*.f6472.8
Applied rewrites72.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6461.9
Applied rewrites61.9%
(FPCore (x y z) :precision binary64 (/ 0.083333333333333 x))
double code(double x, double y, double z) {
return 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 = 0.083333333333333d0 / x
end function
public static double code(double x, double y, double z) {
return 0.083333333333333 / x;
}
def code(x, y, z): return 0.083333333333333 / x
function code(x, y, z) return Float64(0.083333333333333 / x) end
function tmp = code(x, y, z) tmp = 0.083333333333333 / x; end
code[x_, y_, z_] := N[(0.083333333333333 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.083333333333333}{x}
\end{array}
Initial program 93.1%
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-/.f6456.9
Applied rewrites56.9%
Taylor expanded in x around 0
lift-/.f6422.8
Applied rewrites22.8%
herbie shell --seed 2025112
(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)))