
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
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 + (((y - x) * 6.0d0) * ((2.0d0 / 3.0d0) - z))
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
def code(x, y, z): return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z))) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * ((2.0 / 3.0) - z)); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\end{array}
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
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 + (((y - x) * 6.0d0) * ((2.0d0 / 3.0d0) - z))
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
def code(x, y, z): return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z))) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * ((2.0 / 3.0) - z)); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\end{array}
(FPCore (x y z) :precision binary64 (+ (+ x (* (* z (- y x)) -6.0)) (* 4.0 (- y x))))
double code(double x, double y, double z) {
return (x + ((z * (y - x)) * -6.0)) + (4.0 * (y - 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 + ((z * (y - x)) * (-6.0d0))) + (4.0d0 * (y - x))
end function
public static double code(double x, double y, double z) {
return (x + ((z * (y - x)) * -6.0)) + (4.0 * (y - x));
}
def code(x, y, z): return (x + ((z * (y - x)) * -6.0)) + (4.0 * (y - x))
function code(x, y, z) return Float64(Float64(x + Float64(Float64(z * Float64(y - x)) * -6.0)) + Float64(4.0 * Float64(y - x))) end
function tmp = code(x, y, z) tmp = (x + ((z * (y - x)) * -6.0)) + (4.0 * (y - x)); end
code[x_, y_, z_] := N[(N[(x + N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \left(z \cdot \left(y - x\right)\right) \cdot -6\right) + 4 \cdot \left(y - x\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*r*N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift--.f6499.7
Applied rewrites99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -2e+40)
(* (* z x) 6.0)
(if (<= t_0 0.6)
(* (fma -6.0 z 4.0) y)
(if (<= t_0 1.0)
(fma 4.0 (- y x) x)
(if (<= t_0 5e+85) (* (* z 6.0) x) (* (* -6.0 z) y)))))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -2e+40) {
tmp = (z * x) * 6.0;
} else if (t_0 <= 0.6) {
tmp = fma(-6.0, z, 4.0) * y;
} else if (t_0 <= 1.0) {
tmp = fma(4.0, (y - x), x);
} else if (t_0 <= 5e+85) {
tmp = (z * 6.0) * x;
} else {
tmp = (-6.0 * z) * y;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -2e+40) tmp = Float64(Float64(z * x) * 6.0); elseif (t_0 <= 0.6) tmp = Float64(fma(-6.0, z, 4.0) * y); elseif (t_0 <= 1.0) tmp = fma(4.0, Float64(y - x), x); elseif (t_0 <= 5e+85) tmp = Float64(Float64(z * 6.0) * x); else tmp = Float64(Float64(-6.0 * z) * y); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+40], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision], If[LessEqual[t$95$0, 0.6], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$0, 5e+85], N[(N[(z * 6.0), $MachinePrecision] * x), $MachinePrecision], N[(N[(-6.0 * z), $MachinePrecision] * y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+40}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\mathbf{elif}\;t\_0 \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+85}:\\
\;\;\;\;\left(z \cdot 6\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(-6 \cdot z\right) \cdot y\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -2.00000000000000006e40Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6454.6
Applied rewrites54.6%
if -2.00000000000000006e40 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 0.599999999999999978Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.6
Applied rewrites99.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6452.2
Applied rewrites52.2%
if 0.599999999999999978 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.9
Applied rewrites97.9%
if 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 5.0000000000000001e85Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*r*N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift--.f6499.6
Applied rewrites99.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6450.1
Applied rewrites50.1%
Taylor expanded in z around inf
*-commutativeN/A
lift-*.f6445.7
Applied rewrites45.7%
if 5.0000000000000001e85 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6451.1
Applied rewrites51.1%
Taylor expanded in z around inf
lower-*.f6451.1
Applied rewrites51.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -2e+40)
(* (* z x) 6.0)
(if (<= t_0 -100000.0)
(* (* y z) -6.0)
(if (<= t_0 1.0)
(fma 4.0 (- y x) x)
(if (<= t_0 5e+85) (* (* z 6.0) x) (* (* -6.0 z) y)))))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -2e+40) {
tmp = (z * x) * 6.0;
} else if (t_0 <= -100000.0) {
tmp = (y * z) * -6.0;
} else if (t_0 <= 1.0) {
tmp = fma(4.0, (y - x), x);
} else if (t_0 <= 5e+85) {
tmp = (z * 6.0) * x;
} else {
tmp = (-6.0 * z) * y;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -2e+40) tmp = Float64(Float64(z * x) * 6.0); elseif (t_0 <= -100000.0) tmp = Float64(Float64(y * z) * -6.0); elseif (t_0 <= 1.0) tmp = fma(4.0, Float64(y - x), x); elseif (t_0 <= 5e+85) tmp = Float64(Float64(z * 6.0) * x); else tmp = Float64(Float64(-6.0 * z) * y); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+40], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision], If[LessEqual[t$95$0, -100000.0], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$0, 5e+85], N[(N[(z * 6.0), $MachinePrecision] * x), $MachinePrecision], N[(N[(-6.0 * z), $MachinePrecision] * y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+40}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\mathbf{elif}\;t\_0 \leq -100000:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+85}:\\
\;\;\;\;\left(z \cdot 6\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(-6 \cdot z\right) \cdot y\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -2.00000000000000006e40Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6454.6
Applied rewrites54.6%
if -2.00000000000000006e40 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e5Initial program 99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6492.5
Applied rewrites92.5%
Taylor expanded in x around 0
Applied rewrites49.7%
if -1e5 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.2
Applied rewrites97.2%
if 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 5.0000000000000001e85Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*r*N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift--.f6499.6
Applied rewrites99.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6450.1
Applied rewrites50.1%
Taylor expanded in z around inf
*-commutativeN/A
lift-*.f6445.7
Applied rewrites45.7%
if 5.0000000000000001e85 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6451.1
Applied rewrites51.1%
Taylor expanded in z around inf
lower-*.f6451.1
Applied rewrites51.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* -6.0 z) y)) (t_1 (- (/ 2.0 3.0) z)))
(if (<= t_1 -2e+40)
(* (* z x) 6.0)
(if (<= t_1 -100000.0)
t_0
(if (<= t_1 1.0)
(fma 4.0 (- y x) x)
(if (<= t_1 5e+85) (* (* z 6.0) x) t_0))))))
double code(double x, double y, double z) {
double t_0 = (-6.0 * z) * y;
double t_1 = (2.0 / 3.0) - z;
double tmp;
if (t_1 <= -2e+40) {
tmp = (z * x) * 6.0;
} else if (t_1 <= -100000.0) {
tmp = t_0;
} else if (t_1 <= 1.0) {
tmp = fma(4.0, (y - x), x);
} else if (t_1 <= 5e+85) {
tmp = (z * 6.0) * x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(-6.0 * z) * y) t_1 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_1 <= -2e+40) tmp = Float64(Float64(z * x) * 6.0); elseif (t_1 <= -100000.0) tmp = t_0; elseif (t_1 <= 1.0) tmp = fma(4.0, Float64(y - x), x); elseif (t_1 <= 5e+85) tmp = Float64(Float64(z * 6.0) * x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-6.0 * z), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+40], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision], If[LessEqual[t$95$1, -100000.0], t$95$0, If[LessEqual[t$95$1, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$1, 5e+85], N[(N[(z * 6.0), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-6 \cdot z\right) \cdot y\\
t_1 := \frac{2}{3} - z\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+40}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\mathbf{elif}\;t\_1 \leq -100000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+85}:\\
\;\;\;\;\left(z \cdot 6\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -2.00000000000000006e40Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6454.6
Applied rewrites54.6%
if -2.00000000000000006e40 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e5 or 5.0000000000000001e85 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6451.4
Applied rewrites51.4%
Taylor expanded in z around inf
lower-*.f6450.9
Applied rewrites50.9%
if -1e5 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.2
Applied rewrites97.2%
if 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 5.0000000000000001e85Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*r*N/A
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift--.f6499.6
Applied rewrites99.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6450.1
Applied rewrites50.1%
Taylor expanded in z around inf
*-commutativeN/A
lift-*.f6445.7
Applied rewrites45.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -100000.0)
(* (* z x) 6.0)
(if (<= t_0 1.0) (fma 4.0 (- y x) x) (* (* 6.0 x) z)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -100000.0) {
tmp = (z * x) * 6.0;
} else if (t_0 <= 1.0) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = (6.0 * x) * z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -100000.0) tmp = Float64(Float64(z * x) * 6.0); elseif (t_0 <= 1.0) tmp = fma(4.0, Float64(y - x), x); else tmp = Float64(Float64(6.0 * x) * z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -100000.0], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -100000:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e5Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6498.8
Applied rewrites98.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6453.2
Applied rewrites53.2%
if -1e5 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.2
Applied rewrites97.2%
if 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6497.2
Applied rewrites97.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6454.0
Applied rewrites54.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6454.0
Applied rewrites54.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* 6.0 x) z))) (if (<= t_0 -100000.0) t_1 (if (<= t_0 1.0) (fma 4.0 (- y x) x) t_1))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (6.0 * x) * z;
double tmp;
if (t_0 <= -100000.0) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(Float64(6.0 * x) * z) tmp = 0.0 if (t_0 <= -100000.0) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(4.0, Float64(y - x), x); else tmp = t_1; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, -100000.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(6 \cdot x\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -100000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e5 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6498.0
Applied rewrites98.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6453.6
Applied rewrites53.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6453.6
Applied rewrites53.6%
if -1e5 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.2
Applied rewrites97.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* -6.0 z) y)))
(if (<= z -1.95e+86)
t_0
(if (<= z -36.0)
(* (* 6.0 x) z)
(if (<= z 0.66)
(fma 4.0 (- y x) x)
(if (<= z 1.9e+39) t_0 (* (* z x) 6.0)))))))
double code(double x, double y, double z) {
double t_0 = (-6.0 * z) * y;
double tmp;
if (z <= -1.95e+86) {
tmp = t_0;
} else if (z <= -36.0) {
tmp = (6.0 * x) * z;
} else if (z <= 0.66) {
tmp = fma(4.0, (y - x), x);
} else if (z <= 1.9e+39) {
tmp = t_0;
} else {
tmp = (z * x) * 6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(-6.0 * z) * y) tmp = 0.0 if (z <= -1.95e+86) tmp = t_0; elseif (z <= -36.0) tmp = Float64(Float64(6.0 * x) * z); elseif (z <= 0.66) tmp = fma(4.0, Float64(y - x), x); elseif (z <= 1.9e+39) tmp = t_0; else tmp = Float64(Float64(z * x) * 6.0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-6.0 * z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[z, -1.95e+86], t$95$0, If[LessEqual[z, -36.0], N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 0.66], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 1.9e+39], t$95$0, N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-6 \cdot z\right) \cdot y\\
\mathbf{if}\;z \leq -1.95 \cdot 10^{+86}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -36:\\
\;\;\;\;\left(6 \cdot x\right) \cdot z\\
\mathbf{elif}\;z \leq 0.66:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{+39}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\end{array}
\end{array}
if z < -1.9500000000000001e86 or 0.660000000000000031 < z < 1.8999999999999999e39Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6451.3
Applied rewrites51.3%
Taylor expanded in z around inf
lower-*.f6450.2
Applied rewrites50.2%
if -1.9500000000000001e86 < z < -36Initial program 99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6492.6
Applied rewrites92.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6446.4
Applied rewrites46.4%
if -36 < z < 0.660000000000000031Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.5
Applied rewrites97.5%
if 1.8999999999999999e39 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6454.4
Applied rewrites54.4%
(FPCore (x y z) :precision binary64 (if (<= z -0.55) (* (- y x) (* -6.0 z)) (if (<= z 0.65) (fma 4.0 (- y x) x) (* (* (- y x) z) -6.0))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.55) {
tmp = (y - x) * (-6.0 * z);
} else if (z <= 0.65) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = ((y - x) * z) * -6.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -0.55) tmp = Float64(Float64(y - x) * Float64(-6.0 * z)); elseif (z <= 0.65) tmp = fma(4.0, Float64(y - x), x); else tmp = Float64(Float64(Float64(y - x) * z) * -6.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -0.55], N[(N[(y - x), $MachinePrecision] * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.65], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.55:\\
\;\;\;\;\left(y - x\right) \cdot \left(-6 \cdot z\right)\\
\mathbf{elif}\;z \leq 0.65:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y - x\right) \cdot z\right) \cdot -6\\
\end{array}
\end{array}
if z < -0.55000000000000004Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6497.2
Applied rewrites97.2%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f6497.1
Applied rewrites97.1%
if -0.55000000000000004 < z < 0.650000000000000022Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.9
Applied rewrites97.9%
if 0.650000000000000022 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6497.9
Applied rewrites97.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* (- y x) z) -6.0))) (if (<= z -0.55) t_0 (if (<= z 0.65) (fma 4.0 (- y x) x) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y - x) * z) * -6.0;
double tmp;
if (z <= -0.55) {
tmp = t_0;
} else if (z <= 0.65) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(y - x) * z) * -6.0) tmp = 0.0 if (z <= -0.55) tmp = t_0; elseif (z <= 0.65) tmp = fma(4.0, Float64(y - x), x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $MachinePrecision]}, If[LessEqual[z, -0.55], t$95$0, If[LessEqual[z, 0.65], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(y - x\right) \cdot z\right) \cdot -6\\
\mathbf{if}\;z \leq -0.55:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.65:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.55000000000000004 or 0.650000000000000022 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6497.5
Applied rewrites97.5%
if -0.55000000000000004 < z < 0.650000000000000022Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.9
Applied rewrites97.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- x) (fma -6.0 z 3.0)))) (if (<= x -5500000.0) t_0 (if (<= x 9.5e-51) (* (fma -6.0 z 4.0) y) t_0))))
double code(double x, double y, double z) {
double t_0 = -x * fma(-6.0, z, 3.0);
double tmp;
if (x <= -5500000.0) {
tmp = t_0;
} else if (x <= 9.5e-51) {
tmp = fma(-6.0, z, 4.0) * y;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(-x) * fma(-6.0, z, 3.0)) tmp = 0.0 if (x <= -5500000.0) tmp = t_0; elseif (x <= 9.5e-51) tmp = Float64(fma(-6.0, z, 4.0) * y); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[((-x) * N[(-6.0 * z + 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5500000.0], t$95$0, If[LessEqual[x, 9.5e-51], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-x\right) \cdot \mathsf{fma}\left(-6, z, 3\right)\\
\mathbf{if}\;x \leq -5500000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-51}:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.5e6 or 9.4999999999999998e-51 < x Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.8
Applied rewrites99.8%
Taylor expanded in x around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
lower-fma.f6475.4
Applied rewrites75.4%
if -5.5e6 < x < 9.4999999999999998e-51Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6475.0
Applied rewrites75.0%
(FPCore (x y z) :precision binary64 (if (<= y -4.5e+54) (* 4.0 y) (if (<= y 8.4e-55) (* -3.0 x) (* 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.5e+54) {
tmp = 4.0 * y;
} else if (y <= 8.4e-55) {
tmp = -3.0 * x;
} else {
tmp = 4.0 * y;
}
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 <= (-4.5d+54)) then
tmp = 4.0d0 * y
else if (y <= 8.4d-55) then
tmp = (-3.0d0) * x
else
tmp = 4.0d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.5e+54) {
tmp = 4.0 * y;
} else if (y <= 8.4e-55) {
tmp = -3.0 * x;
} else {
tmp = 4.0 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.5e+54: tmp = 4.0 * y elif y <= 8.4e-55: tmp = -3.0 * x else: tmp = 4.0 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.5e+54) tmp = Float64(4.0 * y); elseif (y <= 8.4e-55) tmp = Float64(-3.0 * x); else tmp = Float64(4.0 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.5e+54) tmp = 4.0 * y; elseif (y <= 8.4e-55) tmp = -3.0 * x; else tmp = 4.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.5e+54], N[(4.0 * y), $MachinePrecision], If[LessEqual[y, 8.4e-55], N[(-3.0 * x), $MachinePrecision], N[(4.0 * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{+54}:\\
\;\;\;\;4 \cdot y\\
\mathbf{elif}\;y \leq 8.4 \cdot 10^{-55}:\\
\;\;\;\;-3 \cdot x\\
\mathbf{else}:\\
\;\;\;\;4 \cdot y\\
\end{array}
\end{array}
if y < -4.49999999999999984e54 or 8.4000000000000006e-55 < y Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6450.7
Applied rewrites50.7%
Taylor expanded in x around 0
lower-*.f6437.8
Applied rewrites37.8%
if -4.49999999999999984e54 < y < 8.4000000000000006e-55Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.0
Applied rewrites51.0%
Taylor expanded in x around inf
lower-*.f6438.1
Applied rewrites38.1%
(FPCore (x y z) :precision binary64 (fma (- y x) (fma -6.0 z 4.0) x))
double code(double x, double y, double z) {
return fma((y - x), fma(-6.0, z, 4.0), x);
}
function code(x, y, z) return fma(Float64(y - x), fma(-6.0, z, 4.0), x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(-6.0 * z + 4.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, \mathsf{fma}\left(-6, z, 4\right), x\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
(FPCore (x y z) :precision binary64 (fma 4.0 (- y x) x))
double code(double x, double y, double z) {
return fma(4.0, (y - x), x);
}
function code(x, y, z) return fma(4.0, Float64(y - x), x) end
code[x_, y_, z_] := N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, y - x, x\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6450.9
Applied rewrites50.9%
(FPCore (x y z) :precision binary64 (* -3.0 x))
double code(double x, double y, double z) {
return -3.0 * 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 = (-3.0d0) * x
end function
public static double code(double x, double y, double z) {
return -3.0 * x;
}
def code(x, y, z): return -3.0 * x
function code(x, y, z) return Float64(-3.0 * x) end
function tmp = code(x, y, z) tmp = -3.0 * x; end
code[x_, y_, z_] := N[(-3.0 * x), $MachinePrecision]
\begin{array}{l}
\\
-3 \cdot x
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6450.9
Applied rewrites50.9%
Taylor expanded in x around inf
lower-*.f6426.4
Applied rewrites26.4%
herbie shell --seed 2025095
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, D"
:precision binary64
(+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))