
(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 12 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 (let* ((t_1 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))) (if (<= t_1 1e+305) t_1 (fma (fma b z t) a (* z y)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x + (y * z)) + (t * a)) + ((a * z) * b);
double tmp;
if (t_1 <= 1e+305) {
tmp = t_1;
} else {
tmp = fma(fma(b, z, t), a, (z * y));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) tmp = 0.0 if (t_1 <= 1e+305) tmp = t_1; else tmp = fma(fma(b, z, t), a, Float64(z * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e+305], t$95$1, N[(N[(b * z + t), $MachinePrecision] * a + N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\
\mathbf{if}\;t\_1 \leq 10^{+305}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, z \cdot y\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < 9.9999999999999994e304Initial program 92.4%
if 9.9999999999999994e304 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 92.4%
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.3
Applied rewrites70.3%
(FPCore (x y z t a b) :precision binary64 (if (<= z -2e+166) (fma (fma b a y) z x) (+ (fma z y x) (* (fma b z t) a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -2e+166) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = fma(z, y, x) + (fma(b, z, t) * a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -2e+166) tmp = fma(fma(b, a, y), z, x); else tmp = Float64(fma(z, y, x) + Float64(fma(b, z, t) * a)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -2e+166], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(z * y + x), $MachinePrecision] + N[(N[(b * z + t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+166}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right) + \mathsf{fma}\left(b, z, t\right) \cdot a\\
\end{array}
\end{array}
if z < -1.99999999999999988e166Initial program 92.4%
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.f6475.1
Applied rewrites75.1%
if -1.99999999999999988e166 < z Initial program 92.4%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6494.3
Applied rewrites94.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (fma b a y) z x))) (if (<= z -4.6e+35) t_1 (if (<= z 6.4e+34) (fma (fma b z t) a 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+35) {
tmp = t_1;
} else if (z <= 6.4e+34) {
tmp = fma(fma(b, z, t), a, 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+35) tmp = t_1; elseif (z <= 6.4e+34) tmp = fma(fma(b, z, t), a, 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+35], t$95$1, If[LessEqual[z, 6.4e+34], N[(N[(b * z + t), $MachinePrecision] * a + x), $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^{+35}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 6.4 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.5999999999999996e35 or 6.3999999999999997e34 < z Initial program 92.4%
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.f6475.1
Applied rewrites75.1%
if -4.5999999999999996e35 < z < 6.3999999999999997e34Initial program 92.4%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.2
Applied rewrites74.2%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (fma b a y) z x))) (if (<= z -1e+60) t_1 (if (<= z 1.25e-139) (fma a t (fma 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, a, y), z, x);
double tmp;
if (z <= -1e+60) {
tmp = t_1;
} else if (z <= 1.25e-139) {
tmp = fma(a, t, fma(y, z, 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 <= -1e+60) tmp = t_1; elseif (z <= 1.25e-139) tmp = fma(a, t, fma(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 * a + y), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[z, -1e+60], t$95$1, If[LessEqual[z, 1.25e-139], N[(a * t + N[(y * z + 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 -1 \cdot 10^{+60}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{-139}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(y, z, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -9.9999999999999995e59 or 1.25000000000000008e-139 < z Initial program 92.4%
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.f6475.1
Applied rewrites75.1%
if -9.9999999999999995e59 < z < 1.25000000000000008e-139Initial program 92.4%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/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
lower-fma.f6477.5
Applied rewrites77.5%
(FPCore (x y z t a b) :precision binary64 (if (<= b -1.76e+190) (* (fma b a y) z) (if (<= b 7.5e+183) (fma a t (fma y z x)) (fma (* b z) a x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -1.76e+190) {
tmp = fma(b, a, y) * z;
} else if (b <= 7.5e+183) {
tmp = fma(a, t, fma(y, z, x));
} else {
tmp = fma((b * z), a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -1.76e+190) tmp = Float64(fma(b, a, y) * z); elseif (b <= 7.5e+183) tmp = fma(a, t, fma(y, z, x)); else tmp = fma(Float64(b * z), a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -1.76e+190], N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[b, 7.5e+183], N[(a * t + N[(y * z + x), $MachinePrecision]), $MachinePrecision], N[(N[(b * z), $MachinePrecision] * a + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.76 \cdot 10^{+190}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{+183}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(y, z, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot z, a, x\right)\\
\end{array}
\end{array}
if b < -1.76000000000000004e190Initial program 92.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6450.9
Applied rewrites50.9%
if -1.76000000000000004e190 < b < 7.49999999999999966e183Initial program 92.4%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/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
lower-fma.f6477.5
Applied rewrites77.5%
if 7.49999999999999966e183 < b Initial program 92.4%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.2
Applied rewrites74.2%
Taylor expanded in z around inf
lower-*.f6450.8
Applied rewrites50.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (fma b a y) z)))
(if (<= z -3.65e+59)
t_1
(if (<= z 8.5e-145)
(fma t a x)
(if (<= z 8.6e+35) (fma (* b z) a 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 <= -3.65e+59) {
tmp = t_1;
} else if (z <= 8.5e-145) {
tmp = fma(t, a, x);
} else if (z <= 8.6e+35) {
tmp = fma((b * z), a, 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 <= -3.65e+59) tmp = t_1; elseif (z <= 8.5e-145) tmp = fma(t, a, x); elseif (z <= 8.6e+35) tmp = fma(Float64(b * z), a, 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, -3.65e+59], t$95$1, If[LessEqual[z, 8.5e-145], N[(t * a + x), $MachinePrecision], If[LessEqual[z, 8.6e+35], N[(N[(b * z), $MachinePrecision] * a + 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 -3.65 \cdot 10^{+59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{-145}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{elif}\;z \leq 8.6 \cdot 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot z, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.6500000000000001e59 or 8.5999999999999995e35 < z Initial program 92.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6450.9
Applied rewrites50.9%
if -3.6500000000000001e59 < z < 8.50000000000000043e-145Initial program 92.4%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.2
Applied rewrites74.2%
Taylor expanded in z around 0
Applied rewrites52.0%
if 8.50000000000000043e-145 < z < 8.5999999999999995e35Initial program 92.4%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.2
Applied rewrites74.2%
Taylor expanded in z around inf
lower-*.f6450.8
Applied rewrites50.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (fma b a y) z)))
(if (<= z -3.65e+59)
t_1
(if (<= z 1.25e-139)
(fma t a x)
(if (<= z 9e+35) (fma (* a b) z 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 <= -3.65e+59) {
tmp = t_1;
} else if (z <= 1.25e-139) {
tmp = fma(t, a, x);
} else if (z <= 9e+35) {
tmp = fma((a * b), z, 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 <= -3.65e+59) tmp = t_1; elseif (z <= 1.25e-139) tmp = fma(t, a, x); elseif (z <= 9e+35) tmp = fma(Float64(a * b), z, 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, -3.65e+59], t$95$1, If[LessEqual[z, 1.25e-139], N[(t * a + x), $MachinePrecision], If[LessEqual[z, 9e+35], N[(N[(a * b), $MachinePrecision] * z + 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 -3.65 \cdot 10^{+59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{-139}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot b, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.6500000000000001e59 or 8.9999999999999993e35 < z Initial program 92.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6450.9
Applied rewrites50.9%
if -3.6500000000000001e59 < z < 1.25000000000000008e-139Initial program 92.4%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.2
Applied rewrites74.2%
Taylor expanded in z around 0
Applied rewrites52.0%
if 1.25000000000000008e-139 < z < 8.9999999999999993e35Initial program 92.4%
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.f6475.1
Applied rewrites75.1%
Taylor expanded in y around 0
lower-*.f6450.7
Applied rewrites50.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b a y) z))) (if (<= z -3.65e+59) t_1 (if (<= z 6.4e-18) (fma t a 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 <= -3.65e+59) {
tmp = t_1;
} else if (z <= 6.4e-18) {
tmp = fma(t, a, 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 <= -3.65e+59) tmp = t_1; elseif (z <= 6.4e-18) 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[(b * a + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -3.65e+59], t$95$1, If[LessEqual[z, 6.4e-18], N[(t * a + 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 -3.65 \cdot 10^{+59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 6.4 \cdot 10^{-18}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.6500000000000001e59 or 6.3999999999999998e-18 < z Initial program 92.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6450.9
Applied rewrites50.9%
if -3.6500000000000001e59 < z < 6.3999999999999998e-18Initial program 92.4%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.2
Applied rewrites74.2%
Taylor expanded in z around 0
Applied rewrites52.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma a t (* y z))))
(if (<= z -3.25e+276)
(* (* a b) z)
(if (<= z -2.05e+59) t_1 (if (<= z 9e+35) (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, t, (y * z));
double tmp;
if (z <= -3.25e+276) {
tmp = (a * b) * z;
} else if (z <= -2.05e+59) {
tmp = t_1;
} else if (z <= 9e+35) {
tmp = fma(t, a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(a, t, Float64(y * z)) tmp = 0.0 if (z <= -3.25e+276) tmp = Float64(Float64(a * b) * z); elseif (z <= -2.05e+59) tmp = t_1; elseif (z <= 9e+35) 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 * t + N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.25e+276], N[(N[(a * b), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, -2.05e+59], t$95$1, If[LessEqual[z, 9e+35], N[(t * a + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, t, y \cdot z\right)\\
\mathbf{if}\;z \leq -3.25 \cdot 10^{+276}:\\
\;\;\;\;\left(a \cdot b\right) \cdot z\\
\mathbf{elif}\;z \leq -2.05 \cdot 10^{+59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.24999999999999986e276Initial program 92.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6450.9
Applied rewrites50.9%
Taylor expanded in y around 0
lower-*.f6426.8
Applied rewrites26.8%
if -3.24999999999999986e276 < z < -2.05e59 or 8.9999999999999993e35 < z Initial program 92.4%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/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
lower-fma.f6477.5
Applied rewrites77.5%
Taylor expanded in x around 0
lower-*.f6452.8
Applied rewrites52.8%
if -2.05e59 < z < 8.9999999999999993e35Initial program 92.4%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.2
Applied rewrites74.2%
Taylor expanded in z around 0
Applied rewrites52.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (* a z) b))) (if (<= b -7e+171) t_1 (if (<= b 2.9e+145) (fma t a x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * z) * b;
double tmp;
if (b <= -7e+171) {
tmp = t_1;
} else if (b <= 2.9e+145) {
tmp = fma(t, a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * z) * b) tmp = 0.0 if (b <= -7e+171) tmp = t_1; elseif (b <= 2.9e+145) 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 * z), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[b, -7e+171], t$95$1, If[LessEqual[b, 2.9e+145], N[(t * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a \cdot z\right) \cdot b\\
\mathbf{if}\;b \leq -7 \cdot 10^{+171}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{+145}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -6.9999999999999999e171 or 2.9000000000000001e145 < b Initial program 92.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6450.9
Applied rewrites50.9%
Taylor expanded in y around 0
lower-*.f6426.8
Applied rewrites26.8%
Taylor expanded in y around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6427.7
Applied rewrites27.7%
if -6.9999999999999999e171 < b < 2.9000000000000001e145Initial program 92.4%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.2
Applied rewrites74.2%
Taylor expanded in z around 0
Applied rewrites52.0%
(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.4%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.2
Applied rewrites74.2%
Taylor expanded in z around 0
Applied rewrites52.0%
(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.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6450.0
Applied rewrites50.0%
Taylor expanded in z around 0
Applied rewrites27.5%
herbie shell --seed 2025134
(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)))