
(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 11 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.8
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (if (<= z -0.56) (* (- y x) (* -6.0 z)) (if (<= z 0.53) (fma -3.0 x (* 4.0 y)) (+ x (* (* (- y x) 6.0) (- z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.56) {
tmp = (y - x) * (-6.0 * z);
} else if (z <= 0.53) {
tmp = fma(-3.0, x, (4.0 * y));
} else {
tmp = x + (((y - x) * 6.0) * -z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -0.56) tmp = Float64(Float64(y - x) * Float64(-6.0 * z)); elseif (z <= 0.53) tmp = fma(-3.0, x, Float64(4.0 * y)); else tmp = Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(-z))); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -0.56], N[(N[(y - x), $MachinePrecision] * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.53], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * (-z)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.56:\\
\;\;\;\;\left(y - x\right) \cdot \left(-6 \cdot z\right)\\
\mathbf{elif}\;z \leq 0.53:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < -0.56000000000000005Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6449.6
Applied rewrites49.6%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f6449.6
Applied rewrites49.6%
if -0.56000000000000005 < z < 0.53000000000000003Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6451.7
Applied rewrites51.7%
if 0.53000000000000003 < z Initial program 99.5%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6449.1
Applied rewrites49.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- y x) (* -6.0 z)))) (if (<= z -0.56) t_0 (if (<= z 0.53) (fma -3.0 x (* 4.0 y)) t_0))))
double code(double x, double y, double z) {
double t_0 = (y - x) * (-6.0 * z);
double tmp;
if (z <= -0.56) {
tmp = t_0;
} else if (z <= 0.53) {
tmp = fma(-3.0, x, (4.0 * y));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(y - x) * Float64(-6.0 * z)) tmp = 0.0 if (z <= -0.56) tmp = t_0; elseif (z <= 0.53) 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[(y - x), $MachinePrecision] * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.56], t$95$0, If[LessEqual[z, 0.53], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - x\right) \cdot \left(-6 \cdot z\right)\\
\mathbf{if}\;z \leq -0.56:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.53:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.56000000000000005 or 0.53000000000000003 < z Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6449.6
Applied rewrites49.6%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f6449.6
Applied rewrites49.6%
if -0.56000000000000005 < z < 0.53000000000000003Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6451.7
Applied rewrites51.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* (- y x) z) -6.0))) (if (<= z -0.56) t_0 (if (<= z 0.53) (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.56) {
tmp = t_0;
} else if (z <= 0.53) {
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.56) tmp = t_0; elseif (z <= 0.53) 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.56], t$95$0, If[LessEqual[z, 0.53], 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.56:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.53:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.56000000000000005 or 0.53000000000000003 < z Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6449.6
Applied rewrites49.6%
if -0.56000000000000005 < z < 0.53000000000000003Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6451.7
Applied rewrites51.7%
(FPCore (x y z) :precision binary64 (if (<= z -2.8) (* (fma -6.0 z 4.0) y) (if (<= z 0.5) (fma -3.0 x (* 4.0 y)) (* (* z x) 6.0))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.8) {
tmp = fma(-6.0, z, 4.0) * y;
} else if (z <= 0.5) {
tmp = fma(-3.0, x, (4.0 * y));
} else {
tmp = (z * x) * 6.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -2.8) tmp = Float64(fma(-6.0, z, 4.0) * y); elseif (z <= 0.5) tmp = fma(-3.0, x, Float64(4.0 * y)); else tmp = Float64(Float64(z * x) * 6.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -2.8], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, 0.5], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\end{array}
\end{array}
if z < -2.7999999999999998Initial 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 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6450.3
Applied rewrites50.3%
if -2.7999999999999998 < z < 0.5Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6451.7
Applied rewrites51.7%
if 0.5 < z Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6449.6
Applied rewrites49.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
(FPCore (x y z) :precision binary64 (if (<= z -7800000.0) (* y (* -6.0 z)) (if (<= z 0.5) (fma -3.0 x (* 4.0 y)) (* (* z x) 6.0))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7800000.0) {
tmp = y * (-6.0 * z);
} else if (z <= 0.5) {
tmp = fma(-3.0, x, (4.0 * y));
} else {
tmp = (z * x) * 6.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -7800000.0) tmp = Float64(y * Float64(-6.0 * z)); elseif (z <= 0.5) tmp = fma(-3.0, x, Float64(4.0 * y)); else tmp = Float64(Float64(z * x) * 6.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -7800000.0], N[(y * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.5], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7800000:\\
\;\;\;\;y \cdot \left(-6 \cdot z\right)\\
\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\end{array}
\end{array}
if z < -7.8e6Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6449.6
Applied rewrites49.6%
Taylor expanded in x around 0
Applied rewrites26.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6426.4
Applied rewrites26.4%
if -7.8e6 < z < 0.5Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6451.7
Applied rewrites51.7%
if 0.5 < z Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6449.6
Applied rewrites49.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
(FPCore (x y z) :precision binary64 (if (<= z -7800000.0) (* y (* -6.0 z)) (if (<= z 0.5) (fma 4.0 (- y x) x) (* (* z x) 6.0))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7800000.0) {
tmp = y * (-6.0 * z);
} else if (z <= 0.5) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = (z * x) * 6.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -7800000.0) tmp = Float64(y * Float64(-6.0 * z)); elseif (z <= 0.5) tmp = fma(4.0, Float64(y - x), x); else tmp = Float64(Float64(z * x) * 6.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -7800000.0], N[(y * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.5], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7800000:\\
\;\;\;\;y \cdot \left(-6 \cdot z\right)\\
\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\end{array}
\end{array}
if z < -7.8e6Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6449.6
Applied rewrites49.6%
Taylor expanded in x around 0
Applied rewrites26.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6426.4
Applied rewrites26.4%
if -7.8e6 < z < 0.5Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.7
Applied rewrites51.7%
if 0.5 < z Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6449.6
Applied rewrites49.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
(FPCore (x y z)
:precision binary64
(if (<= z -2.8)
(* y (* -6.0 z))
(if (<= z 7e-301)
(* 4.0 y)
(if (<= z 2.5e-69)
(* -3.0 x)
(if (<= z 0.53) (* 4.0 y) (* (* z x) 6.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.8) {
tmp = y * (-6.0 * z);
} else if (z <= 7e-301) {
tmp = 4.0 * y;
} else if (z <= 2.5e-69) {
tmp = -3.0 * x;
} else if (z <= 0.53) {
tmp = 4.0 * y;
} else {
tmp = (z * x) * 6.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) :: tmp
if (z <= (-2.8d0)) then
tmp = y * ((-6.0d0) * z)
else if (z <= 7d-301) then
tmp = 4.0d0 * y
else if (z <= 2.5d-69) then
tmp = (-3.0d0) * x
else if (z <= 0.53d0) then
tmp = 4.0d0 * y
else
tmp = (z * x) * 6.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.8) {
tmp = y * (-6.0 * z);
} else if (z <= 7e-301) {
tmp = 4.0 * y;
} else if (z <= 2.5e-69) {
tmp = -3.0 * x;
} else if (z <= 0.53) {
tmp = 4.0 * y;
} else {
tmp = (z * x) * 6.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.8: tmp = y * (-6.0 * z) elif z <= 7e-301: tmp = 4.0 * y elif z <= 2.5e-69: tmp = -3.0 * x elif z <= 0.53: tmp = 4.0 * y else: tmp = (z * x) * 6.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.8) tmp = Float64(y * Float64(-6.0 * z)); elseif (z <= 7e-301) tmp = Float64(4.0 * y); elseif (z <= 2.5e-69) tmp = Float64(-3.0 * x); elseif (z <= 0.53) tmp = Float64(4.0 * y); else tmp = Float64(Float64(z * x) * 6.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.8) tmp = y * (-6.0 * z); elseif (z <= 7e-301) tmp = 4.0 * y; elseif (z <= 2.5e-69) tmp = -3.0 * x; elseif (z <= 0.53) tmp = 4.0 * y; else tmp = (z * x) * 6.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.8], N[(y * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7e-301], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 2.5e-69], N[(-3.0 * x), $MachinePrecision], If[LessEqual[z, 0.53], N[(4.0 * y), $MachinePrecision], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8:\\
\;\;\;\;y \cdot \left(-6 \cdot z\right)\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-301}:\\
\;\;\;\;4 \cdot y\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-69}:\\
\;\;\;\;-3 \cdot x\\
\mathbf{elif}\;z \leq 0.53:\\
\;\;\;\;4 \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\end{array}
\end{array}
if z < -2.7999999999999998Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6449.6
Applied rewrites49.6%
Taylor expanded in x around 0
Applied rewrites26.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6426.4
Applied rewrites26.4%
if -2.7999999999999998 < z < 6.99999999999999984e-301 or 2.50000000000000017e-69 < z < 0.53000000000000003Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around 0
lower-*.f6426.1
Applied rewrites26.1%
if 6.99999999999999984e-301 < z < 2.50000000000000017e-69Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around inf
lower-*.f6427.3
Applied rewrites27.3%
if 0.53000000000000003 < z Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6449.6
Applied rewrites49.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z x) 6.0)))
(if (<= z -1.25e-8)
t_0
(if (<= z 7e-301)
(* 4.0 y)
(if (<= z 2.5e-69) (* -3.0 x) (if (<= z 0.53) (* 4.0 y) t_0))))))
double code(double x, double y, double z) {
double t_0 = (z * x) * 6.0;
double tmp;
if (z <= -1.25e-8) {
tmp = t_0;
} else if (z <= 7e-301) {
tmp = 4.0 * y;
} else if (z <= 2.5e-69) {
tmp = -3.0 * x;
} else if (z <= 0.53) {
tmp = 4.0 * y;
} 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) :: tmp
t_0 = (z * x) * 6.0d0
if (z <= (-1.25d-8)) then
tmp = t_0
else if (z <= 7d-301) then
tmp = 4.0d0 * y
else if (z <= 2.5d-69) then
tmp = (-3.0d0) * x
else if (z <= 0.53d0) then
tmp = 4.0d0 * y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z * x) * 6.0;
double tmp;
if (z <= -1.25e-8) {
tmp = t_0;
} else if (z <= 7e-301) {
tmp = 4.0 * y;
} else if (z <= 2.5e-69) {
tmp = -3.0 * x;
} else if (z <= 0.53) {
tmp = 4.0 * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (z * x) * 6.0 tmp = 0 if z <= -1.25e-8: tmp = t_0 elif z <= 7e-301: tmp = 4.0 * y elif z <= 2.5e-69: tmp = -3.0 * x elif z <= 0.53: tmp = 4.0 * y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(z * x) * 6.0) tmp = 0.0 if (z <= -1.25e-8) tmp = t_0; elseif (z <= 7e-301) tmp = Float64(4.0 * y); elseif (z <= 2.5e-69) tmp = Float64(-3.0 * x); elseif (z <= 0.53) tmp = Float64(4.0 * y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * x) * 6.0; tmp = 0.0; if (z <= -1.25e-8) tmp = t_0; elseif (z <= 7e-301) tmp = 4.0 * y; elseif (z <= 2.5e-69) tmp = -3.0 * x; elseif (z <= 0.53) tmp = 4.0 * y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]}, If[LessEqual[z, -1.25e-8], t$95$0, If[LessEqual[z, 7e-301], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 2.5e-69], N[(-3.0 * x), $MachinePrecision], If[LessEqual[z, 0.53], N[(4.0 * y), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot x\right) \cdot 6\\
\mathbf{if}\;z \leq -1.25 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-301}:\\
\;\;\;\;4 \cdot y\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-69}:\\
\;\;\;\;-3 \cdot x\\
\mathbf{elif}\;z \leq 0.53:\\
\;\;\;\;4 \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.2499999999999999e-8 or 0.53000000000000003 < z Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6449.6
Applied rewrites49.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
if -1.2499999999999999e-8 < z < 6.99999999999999984e-301 or 2.50000000000000017e-69 < z < 0.53000000000000003Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around 0
lower-*.f6426.1
Applied rewrites26.1%
if 6.99999999999999984e-301 < z < 2.50000000000000017e-69Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around inf
lower-*.f6427.3
Applied rewrites27.3%
(FPCore (x y z) :precision binary64 (if (<= x -1.65e+71) (* -3.0 x) (if (<= x 7.6e-178) (* 4.0 y) (* -3.0 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.65e+71) {
tmp = -3.0 * x;
} else if (x <= 7.6e-178) {
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.65d+71)) then
tmp = (-3.0d0) * x
else if (x <= 7.6d-178) 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.65e+71) {
tmp = -3.0 * x;
} else if (x <= 7.6e-178) {
tmp = 4.0 * y;
} else {
tmp = -3.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.65e+71: tmp = -3.0 * x elif x <= 7.6e-178: tmp = 4.0 * y else: tmp = -3.0 * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.65e+71) tmp = Float64(-3.0 * x); elseif (x <= 7.6e-178) 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.65e+71) tmp = -3.0 * x; elseif (x <= 7.6e-178) tmp = 4.0 * y; else tmp = -3.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.65e+71], N[(-3.0 * x), $MachinePrecision], If[LessEqual[x, 7.6e-178], N[(4.0 * y), $MachinePrecision], N[(-3.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.65 \cdot 10^{+71}:\\
\;\;\;\;-3 \cdot x\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{-178}:\\
\;\;\;\;4 \cdot y\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot x\\
\end{array}
\end{array}
if x < -1.6499999999999999e71 or 7.60000000000000029e-178 < x Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around inf
lower-*.f6427.3
Applied rewrites27.3%
if -1.6499999999999999e71 < x < 7.60000000000000029e-178Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around 0
lower-*.f6426.1
Applied rewrites26.1%
(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--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around inf
lower-*.f6427.3
Applied rewrites27.3%
herbie shell --seed 2025139
(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))))