
(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 (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
(let* ((t_0 (* (fma -6.0 z 4.0) y)))
(if (<= z -2.8e-7)
t_0
(if (<= z 0.0018)
(fma -3.0 x (* 4.0 y))
(if (<= z 3.7e+232) t_0 (* (* 6.0 x) z))))))
double code(double x, double y, double z) {
double t_0 = fma(-6.0, z, 4.0) * y;
double tmp;
if (z <= -2.8e-7) {
tmp = t_0;
} else if (z <= 0.0018) {
tmp = fma(-3.0, x, (4.0 * y));
} else if (z <= 3.7e+232) {
tmp = t_0;
} else {
tmp = (6.0 * x) * z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(fma(-6.0, z, 4.0) * y) tmp = 0.0 if (z <= -2.8e-7) tmp = t_0; elseif (z <= 0.0018) tmp = fma(-3.0, x, Float64(4.0 * y)); elseif (z <= 3.7e+232) tmp = t_0; else tmp = Float64(Float64(6.0 * x) * z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[z, -2.8e-7], t$95$0, If[LessEqual[z, 0.0018], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.7e+232], t$95$0, N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{if}\;z \leq -2.8 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.0018:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{+232}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if z < -2.80000000000000019e-7 or 0.0018 < z < 3.69999999999999973e232Initial program 99.7%
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.9
Applied rewrites51.9%
if -2.80000000000000019e-7 < z < 0.0018Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6498.6
Applied rewrites98.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6498.7
Applied rewrites98.7%
if 3.69999999999999973e232 < z Initial program 99.9%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval53.8
Applied rewrites53.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6454.3
Applied rewrites54.3%
Taylor expanded in z around inf
lift-*.f6454.3
Applied rewrites54.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z y) -6.0)))
(if (<= z -1.25)
t_0
(if (<= z 0.65)
(fma -3.0 x (* 4.0 y))
(if (<= z 3.7e+232) t_0 (* (* 6.0 x) z))))))
double code(double x, double y, double z) {
double t_0 = (z * y) * -6.0;
double tmp;
if (z <= -1.25) {
tmp = t_0;
} else if (z <= 0.65) {
tmp = fma(-3.0, x, (4.0 * y));
} else if (z <= 3.7e+232) {
tmp = t_0;
} else {
tmp = (6.0 * x) * z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(z * y) * -6.0) tmp = 0.0 if (z <= -1.25) tmp = t_0; elseif (z <= 0.65) tmp = fma(-3.0, x, Float64(4.0 * y)); elseif (z <= 3.7e+232) tmp = t_0; else tmp = Float64(Float64(6.0 * x) * z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * y), $MachinePrecision] * -6.0), $MachinePrecision]}, If[LessEqual[z, -1.25], t$95$0, If[LessEqual[z, 0.65], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.7e+232], t$95$0, N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot y\right) \cdot -6\\
\mathbf{if}\;z \leq -1.25:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.65:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{+232}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if z < -1.25 or 0.650000000000000022 < z < 3.69999999999999973e232Initial program 99.7%
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 z around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
Applied rewrites97.4%
Taylor expanded in x around 0
Applied rewrites51.0%
if -1.25 < z < 0.650000000000000022Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.5
Applied rewrites97.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6497.6
Applied rewrites97.6%
if 3.69999999999999973e232 < z Initial program 99.9%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval53.8
Applied rewrites53.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6454.3
Applied rewrites54.3%
Taylor expanded in z around inf
lift-*.f6454.3
Applied rewrites54.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z y) -6.0)))
(if (<= z -1.25)
t_0
(if (<= z 0.65)
(fma 4.0 (- y x) x)
(if (<= z 3.7e+232) t_0 (* (* 6.0 x) z))))))
double code(double x, double y, double z) {
double t_0 = (z * y) * -6.0;
double tmp;
if (z <= -1.25) {
tmp = t_0;
} else if (z <= 0.65) {
tmp = fma(4.0, (y - x), x);
} else if (z <= 3.7e+232) {
tmp = t_0;
} else {
tmp = (6.0 * x) * z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(z * y) * -6.0) tmp = 0.0 if (z <= -1.25) tmp = t_0; elseif (z <= 0.65) tmp = fma(4.0, Float64(y - x), x); elseif (z <= 3.7e+232) tmp = t_0; else tmp = Float64(Float64(6.0 * x) * z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * y), $MachinePrecision] * -6.0), $MachinePrecision]}, If[LessEqual[z, -1.25], t$95$0, If[LessEqual[z, 0.65], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 3.7e+232], t$95$0, N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot y\right) \cdot -6\\
\mathbf{if}\;z \leq -1.25:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.65:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{+232}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if z < -1.25 or 0.650000000000000022 < z < 3.69999999999999973e232Initial program 99.7%
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 z around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
Applied rewrites97.4%
Taylor expanded in x around 0
Applied rewrites51.0%
if -1.25 < z < 0.650000000000000022Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.5
Applied rewrites97.5%
if 3.69999999999999973e232 < z Initial program 99.9%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval53.8
Applied rewrites53.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6454.3
Applied rewrites54.3%
Taylor expanded in z around inf
lift-*.f6454.3
Applied rewrites54.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (* -6.0 (- y x))))) (if (<= z -0.58) t_0 (if (<= z 0.6) (fma -3.0 x (* 4.0 y)) t_0))))
double code(double x, double y, double z) {
double t_0 = z * (-6.0 * (y - x));
double tmp;
if (z <= -0.58) {
tmp = t_0;
} else if (z <= 0.6) {
tmp = fma(-3.0, x, (4.0 * y));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(z * Float64(-6.0 * Float64(y - x))) tmp = 0.0 if (z <= -0.58) tmp = t_0; elseif (z <= 0.6) tmp = fma(-3.0, x, Float64(4.0 * y)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(-6.0 * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.58], t$95$0, If[LessEqual[z, 0.6], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-6 \cdot \left(y - x\right)\right)\\
\mathbf{if}\;z \leq -0.58:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.57999999999999996 or 0.599999999999999978 < z Initial program 99.7%
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 z around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
Applied rewrites97.6%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f6497.7
Applied rewrites97.7%
if -0.57999999999999996 < z < 0.599999999999999978Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.5
Applied rewrites97.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6497.6
Applied rewrites97.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* (- y x) z) -6.0))) (if (<= z -0.58) t_0 (if (<= z 0.6) (fma -3.0 x (* 4.0 y)) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y - x) * z) * -6.0;
double tmp;
if (z <= -0.58) {
tmp = t_0;
} else if (z <= 0.6) {
tmp = fma(-3.0, x, (4.0 * y));
} 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.58) tmp = t_0; elseif (z <= 0.6) tmp = fma(-3.0, x, Float64(4.0 * y)); 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.58], t$95$0, If[LessEqual[z, 0.6], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $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.58:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.57999999999999996 or 0.599999999999999978 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6497.6
Applied rewrites97.6%
if -0.57999999999999996 < z < 0.599999999999999978Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.5
Applied rewrites97.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6497.6
Applied rewrites97.6%
(FPCore (x y z) :precision binary64 (if (<= x -19000.0) (* (- (* 6.0 z) 3.0) x) (if (<= x 6800000000.0) (* (fma -6.0 z 4.0) y) (* (- x) (fma -6.0 z 3.0)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -19000.0) {
tmp = ((6.0 * z) - 3.0) * x;
} else if (x <= 6800000000.0) {
tmp = fma(-6.0, z, 4.0) * y;
} else {
tmp = -x * fma(-6.0, z, 3.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -19000.0) tmp = Float64(Float64(Float64(6.0 * z) - 3.0) * x); elseif (x <= 6800000000.0) tmp = Float64(fma(-6.0, z, 4.0) * y); else tmp = Float64(Float64(-x) * fma(-6.0, z, 3.0)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -19000.0], N[(N[(N[(6.0 * z), $MachinePrecision] - 3.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 6800000000.0], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision], N[((-x) * N[(-6.0 * z + 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -19000:\\
\;\;\;\;\left(6 \cdot z - 3\right) \cdot x\\
\mathbf{elif}\;x \leq 6800000000:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \mathsf{fma}\left(-6, z, 3\right)\\
\end{array}
\end{array}
if x < -19000Initial program 99.5%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval77.8
Applied rewrites77.8%
Taylor expanded in z around 0
Applied rewrites38.4%
Taylor expanded in z around 0
lower--.f64N/A
lower-*.f6477.8
Applied rewrites77.8%
if -19000 < x < 6.8e9Initial 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.f6473.9
Applied rewrites73.9%
if 6.8e9 < x Initial 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.8
Applied rewrites99.8%
Taylor expanded in x around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
+-commutativeN/A
lower-fma.f6477.4
Applied rewrites77.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- x) (fma -6.0 z 3.0))))
(if (<= x -19000.0)
t_0
(if (<= x 6800000000.0) (* (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 <= -19000.0) {
tmp = t_0;
} else if (x <= 6800000000.0) {
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 <= -19000.0) tmp = t_0; elseif (x <= 6800000000.0) 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, -19000.0], t$95$0, If[LessEqual[x, 6800000000.0], 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 -19000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6800000000:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -19000 or 6.8e9 < x Initial 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.8
Applied rewrites99.8%
Taylor expanded in x around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
+-commutativeN/A
lower-fma.f6477.6
Applied rewrites77.6%
if -19000 < x < 6.8e9Initial 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.f6473.9
Applied rewrites73.9%
(FPCore (x y z) :precision binary64 (if (<= z -9.5e+16) (* (* z 6.0) x) (if (<= z 0.55) (fma 4.0 (- y x) x) (* (* 6.0 x) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9.5e+16) {
tmp = (z * 6.0) * x;
} else if (z <= 0.55) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = (6.0 * x) * z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -9.5e+16) tmp = Float64(Float64(z * 6.0) * x); elseif (z <= 0.55) tmp = fma(4.0, Float64(y - x), x); else tmp = Float64(Float64(6.0 * x) * z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -9.5e+16], N[(N[(z * 6.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 0.55], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{+16}:\\
\;\;\;\;\left(z \cdot 6\right) \cdot x\\
\mathbf{elif}\;z \leq 0.55:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if z < -9.5e16Initial program 99.7%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval52.1
Applied rewrites52.1%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6452.1
Applied rewrites52.1%
if -9.5e16 < z < 0.55000000000000004Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6495.2
Applied rewrites95.2%
if 0.55000000000000004 < z Initial program 99.7%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval52.8
Applied rewrites52.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.9
Applied rewrites52.9%
Taylor expanded in z around inf
lift-*.f6451.9
Applied rewrites51.9%
(FPCore (x y z) :precision binary64 (if (<= z -9.5e+16) (* (* z x) 6.0) (if (<= z 0.55) (fma 4.0 (- y x) x) (* (* 6.0 x) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9.5e+16) {
tmp = (z * x) * 6.0;
} else if (z <= 0.55) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = (6.0 * x) * z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -9.5e+16) tmp = Float64(Float64(z * x) * 6.0); elseif (z <= 0.55) tmp = fma(4.0, Float64(y - x), x); else tmp = Float64(Float64(6.0 * x) * z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -9.5e+16], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision], If[LessEqual[z, 0.55], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{+16}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\mathbf{elif}\;z \leq 0.55:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if z < -9.5e16Initial program 99.7%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval52.1
Applied rewrites52.1%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6452.1
Applied rewrites52.1%
if -9.5e16 < z < 0.55000000000000004Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6495.2
Applied rewrites95.2%
if 0.55000000000000004 < z Initial program 99.7%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval52.8
Applied rewrites52.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.9
Applied rewrites52.9%
Taylor expanded in z around inf
lift-*.f6451.9
Applied rewrites51.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* 6.0 x) z))) (if (<= z -9.5e+16) t_0 (if (<= z 0.55) (fma 4.0 (- y x) x) t_0))))
double code(double x, double y, double z) {
double t_0 = (6.0 * x) * z;
double tmp;
if (z <= -9.5e+16) {
tmp = t_0;
} else if (z <= 0.55) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(6.0 * x) * z) tmp = 0.0 if (z <= -9.5e+16) tmp = t_0; elseif (z <= 0.55) 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[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -9.5e+16], t$95$0, If[LessEqual[z, 0.55], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(6 \cdot x\right) \cdot z\\
\mathbf{if}\;z \leq -9.5 \cdot 10^{+16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.55:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -9.5e16 or 0.55000000000000004 < z Initial program 99.7%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval52.5
Applied rewrites52.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.5
Applied rewrites52.5%
Taylor expanded in z around inf
lift-*.f6452.0
Applied rewrites52.0%
if -9.5e16 < z < 0.55000000000000004Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6495.2
Applied rewrites95.2%
(FPCore (x y z) :precision binary64 (if (<= x -1.95e-51) (* -3.0 x) (if (<= x 4e-6) (* 4.0 y) (* -3.0 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.95e-51) {
tmp = -3.0 * x;
} else if (x <= 4e-6) {
tmp = 4.0 * y;
} else {
tmp = -3.0 * x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1.95d-51)) then
tmp = (-3.0d0) * x
else if (x <= 4d-6) then
tmp = 4.0d0 * y
else
tmp = (-3.0d0) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.95e-51) {
tmp = -3.0 * x;
} else if (x <= 4e-6) {
tmp = 4.0 * y;
} else {
tmp = -3.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.95e-51: tmp = -3.0 * x elif x <= 4e-6: tmp = 4.0 * y else: tmp = -3.0 * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.95e-51) tmp = Float64(-3.0 * x); elseif (x <= 4e-6) tmp = Float64(4.0 * y); else tmp = Float64(-3.0 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.95e-51) tmp = -3.0 * x; elseif (x <= 4e-6) tmp = 4.0 * y; else tmp = -3.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.95e-51], N[(-3.0 * x), $MachinePrecision], If[LessEqual[x, 4e-6], N[(4.0 * y), $MachinePrecision], N[(-3.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.95 \cdot 10^{-51}:\\
\;\;\;\;-3 \cdot x\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-6}:\\
\;\;\;\;4 \cdot y\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot x\\
\end{array}
\end{array}
if x < -1.9499999999999999e-51 or 3.99999999999999982e-6 < x Initial program 99.6%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval74.4
Applied rewrites74.4%
Taylor expanded in z around 0
Applied rewrites37.2%
if -1.9499999999999999e-51 < x < 3.99999999999999982e-6Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6450.3
Applied rewrites50.3%
Taylor expanded in x around 0
lower-*.f6439.1
Applied rewrites39.1%
(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.7
Applied rewrites50.7%
(FPCore (x y z) :precision binary64 (* 4.0 y))
double code(double x, double y, double z) {
return 4.0 * y;
}
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 = 4.0d0 * y
end function
public static double code(double x, double y, double z) {
return 4.0 * y;
}
def code(x, y, z): return 4.0 * y
function code(x, y, z) return Float64(4.0 * y) end
function tmp = code(x, y, z) tmp = 4.0 * y; end
code[x_, y_, z_] := N[(4.0 * y), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot y
\end{array}
Initial program 99.5%
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-*.f6426.2
Applied rewrites26.2%
herbie shell --seed 2025089
(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))))