
(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]
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
Herbie found 14 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]
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
(FPCore (x y z t a b) :precision binary64 (if (<= a -2.9e+99) (fma (fma z b t) a x) (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -2.9e+99) {
tmp = fma(fma(z, b, t), a, x);
} else {
tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -2.9e+99) tmp = fma(fma(z, b, t), a, x); else tmp = Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -2.9e+99], N[(N[(z * b + t), $MachinePrecision] * a + x), $MachinePrecision], 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}
\mathbf{if}\;a \leq -2.9 \cdot 10^{+99}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\
\end{array}
if a < -2.9000000000000002e99Initial program 91.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.6%
Applied rewrites74.6%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
Applied rewrites75.3%
if -2.9000000000000002e99 < a Initial program 91.9%
(FPCore (x y z t a b) :precision binary64 (if (<= z -5.8e+190) (* (fma a b y) z) (fma (fma b z t) a (fma z y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -5.8e+190) {
tmp = fma(a, b, y) * z;
} else {
tmp = fma(fma(b, z, t), a, fma(z, y, x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -5.8e+190) tmp = Float64(fma(a, b, y) * z); else tmp = fma(fma(b, z, t), a, fma(z, y, x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -5.8e+190], N[(N[(a * b + y), $MachinePrecision] * z), $MachinePrecision], N[(N[(b * z + t), $MachinePrecision] * a + N[(z * y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+190}:\\
\;\;\;\;\mathsf{fma}\left(a, b, y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, \mathsf{fma}\left(z, y, x\right)\right)\\
\end{array}
if z < -5.79999999999999979e190Initial program 91.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.3%
Applied rewrites50.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.3%
Applied rewrites50.3%
if -5.79999999999999979e190 < z Initial program 91.9%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.8%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.8%
Applied rewrites94.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma t a (fma z y x))))
(if (<= t -2.5e-18)
t_1
(if (<= t 3.1e+55) (+ x (fma a (* b z) (* y z))) t_1))))double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(t, a, fma(z, y, x));
double tmp;
if (t <= -2.5e-18) {
tmp = t_1;
} else if (t <= 3.1e+55) {
tmp = x + fma(a, (b * z), (y * z));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(t, a, fma(z, y, x)) tmp = 0.0 if (t <= -2.5e-18) tmp = t_1; elseif (t <= 3.1e+55) tmp = Float64(x + fma(a, Float64(b * z), Float64(y * z))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(t * a + N[(z * y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -2.5e-18], t$95$1, If[LessEqual[t, 3.1e+55], N[(x + N[(a * N[(b * z), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, a, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{if}\;t \leq -2.5 \cdot 10^{-18}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3.1 \cdot 10^{+55}:\\
\;\;\;\;x + \mathsf{fma}\left(a, b \cdot z, y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if t < -2.50000000000000018e-18 or 3.09999999999999994e55 < t Initial program 91.9%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.8%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.8%
Applied rewrites94.8%
Taylor expanded in z around 0
Applied rewrites76.8%
if -2.50000000000000018e-18 < t < 3.09999999999999994e55Initial program 91.9%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6471.2%
Applied rewrites71.2%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (fma z b t) a x))) (if (<= a -2.05e-67) t_1 (if (<= a 4.8e+125) (fma t a (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(z, b, t), a, x);
double tmp;
if (a <= -2.05e-67) {
tmp = t_1;
} else if (a <= 4.8e+125) {
tmp = fma(t, a, fma(z, y, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(fma(z, b, t), a, x) tmp = 0.0 if (a <= -2.05e-67) tmp = t_1; elseif (a <= 4.8e+125) tmp = fma(t, a, 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[(z * b + t), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[a, -2.05e-67], t$95$1, If[LessEqual[a, 4.8e+125], N[(t * a + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\\
\mathbf{if}\;a \leq -2.05 \cdot 10^{-67}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 4.8 \cdot 10^{+125}:\\
\;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if a < -2.0499999999999999e-67 or 4.7999999999999999e125 < a Initial program 91.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.6%
Applied rewrites74.6%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
Applied rewrites75.3%
if -2.0499999999999999e-67 < a < 4.7999999999999999e125Initial program 91.9%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.8%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.8%
Applied rewrites94.8%
Taylor expanded in z around 0
Applied rewrites76.8%
(FPCore (x y z t a b) :precision binary64 (if (<= a -2.05e-67) (fma (fma z b t) a x) (if (<= a 4.5e+125) (fma t a (fma z y x)) (+ x (fma a t (* a (* b z)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -2.05e-67) {
tmp = fma(fma(z, b, t), a, x);
} else if (a <= 4.5e+125) {
tmp = fma(t, a, fma(z, y, x));
} else {
tmp = x + fma(a, t, (a * (b * z)));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -2.05e-67) tmp = fma(fma(z, b, t), a, x); elseif (a <= 4.5e+125) tmp = fma(t, a, fma(z, y, x)); else tmp = Float64(x + fma(a, t, Float64(a * Float64(b * z)))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -2.05e-67], N[(N[(z * b + t), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[a, 4.5e+125], N[(t * a + N[(z * y + x), $MachinePrecision]), $MachinePrecision], N[(x + N[(a * t + N[(a * N[(b * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;a \leq -2.05 \cdot 10^{-67}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\\
\mathbf{elif}\;a \leq 4.5 \cdot 10^{+125}:\\
\;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right)\\
\end{array}
if a < -2.0499999999999999e-67Initial program 91.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.6%
Applied rewrites74.6%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
Applied rewrites75.3%
if -2.0499999999999999e-67 < a < 4.5e125Initial program 91.9%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.8%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.8%
Applied rewrites94.8%
Taylor expanded in z around 0
Applied rewrites76.8%
if 4.5e125 < a Initial program 91.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.6%
Applied rewrites74.6%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma a b y) z))) (if (<= z -5.8e+190) t_1 (if (<= z 4.1e+39) (fma (fma z b 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 <= -5.8e+190) {
tmp = t_1;
} else if (z <= 4.1e+39) {
tmp = fma(fma(z, b, 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 <= -5.8e+190) tmp = t_1; elseif (z <= 4.1e+39) tmp = fma(fma(z, b, 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, -5.8e+190], t$95$1, If[LessEqual[z, 4.1e+39], N[(N[(z * b + t), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, y\right) \cdot z\\
\mathbf{if}\;z \leq -5.8 \cdot 10^{+190}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.1 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -5.79999999999999979e190 or 4.10000000000000004e39 < z Initial program 91.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.3%
Applied rewrites50.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.3%
Applied rewrites50.3%
if -5.79999999999999979e190 < z < 4.10000000000000004e39Initial program 91.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.6%
Applied rewrites74.6%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
Applied rewrites75.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma a b y) z))) (if (<= z -4.3e-47) t_1 (if (<= z 4.2e-9) (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 <= -4.3e-47) {
tmp = t_1;
} else if (z <= 4.2e-9) {
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 <= -4.3e-47) tmp = t_1; elseif (z <= 4.2e-9) 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, -4.3e-47], t$95$1, If[LessEqual[z, 4.2e-9], N[(t * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, y\right) \cdot z\\
\mathbf{if}\;z \leq -4.3 \cdot 10^{-47}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -4.2999999999999998e-47 or 4.20000000000000039e-9 < z Initial program 91.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.3%
Applied rewrites50.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.3%
Applied rewrites50.3%
if -4.2999999999999998e-47 < z < 4.20000000000000039e-9Initial program 91.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.6%
Applied rewrites74.6%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
Applied rewrites75.3%
Taylor expanded in z around 0
Applied rewrites52.7%
(FPCore (x y z t a b) :precision binary64 (if (<= t -380.0) (fma t a x) (if (<= t 6.9e+56) (fma (* z b) a x) (fma t a x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -380.0) {
tmp = fma(t, a, x);
} else if (t <= 6.9e+56) {
tmp = fma((z * b), a, x);
} else {
tmp = fma(t, a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -380.0) tmp = fma(t, a, x); elseif (t <= 6.9e+56) tmp = fma(Float64(z * b), a, x); else tmp = fma(t, a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -380.0], N[(t * a + x), $MachinePrecision], If[LessEqual[t, 6.9e+56], N[(N[(z * b), $MachinePrecision] * a + x), $MachinePrecision], N[(t * a + x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;t \leq -380:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{elif}\;t \leq 6.9 \cdot 10^{+56}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot b, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\end{array}
if t < -380 or 6.9e56 < t Initial program 91.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.6%
Applied rewrites74.6%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
Applied rewrites75.3%
Taylor expanded in z around 0
Applied rewrites52.7%
if -380 < t < 6.9e56Initial program 91.9%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6471.2%
Applied rewrites71.2%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6451.3%
Applied rewrites51.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.3%
Applied rewrites51.3%
(FPCore (x y z t a b) :precision binary64 (if (<= t -380.0) (fma t a x) (if (<= t 6.9e+56) (fma (* a b) z x) (fma t a x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -380.0) {
tmp = fma(t, a, x);
} else if (t <= 6.9e+56) {
tmp = fma((a * b), z, x);
} else {
tmp = fma(t, a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -380.0) tmp = fma(t, a, x); elseif (t <= 6.9e+56) tmp = fma(Float64(a * b), z, x); else tmp = fma(t, a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -380.0], N[(t * a + x), $MachinePrecision], If[LessEqual[t, 6.9e+56], N[(N[(a * b), $MachinePrecision] * z + x), $MachinePrecision], N[(t * a + x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;t \leq -380:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{elif}\;t \leq 6.9 \cdot 10^{+56}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot b, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\end{array}
if t < -380 or 6.9e56 < t Initial program 91.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.6%
Applied rewrites74.6%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
Applied rewrites75.3%
Taylor expanded in z around 0
Applied rewrites52.7%
if -380 < t < 6.9e56Initial program 91.9%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6471.2%
Applied rewrites71.2%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6451.3%
Applied rewrites51.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6451.2%
Applied rewrites51.2%
(FPCore (x y z t a b) :precision binary64 (if (<= z -1.35e+147) (* z (* a b)) (if (<= z 2.6e+201) (fma t a x) (* (* a z) b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -1.35e+147) {
tmp = z * (a * b);
} else if (z <= 2.6e+201) {
tmp = fma(t, a, x);
} else {
tmp = (a * z) * b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -1.35e+147) tmp = Float64(z * Float64(a * b)); elseif (z <= 2.6e+201) tmp = fma(t, a, x); else tmp = Float64(Float64(a * z) * b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -1.35e+147], N[(z * N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.6e+201], N[(t * a + x), $MachinePrecision], N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+147}:\\
\;\;\;\;z \cdot \left(a \cdot b\right)\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+201}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot z\right) \cdot b\\
\end{array}
if z < -1.34999999999999999e147Initial program 91.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.3%
Applied rewrites50.3%
Taylor expanded in y around 0
lower-*.f6427.3%
Applied rewrites27.3%
if -1.34999999999999999e147 < z < 2.59999999999999985e201Initial program 91.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.6%
Applied rewrites74.6%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
Applied rewrites75.3%
Taylor expanded in z around 0
Applied rewrites52.7%
if 2.59999999999999985e201 < z Initial program 91.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.3%
Applied rewrites50.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f6427.3%
Applied rewrites27.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6428.2%
Applied rewrites28.2%
(FPCore (x y z t a b) :precision binary64 (if (<= z -1.35e+147) (* a (* b z)) (if (<= z 2.6e+201) (fma t a x) (* (* a z) b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -1.35e+147) {
tmp = a * (b * z);
} else if (z <= 2.6e+201) {
tmp = fma(t, a, x);
} else {
tmp = (a * z) * b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -1.35e+147) tmp = Float64(a * Float64(b * z)); elseif (z <= 2.6e+201) tmp = fma(t, a, x); else tmp = Float64(Float64(a * z) * b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -1.35e+147], N[(a * N[(b * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.6e+201], N[(t * a + x), $MachinePrecision], N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+147}:\\
\;\;\;\;a \cdot \left(b \cdot z\right)\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+201}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot z\right) \cdot b\\
\end{array}
if z < -1.34999999999999999e147Initial program 91.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.3%
Applied rewrites50.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f6427.3%
Applied rewrites27.3%
if -1.34999999999999999e147 < z < 2.59999999999999985e201Initial program 91.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.6%
Applied rewrites74.6%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
Applied rewrites75.3%
Taylor expanded in z around 0
Applied rewrites52.7%
if 2.59999999999999985e201 < z Initial program 91.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.3%
Applied rewrites50.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f6427.3%
Applied rewrites27.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6428.2%
Applied rewrites28.2%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* a (* b z)))) (if (<= z -1.35e+147) t_1 (if (<= z 2.6e+201) (fma t a x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a * (b * z);
double tmp;
if (z <= -1.35e+147) {
tmp = t_1;
} else if (z <= 2.6e+201) {
tmp = fma(t, a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(a * Float64(b * z)) tmp = 0.0 if (z <= -1.35e+147) tmp = t_1; elseif (z <= 2.6e+201) 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[(a * N[(b * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.35e+147], t$95$1, If[LessEqual[z, 2.6e+201], N[(t * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := a \cdot \left(b \cdot z\right)\\
\mathbf{if}\;z \leq -1.35 \cdot 10^{+147}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+201}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -1.34999999999999999e147 or 2.59999999999999985e201 < z Initial program 91.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.3%
Applied rewrites50.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f6427.3%
Applied rewrites27.3%
if -1.34999999999999999e147 < z < 2.59999999999999985e201Initial program 91.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.6%
Applied rewrites74.6%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
Applied rewrites75.3%
Taylor expanded in z around 0
Applied rewrites52.7%
(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]
\mathsf{fma}\left(t, a, x\right)
Initial program 91.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.6%
Applied rewrites74.6%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.3%
Applied rewrites75.3%
Taylor expanded in z around 0
Applied rewrites52.7%
(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]
a \cdot t
Initial program 91.9%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.9%
Applied rewrites50.9%
Taylor expanded in z around 0
lower-*.f6428.1%
Applied rewrites28.1%
herbie shell --seed 2025188
(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)))