
(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]
\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}
Herbie found 20 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]
\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}
(FPCore (x y z) :precision binary64 (fma (fma z (- y -0.0007936500793651) -0.0027777777777778) (/ z x) (- (/ 0.083333333333333 x) (fma (- 0.5 x) (log x) (- x 0.91893853320467)))))
double code(double x, double y, double z) {
return fma(fma(z, (y - -0.0007936500793651), -0.0027777777777778), (z / x), ((0.083333333333333 / x) - fma((0.5 - x), log(x), (x - 0.91893853320467))));
}
function code(x, y, z) return fma(fma(z, Float64(y - -0.0007936500793651), -0.0027777777777778), Float64(z / x), Float64(Float64(0.083333333333333 / x) - fma(Float64(0.5 - x), log(x), Float64(x - 0.91893853320467)))) end
code[x_, y_, z_] := N[(N[(z * N[(y - -0.0007936500793651), $MachinePrecision] + -0.0027777777777778), $MachinePrecision] * N[(z / x), $MachinePrecision] + N[(N[(0.083333333333333 / x), $MachinePrecision] - N[(N[(0.5 - x), $MachinePrecision] * N[Log[x], $MachinePrecision] + N[(x - 0.91893853320467), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\mathsf{fma}\left(z, y - -0.0007936500793651, -0.0027777777777778\right), \frac{z}{x}, \frac{0.083333333333333}{x} - \mathsf{fma}\left(0.5 - x, \log x, x - 0.91893853320467\right)\right)
Initial program 93.6%
Applied rewrites98.6%
(FPCore (x y z) :precision binary64 (fma (/ (fma z (- y -0.0007936500793651) -0.0027777777777778) x) z (- (/ 0.083333333333333 x) (fma (- 0.5 x) (log x) (- x 0.91893853320467)))))
double code(double x, double y, double z) {
return fma((fma(z, (y - -0.0007936500793651), -0.0027777777777778) / x), z, ((0.083333333333333 / x) - fma((0.5 - x), log(x), (x - 0.91893853320467))));
}
function code(x, y, z) return fma(Float64(fma(z, Float64(y - -0.0007936500793651), -0.0027777777777778) / x), z, Float64(Float64(0.083333333333333 / x) - fma(Float64(0.5 - x), log(x), Float64(x - 0.91893853320467)))) end
code[x_, y_, z_] := N[(N[(N[(z * N[(y - -0.0007936500793651), $MachinePrecision] + -0.0027777777777778), $MachinePrecision] / x), $MachinePrecision] * z + N[(N[(0.083333333333333 / x), $MachinePrecision] - N[(N[(0.5 - x), $MachinePrecision] * N[Log[x], $MachinePrecision] + N[(x - 0.91893853320467), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\frac{\mathsf{fma}\left(z, y - -0.0007936500793651, -0.0027777777777778\right)}{x}, z, \frac{0.083333333333333}{x} - \mathsf{fma}\left(0.5 - x, \log x, x - 0.91893853320467\right)\right)
Initial program 93.6%
Applied rewrites97.8%
(FPCore (x y z)
:precision binary64
(if (<= x 1e+85)
(-
(-
(/
(fma
(fma z (- y -0.0007936500793651) -0.0027777777777778)
z
0.083333333333333)
x)
-0.91893853320467)
(fma (- 0.5 x) (log x) x))
(fma
(* y z)
(/ z x)
(-
(/ 0.083333333333333 x)
(fma (- 0.5 x) (log x) (- x 0.91893853320467))))))double code(double x, double y, double z) {
double tmp;
if (x <= 1e+85) {
tmp = ((fma(fma(z, (y - -0.0007936500793651), -0.0027777777777778), z, 0.083333333333333) / x) - -0.91893853320467) - fma((0.5 - x), log(x), x);
} else {
tmp = fma((y * z), (z / x), ((0.083333333333333 / x) - fma((0.5 - x), log(x), (x - 0.91893853320467))));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1e+85) tmp = Float64(Float64(Float64(fma(fma(z, Float64(y - -0.0007936500793651), -0.0027777777777778), z, 0.083333333333333) / x) - -0.91893853320467) - fma(Float64(0.5 - x), log(x), x)); else tmp = fma(Float64(y * z), Float64(z / x), Float64(Float64(0.083333333333333 / x) - fma(Float64(0.5 - x), log(x), Float64(x - 0.91893853320467)))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1e+85], N[(N[(N[(N[(N[(z * N[(y - -0.0007936500793651), $MachinePrecision] + -0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision] - -0.91893853320467), $MachinePrecision] - N[(N[(0.5 - x), $MachinePrecision] * N[Log[x], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(N[(y * z), $MachinePrecision] * N[(z / x), $MachinePrecision] + N[(N[(0.083333333333333 / x), $MachinePrecision] - N[(N[(0.5 - x), $MachinePrecision] * N[Log[x], $MachinePrecision] + N[(x - 0.91893853320467), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+85}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(z, y - -0.0007936500793651, -0.0027777777777778\right), z, 0.083333333333333\right)}{x} - -0.91893853320467\right) - \mathsf{fma}\left(0.5 - x, \log x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, \frac{z}{x}, \frac{0.083333333333333}{x} - \mathsf{fma}\left(0.5 - x, \log x, x - 0.91893853320467\right)\right)\\
\end{array}
if x < 1e85Initial program 93.6%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
add-flipN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.7%
if 1e85 < x Initial program 93.6%
Applied rewrites98.6%
Taylor expanded in y around inf
lower-*.f6485.0
Applied rewrites85.0%
(FPCore (x y z)
:precision binary64
(if (<= x 1e+85)
(fma
(- x 0.5)
(log x)
(-
(- 0.91893853320467 x)
(/
(fma
(fma (- -0.0007936500793651 y) z 0.0027777777777778)
z
-0.083333333333333)
x)))
(fma
(* y z)
(/ z x)
(-
(/ 0.083333333333333 x)
(fma (- 0.5 x) (log x) (- x 0.91893853320467))))))double code(double x, double y, double z) {
double tmp;
if (x <= 1e+85) {
tmp = fma((x - 0.5), log(x), ((0.91893853320467 - x) - (fma(fma((-0.0007936500793651 - y), z, 0.0027777777777778), z, -0.083333333333333) / x)));
} else {
tmp = fma((y * z), (z / x), ((0.083333333333333 / x) - fma((0.5 - x), log(x), (x - 0.91893853320467))));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1e+85) tmp = fma(Float64(x - 0.5), log(x), Float64(Float64(0.91893853320467 - x) - Float64(fma(fma(Float64(-0.0007936500793651 - y), z, 0.0027777777777778), z, -0.083333333333333) / x))); else tmp = fma(Float64(y * z), Float64(z / x), Float64(Float64(0.083333333333333 / x) - fma(Float64(0.5 - x), log(x), Float64(x - 0.91893853320467)))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1e+85], N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision] + N[(N[(0.91893853320467 - x), $MachinePrecision] - N[(N[(N[(N[(-0.0007936500793651 - y), $MachinePrecision] * z + 0.0027777777777778), $MachinePrecision] * z + -0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * z), $MachinePrecision] * N[(z / x), $MachinePrecision] + N[(N[(0.083333333333333 / x), $MachinePrecision] - N[(N[(0.5 - x), $MachinePrecision] * N[Log[x], $MachinePrecision] + N[(x - 0.91893853320467), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+85}:\\
\;\;\;\;\mathsf{fma}\left(x - 0.5, \log x, \left(0.91893853320467 - x\right) - \frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.0007936500793651 - y, z, 0.0027777777777778\right), z, -0.083333333333333\right)}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, \frac{z}{x}, \frac{0.083333333333333}{x} - \mathsf{fma}\left(0.5 - x, \log x, x - 0.91893853320467\right)\right)\\
\end{array}
if x < 1e85Initial program 93.6%
Applied rewrites93.7%
if 1e85 < x Initial program 93.6%
Applied rewrites98.6%
Taylor expanded in y around inf
lower-*.f6485.0
Applied rewrites85.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* (/ (- y -0.0007936500793651) x) z) z)))
(if (<= z -3.7e+84)
t_0
(if (<= z 7.5e+64)
(-
(- (/ (fma (* y z) z 0.083333333333333) x) -0.91893853320467)
(fma (- 0.5 x) (log x) x))
t_0))))double code(double x, double y, double z) {
double t_0 = (((y - -0.0007936500793651) / x) * z) * z;
double tmp;
if (z <= -3.7e+84) {
tmp = t_0;
} else if (z <= 7.5e+64) {
tmp = ((fma((y * z), z, 0.083333333333333) / x) - -0.91893853320467) - fma((0.5 - x), log(x), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(y - -0.0007936500793651) / x) * z) * z) tmp = 0.0 if (z <= -3.7e+84) tmp = t_0; elseif (z <= 7.5e+64) tmp = Float64(Float64(Float64(fma(Float64(y * z), z, 0.083333333333333) / x) - -0.91893853320467) - fma(Float64(0.5 - x), log(x), x)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y - -0.0007936500793651), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -3.7e+84], t$95$0, If[LessEqual[z, 7.5e+64], N[(N[(N[(N[(N[(y * z), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision] - -0.91893853320467), $MachinePrecision] - N[(N[(0.5 - x), $MachinePrecision] * N[Log[x], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \left(\frac{y - -0.0007936500793651}{x} \cdot z\right) \cdot z\\
\mathbf{if}\;z \leq -3.7 \cdot 10^{+84}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{+64}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(y \cdot z, z, 0.083333333333333\right)}{x} - -0.91893853320467\right) - \mathsf{fma}\left(0.5 - x, \log x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -3.7e84 or 7.5000000000000005e64 < z Initial program 93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6442.1
Applied rewrites42.1%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6444.0
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
mult-flip-revN/A
div-add-revN/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
lower-/.f6444.0
Applied rewrites44.0%
if -3.7e84 < z < 7.5000000000000005e64Initial program 93.6%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
add-flipN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.7%
Taylor expanded in y around inf
lower-*.f6482.3
Applied rewrites82.3%
(FPCore (x y z)
:precision binary64
(if (<= x 350000.0)
(/
1.0
(/
x
(fma
(fma (- y -0.0007936500793651) z -0.0027777777777778)
z
0.083333333333333)))
(fma
(* y z)
(/ z x)
(-
(/ 0.083333333333333 x)
(fma (- 0.5 x) (log x) (- x 0.91893853320467))))))double code(double x, double y, double z) {
double tmp;
if (x <= 350000.0) {
tmp = 1.0 / (x / fma(fma((y - -0.0007936500793651), z, -0.0027777777777778), z, 0.083333333333333));
} else {
tmp = fma((y * z), (z / x), ((0.083333333333333 / x) - fma((0.5 - x), log(x), (x - 0.91893853320467))));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 350000.0) tmp = Float64(1.0 / Float64(x / fma(fma(Float64(y - -0.0007936500793651), z, -0.0027777777777778), z, 0.083333333333333))); else tmp = fma(Float64(y * z), Float64(z / x), Float64(Float64(0.083333333333333 / x) - fma(Float64(0.5 - x), log(x), Float64(x - 0.91893853320467)))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 350000.0], N[(1.0 / N[(x / N[(N[(N[(y - -0.0007936500793651), $MachinePrecision] * z + -0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * z), $MachinePrecision] * N[(z / x), $MachinePrecision] + N[(N[(0.083333333333333 / x), $MachinePrecision] - N[(N[(0.5 - x), $MachinePrecision] * N[Log[x], $MachinePrecision] + N[(x - 0.91893853320467), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 350000:\\
\;\;\;\;\frac{1}{\frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(y - -0.0007936500793651, z, -0.0027777777777778\right), z, 0.083333333333333\right)}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, \frac{z}{x}, \frac{0.083333333333333}{x} - \mathsf{fma}\left(0.5 - x, \log x, x - 0.91893853320467\right)\right)\\
\end{array}
if x < 3.5e5Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
lift-/.f64N/A
div-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
metadata-evalN/A
lift-fma.f64N/A
lift-fma.f64N/A
lower-unsound-/.f64N/A
Applied rewrites62.8%
if 3.5e5 < x Initial program 93.6%
Applied rewrites98.6%
Taylor expanded in y around inf
lower-*.f6485.0
Applied rewrites85.0%
(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 (* (* (/ (- y -0.0007936500793651) x) z) z)))
(if (<= t_0 -5e+45)
t_1
(if (<= t_0 2e+304)
(-
(- (/ 0.083333333333333 x) -0.91893853320467)
(fma (- 0.5 x) (log x) x))
t_1))))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 = (((y - -0.0007936500793651) / x) * z) * z;
double tmp;
if (t_0 <= -5e+45) {
tmp = t_1;
} else if (t_0 <= 2e+304) {
tmp = ((0.083333333333333 / x) - -0.91893853320467) - fma((0.5 - x), log(x), x);
} else {
tmp = t_1;
}
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(Float64(Float64(y - -0.0007936500793651) / x) * z) * z) tmp = 0.0 if (t_0 <= -5e+45) tmp = t_1; elseif (t_0 <= 2e+304) tmp = Float64(Float64(Float64(0.083333333333333 / x) - -0.91893853320467) - fma(Float64(0.5 - x), log(x), x)); else tmp = t_1; end return 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[(N[(N[(y - -0.0007936500793651), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+45], t$95$1, If[LessEqual[t$95$0, 2e+304], N[(N[(N[(0.083333333333333 / x), $MachinePrecision] - -0.91893853320467), $MachinePrecision] - N[(N[(0.5 - x), $MachinePrecision] * N[Log[x], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\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 := \left(\frac{y - -0.0007936500793651}{x} \cdot z\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+304}:\\
\;\;\;\;\left(\frac{0.083333333333333}{x} - -0.91893853320467\right) - \mathsf{fma}\left(0.5 - x, \log x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\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)) < -5e45 or 1.9999999999999999e304 < (+.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 93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6442.1
Applied rewrites42.1%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6444.0
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
mult-flip-revN/A
div-add-revN/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
lower-/.f6444.0
Applied rewrites44.0%
if -5e45 < (+.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.9999999999999999e304Initial program 93.6%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
add-flipN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.7%
Taylor expanded in z around 0
Applied rewrites57.3%
(FPCore (x y z)
:precision binary64
(if (<= x 1.05e+85)
(fma
(fma z (- y -0.0007936500793651) -0.0027777777777778)
(/ z x)
(/ 0.083333333333333 x))
(* x (- (* -1.0 (log (/ 1.0 x))) 1.0))))double code(double x, double y, double z) {
double tmp;
if (x <= 1.05e+85) {
tmp = fma(fma(z, (y - -0.0007936500793651), -0.0027777777777778), (z / x), (0.083333333333333 / x));
} else {
tmp = x * ((-1.0 * log((1.0 / x))) - 1.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.05e+85) tmp = fma(fma(z, Float64(y - -0.0007936500793651), -0.0027777777777778), Float64(z / x), Float64(0.083333333333333 / x)); else tmp = Float64(x * Float64(Float64(-1.0 * log(Float64(1.0 / x))) - 1.0)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.05e+85], N[(N[(z * N[(y - -0.0007936500793651), $MachinePrecision] + -0.0027777777777778), $MachinePrecision] * N[(z / x), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(-1.0 * N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 1.05 \cdot 10^{+85}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z, y - -0.0007936500793651, -0.0027777777777778\right), \frac{z}{x}, \frac{0.083333333333333}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-1 \cdot \log \left(\frac{1}{x}\right) - 1\right)\\
\end{array}
if x < 1.05000000000000005e85Initial program 93.6%
Applied rewrites98.6%
Taylor expanded in x around 0
lower-/.f6465.1
Applied rewrites65.1%
if 1.05000000000000005e85 < x Initial program 93.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
(FPCore (x y z)
:precision binary64
(if (<= x 1.05e+85)
(/
1.0
(/
x
(fma
(fma (- y -0.0007936500793651) z -0.0027777777777778)
z
0.083333333333333)))
(* x (- (* -1.0 (log (/ 1.0 x))) 1.0))))double code(double x, double y, double z) {
double tmp;
if (x <= 1.05e+85) {
tmp = 1.0 / (x / fma(fma((y - -0.0007936500793651), z, -0.0027777777777778), z, 0.083333333333333));
} else {
tmp = x * ((-1.0 * log((1.0 / x))) - 1.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.05e+85) tmp = Float64(1.0 / Float64(x / fma(fma(Float64(y - -0.0007936500793651), z, -0.0027777777777778), z, 0.083333333333333))); else tmp = Float64(x * Float64(Float64(-1.0 * log(Float64(1.0 / x))) - 1.0)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.05e+85], N[(1.0 / N[(x / N[(N[(N[(y - -0.0007936500793651), $MachinePrecision] * z + -0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(-1.0 * N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 1.05 \cdot 10^{+85}:\\
\;\;\;\;\frac{1}{\frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(y - -0.0007936500793651, z, -0.0027777777777778\right), z, 0.083333333333333\right)}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-1 \cdot \log \left(\frac{1}{x}\right) - 1\right)\\
\end{array}
if x < 1.05000000000000005e85Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
lift-/.f64N/A
div-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
metadata-evalN/A
lift-fma.f64N/A
lift-fma.f64N/A
lower-unsound-/.f64N/A
Applied rewrites62.8%
if 1.05000000000000005e85 < x Initial program 93.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
(FPCore (x y z)
:precision binary64
(if (<= x 1.05e+85)
(/
(fma
(fma (- y -0.0007936500793651) z -0.0027777777777778)
z
0.083333333333333)
x)
(- 0.91893853320467 (fma (- 0.5 x) (log x) x))))double code(double x, double y, double z) {
double tmp;
if (x <= 1.05e+85) {
tmp = fma(fma((y - -0.0007936500793651), z, -0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = 0.91893853320467 - fma((0.5 - x), log(x), x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.05e+85) tmp = Float64(fma(fma(Float64(y - -0.0007936500793651), z, -0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(0.91893853320467 - fma(Float64(0.5 - x), log(x), x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.05e+85], N[(N[(N[(N[(y - -0.0007936500793651), $MachinePrecision] * z + -0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(0.91893853320467 - N[(N[(0.5 - x), $MachinePrecision] * N[Log[x], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 1.05 \cdot 10^{+85}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(y - -0.0007936500793651, z, -0.0027777777777778\right), z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;0.91893853320467 - \mathsf{fma}\left(0.5 - x, \log x, x\right)\\
\end{array}
if x < 1.05000000000000005e85Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
Applied rewrites62.8%
if 1.05000000000000005e85 < x Initial program 93.6%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
add-flipN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.7%
Taylor expanded in x around inf
Applied rewrites36.5%
(FPCore (x y z)
:precision binary64
(if (<= x 1.05e+85)
(/
(fma
(fma (- y -0.0007936500793651) z -0.0027777777777778)
z
0.083333333333333)
x)
(* x (- (* -1.0 (log (/ 1.0 x))) 1.0))))double code(double x, double y, double z) {
double tmp;
if (x <= 1.05e+85) {
tmp = fma(fma((y - -0.0007936500793651), z, -0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = x * ((-1.0 * log((1.0 / x))) - 1.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.05e+85) tmp = Float64(fma(fma(Float64(y - -0.0007936500793651), z, -0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(x * Float64(Float64(-1.0 * log(Float64(1.0 / x))) - 1.0)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.05e+85], N[(N[(N[(N[(y - -0.0007936500793651), $MachinePrecision] * z + -0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(x * N[(N[(-1.0 * N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 1.05 \cdot 10^{+85}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(y - -0.0007936500793651, z, -0.0027777777777778\right), z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-1 \cdot \log \left(\frac{1}{x}\right) - 1\right)\\
\end{array}
if x < 1.05000000000000005e85Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
Applied rewrites62.8%
if 1.05000000000000005e85 < x Initial program 93.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-/.f6435.1
Applied rewrites35.1%
(FPCore (x y z)
:precision binary64
(if (<= x 1.05e+71)
(/
(fma
(fma (- y -0.0007936500793651) z -0.0027777777777778)
z
0.083333333333333)
x)
(* (* (/ (- y -0.0007936500793651) x) z) z)))double code(double x, double y, double z) {
double tmp;
if (x <= 1.05e+71) {
tmp = fma(fma((y - -0.0007936500793651), z, -0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = (((y - -0.0007936500793651) / x) * z) * z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.05e+71) tmp = Float64(fma(fma(Float64(y - -0.0007936500793651), z, -0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(Float64(Float64(Float64(y - -0.0007936500793651) / x) * z) * z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.05e+71], N[(N[(N[(N[(y - -0.0007936500793651), $MachinePrecision] * z + -0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[(y - -0.0007936500793651), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 1.05 \cdot 10^{+71}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(y - -0.0007936500793651, z, -0.0027777777777778\right), z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{y - -0.0007936500793651}{x} \cdot z\right) \cdot z\\
\end{array}
if x < 1.04999999999999995e71Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
Applied rewrites62.8%
if 1.04999999999999995e71 < x Initial program 93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6442.1
Applied rewrites42.1%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6444.0
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
mult-flip-revN/A
div-add-revN/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
lower-/.f6444.0
Applied rewrites44.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* (/ (- y -0.0007936500793651) x) z) z))
(t_1
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)))
(if (<= t_1 -1e+24)
t_0
(if (<= t_1 5e+32)
(/
(+
0.083333333333333
(* z (- (* 0.0007936500793651 z) 0.0027777777777778)))
x)
t_0))))double code(double x, double y, double z) {
double t_0 = (((y - -0.0007936500793651) / x) * z) * z;
double t_1 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333;
double tmp;
if (t_1 <= -1e+24) {
tmp = t_0;
} else if (t_1 <= 5e+32) {
tmp = (0.083333333333333 + (z * ((0.0007936500793651 * z) - 0.0027777777777778))) / x;
} else {
tmp = t_0;
}
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)) / x) * z) * z
t_1 = ((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0
if (t_1 <= (-1d+24)) then
tmp = t_0
else if (t_1 <= 5d+32) then
tmp = (0.083333333333333d0 + (z * ((0.0007936500793651d0 * z) - 0.0027777777777778d0))) / x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (((y - -0.0007936500793651) / x) * z) * z;
double t_1 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333;
double tmp;
if (t_1 <= -1e+24) {
tmp = t_0;
} else if (t_1 <= 5e+32) {
tmp = (0.083333333333333 + (z * ((0.0007936500793651 * z) - 0.0027777777777778))) / x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (((y - -0.0007936500793651) / x) * z) * z t_1 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333 tmp = 0 if t_1 <= -1e+24: tmp = t_0 elif t_1 <= 5e+32: tmp = (0.083333333333333 + (z * ((0.0007936500793651 * z) - 0.0027777777777778))) / x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(y - -0.0007936500793651) / x) * z) * z) t_1 = Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) tmp = 0.0 if (t_1 <= -1e+24) tmp = t_0; elseif (t_1 <= 5e+32) tmp = Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(0.0007936500793651 * z) - 0.0027777777777778))) / x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (((y - -0.0007936500793651) / x) * z) * z; t_1 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333; tmp = 0.0; if (t_1 <= -1e+24) tmp = t_0; elseif (t_1 <= 5e+32) tmp = (0.083333333333333 + (z * ((0.0007936500793651 * z) - 0.0027777777777778))) / x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y - -0.0007936500793651), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+24], t$95$0, If[LessEqual[t$95$1, 5e+32], N[(N[(0.083333333333333 + N[(z * N[(N[(0.0007936500793651 * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \left(\frac{y - -0.0007936500793651}{x} \cdot z\right) \cdot z\\
t_1 := \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+32}:\\
\;\;\;\;\frac{0.083333333333333 + z \cdot \left(0.0007936500793651 \cdot z - 0.0027777777777778\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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)) < -9.9999999999999998e23 or 4.9999999999999997e32 < (+.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 93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6442.1
Applied rewrites42.1%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6444.0
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
mult-flip-revN/A
div-add-revN/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
lower-/.f6444.0
Applied rewrites44.0%
if -9.9999999999999998e23 < (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) < 4.9999999999999997e32Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
Taylor expanded in y around 0
lower-*.f6446.4
Applied rewrites46.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* (/ (- y -0.0007936500793651) x) z) z))
(t_1
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)))
(if (<= t_1 -1e+24)
t_0
(if (<= t_1 0.1) (/ 1.0 (/ x 0.083333333333333)) t_0))))double code(double x, double y, double z) {
double t_0 = (((y - -0.0007936500793651) / x) * z) * z;
double t_1 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333;
double tmp;
if (t_1 <= -1e+24) {
tmp = t_0;
} else if (t_1 <= 0.1) {
tmp = 1.0 / (x / 0.083333333333333);
} else {
tmp = t_0;
}
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)) / x) * z) * z
t_1 = ((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0
if (t_1 <= (-1d+24)) then
tmp = t_0
else if (t_1 <= 0.1d0) then
tmp = 1.0d0 / (x / 0.083333333333333d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (((y - -0.0007936500793651) / x) * z) * z;
double t_1 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333;
double tmp;
if (t_1 <= -1e+24) {
tmp = t_0;
} else if (t_1 <= 0.1) {
tmp = 1.0 / (x / 0.083333333333333);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (((y - -0.0007936500793651) / x) * z) * z t_1 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333 tmp = 0 if t_1 <= -1e+24: tmp = t_0 elif t_1 <= 0.1: tmp = 1.0 / (x / 0.083333333333333) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(y - -0.0007936500793651) / x) * z) * z) t_1 = Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) tmp = 0.0 if (t_1 <= -1e+24) tmp = t_0; elseif (t_1 <= 0.1) tmp = Float64(1.0 / Float64(x / 0.083333333333333)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (((y - -0.0007936500793651) / x) * z) * z; t_1 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333; tmp = 0.0; if (t_1 <= -1e+24) tmp = t_0; elseif (t_1 <= 0.1) tmp = 1.0 / (x / 0.083333333333333); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y - -0.0007936500793651), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+24], t$95$0, If[LessEqual[t$95$1, 0.1], N[(1.0 / N[(x / 0.083333333333333), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \left(\frac{y - -0.0007936500793651}{x} \cdot z\right) \cdot z\\
t_1 := \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 0.1:\\
\;\;\;\;\frac{1}{\frac{x}{0.083333333333333}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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)) < -9.9999999999999998e23 or 0.10000000000000001 < (+.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 93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6442.1
Applied rewrites42.1%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6444.0
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
mult-flip-revN/A
div-add-revN/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
lower-/.f6444.0
Applied rewrites44.0%
if -9.9999999999999998e23 < (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) < 0.10000000000000001Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
Taylor expanded in z around 0
Applied rewrites23.3%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6423.3
Applied rewrites23.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)))
(if (<= t_0 -1e+24)
(* (* z z) (/ y x))
(if (<= t_0 500.0)
(/ 1.0 (/ x 0.083333333333333))
(* (* z z) (/ 0.0007936500793651 x))))))double code(double x, double y, double z) {
double t_0 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333;
double tmp;
if (t_0 <= -1e+24) {
tmp = (z * z) * (y / x);
} else if (t_0 <= 500.0) {
tmp = 1.0 / (x / 0.083333333333333);
} else {
tmp = (z * z) * (0.0007936500793651 / 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) - 0.0027777777777778d0) * z) + 0.083333333333333d0
if (t_0 <= (-1d+24)) then
tmp = (z * z) * (y / x)
else if (t_0 <= 500.0d0) then
tmp = 1.0d0 / (x / 0.083333333333333d0)
else
tmp = (z * z) * (0.0007936500793651d0 / x)
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) + 0.083333333333333;
double tmp;
if (t_0 <= -1e+24) {
tmp = (z * z) * (y / x);
} else if (t_0 <= 500.0) {
tmp = 1.0 / (x / 0.083333333333333);
} else {
tmp = (z * z) * (0.0007936500793651 / x);
}
return tmp;
}
def code(x, y, z): t_0 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333 tmp = 0 if t_0 <= -1e+24: tmp = (z * z) * (y / x) elif t_0 <= 500.0: tmp = 1.0 / (x / 0.083333333333333) else: tmp = (z * z) * (0.0007936500793651 / x) return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) tmp = 0.0 if (t_0 <= -1e+24) tmp = Float64(Float64(z * z) * Float64(y / x)); elseif (t_0 <= 500.0) tmp = Float64(1.0 / Float64(x / 0.083333333333333)); else tmp = Float64(Float64(z * z) * Float64(0.0007936500793651 / x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333; tmp = 0.0; if (t_0 <= -1e+24) tmp = (z * z) * (y / x); elseif (t_0 <= 500.0) tmp = 1.0 / (x / 0.083333333333333); else tmp = (z * z) * (0.0007936500793651 / x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+24], N[(N[(z * z), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 500.0], N[(1.0 / N[(x / 0.083333333333333), $MachinePrecision]), $MachinePrecision], N[(N[(z * z), $MachinePrecision] * N[(0.0007936500793651 / x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+24}:\\
\;\;\;\;\left(z \cdot z\right) \cdot \frac{y}{x}\\
\mathbf{elif}\;t\_0 \leq 500:\\
\;\;\;\;\frac{1}{\frac{x}{0.083333333333333}}\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot z\right) \cdot \frac{0.0007936500793651}{x}\\
\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)) < -9.9999999999999998e23Initial program 93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6442.1
Applied rewrites42.1%
lift-pow.f64N/A
unpow2N/A
lower-*.f6442.1
Applied rewrites42.1%
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
distribute-rgt-outN/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
lower-*.f6442.1
Applied rewrites42.1%
Taylor expanded in y around inf
lower-/.f6430.4
Applied rewrites30.4%
if -9.9999999999999998e23 < (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) < 500Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
Taylor expanded in z around 0
Applied rewrites23.3%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6423.3
Applied rewrites23.3%
if 500 < (+.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 93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6442.1
Applied rewrites42.1%
lift-pow.f64N/A
unpow2N/A
lower-*.f6442.1
Applied rewrites42.1%
Taylor expanded in y around 0
lower-/.f6425.7
Applied rewrites25.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z z) (/ y x)))
(t_1
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)))
(if (<= t_1 -1e+24)
t_0
(if (<= t_1 4e+68) (/ 1.0 (/ x 0.083333333333333)) t_0))))double code(double x, double y, double z) {
double t_0 = (z * z) * (y / x);
double t_1 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333;
double tmp;
if (t_1 <= -1e+24) {
tmp = t_0;
} else if (t_1 <= 4e+68) {
tmp = 1.0 / (x / 0.083333333333333);
} else {
tmp = t_0;
}
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 = (z * z) * (y / x)
t_1 = ((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0
if (t_1 <= (-1d+24)) then
tmp = t_0
else if (t_1 <= 4d+68) then
tmp = 1.0d0 / (x / 0.083333333333333d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z * z) * (y / x);
double t_1 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333;
double tmp;
if (t_1 <= -1e+24) {
tmp = t_0;
} else if (t_1 <= 4e+68) {
tmp = 1.0 / (x / 0.083333333333333);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (z * z) * (y / x) t_1 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333 tmp = 0 if t_1 <= -1e+24: tmp = t_0 elif t_1 <= 4e+68: tmp = 1.0 / (x / 0.083333333333333) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(z * z) * Float64(y / x)) t_1 = Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) tmp = 0.0 if (t_1 <= -1e+24) tmp = t_0; elseif (t_1 <= 4e+68) tmp = Float64(1.0 / Float64(x / 0.083333333333333)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * z) * (y / x); t_1 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333; tmp = 0.0; if (t_1 <= -1e+24) tmp = t_0; elseif (t_1 <= 4e+68) tmp = 1.0 / (x / 0.083333333333333); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * z), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+24], t$95$0, If[LessEqual[t$95$1, 4e+68], N[(1.0 / N[(x / 0.083333333333333), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \left(z \cdot z\right) \cdot \frac{y}{x}\\
t_1 := \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+68}:\\
\;\;\;\;\frac{1}{\frac{x}{0.083333333333333}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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)) < -9.9999999999999998e23 or 3.99999999999999981e68 < (+.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 93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6442.1
Applied rewrites42.1%
lift-pow.f64N/A
unpow2N/A
lower-*.f6442.1
Applied rewrites42.1%
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
distribute-rgt-outN/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
lower-*.f6442.1
Applied rewrites42.1%
Taylor expanded in y around inf
lower-/.f6430.4
Applied rewrites30.4%
if -9.9999999999999998e23 < (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) < 3.99999999999999981e68Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
Taylor expanded in z around 0
Applied rewrites23.3%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6423.3
Applied rewrites23.3%
(FPCore (x y z) :precision binary64 (/ (+ 0.083333333333333 (* -0.0027777777777778 z)) x))
double code(double x, double y, double z) {
return (0.083333333333333 + (-0.0027777777777778 * 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 = (0.083333333333333d0 + ((-0.0027777777777778d0) * z)) / x
end function
public static double code(double x, double y, double z) {
return (0.083333333333333 + (-0.0027777777777778 * z)) / x;
}
def code(x, y, z): return (0.083333333333333 + (-0.0027777777777778 * z)) / x
function code(x, y, z) return Float64(Float64(0.083333333333333 + Float64(-0.0027777777777778 * z)) / x) end
function tmp = code(x, y, z) tmp = (0.083333333333333 + (-0.0027777777777778 * z)) / x; end
code[x_, y_, z_] := N[(N[(0.083333333333333 + N[(-0.0027777777777778 * z), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\frac{0.083333333333333 + -0.0027777777777778 \cdot z}{x}
Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
Taylor expanded in z around 0
lower-*.f6428.7
Applied rewrites28.7%
(FPCore (x y z) :precision binary64 (/ 1.0 (/ x 0.083333333333333)))
double code(double x, double y, double z) {
return 1.0 / (x / 0.083333333333333);
}
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 = 1.0d0 / (x / 0.083333333333333d0)
end function
public static double code(double x, double y, double z) {
return 1.0 / (x / 0.083333333333333);
}
def code(x, y, z): return 1.0 / (x / 0.083333333333333)
function code(x, y, z) return Float64(1.0 / Float64(x / 0.083333333333333)) end
function tmp = code(x, y, z) tmp = 1.0 / (x / 0.083333333333333); end
code[x_, y_, z_] := N[(1.0 / N[(x / 0.083333333333333), $MachinePrecision]), $MachinePrecision]
\frac{1}{\frac{x}{0.083333333333333}}
Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
Taylor expanded in z around 0
Applied rewrites23.3%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6423.3
Applied rewrites23.3%
(FPCore (x y z) :precision binary64 (* (/ 1.0 x) 0.083333333333333))
double code(double x, double y, double z) {
return (1.0 / x) * 0.083333333333333;
}
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 = (1.0d0 / x) * 0.083333333333333d0
end function
public static double code(double x, double y, double z) {
return (1.0 / x) * 0.083333333333333;
}
def code(x, y, z): return (1.0 / x) * 0.083333333333333
function code(x, y, z) return Float64(Float64(1.0 / x) * 0.083333333333333) end
function tmp = code(x, y, z) tmp = (1.0 / x) * 0.083333333333333; end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] * 0.083333333333333), $MachinePrecision]
\frac{1}{x} \cdot 0.083333333333333
Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
Taylor expanded in z around 0
Applied rewrites23.3%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6423.3
Applied rewrites23.3%
(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]
\frac{0.083333333333333}{x}
Initial program 93.6%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f6462.8
Applied rewrites62.8%
Taylor expanded in z around 0
Applied rewrites23.3%
herbie shell --seed 2025172
(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)))