
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
return x + (((y - x) * 6.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) * z)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
def code(x, y, z): return x + (((y - x) * 6.0) * z)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * z); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
return x + (((y - x) * 6.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) * z)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
def code(x, y, z): return x + (((y - x) * 6.0) * z)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * z); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
return x + (((y - x) * 6.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) * z)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
def code(x, y, z): return x + (((y - x) * 6.0) * z)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * z); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}
Initial program 99.7%
(FPCore (x y z) :precision binary64 (fma (* z (- y x)) 6.0 x))
double code(double x, double y, double z) {
return fma((z * (y - x)), 6.0, x);
}
function code(x, y, z) return fma(Float64(z * Float64(y - x)), 6.0, x) end
code[x_, y_, z_] := N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] * 6.0 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z \cdot \left(y - x\right), 6, x\right)
\end{array}
Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* 6.0 (* z (- y x))))) (if (<= z -0.135) t_0 (if (<= z 0.165) (+ x (* (* y 6.0) z)) t_0))))
double code(double x, double y, double z) {
double t_0 = 6.0 * (z * (y - x));
double tmp;
if (z <= -0.135) {
tmp = t_0;
} else if (z <= 0.165) {
tmp = x + ((y * 6.0) * z);
} 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 = 6.0d0 * (z * (y - x))
if (z <= (-0.135d0)) then
tmp = t_0
else if (z <= 0.165d0) then
tmp = x + ((y * 6.0d0) * z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 6.0 * (z * (y - x));
double tmp;
if (z <= -0.135) {
tmp = t_0;
} else if (z <= 0.165) {
tmp = x + ((y * 6.0) * z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 6.0 * (z * (y - x)) tmp = 0 if z <= -0.135: tmp = t_0 elif z <= 0.165: tmp = x + ((y * 6.0) * z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(6.0 * Float64(z * Float64(y - x))) tmp = 0.0 if (z <= -0.135) tmp = t_0; elseif (z <= 0.165) tmp = Float64(x + Float64(Float64(y * 6.0) * z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 6.0 * (z * (y - x)); tmp = 0.0; if (z <= -0.135) tmp = t_0; elseif (z <= 0.165) tmp = x + ((y * 6.0) * z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.135], t$95$0, If[LessEqual[z, 0.165], N[(x + N[(N[(y * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(z \cdot \left(y - x\right)\right)\\
\mathbf{if}\;z \leq -0.135:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.165:\\
\;\;\;\;x + \left(y \cdot 6\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.13500000000000001 or 0.165000000000000008 < z Initial program 99.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6441.7
Applied rewrites41.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6441.7
Applied rewrites41.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f6465.0
Applied rewrites65.0%
if -0.13500000000000001 < z < 0.165000000000000008Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites75.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* 6.0 (* z (- y x))))) (if (<= z -0.165) t_0 (if (<= z 0.165) (fma (* y z) 6.0 x) t_0))))
double code(double x, double y, double z) {
double t_0 = 6.0 * (z * (y - x));
double tmp;
if (z <= -0.165) {
tmp = t_0;
} else if (z <= 0.165) {
tmp = fma((y * z), 6.0, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(6.0 * Float64(z * Float64(y - x))) tmp = 0.0 if (z <= -0.165) tmp = t_0; elseif (z <= 0.165) tmp = fma(Float64(y * z), 6.0, x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.165], t$95$0, If[LessEqual[z, 0.165], N[(N[(y * z), $MachinePrecision] * 6.0 + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(z \cdot \left(y - x\right)\right)\\
\mathbf{if}\;z \leq -0.165:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.165:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, 6, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.165000000000000008 or 0.165000000000000008 < z Initial program 99.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6441.7
Applied rewrites41.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6441.7
Applied rewrites41.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f6465.0
Applied rewrites65.0%
if -0.165000000000000008 < z < 0.165000000000000008Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites75.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6475.9
Applied rewrites75.9%
(FPCore (x y z) :precision binary64 (if (<= y -3e+58) (fma (* z 6.0) y x) (if (<= y 7.4e-40) (fma (* -6.0 x) z x) (fma (* y z) 6.0 x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3e+58) {
tmp = fma((z * 6.0), y, x);
} else if (y <= 7.4e-40) {
tmp = fma((-6.0 * x), z, x);
} else {
tmp = fma((y * z), 6.0, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -3e+58) tmp = fma(Float64(z * 6.0), y, x); elseif (y <= 7.4e-40) tmp = fma(Float64(-6.0 * x), z, x); else tmp = fma(Float64(y * z), 6.0, x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -3e+58], N[(N[(z * 6.0), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[y, 7.4e-40], N[(N[(-6.0 * x), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(y * z), $MachinePrecision] * 6.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+58}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot 6, y, x\right)\\
\mathbf{elif}\;y \leq 7.4 \cdot 10^{-40}:\\
\;\;\;\;\mathsf{fma}\left(-6 \cdot x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, 6, x\right)\\
\end{array}
\end{array}
if y < -3.0000000000000002e58Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites75.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-fma.f6475.9
Applied rewrites75.9%
if -3.0000000000000002e58 < y < 7.39999999999999997e-40Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6462.3
Applied rewrites62.3%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6462.2
Applied rewrites62.2%
if 7.39999999999999997e-40 < y Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites75.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6475.9
Applied rewrites75.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (* z 6.0) y x))) (if (<= y -3e+58) t_0 (if (<= y 7.4e-40) (fma (* -6.0 x) z x) t_0))))
double code(double x, double y, double z) {
double t_0 = fma((z * 6.0), y, x);
double tmp;
if (y <= -3e+58) {
tmp = t_0;
} else if (y <= 7.4e-40) {
tmp = fma((-6.0 * x), z, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(z * 6.0), y, x) tmp = 0.0 if (y <= -3e+58) tmp = t_0; elseif (y <= 7.4e-40) tmp = fma(Float64(-6.0 * x), z, x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * 6.0), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[y, -3e+58], t$95$0, If[LessEqual[y, 7.4e-40], N[(N[(-6.0 * x), $MachinePrecision] * z + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(z \cdot 6, y, x\right)\\
\mathbf{if}\;y \leq -3 \cdot 10^{+58}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 7.4 \cdot 10^{-40}:\\
\;\;\;\;\mathsf{fma}\left(-6 \cdot x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.0000000000000002e58 or 7.39999999999999997e-40 < y Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites75.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-fma.f6475.9
Applied rewrites75.9%
if -3.0000000000000002e58 < y < 7.39999999999999997e-40Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6462.3
Applied rewrites62.3%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6462.2
Applied rewrites62.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* 6.0 y) z))) (if (<= y -3e+67) t_0 (if (<= y 2.75e-18) (fma (* -6.0 x) z x) t_0))))
double code(double x, double y, double z) {
double t_0 = (6.0 * y) * z;
double tmp;
if (y <= -3e+67) {
tmp = t_0;
} else if (y <= 2.75e-18) {
tmp = fma((-6.0 * x), z, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(6.0 * y) * z) tmp = 0.0 if (y <= -3e+67) tmp = t_0; elseif (y <= 2.75e-18) tmp = fma(Float64(-6.0 * x), z, x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[y, -3e+67], t$95$0, If[LessEqual[y, 2.75e-18], N[(N[(-6.0 * x), $MachinePrecision] * z + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(6 \cdot y\right) \cdot z\\
\mathbf{if}\;y \leq -3 \cdot 10^{+67}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.75 \cdot 10^{-18}:\\
\;\;\;\;\mathsf{fma}\left(-6 \cdot x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.0000000000000001e67 or 2.75e-18 < y Initial program 99.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6441.7
Applied rewrites41.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6441.7
Applied rewrites41.7%
if -3.0000000000000001e67 < y < 2.75e-18Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6462.3
Applied rewrites62.3%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6462.2
Applied rewrites62.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* 6.0 y) z)))
(if (<= z -1.65e-146)
t_0
(if (<= z 0.165) (* x 1.0) (if (<= z 6e+164) (* x (* -6.0 z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = (6.0 * y) * z;
double tmp;
if (z <= -1.65e-146) {
tmp = t_0;
} else if (z <= 0.165) {
tmp = x * 1.0;
} else if (z <= 6e+164) {
tmp = x * (-6.0 * z);
} 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 = (6.0d0 * y) * z
if (z <= (-1.65d-146)) then
tmp = t_0
else if (z <= 0.165d0) then
tmp = x * 1.0d0
else if (z <= 6d+164) then
tmp = x * ((-6.0d0) * z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (6.0 * y) * z;
double tmp;
if (z <= -1.65e-146) {
tmp = t_0;
} else if (z <= 0.165) {
tmp = x * 1.0;
} else if (z <= 6e+164) {
tmp = x * (-6.0 * z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (6.0 * y) * z tmp = 0 if z <= -1.65e-146: tmp = t_0 elif z <= 0.165: tmp = x * 1.0 elif z <= 6e+164: tmp = x * (-6.0 * z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(6.0 * y) * z) tmp = 0.0 if (z <= -1.65e-146) tmp = t_0; elseif (z <= 0.165) tmp = Float64(x * 1.0); elseif (z <= 6e+164) tmp = Float64(x * Float64(-6.0 * z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (6.0 * y) * z; tmp = 0.0; if (z <= -1.65e-146) tmp = t_0; elseif (z <= 0.165) tmp = x * 1.0; elseif (z <= 6e+164) tmp = x * (-6.0 * z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1.65e-146], t$95$0, If[LessEqual[z, 0.165], N[(x * 1.0), $MachinePrecision], If[LessEqual[z, 6e+164], N[(x * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(6 \cdot y\right) \cdot z\\
\mathbf{if}\;z \leq -1.65 \cdot 10^{-146}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.165:\\
\;\;\;\;x \cdot 1\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+164}:\\
\;\;\;\;x \cdot \left(-6 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.65e-146 or 6.00000000000000001e164 < z Initial program 99.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6441.7
Applied rewrites41.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6441.7
Applied rewrites41.7%
if -1.65e-146 < z < 0.165000000000000008Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6462.3
Applied rewrites62.3%
Taylor expanded in z around 0
Applied rewrites36.5%
if 0.165000000000000008 < z < 6.00000000000000001e164Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6462.3
Applied rewrites62.3%
Taylor expanded in z around 0
Applied rewrites36.5%
Taylor expanded in z around inf
lower-*.f6428.1
Applied rewrites28.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* 6.0 y) z))) (if (<= y -1.05e+20) t_0 (if (<= y 2.5e-19) (* x 1.0) t_0))))
double code(double x, double y, double z) {
double t_0 = (6.0 * y) * z;
double tmp;
if (y <= -1.05e+20) {
tmp = t_0;
} else if (y <= 2.5e-19) {
tmp = x * 1.0;
} 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 = (6.0d0 * y) * z
if (y <= (-1.05d+20)) then
tmp = t_0
else if (y <= 2.5d-19) then
tmp = x * 1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (6.0 * y) * z;
double tmp;
if (y <= -1.05e+20) {
tmp = t_0;
} else if (y <= 2.5e-19) {
tmp = x * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (6.0 * y) * z tmp = 0 if y <= -1.05e+20: tmp = t_0 elif y <= 2.5e-19: tmp = x * 1.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(6.0 * y) * z) tmp = 0.0 if (y <= -1.05e+20) tmp = t_0; elseif (y <= 2.5e-19) tmp = Float64(x * 1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (6.0 * y) * z; tmp = 0.0; if (y <= -1.05e+20) tmp = t_0; elseif (y <= 2.5e-19) tmp = x * 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[y, -1.05e+20], t$95$0, If[LessEqual[y, 2.5e-19], N[(x * 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(6 \cdot y\right) \cdot z\\
\mathbf{if}\;y \leq -1.05 \cdot 10^{+20}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-19}:\\
\;\;\;\;x \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.05e20 or 2.5000000000000002e-19 < y Initial program 99.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6441.7
Applied rewrites41.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6441.7
Applied rewrites41.7%
if -1.05e20 < y < 2.5000000000000002e-19Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6462.3
Applied rewrites62.3%
Taylor expanded in z around 0
Applied rewrites36.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* 6.0 (* y z)))) (if (<= y -1.05e+20) t_0 (if (<= y 2.5e-19) (* x 1.0) t_0))))
double code(double x, double y, double z) {
double t_0 = 6.0 * (y * z);
double tmp;
if (y <= -1.05e+20) {
tmp = t_0;
} else if (y <= 2.5e-19) {
tmp = x * 1.0;
} 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 = 6.0d0 * (y * z)
if (y <= (-1.05d+20)) then
tmp = t_0
else if (y <= 2.5d-19) then
tmp = x * 1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 6.0 * (y * z);
double tmp;
if (y <= -1.05e+20) {
tmp = t_0;
} else if (y <= 2.5e-19) {
tmp = x * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 6.0 * (y * z) tmp = 0 if y <= -1.05e+20: tmp = t_0 elif y <= 2.5e-19: tmp = x * 1.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(6.0 * Float64(y * z)) tmp = 0.0 if (y <= -1.05e+20) tmp = t_0; elseif (y <= 2.5e-19) tmp = Float64(x * 1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 6.0 * (y * z); tmp = 0.0; if (y <= -1.05e+20) tmp = t_0; elseif (y <= 2.5e-19) tmp = x * 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.05e+20], t$95$0, If[LessEqual[y, 2.5e-19], N[(x * 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(y \cdot z\right)\\
\mathbf{if}\;y \leq -1.05 \cdot 10^{+20}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-19}:\\
\;\;\;\;x \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.05e20 or 2.5000000000000002e-19 < y Initial program 99.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6441.7
Applied rewrites41.7%
if -1.05e20 < y < 2.5000000000000002e-19Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6462.3
Applied rewrites62.3%
Taylor expanded in z around 0
Applied rewrites36.5%
(FPCore (x y z) :precision binary64 (* x 1.0))
double code(double x, double y, double z) {
return x * 1.0;
}
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 * 1.0d0
end function
public static double code(double x, double y, double z) {
return x * 1.0;
}
def code(x, y, z): return x * 1.0
function code(x, y, z) return Float64(x * 1.0) end
function tmp = code(x, y, z) tmp = x * 1.0; end
code[x_, y_, z_] := N[(x * 1.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 1
\end{array}
Initial program 99.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6462.3
Applied rewrites62.3%
Taylor expanded in z around 0
Applied rewrites36.5%
herbie shell --seed 2025142
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
:precision binary64
(+ x (* (* (- y x) 6.0) z)))