
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
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, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b): return ((x + (y * z)) + (t * a)) + ((a * z) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
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, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b): return ((x + (y * z)) + (t * a)) + ((a * z) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (if (<= a -2e+158) (fma (fma b z t) a x) (fma z (fma b a y) (fma a t x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -2e+158) {
tmp = fma(fma(b, z, t), a, x);
} else {
tmp = fma(z, fma(b, a, y), fma(a, t, x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -2e+158) tmp = fma(fma(b, z, t), a, x); else tmp = fma(z, fma(b, a, y), fma(a, t, x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -2e+158], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision], N[(z * N[(b * a + y), $MachinePrecision] + N[(a * t + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2 \cdot 10^{+158}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \mathsf{fma}\left(b, a, y\right), \mathsf{fma}\left(a, t, x\right)\right)\\
\end{array}
\end{array}
if a < -1.99999999999999991e158Initial program 92.1%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.0
Applied rewrites74.0%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.7
Applied rewrites74.7%
if -1.99999999999999991e158 < a Initial program 92.1%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6494.7
Applied rewrites94.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (fma b z t) a x))) (if (<= a -245.0) t_1 (if (<= a 1.6e-20) (fma (fma a b y) z x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(fma(b, z, t), a, x);
double tmp;
if (a <= -245.0) {
tmp = t_1;
} else if (a <= 1.6e-20) {
tmp = fma(fma(a, b, y), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(fma(b, z, t), a, x) tmp = 0.0 if (a <= -245.0) tmp = t_1; elseif (a <= 1.6e-20) tmp = fma(fma(a, b, y), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[a, -245.0], t$95$1, If[LessEqual[a, 1.6e-20], N[(N[(a * b + y), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{if}\;a \leq -245:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -245 or 1.59999999999999985e-20 < a Initial program 92.1%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.0
Applied rewrites74.0%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.7
Applied rewrites74.7%
if -245 < a < 1.59999999999999985e-20Initial program 92.1%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-inN/A
lift-fma.f64N/A
*-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-fma.f6473.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6473.8
Applied rewrites73.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (fma a b y) z x))) (if (<= z -2.2e-48) t_1 (if (<= z 4.2e-25) (fma z y (fma a t x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(fma(a, b, y), z, x);
double tmp;
if (z <= -2.2e-48) {
tmp = t_1;
} else if (z <= 4.2e-25) {
tmp = fma(z, y, fma(a, t, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(fma(a, b, y), z, x) tmp = 0.0 if (z <= -2.2e-48) tmp = t_1; elseif (z <= 4.2e-25) tmp = fma(z, y, fma(a, t, x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b + y), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[z, -2.2e-48], t$95$1, If[LessEqual[z, 4.2e-25], N[(z * y + N[(a * t + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, x\right)\\
\mathbf{if}\;z \leq -2.2 \cdot 10^{-48}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{-25}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(a, t, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.20000000000000013e-48 or 4.20000000000000005e-25 < z Initial program 92.1%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-inN/A
lift-fma.f64N/A
*-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-fma.f6473.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6473.8
Applied rewrites73.8%
if -2.20000000000000013e-48 < z < 4.20000000000000005e-25Initial program 92.1%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-inN/A
lift-fma.f64N/A
*-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-fma.f6473.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6473.8
Applied rewrites73.8%
Taylor expanded in b around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f6477.8
Applied rewrites77.8%
lift-+.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+r+N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6477.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6477.9
Applied rewrites77.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (* a b) z x))) (if (<= b -1.05e+101) t_1 (if (<= b 3.6e+113) (fma z y (fma a t x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((a * b), z, x);
double tmp;
if (b <= -1.05e+101) {
tmp = t_1;
} else if (b <= 3.6e+113) {
tmp = fma(z, y, fma(a, t, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(a * b), z, x) tmp = 0.0 if (b <= -1.05e+101) tmp = t_1; elseif (b <= 3.6e+113) tmp = fma(z, y, fma(a, t, x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[b, -1.05e+101], t$95$1, If[LessEqual[b, 3.6e+113], N[(z * y + N[(a * t + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a \cdot b, z, x\right)\\
\mathbf{if}\;b \leq -1.05 \cdot 10^{+101}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 3.6 \cdot 10^{+113}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(a, t, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -1.05e101 or 3.59999999999999992e113 < b Initial program 92.1%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-inN/A
lift-fma.f64N/A
*-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-fma.f6473.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6473.8
Applied rewrites73.8%
Taylor expanded in y around 0
lower-*.f6449.8
Applied rewrites49.8%
if -1.05e101 < b < 3.59999999999999992e113Initial program 92.1%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-inN/A
lift-fma.f64N/A
*-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-fma.f6473.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6473.8
Applied rewrites73.8%
Taylor expanded in b around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f6477.8
Applied rewrites77.8%
lift-+.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+r+N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6477.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6477.9
Applied rewrites77.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma a b y) z))) (if (<= z -1.85e+24) t_1 (if (<= z 7.6e-29) (fma t a x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(a, b, y) * z;
double tmp;
if (z <= -1.85e+24) {
tmp = t_1;
} else if (z <= 7.6e-29) {
tmp = fma(t, a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(a, b, y) * z) tmp = 0.0 if (z <= -1.85e+24) tmp = t_1; elseif (z <= 7.6e-29) tmp = fma(t, a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1.85e+24], t$95$1, If[LessEqual[z, 7.6e-29], N[(t * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, y\right) \cdot z\\
\mathbf{if}\;z \leq -1.85 \cdot 10^{+24}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 7.6 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.85e24 or 7.59999999999999951e-29 < z Initial program 92.1%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.0
Applied rewrites50.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.0
Applied rewrites50.0%
if -1.85e24 < z < 7.59999999999999951e-29Initial program 92.1%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-inN/A
lift-fma.f64N/A
*-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-fma.f6473.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6473.8
Applied rewrites73.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6453.0
Applied rewrites53.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6453.0
Applied rewrites53.0%
(FPCore (x y z t a b) :precision binary64 (if (<= a -216.0) (fma t a x) (if (<= a 0.00255) (+ x (* y z)) (fma t a x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -216.0) {
tmp = fma(t, a, x);
} else if (a <= 0.00255) {
tmp = x + (y * z);
} else {
tmp = fma(t, a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -216.0) tmp = fma(t, a, x); elseif (a <= 0.00255) tmp = Float64(x + Float64(y * z)); else tmp = fma(t, a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -216.0], N[(t * a + x), $MachinePrecision], If[LessEqual[a, 0.00255], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision], N[(t * a + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -216:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{elif}\;a \leq 0.00255:\\
\;\;\;\;x + y \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\end{array}
\end{array}
if a < -216 or 0.0025500000000000002 < a Initial program 92.1%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-inN/A
lift-fma.f64N/A
*-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-fma.f6473.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6473.8
Applied rewrites73.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6453.0
Applied rewrites53.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6453.0
Applied rewrites53.0%
if -216 < a < 0.0025500000000000002Initial program 92.1%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6494.7
Applied rewrites94.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f6451.8
Applied rewrites51.8%
(FPCore (x y z t a b) :precision binary64 (fma t a x))
double code(double x, double y, double z, double t, double a, double b) {
return fma(t, a, x);
}
function code(x, y, z, t, a, b) return fma(t, a, x) end
code[x_, y_, z_, t_, a_, b_] := N[(t * a + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(t, a, x\right)
\end{array}
Initial program 92.1%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-inN/A
lift-fma.f64N/A
*-commutativeN/A
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-fma.f6473.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6473.8
Applied rewrites73.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6453.0
Applied rewrites53.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6453.0
Applied rewrites53.0%
(FPCore (x y z t a b) :precision binary64 (* a t))
double code(double x, double y, double z, double t, double a, double b) {
return a * t;
}
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, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = a * t
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a * t;
}
def code(x, y, z, t, a, b): return a * t
function code(x, y, z, t, a, b) return Float64(a * t) end
function tmp = code(x, y, z, t, a, b) tmp = a * t; end
code[x_, y_, z_, t_, a_, b_] := N[(a * t), $MachinePrecision]
\begin{array}{l}
\\
a \cdot t
\end{array}
Initial program 92.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.9
Applied rewrites50.9%
Taylor expanded in z around 0
Applied rewrites29.0%
herbie shell --seed 2025159
(FPCore (x y z t a b)
:name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
:precision binary64
(+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))