
(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 13 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 -2.1e+171)
(fma (fma b z t) a x)
(if (<= a 0.05)
(+ (fma a t x) (* (fma b a y) z))
(* (+ (fma b z (/ (fma z y x) a)) t) a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -2.1e+171) {
tmp = fma(fma(b, z, t), a, x);
} else if (a <= 0.05) {
tmp = fma(a, t, x) + (fma(b, a, y) * z);
} else {
tmp = (fma(b, z, (fma(z, y, x) / a)) + t) * a;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -2.1e+171) tmp = fma(fma(b, z, t), a, x); elseif (a <= 0.05) tmp = Float64(fma(a, t, x) + Float64(fma(b, a, y) * z)); else tmp = Float64(Float64(fma(b, z, Float64(fma(z, y, x) / a)) + t) * a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -2.1e+171], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[a, 0.05], N[(N[(a * t + x), $MachinePrecision] + N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * z + N[(N[(z * y + x), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.1 \cdot 10^{+171}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{elif}\;a \leq 0.05:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right) + \mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(b, z, \frac{\mathsf{fma}\left(z, y, x\right)}{a}\right) + t\right) \cdot a\\
\end{array}
\end{array}
if a < -2.1000000000000001e171Initial program 92.6%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6475.2
Applied rewrites75.2%
if -2.1000000000000001e171 < a < 0.050000000000000003Initial program 92.6%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6494.3
Applied rewrites94.3%
if 0.050000000000000003 < a Initial program 92.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-fma.f64N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6482.7
Applied rewrites82.7%
(FPCore (x y z t a b)
:precision binary64
(if (<= a -2.1e+171)
(fma (fma b z t) a x)
(if (<= a 1.12e+61)
(+ (fma a t x) (* (fma b a y) z))
(fma (fma b z t) a (* z y)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -2.1e+171) {
tmp = fma(fma(b, z, t), a, x);
} else if (a <= 1.12e+61) {
tmp = fma(a, t, x) + (fma(b, a, y) * z);
} else {
tmp = fma(fma(b, z, t), a, (z * y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -2.1e+171) tmp = fma(fma(b, z, t), a, x); elseif (a <= 1.12e+61) tmp = Float64(fma(a, t, x) + Float64(fma(b, a, y) * z)); else tmp = fma(fma(b, z, t), a, Float64(z * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -2.1e+171], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[a, 1.12e+61], N[(N[(a * t + x), $MachinePrecision] + N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(b * z + t), $MachinePrecision] * a + N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.1 \cdot 10^{+171}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{elif}\;a \leq 1.12 \cdot 10^{+61}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right) + \mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, z \cdot y\right)\\
\end{array}
\end{array}
if a < -2.1000000000000001e171Initial program 92.6%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6475.2
Applied rewrites75.2%
if -2.1000000000000001e171 < a < 1.12e61Initial program 92.6%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6494.3
Applied rewrites94.3%
if 1.12e61 < a Initial program 92.6%
Taylor expanded in x around 0
associate-+r+N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6470.7
Applied rewrites70.7%
(FPCore (x y z t a b) :precision binary64 (if (<= a -2.8e-20) (fma (fma b z t) a x) (if (<= a 2e-22) (fma (fma b a y) z x) (fma (fma b z t) a (* z y)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -2.8e-20) {
tmp = fma(fma(b, z, t), a, x);
} else if (a <= 2e-22) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = fma(fma(b, z, t), a, (z * y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -2.8e-20) tmp = fma(fma(b, z, t), a, x); elseif (a <= 2e-22) tmp = fma(fma(b, a, y), z, x); else tmp = fma(fma(b, z, t), a, Float64(z * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -2.8e-20], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[a, 2e-22], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(b * z + t), $MachinePrecision] * a + N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.8 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{elif}\;a \leq 2 \cdot 10^{-22}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, z \cdot y\right)\\
\end{array}
\end{array}
if a < -2.8000000000000003e-20Initial program 92.6%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6475.2
Applied rewrites75.2%
if -2.8000000000000003e-20 < a < 2.0000000000000001e-22Initial program 92.6%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6473.9
Applied rewrites73.9%
if 2.0000000000000001e-22 < a Initial program 92.6%
Taylor expanded in x around 0
associate-+r+N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6470.7
Applied rewrites70.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (fma b z t) a x))) (if (<= a -2.8e-20) t_1 (if (<= a 9e+15) (fma (fma b a 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 <= -2.8e-20) {
tmp = t_1;
} else if (a <= 9e+15) {
tmp = fma(fma(b, a, 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 <= -2.8e-20) tmp = t_1; elseif (a <= 9e+15) tmp = fma(fma(b, a, 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, -2.8e-20], t$95$1, If[LessEqual[a, 9e+15], N[(N[(b * a + 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 -2.8 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 9 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -2.8000000000000003e-20 or 9e15 < a Initial program 92.6%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6475.2
Applied rewrites75.2%
if -2.8000000000000003e-20 < a < 9e15Initial program 92.6%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6473.9
Applied rewrites73.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (fma b a y) z x))) (if (<= z -4.6e+18) t_1 (if (<= z 1.45e-63) (fma a t (fma z y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(fma(b, a, y), z, x);
double tmp;
if (z <= -4.6e+18) {
tmp = t_1;
} else if (z <= 1.45e-63) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(fma(b, a, y), z, x) tmp = 0.0 if (z <= -4.6e+18) tmp = t_1; elseif (z <= 1.45e-63) tmp = fma(a, t, fma(z, y, x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[z, -4.6e+18], t$95$1, If[LessEqual[z, 1.45e-63], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{if}\;z \leq -4.6 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{-63}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.6e18 or 1.44999999999999987e-63 < z Initial program 92.6%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6473.9
Applied rewrites73.9%
if -4.6e18 < z < 1.44999999999999987e-63Initial program 92.6%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6494.3
Applied rewrites94.3%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lift-fma.f6478.4
Applied rewrites78.4%
(FPCore (x y z t a b) :precision binary64 (if (<= b -8.5e+78) (* (fma b z t) a) (if (<= b 3.6e+148) (fma a t (fma z y x)) (fma (* b a) z x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -8.5e+78) {
tmp = fma(b, z, t) * a;
} else if (b <= 3.6e+148) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = fma((b * a), z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -8.5e+78) tmp = Float64(fma(b, z, t) * a); elseif (b <= 3.6e+148) tmp = fma(a, t, fma(z, y, x)); else tmp = fma(Float64(b * a), z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -8.5e+78], N[(N[(b * z + t), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[b, 3.6e+148], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], N[(N[(b * a), $MachinePrecision] * z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.5 \cdot 10^{+78}:\\
\;\;\;\;\mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{elif}\;b \leq 3.6 \cdot 10^{+148}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot a, z, x\right)\\
\end{array}
\end{array}
if b < -8.50000000000000079e78Initial program 92.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6451.5
Applied rewrites51.5%
if -8.50000000000000079e78 < b < 3.60000000000000006e148Initial program 92.6%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6494.3
Applied rewrites94.3%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lift-fma.f6478.4
Applied rewrites78.4%
if 3.60000000000000006e148 < b Initial program 92.6%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6473.9
Applied rewrites73.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6450.2
Applied rewrites50.2%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b z t) a))) (if (<= a -7.5e-26) t_1 (if (<= a 4e-14) (fma z y x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(b, z, t) * a;
double tmp;
if (a <= -7.5e-26) {
tmp = t_1;
} else if (a <= 4e-14) {
tmp = fma(z, y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(b, z, t) * a) tmp = 0.0 if (a <= -7.5e-26) tmp = t_1; elseif (a <= 4e-14) tmp = fma(z, y, 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), $MachinePrecision]}, If[LessEqual[a, -7.5e-26], t$95$1, If[LessEqual[a, 4e-14], N[(z * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{if}\;a \leq -7.5 \cdot 10^{-26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 4 \cdot 10^{-14}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -7.4999999999999994e-26 or 4e-14 < a Initial program 92.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6451.5
Applied rewrites51.5%
if -7.4999999999999994e-26 < a < 4e-14Initial program 92.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.0
Applied rewrites52.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b a y) z))) (if (<= z -2e+42) t_1 (if (<= z 1.38e-61) (fma a t x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(b, a, y) * z;
double tmp;
if (z <= -2e+42) {
tmp = t_1;
} else if (z <= 1.38e-61) {
tmp = fma(a, t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(b, a, y) * z) tmp = 0.0 if (z <= -2e+42) tmp = t_1; elseif (z <= 1.38e-61) tmp = 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[(b * a + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -2e+42], t$95$1, If[LessEqual[z, 1.38e-61], N[(a * t + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{if}\;z \leq -2 \cdot 10^{+42}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.38 \cdot 10^{-61}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.00000000000000009e42 or 1.37999999999999992e-61 < z Initial program 92.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6450.0
Applied rewrites50.0%
if -2.00000000000000009e42 < z < 1.37999999999999992e-61Initial program 92.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.2%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6453.4
Applied rewrites53.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (* b z) a)))
(if (<= b -8.5e+78)
t_1
(if (<= b -4.2e-223)
(fma z y x)
(if (<= b 9.6e-214) (fma a t x) (if (<= b 2e+153) (fma z y x) t_1))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (b * z) * a;
double tmp;
if (b <= -8.5e+78) {
tmp = t_1;
} else if (b <= -4.2e-223) {
tmp = fma(z, y, x);
} else if (b <= 9.6e-214) {
tmp = fma(a, t, x);
} else if (b <= 2e+153) {
tmp = fma(z, y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(b * z) * a) tmp = 0.0 if (b <= -8.5e+78) tmp = t_1; elseif (b <= -4.2e-223) tmp = fma(z, y, x); elseif (b <= 9.6e-214) tmp = fma(a, t, x); elseif (b <= 2e+153) tmp = fma(z, y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * z), $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[b, -8.5e+78], t$95$1, If[LessEqual[b, -4.2e-223], N[(z * y + x), $MachinePrecision], If[LessEqual[b, 9.6e-214], N[(a * t + x), $MachinePrecision], If[LessEqual[b, 2e+153], N[(z * y + x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(b \cdot z\right) \cdot a\\
\mathbf{if}\;b \leq -8.5 \cdot 10^{+78}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -4.2 \cdot 10^{-223}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;b \leq 9.6 \cdot 10^{-214}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -8.50000000000000079e78 or 2e153 < b Initial program 92.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6450.0
Applied rewrites50.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f6426.6
Applied rewrites26.6%
if -8.50000000000000079e78 < b < -4.19999999999999965e-223 or 9.60000000000000081e-214 < b < 2e153Initial program 92.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.0
Applied rewrites52.0%
if -4.19999999999999965e-223 < b < 9.60000000000000081e-214Initial program 92.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.2%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6453.4
Applied rewrites53.4%
(FPCore (x y z t a b) :precision binary64 (if (<= z -1.55e+156) (fma z y x) (if (<= z 3.5e-63) (fma a t x) (fma z y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -1.55e+156) {
tmp = fma(z, y, x);
} else if (z <= 3.5e-63) {
tmp = fma(a, t, x);
} else {
tmp = fma(z, y, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -1.55e+156) tmp = fma(z, y, x); elseif (z <= 3.5e-63) tmp = fma(a, t, x); else tmp = fma(z, y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -1.55e+156], N[(z * y + x), $MachinePrecision], If[LessEqual[z, 3.5e-63], N[(a * t + x), $MachinePrecision], N[(z * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{+156}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-63}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\end{array}
\end{array}
if z < -1.5500000000000001e156 or 3.50000000000000003e-63 < z Initial program 92.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.0
Applied rewrites52.0%
if -1.5500000000000001e156 < z < 3.50000000000000003e-63Initial program 92.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.2%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6453.4
Applied rewrites53.4%
(FPCore (x y z t a b) :precision binary64 (fma a t x))
double code(double x, double y, double z, double t, double a, double b) {
return fma(a, t, x);
}
function code(x, y, z, t, a, b) return fma(a, t, x) end
code[x_, y_, z_, t_, a_, b_] := N[(a * t + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a, t, x\right)
\end{array}
Initial program 92.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.2%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6453.4
Applied rewrites53.4%
(FPCore (x y z t a b) :precision binary64 (if (<= x -8.5e+74) (* 1.0 x) (if (<= x 5e-22) (* t a) (* 1.0 x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -8.5e+74) {
tmp = 1.0 * x;
} else if (x <= 5e-22) {
tmp = t * a;
} else {
tmp = 1.0 * x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, 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
real(8) :: tmp
if (x <= (-8.5d+74)) then
tmp = 1.0d0 * x
else if (x <= 5d-22) then
tmp = t * a
else
tmp = 1.0d0 * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -8.5e+74) {
tmp = 1.0 * x;
} else if (x <= 5e-22) {
tmp = t * a;
} else {
tmp = 1.0 * x;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= -8.5e+74: tmp = 1.0 * x elif x <= 5e-22: tmp = t * a else: tmp = 1.0 * x return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -8.5e+74) tmp = Float64(1.0 * x); elseif (x <= 5e-22) tmp = Float64(t * a); else tmp = Float64(1.0 * x); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (x <= -8.5e+74) tmp = 1.0 * x; elseif (x <= 5e-22) tmp = t * a; else tmp = 1.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -8.5e+74], N[(1.0 * x), $MachinePrecision], If[LessEqual[x, 5e-22], N[(t * a), $MachinePrecision], N[(1.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{+74}:\\
\;\;\;\;1 \cdot x\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-22}:\\
\;\;\;\;t \cdot a\\
\mathbf{else}:\\
\;\;\;\;1 \cdot x\\
\end{array}
\end{array}
if x < -8.50000000000000028e74 or 4.99999999999999954e-22 < x Initial program 92.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.2%
Taylor expanded in x around inf
Applied rewrites26.1%
if -8.50000000000000028e74 < x < 4.99999999999999954e-22Initial program 92.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-fma.f64N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6482.7
Applied rewrites82.7%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6445.9
Applied rewrites45.9%
Taylor expanded in x around 0
Applied rewrites29.4%
(FPCore (x y z t a b) :precision binary64 (* t a))
double code(double x, double y, double z, double t, double a, double b) {
return t * a;
}
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 = t * a
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return t * a;
}
def code(x, y, z, t, a, b): return t * a
function code(x, y, z, t, a, b) return Float64(t * a) end
function tmp = code(x, y, z, t, a, b) tmp = t * a; end
code[x_, y_, z_, t_, a_, b_] := N[(t * a), $MachinePrecision]
\begin{array}{l}
\\
t \cdot a
\end{array}
Initial program 92.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-fma.f64N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6482.7
Applied rewrites82.7%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6445.9
Applied rewrites45.9%
Taylor expanded in x around 0
Applied rewrites29.4%
herbie shell --seed 2025142
(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)))