
(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 (+ x (fma (* (- x y) z) 6.0 (* 4.0 (- y x)))))
double code(double x, double y, double z) {
return x + fma(((x - y) * z), 6.0, (4.0 * (y - x)));
}
function code(x, y, z) return Float64(x + fma(Float64(Float64(x - y) * z), 6.0, Float64(4.0 * Float64(y - x)))) end
code[x_, y_, z_] := N[(x + N[(N[(N[(x - y), $MachinePrecision] * z), $MachinePrecision] * 6.0 + N[(4.0 * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \mathsf{fma}\left(\left(x - y\right) \cdot z, 6, 4 \cdot \left(y - x\right)\right)
\end{array}
Initial program 99.5%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-/.f64N/A
*-commutativeN/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lower-+.f64N/A
metadata-eval85.2
Applied rewrites85.2%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -5e+66)
(* (* z x) 6.0)
(if (<= t_0 0.66666666)
(* (fma -6.0 z 4.0) y)
(if (<= t_0 1.0)
(fma -3.0 x (* 4.0 y))
(if (or (<= t_0 2e+55) (not (<= t_0 1e+210)))
(* (* z 6.0) x)
(* (* y z) -6.0)))))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -5e+66) {
tmp = (z * x) * 6.0;
} else if (t_0 <= 0.66666666) {
tmp = fma(-6.0, z, 4.0) * y;
} else if (t_0 <= 1.0) {
tmp = fma(-3.0, x, (4.0 * y));
} else if ((t_0 <= 2e+55) || !(t_0 <= 1e+210)) {
tmp = (z * 6.0) * x;
} else {
tmp = (y * z) * -6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -5e+66) tmp = Float64(Float64(z * x) * 6.0); elseif (t_0 <= 0.66666666) tmp = Float64(fma(-6.0, z, 4.0) * y); elseif (t_0 <= 1.0) tmp = fma(-3.0, x, Float64(4.0 * y)); elseif ((t_0 <= 2e+55) || !(t_0 <= 1e+210)) tmp = Float64(Float64(z * 6.0) * x); else tmp = Float64(Float64(y * z) * -6.0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+66], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision], If[LessEqual[t$95$0, 0.66666666], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, 2e+55], N[Not[LessEqual[t$95$0, 1e+210]], $MachinePrecision]], N[(N[(z * 6.0), $MachinePrecision] * x), $MachinePrecision], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+66}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\mathbf{elif}\;t\_0 \leq 0.66666666:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+55} \lor \neg \left(t\_0 \leq 10^{+210}\right):\\
\;\;\;\;\left(z \cdot 6\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -4.99999999999999991e66Initial program 99.8%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval60.3
Applied rewrites60.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites60.3%
if -4.99999999999999991e66 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 0.66666665999999997Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.5
Applied rewrites99.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6480.5
Applied rewrites80.5%
if 0.66666665999999997 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.5
Applied rewrites97.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6497.6
Applied rewrites97.6%
if 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 2.00000000000000002e55 or 9.99999999999999927e209 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval79.8
Applied rewrites79.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6474.2
Applied rewrites74.2%
if 2.00000000000000002e55 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 9.99999999999999927e209Initial program 99.6%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-/.f64N/A
*-commutativeN/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lower-+.f64N/A
metadata-eval67.7
Applied rewrites67.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.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 0
lower-*.f6465.8
Applied rewrites65.8%
Final simplification80.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -2.0)
(* (* z x) 6.0)
(if (<= t_0 1.0)
(fma -3.0 x (* 4.0 y))
(if (or (<= t_0 2e+55) (not (<= t_0 1e+210)))
(* (* z 6.0) x)
(* (* y z) -6.0))))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -2.0) {
tmp = (z * x) * 6.0;
} else if (t_0 <= 1.0) {
tmp = fma(-3.0, x, (4.0 * y));
} else if ((t_0 <= 2e+55) || !(t_0 <= 1e+210)) {
tmp = (z * 6.0) * x;
} else {
tmp = (y * z) * -6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -2.0) tmp = Float64(Float64(z * x) * 6.0); elseif (t_0 <= 1.0) tmp = fma(-3.0, x, Float64(4.0 * y)); elseif ((t_0 <= 2e+55) || !(t_0 <= 1e+210)) tmp = Float64(Float64(z * 6.0) * x); else tmp = Float64(Float64(y * z) * -6.0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -2.0], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, 2e+55], N[Not[LessEqual[t$95$0, 1e+210]], $MachinePrecision]], N[(N[(z * 6.0), $MachinePrecision] * x), $MachinePrecision], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -2:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+55} \lor \neg \left(t\_0 \leq 10^{+210}\right):\\
\;\;\;\;\left(z \cdot 6\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -2Initial program 99.8%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval56.6
Applied rewrites56.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6456.7
Applied rewrites56.7%
if -2 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6495.9
Applied rewrites95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6495.9
Applied rewrites95.9%
if 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 2.00000000000000002e55 or 9.99999999999999927e209 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval79.8
Applied rewrites79.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6474.2
Applied rewrites74.2%
if 2.00000000000000002e55 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 9.99999999999999927e209Initial program 99.6%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-/.f64N/A
*-commutativeN/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lower-+.f64N/A
metadata-eval67.7
Applied rewrites67.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.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 0
lower-*.f6465.8
Applied rewrites65.8%
Final simplification78.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z x) 6.0)))
(if (<= z -2.9e+211)
t_0
(if (<= z -1.9e+62)
(* (* -6.0 z) y)
(if (or (<= z -3.7) (not (<= z 0.52))) t_0 (fma 4.0 (- y x) x))))))
double code(double x, double y, double z) {
double t_0 = (z * x) * 6.0;
double tmp;
if (z <= -2.9e+211) {
tmp = t_0;
} else if (z <= -1.9e+62) {
tmp = (-6.0 * z) * y;
} else if ((z <= -3.7) || !(z <= 0.52)) {
tmp = t_0;
} else {
tmp = fma(4.0, (y - x), x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(z * x) * 6.0) tmp = 0.0 if (z <= -2.9e+211) tmp = t_0; elseif (z <= -1.9e+62) tmp = Float64(Float64(-6.0 * z) * y); elseif ((z <= -3.7) || !(z <= 0.52)) tmp = t_0; else tmp = fma(4.0, Float64(y - x), x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]}, If[LessEqual[z, -2.9e+211], t$95$0, If[LessEqual[z, -1.9e+62], N[(N[(-6.0 * z), $MachinePrecision] * y), $MachinePrecision], If[Or[LessEqual[z, -3.7], N[Not[LessEqual[z, 0.52]], $MachinePrecision]], t$95$0, N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot x\right) \cdot 6\\
\mathbf{if}\;z \leq -2.9 \cdot 10^{+211}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.9 \cdot 10^{+62}:\\
\;\;\;\;\left(-6 \cdot z\right) \cdot y\\
\mathbf{elif}\;z \leq -3.7 \lor \neg \left(z \leq 0.52\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\end{array}
\end{array}
if z < -2.9e211 or -1.89999999999999992e62 < z < -3.7000000000000002 or 0.52000000000000002 < z Initial program 99.7%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval64.7
Applied rewrites64.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6462.8
Applied rewrites62.8%
if -2.9e211 < z < -1.89999999999999992e62Initial 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 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6465.7
Applied rewrites65.7%
Taylor expanded in z around inf
lower-*.f6465.8
Applied rewrites65.8%
if -3.7000000000000002 < z < 0.52000000000000002Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6495.9
Applied rewrites95.9%
Final simplification78.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z 6.0) x)))
(if (<= z -2.9e+211)
t_0
(if (<= z -1.9e+62)
(* (* y z) -6.0)
(if (<= z -3.7)
t_0
(if (<= z 0.52) (fma 4.0 (- y x) x) (* (* z x) 6.0)))))))
double code(double x, double y, double z) {
double t_0 = (z * 6.0) * x;
double tmp;
if (z <= -2.9e+211) {
tmp = t_0;
} else if (z <= -1.9e+62) {
tmp = (y * z) * -6.0;
} else if (z <= -3.7) {
tmp = t_0;
} else if (z <= 0.52) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = (z * x) * 6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(z * 6.0) * x) tmp = 0.0 if (z <= -2.9e+211) tmp = t_0; elseif (z <= -1.9e+62) tmp = Float64(Float64(y * z) * -6.0); elseif (z <= -3.7) tmp = t_0; elseif (z <= 0.52) tmp = fma(4.0, Float64(y - x), x); else tmp = Float64(Float64(z * x) * 6.0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * 6.0), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[z, -2.9e+211], t$95$0, If[LessEqual[z, -1.9e+62], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], If[LessEqual[z, -3.7], t$95$0, If[LessEqual[z, 0.52], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot 6\right) \cdot x\\
\mathbf{if}\;z \leq -2.9 \cdot 10^{+211}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.9 \cdot 10^{+62}:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\mathbf{elif}\;z \leq -3.7:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.52:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\end{array}
\end{array}
if z < -2.9e211 or -1.89999999999999992e62 < z < -3.7000000000000002Initial program 99.7%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval79.8
Applied rewrites79.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6474.2
Applied rewrites74.2%
if -2.9e211 < z < -1.89999999999999992e62Initial program 99.6%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-/.f64N/A
*-commutativeN/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lower-+.f64N/A
metadata-eval67.7
Applied rewrites67.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.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 0
lower-*.f6465.8
Applied rewrites65.8%
if -3.7000000000000002 < z < 0.52000000000000002Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6495.9
Applied rewrites95.9%
if 0.52000000000000002 < z Initial program 99.8%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval56.6
Applied rewrites56.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6456.7
Applied rewrites56.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z 6.0) x)))
(if (<= z -2.9e+211)
t_0
(if (<= z -1.9e+62)
(* (* -6.0 z) y)
(if (<= z -3.7)
t_0
(if (<= z 0.52) (fma 4.0 (- y x) x) (* (* z x) 6.0)))))))
double code(double x, double y, double z) {
double t_0 = (z * 6.0) * x;
double tmp;
if (z <= -2.9e+211) {
tmp = t_0;
} else if (z <= -1.9e+62) {
tmp = (-6.0 * z) * y;
} else if (z <= -3.7) {
tmp = t_0;
} else if (z <= 0.52) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = (z * x) * 6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(z * 6.0) * x) tmp = 0.0 if (z <= -2.9e+211) tmp = t_0; elseif (z <= -1.9e+62) tmp = Float64(Float64(-6.0 * z) * y); elseif (z <= -3.7) tmp = t_0; elseif (z <= 0.52) tmp = fma(4.0, Float64(y - x), x); else tmp = Float64(Float64(z * x) * 6.0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * 6.0), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[z, -2.9e+211], t$95$0, If[LessEqual[z, -1.9e+62], N[(N[(-6.0 * z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, -3.7], t$95$0, If[LessEqual[z, 0.52], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot 6\right) \cdot x\\
\mathbf{if}\;z \leq -2.9 \cdot 10^{+211}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.9 \cdot 10^{+62}:\\
\;\;\;\;\left(-6 \cdot z\right) \cdot y\\
\mathbf{elif}\;z \leq -3.7:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.52:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\end{array}
\end{array}
if z < -2.9e211 or -1.89999999999999992e62 < z < -3.7000000000000002Initial program 99.7%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval79.8
Applied rewrites79.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6474.2
Applied rewrites74.2%
if -2.9e211 < z < -1.89999999999999992e62Initial 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 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6465.7
Applied rewrites65.7%
Taylor expanded in z around inf
lower-*.f6465.8
Applied rewrites65.8%
if -3.7000000000000002 < z < 0.52000000000000002Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6495.9
Applied rewrites95.9%
if 0.52000000000000002 < z Initial program 99.8%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval56.6
Applied rewrites56.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6456.7
Applied rewrites56.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.56) (not (<= z 0.53))) (* (* (- y x) z) -6.0) (fma -3.0 x (* 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.56) || !(z <= 0.53)) {
tmp = ((y - x) * z) * -6.0;
} else {
tmp = fma(-3.0, x, (4.0 * y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -0.56) || !(z <= 0.53)) tmp = Float64(Float64(Float64(y - x) * z) * -6.0); else tmp = fma(-3.0, x, Float64(4.0 * y)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.56], N[Not[LessEqual[z, 0.53]], $MachinePrecision]], N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $MachinePrecision], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.56 \lor \neg \left(z \leq 0.53\right):\\
\;\;\;\;\left(\left(y - x\right) \cdot z\right) \cdot -6\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\end{array}
\end{array}
if z < -0.56000000000000005 or 0.53000000000000003 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6497.5
Applied rewrites97.5%
if -0.56000000000000005 < z < 0.53000000000000003Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6495.9
Applied rewrites95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6495.9
Applied rewrites95.9%
Final simplification96.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.5e-81) (not (<= x 2.7e-30))) (* (- x) (fma -6.0 z 3.0)) (* (fma -6.0 z 4.0) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e-81) || !(x <= 2.7e-30)) {
tmp = -x * fma(-6.0, z, 3.0);
} else {
tmp = fma(-6.0, z, 4.0) * y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((x <= -5.5e-81) || !(x <= 2.7e-30)) tmp = Float64(Float64(-x) * fma(-6.0, z, 3.0)); else tmp = Float64(fma(-6.0, z, 4.0) * y); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.5e-81], N[Not[LessEqual[x, 2.7e-30]], $MachinePrecision]], N[((-x) * N[(-6.0 * z + 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{-81} \lor \neg \left(x \leq 2.7 \cdot 10^{-30}\right):\\
\;\;\;\;\left(-x\right) \cdot \mathsf{fma}\left(-6, z, 3\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\end{array}
\end{array}
if x < -5.50000000000000026e-81 or 2.69999999999999987e-30 < x Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.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.f6482.4
Applied rewrites82.4%
if -5.50000000000000026e-81 < x < 2.69999999999999987e-30Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6483.2
Applied rewrites83.2%
Final simplification82.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)) (* (* (- y x) z) -6.0))))
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 = ((y - x) * z) * -6.0;
}
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(Float64(Float64(y - x) * z) * -6.0); 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[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $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}:\\
\;\;\;\;\left(\left(y - x\right) \cdot z\right) \cdot -6\\
\end{array}
\end{array}
if z < -0.56000000000000005Initial program 99.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-/.f64N/A
*-commutativeN/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lower-+.f64N/A
metadata-eval76.8
Applied rewrites76.8%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift--.f6499.7
Applied rewrites99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6496.4
Applied rewrites96.4%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f6496.4
Applied rewrites96.4%
if -0.56000000000000005 < z < 0.53000000000000003Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6495.9
Applied rewrites95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6495.9
Applied rewrites95.9%
if 0.53000000000000003 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6498.6
Applied rewrites98.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.7) (not (<= z 0.52))) (* (* z x) 6.0) (fma 4.0 (- y x) x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.7) || !(z <= 0.52)) {
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 <= -3.7) || !(z <= 0.52)) 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, -3.7], N[Not[LessEqual[z, 0.52]], $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 -3.7 \lor \neg \left(z \leq 0.52\right):\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\end{array}
\end{array}
if z < -3.7000000000000002 or 0.52000000000000002 < z Initial program 99.7%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval57.9
Applied rewrites57.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6456.4
Applied rewrites56.4%
if -3.7000000000000002 < z < 0.52000000000000002Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6495.9
Applied rewrites95.9%
Final simplification74.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.9e-98) (not (<= x 2950000000.0))) (* -3.0 x) (* 4.0 y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.9e-98) || !(x <= 2950000000.0)) {
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 <= (-2.9d-98)) .or. (.not. (x <= 2950000000.0d0))) 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 <= -2.9e-98) || !(x <= 2950000000.0)) {
tmp = -3.0 * x;
} else {
tmp = 4.0 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.9e-98) or not (x <= 2950000000.0): tmp = -3.0 * x else: tmp = 4.0 * y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.9e-98) || !(x <= 2950000000.0)) 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 <= -2.9e-98) || ~((x <= 2950000000.0))) tmp = -3.0 * x; else tmp = 4.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.9e-98], N[Not[LessEqual[x, 2950000000.0]], $MachinePrecision]], N[(-3.0 * x), $MachinePrecision], N[(4.0 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{-98} \lor \neg \left(x \leq 2950000000\right):\\
\;\;\;\;-3 \cdot x\\
\mathbf{else}:\\
\;\;\;\;4 \cdot y\\
\end{array}
\end{array}
if x < -2.9e-98 or 2.95e9 < x Initial program 99.5%
Taylor expanded in x around inf
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
metadata-eval83.2
Applied rewrites83.2%
Taylor expanded in z around 0
Applied rewrites36.4%
if -2.9e-98 < x < 2.95e9Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6449.2
Applied rewrites49.2%
Taylor expanded in x around 0
lower-*.f6440.3
Applied rewrites40.3%
Final simplification38.0%
(FPCore (x y z) :precision binary64 (fma (- y x) (fma -6.0 z 4.0) x))
double code(double x, double y, double z) {
return fma((y - x), fma(-6.0, z, 4.0), x);
}
function code(x, y, z) return fma(Float64(y - x), fma(-6.0, z, 4.0), x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(-6.0 * z + 4.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, \mathsf{fma}\left(-6, z, 4\right), x\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
(FPCore (x y z) :precision binary64 (fma 4.0 (- y x) x))
double code(double x, double y, double z) {
return fma(4.0, (y - x), x);
}
function code(x, y, z) return fma(4.0, Float64(y - x), x) end
code[x_, y_, z_] := N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, y - x, x\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6446.5
Applied rewrites46.5%
(FPCore (x y z) :precision binary64 (* 4.0 y))
double code(double x, double y, double z) {
return 4.0 * y;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 4.0d0 * y
end function
public static double code(double x, double y, double z) {
return 4.0 * y;
}
def code(x, y, z): return 4.0 * y
function code(x, y, z) return Float64(4.0 * y) end
function tmp = code(x, y, z) tmp = 4.0 * y; end
code[x_, y_, z_] := N[(4.0 * y), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot y
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6446.5
Applied rewrites46.5%
Taylor expanded in x around 0
lower-*.f6422.2
Applied rewrites22.2%
herbie shell --seed 2025057
(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))))