
(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}
Sampling outcomes in binary64 precision:
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.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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (fma -6.0 z 4.0) y)))
(if (<= z -4.2e+191)
(* (- x) (* -6.0 z))
(if (<= z -1.1e-11)
t_0
(if (<= z 5.4e-7)
(fma -3.0 x (* 4.0 y))
(if (<= z 9e+120) 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 <= -4.2e+191) {
tmp = -x * (-6.0 * z);
} else if (z <= -1.1e-11) {
tmp = t_0;
} else if (z <= 5.4e-7) {
tmp = fma(-3.0, x, (4.0 * y));
} else if (z <= 9e+120) {
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 <= -4.2e+191) tmp = Float64(Float64(-x) * Float64(-6.0 * z)); elseif (z <= -1.1e-11) tmp = t_0; elseif (z <= 5.4e-7) tmp = fma(-3.0, x, Float64(4.0 * y)); elseif (z <= 9e+120) 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, -4.2e+191], N[((-x) * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1.1e-11], t$95$0, If[LessEqual[z, 5.4e-7], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9e+120], 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 -4.2 \cdot 10^{+191}:\\
\;\;\;\;\left(-x\right) \cdot \left(-6 \cdot z\right)\\
\mathbf{elif}\;z \leq -1.1 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 5.4 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+120}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if z < -4.2000000000000001e191Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6472.8
Applied rewrites72.8%
if -4.2000000000000001e191 < z < -1.1000000000000001e-11 or 5.40000000000000018e-7 < z < 8.99999999999999953e120Initial 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.f6458.2
Applied rewrites58.2%
if -1.1000000000000001e-11 < z < 5.40000000000000018e-7Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.4
Applied rewrites99.4%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
if 8.99999999999999953e120 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f6467.7
Applied rewrites67.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* 6.0 x) z)) (t_1 (* (fma -6.0 z 4.0) y)))
(if (<= z -4.2e+191)
t_0
(if (<= z -1.1e-11)
t_1
(if (<= z 5.4e-7) (fma -3.0 x (* 4.0 y)) (if (<= z 9e+120) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = (6.0 * x) * z;
double t_1 = fma(-6.0, z, 4.0) * y;
double tmp;
if (z <= -4.2e+191) {
tmp = t_0;
} else if (z <= -1.1e-11) {
tmp = t_1;
} else if (z <= 5.4e-7) {
tmp = fma(-3.0, x, (4.0 * y));
} else if (z <= 9e+120) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(6.0 * x) * z) t_1 = Float64(fma(-6.0, z, 4.0) * y) tmp = 0.0 if (z <= -4.2e+191) tmp = t_0; elseif (z <= -1.1e-11) tmp = t_1; elseif (z <= 5.4e-7) tmp = fma(-3.0, x, Float64(4.0 * y)); elseif (z <= 9e+120) tmp = t_1; else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[z, -4.2e+191], t$95$0, If[LessEqual[z, -1.1e-11], t$95$1, If[LessEqual[z, 5.4e-7], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9e+120], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(6 \cdot x\right) \cdot z\\
t_1 := \mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+191}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.1 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5.4 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+120}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.2000000000000001e191 or 8.99999999999999953e120 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f6468.3
Applied rewrites68.3%
if -4.2000000000000001e191 < z < -1.1000000000000001e-11 or 5.40000000000000018e-7 < z < 8.99999999999999953e120Initial 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.f6458.2
Applied rewrites58.2%
if -1.1000000000000001e-11 < z < 5.40000000000000018e-7Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.4
Applied rewrites99.4%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* 6.0 x) z)))
(if (<= z -4.2e+191)
t_0
(if (<= z -2100000.0)
(* (* -6.0 y) z)
(if (<= z 0.68)
(fma -3.0 x (* 4.0 y))
(if (<= z 9e+120) (* (* y z) -6.0) t_0))))))
double code(double x, double y, double z) {
double t_0 = (6.0 * x) * z;
double tmp;
if (z <= -4.2e+191) {
tmp = t_0;
} else if (z <= -2100000.0) {
tmp = (-6.0 * y) * z;
} else if (z <= 0.68) {
tmp = fma(-3.0, x, (4.0 * y));
} else if (z <= 9e+120) {
tmp = (y * z) * -6.0;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(6.0 * x) * z) tmp = 0.0 if (z <= -4.2e+191) tmp = t_0; elseif (z <= -2100000.0) tmp = Float64(Float64(-6.0 * y) * z); elseif (z <= 0.68) tmp = fma(-3.0, x, Float64(4.0 * y)); elseif (z <= 9e+120) tmp = Float64(Float64(y * z) * -6.0); 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, -4.2e+191], t$95$0, If[LessEqual[z, -2100000.0], N[(N[(-6.0 * y), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 0.68], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9e+120], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(6 \cdot x\right) \cdot z\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+191}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2100000:\\
\;\;\;\;\left(-6 \cdot y\right) \cdot z\\
\mathbf{elif}\;z \leq 0.68:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+120}:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.2000000000000001e191 or 8.99999999999999953e120 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f6468.3
Applied rewrites68.3%
if -4.2000000000000001e191 < z < -2.1e6Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.9
Applied rewrites99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lift--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
lower-*.f6461.3
Applied rewrites61.3%
if -2.1e6 < z < 0.680000000000000049Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.2
Applied rewrites97.2%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6497.3
Applied rewrites97.3%
if 0.680000000000000049 < z < 8.99999999999999953e120Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6494.1
Applied rewrites94.1%
Taylor expanded in x around 0
Applied rewrites54.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* 6.0 x) z)))
(if (<= z -4.2e+191)
t_0
(if (<= z -2100000.0)
(* (* -6.0 y) z)
(if (<= z 0.68)
(fma 4.0 (- y x) x)
(if (<= z 9e+120) (* (* y z) -6.0) t_0))))))
double code(double x, double y, double z) {
double t_0 = (6.0 * x) * z;
double tmp;
if (z <= -4.2e+191) {
tmp = t_0;
} else if (z <= -2100000.0) {
tmp = (-6.0 * y) * z;
} else if (z <= 0.68) {
tmp = fma(4.0, (y - x), x);
} else if (z <= 9e+120) {
tmp = (y * z) * -6.0;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(6.0 * x) * z) tmp = 0.0 if (z <= -4.2e+191) tmp = t_0; elseif (z <= -2100000.0) tmp = Float64(Float64(-6.0 * y) * z); elseif (z <= 0.68) tmp = fma(4.0, Float64(y - x), x); elseif (z <= 9e+120) tmp = Float64(Float64(y * z) * -6.0); 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, -4.2e+191], t$95$0, If[LessEqual[z, -2100000.0], N[(N[(-6.0 * y), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 0.68], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 9e+120], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(6 \cdot x\right) \cdot z\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+191}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2100000:\\
\;\;\;\;\left(-6 \cdot y\right) \cdot z\\
\mathbf{elif}\;z \leq 0.68:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+120}:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.2000000000000001e191 or 8.99999999999999953e120 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f6468.3
Applied rewrites68.3%
if -4.2000000000000001e191 < z < -2.1e6Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.9
Applied rewrites99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lift--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
lower-*.f6461.3
Applied rewrites61.3%
if -2.1e6 < z < 0.680000000000000049Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.2
Applied rewrites97.2%
if 0.680000000000000049 < z < 8.99999999999999953e120Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6494.1
Applied rewrites94.1%
Taylor expanded in x around 0
Applied rewrites54.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* 6.0 x) z)) (t_1 (* (* -6.0 y) z)))
(if (<= z -4.2e+191)
t_0
(if (<= z -2100000.0)
t_1
(if (<= z 0.68) (fma 4.0 (- y x) x) (if (<= z 9e+120) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = (6.0 * x) * z;
double t_1 = (-6.0 * y) * z;
double tmp;
if (z <= -4.2e+191) {
tmp = t_0;
} else if (z <= -2100000.0) {
tmp = t_1;
} else if (z <= 0.68) {
tmp = fma(4.0, (y - x), x);
} else if (z <= 9e+120) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(6.0 * x) * z) t_1 = Float64(Float64(-6.0 * y) * z) tmp = 0.0 if (z <= -4.2e+191) tmp = t_0; elseif (z <= -2100000.0) tmp = t_1; elseif (z <= 0.68) tmp = fma(4.0, Float64(y - x), x); elseif (z <= 9e+120) tmp = t_1; else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-6.0 * y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -4.2e+191], t$95$0, If[LessEqual[z, -2100000.0], t$95$1, If[LessEqual[z, 0.68], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 9e+120], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(6 \cdot x\right) \cdot z\\
t_1 := \left(-6 \cdot y\right) \cdot z\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+191}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2100000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 0.68:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+120}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.2000000000000001e191 or 8.99999999999999953e120 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f6468.3
Applied rewrites68.3%
if -4.2000000000000001e191 < z < -2.1e6 or 0.680000000000000049 < z < 8.99999999999999953e120Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lift--.f6497.5
Applied rewrites97.5%
Taylor expanded in x around 0
lower-*.f6458.6
Applied rewrites58.6%
if -2.1e6 < z < 0.680000000000000049Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.2
Applied rewrites97.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z x) 6.0)) (t_1 (* (* -6.0 y) z)))
(if (<= z -4.2e+191)
t_0
(if (<= z -2100000.0)
t_1
(if (<= z 0.68) (fma 4.0 (- y x) x) (if (<= z 9e+120) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = (z * x) * 6.0;
double t_1 = (-6.0 * y) * z;
double tmp;
if (z <= -4.2e+191) {
tmp = t_0;
} else if (z <= -2100000.0) {
tmp = t_1;
} else if (z <= 0.68) {
tmp = fma(4.0, (y - x), x);
} else if (z <= 9e+120) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(z * x) * 6.0) t_1 = Float64(Float64(-6.0 * y) * z) tmp = 0.0 if (z <= -4.2e+191) tmp = t_0; elseif (z <= -2100000.0) tmp = t_1; elseif (z <= 0.68) tmp = fma(4.0, Float64(y - x), x); elseif (z <= 9e+120) tmp = t_1; else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-6.0 * y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -4.2e+191], t$95$0, If[LessEqual[z, -2100000.0], t$95$1, If[LessEqual[z, 0.68], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 9e+120], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot x\right) \cdot 6\\
t_1 := \left(-6 \cdot y\right) \cdot z\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+191}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2100000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 0.68:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+120}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.2000000000000001e191 or 8.99999999999999953e120 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6468.1
Applied rewrites68.1%
if -4.2000000000000001e191 < z < -2.1e6 or 0.680000000000000049 < z < 8.99999999999999953e120Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lift--.f6497.5
Applied rewrites97.5%
Taylor expanded in x around 0
lower-*.f6458.6
Applied rewrites58.6%
if -2.1e6 < z < 0.680000000000000049Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.2
Applied rewrites97.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.52) (not (<= z 0.68))) (* (* -6.0 (- y x)) z) (fma -3.0 x (* 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.52) || !(z <= 0.68)) {
tmp = (-6.0 * (y - x)) * z;
} else {
tmp = fma(-3.0, x, (4.0 * y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -0.52) || !(z <= 0.68)) tmp = Float64(Float64(-6.0 * Float64(y - x)) * z); else tmp = fma(-3.0, x, Float64(4.0 * y)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.52], N[Not[LessEqual[z, 0.68]], $MachinePrecision]], N[(N[(-6.0 * N[(y - x), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.52 \lor \neg \left(z \leq 0.68\right):\\
\;\;\;\;\left(-6 \cdot \left(y - x\right)\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\end{array}
\end{array}
if z < -0.52000000000000002 or 0.680000000000000049 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
lower-*.f64N/A
lift--.f6497.8
Applied rewrites97.8%
if -0.52000000000000002 < z < 0.680000000000000049Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6498.7
Applied rewrites98.7%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6498.8
Applied rewrites98.8%
Final simplification98.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -106000000.0) (not (<= y 2.5e-41))) (* (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 ((y <= -106000000.0) || !(y <= 2.5e-41)) {
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 ((y <= -106000000.0) || !(y <= 2.5e-41)) 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[Or[LessEqual[y, -106000000.0], N[Not[LessEqual[y, 2.5e-41]], $MachinePrecision]], 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}\;y \leq -106000000 \lor \neg \left(y \leq 2.5 \cdot 10^{-41}\right):\\
\;\;\;\;\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 y < -1.06e8 or 2.4999999999999998e-41 < y 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.9
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6478.1
Applied rewrites78.1%
if -1.06e8 < y < 2.4999999999999998e-41Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
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.f6485.0
Applied rewrites85.0%
Final simplification81.4%
(FPCore (x y z) :precision binary64 (if (<= z -0.52) (* (* -6.0 (- y x)) z) (if (<= z 0.68) (fma -3.0 x (* 4.0 y)) (* (* (- y x) z) -6.0))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.52) {
tmp = (-6.0 * (y - x)) * z;
} else if (z <= 0.68) {
tmp = fma(-3.0, x, (4.0 * y));
} else {
tmp = ((y - x) * z) * -6.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -0.52) tmp = Float64(Float64(-6.0 * Float64(y - x)) * z); elseif (z <= 0.68) tmp = fma(-3.0, x, Float64(4.0 * y)); else tmp = Float64(Float64(Float64(y - x) * z) * -6.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -0.52], N[(N[(-6.0 * N[(y - x), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 0.68], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.52:\\
\;\;\;\;\left(-6 \cdot \left(y - x\right)\right) \cdot z\\
\mathbf{elif}\;z \leq 0.68:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y - x\right) \cdot z\right) \cdot -6\\
\end{array}
\end{array}
if z < -0.52000000000000002Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6499.9
Applied rewrites99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lift--.f6498.5
Applied rewrites98.5%
if -0.52000000000000002 < z < 0.680000000000000049Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6498.7
Applied rewrites98.7%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6498.8
Applied rewrites98.8%
if 0.680000000000000049 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6497.0
Applied rewrites97.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -9.2) (not (<= z 0.68))) (* (* z x) 6.0) (fma 4.0 (- y x) x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9.2) || !(z <= 0.68)) {
tmp = (z * x) * 6.0;
} else {
tmp = fma(4.0, (y - x), x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -9.2) || !(z <= 0.68)) tmp = Float64(Float64(z * x) * 6.0); else tmp = fma(4.0, Float64(y - x), x); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -9.2], N[Not[LessEqual[z, 0.68]], $MachinePrecision]], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.2 \lor \neg \left(z \leq 0.68\right):\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\end{array}
\end{array}
if z < -9.1999999999999993 or 0.680000000000000049 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6497.7
Applied rewrites97.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6453.0
Applied rewrites53.0%
if -9.1999999999999993 < z < 0.680000000000000049Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6498.7
Applied rewrites98.7%
Final simplification73.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.05e+122) (not (<= x 1.65e+17))) (* -3.0 x) (* 4.0 y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.05e+122) || !(x <= 1.65e+17)) {
tmp = -3.0 * x;
} else {
tmp = 4.0 * y;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1.05d+122)) .or. (.not. (x <= 1.65d+17))) then
tmp = (-3.0d0) * x
else
tmp = 4.0d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.05e+122) || !(x <= 1.65e+17)) {
tmp = -3.0 * x;
} else {
tmp = 4.0 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.05e+122) or not (x <= 1.65e+17): tmp = -3.0 * x else: tmp = 4.0 * y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.05e+122) || !(x <= 1.65e+17)) tmp = Float64(-3.0 * x); else tmp = Float64(4.0 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.05e+122) || ~((x <= 1.65e+17))) tmp = -3.0 * x; else tmp = 4.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.05e+122], N[Not[LessEqual[x, 1.65e+17]], $MachinePrecision]], N[(-3.0 * x), $MachinePrecision], N[(4.0 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+122} \lor \neg \left(x \leq 1.65 \cdot 10^{+17}\right):\\
\;\;\;\;-3 \cdot x\\
\mathbf{else}:\\
\;\;\;\;4 \cdot y\\
\end{array}
\end{array}
if x < -1.05000000000000008e122 or 1.65e17 < x Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6447.4
Applied rewrites47.4%
Taylor expanded in x around inf
lower-*.f6441.1
Applied rewrites41.1%
if -1.05000000000000008e122 < x < 1.65e17Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6446.9
Applied rewrites46.9%
Taylor expanded in x around 0
lower-*.f6435.8
Applied rewrites35.8%
Final simplification38.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.6%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6447.1
Applied rewrites47.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.6%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6447.1
Applied rewrites47.1%
Taylor expanded in x around inf
lower-*.f6425.3
Applied rewrites25.3%
herbie shell --seed 2025085
(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))))