
(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 9 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
(let* ((t_1 (fma (fma b z t) a (fma z y x))))
(if (<= a -1e+137)
t_1
(if (<= a 1e-6) (fma z (fma b a y) (fma a t x)) t_1))))double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(fma(b, z, t), a, fma(z, y, x));
double tmp;
if (a <= -1e+137) {
tmp = t_1;
} else if (a <= 1e-6) {
tmp = fma(z, fma(b, a, y), fma(a, t, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(fma(b, z, t), a, fma(z, y, x)) tmp = 0.0 if (a <= -1e+137) tmp = t_1; elseif (a <= 1e-6) tmp = fma(z, fma(b, a, y), fma(a, t, x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * z + t), $MachinePrecision] * a + N[(z * y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -1e+137], t$95$1, If[LessEqual[a, 1e-6], N[(z * N[(b * a + y), $MachinePrecision] + N[(a * t + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{if}\;a \leq -1 \cdot 10^{+137}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(z, \mathsf{fma}\left(b, a, y\right), \mathsf{fma}\left(a, t, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if a < -1e137 or 9.9999999999999995e-7 < a Initial program 92.1%
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.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.4%
Applied rewrites94.4%
if -1e137 < a < 9.9999999999999995e-7Initial program 92.1%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6495.0%
Applied rewrites95.0%
(FPCore (x y z t a b) :precision binary64 (if (<= a -6.8e+165) (* (fma b z t) a) (if (<= a 5e+122) (fma z (fma b a y) (fma a t x)) (fma (fma b z t) a x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -6.8e+165) {
tmp = fma(b, z, t) * a;
} else if (a <= 5e+122) {
tmp = fma(z, fma(b, a, y), fma(a, t, x));
} else {
tmp = fma(fma(b, z, t), a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -6.8e+165) tmp = Float64(fma(b, z, t) * a); elseif (a <= 5e+122) tmp = fma(z, fma(b, a, y), fma(a, t, x)); else tmp = fma(fma(b, z, t), a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -6.8e+165], N[(N[(b * z + t), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[a, 5e+122], N[(z * N[(b * a + y), $MachinePrecision] + N[(a * t + x), $MachinePrecision]), $MachinePrecision], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;a \leq -6.8 \cdot 10^{+165}:\\
\;\;\;\;\mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{elif}\;a \leq 5 \cdot 10^{+122}:\\
\;\;\;\;\mathsf{fma}\left(z, \mathsf{fma}\left(b, a, y\right), \mathsf{fma}\left(a, t, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\end{array}
if a < -6.8000000000000002e165Initial program 92.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.5%
Applied rewrites50.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.5%
Applied rewrites50.5%
if -6.8000000000000002e165 < a < 4.9999999999999999e122Initial program 92.1%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6495.0%
Applied rewrites95.0%
if 4.9999999999999999e122 < a Initial program 92.1%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.7%
Applied rewrites74.7%
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
lower-fma.f6475.3%
Applied rewrites75.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (fma b z t) a x))) (if (<= a -2.3e+95) t_1 (if (<= a 1.25e+52) (fma (fma a b y) z x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(fma(b, z, t), a, x);
double tmp;
if (a <= -2.3e+95) {
tmp = t_1;
} else if (a <= 1.25e+52) {
tmp = fma(fma(a, b, y), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(fma(b, z, t), a, x) tmp = 0.0 if (a <= -2.3e+95) tmp = t_1; elseif (a <= 1.25e+52) tmp = fma(fma(a, b, y), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[a, -2.3e+95], t$95$1, If[LessEqual[a, 1.25e+52], N[(N[(a * b + y), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{if}\;a \leq -2.3 \cdot 10^{+95}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.25 \cdot 10^{+52}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if a < -2.3e95 or 1.25e52 < a Initial program 92.1%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.7%
Applied rewrites74.7%
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
lower-fma.f6475.3%
Applied rewrites75.3%
if -2.3e95 < a < 1.25e52Initial program 92.1%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6495.0%
Applied rewrites95.0%
Taylor expanded in x around 0
lower-*.f6469.8%
Applied rewrites69.8%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6474.8%
Applied rewrites74.8%
+-commutative74.8%
distribute-rgt-in74.8%
associate-*l*74.8%
*-commutative74.8%
+-commutative74.8%
associate-+r+74.8%
associate-+r+74.8%
+-commutative74.8%
*-commutative74.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6474.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-fma.f6474.8%
Applied rewrites74.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b z t) a))) (if (<= a -2.3e+95) t_1 (if (<= a 1.25e+52) (fma (fma a b y) z x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(b, z, t) * a;
double tmp;
if (a <= -2.3e+95) {
tmp = t_1;
} else if (a <= 1.25e+52) {
tmp = fma(fma(a, b, y), z, 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 <= -2.3e+95) tmp = t_1; elseif (a <= 1.25e+52) tmp = fma(fma(a, b, y), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * z + t), $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[a, -2.3e+95], t$95$1, If[LessEqual[a, 1.25e+52], N[(N[(a * b + y), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{if}\;a \leq -2.3 \cdot 10^{+95}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.25 \cdot 10^{+52}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if a < -2.3e95 or 1.25e52 < a Initial program 92.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.5%
Applied rewrites50.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.5%
Applied rewrites50.5%
if -2.3e95 < a < 1.25e52Initial program 92.1%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6495.0%
Applied rewrites95.0%
Taylor expanded in x around 0
lower-*.f6469.8%
Applied rewrites69.8%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6474.8%
Applied rewrites74.8%
+-commutative74.8%
distribute-rgt-in74.8%
associate-*l*74.8%
*-commutative74.8%
+-commutative74.8%
associate-+r+74.8%
associate-+r+74.8%
+-commutative74.8%
*-commutative74.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6474.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-fma.f6474.8%
Applied rewrites74.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b z t) a))) (if (<= a -2.3e+95) t_1 (if (<= a 1.25e+52) (* (fma a b y) z) 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 <= -2.3e+95) {
tmp = t_1;
} else if (a <= 1.25e+52) {
tmp = fma(a, b, y) * z;
} 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 <= -2.3e+95) tmp = t_1; elseif (a <= 1.25e+52) tmp = Float64(fma(a, b, y) * z); 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, -2.3e+95], t$95$1, If[LessEqual[a, 1.25e+52], N[(N[(a * b + y), $MachinePrecision] * z), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{if}\;a \leq -2.3 \cdot 10^{+95}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.25 \cdot 10^{+52}:\\
\;\;\;\;\mathsf{fma}\left(a, b, y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if a < -2.3e95 or 1.25e52 < a Initial program 92.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.5%
Applied rewrites50.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.5%
Applied rewrites50.5%
if -2.3e95 < a < 1.25e52Initial program 92.1%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6449.9%
Applied rewrites49.9%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f64N/A
lower-*.f6449.9%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6449.9%
Applied rewrites49.9%
(FPCore (x y z t a b) :precision binary64 (if (<= t -9.4e+78) (* a t) (if (<= t 3.1e+168) (* (fma a b y) z) (* a t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -9.4e+78) {
tmp = a * t;
} else if (t <= 3.1e+168) {
tmp = fma(a, b, y) * z;
} else {
tmp = a * t;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -9.4e+78) tmp = Float64(a * t); elseif (t <= 3.1e+168) tmp = Float64(fma(a, b, y) * z); else tmp = Float64(a * t); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -9.4e+78], N[(a * t), $MachinePrecision], If[LessEqual[t, 3.1e+168], N[(N[(a * b + y), $MachinePrecision] * z), $MachinePrecision], N[(a * t), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;t \leq -9.4 \cdot 10^{+78}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;t \leq 3.1 \cdot 10^{+168}:\\
\;\;\;\;\mathsf{fma}\left(a, b, y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
if t < -9.4000000000000001e78 or 3.1e168 < t Initial program 92.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.5%
Applied rewrites50.5%
Taylor expanded in z around 0
Applied rewrites28.1%
if -9.4000000000000001e78 < t < 3.1e168Initial program 92.1%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6449.9%
Applied rewrites49.9%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f64N/A
lower-*.f6449.9%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6449.9%
Applied rewrites49.9%
(FPCore (x y z t a b) :precision binary64 (if (<= a -3.2e-25) (* a (* b z)) (if (<= a 1.25e+52) (* y z) (* a t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -3.2e-25) {
tmp = a * (b * z);
} else if (a <= 1.25e+52) {
tmp = y * z;
} else {
tmp = a * t;
}
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 (a <= (-3.2d-25)) then
tmp = a * (b * z)
else if (a <= 1.25d+52) then
tmp = y * z
else
tmp = a * t
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 (a <= -3.2e-25) {
tmp = a * (b * z);
} else if (a <= 1.25e+52) {
tmp = y * z;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if a <= -3.2e-25: tmp = a * (b * z) elif a <= 1.25e+52: tmp = y * z else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -3.2e-25) tmp = Float64(a * Float64(b * z)); elseif (a <= 1.25e+52) tmp = Float64(y * z); else tmp = Float64(a * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (a <= -3.2e-25) tmp = a * (b * z); elseif (a <= 1.25e+52) tmp = y * z; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -3.2e-25], N[(a * N[(b * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.25e+52], N[(y * z), $MachinePrecision], N[(a * t), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;a \leq -3.2 \cdot 10^{-25}:\\
\;\;\;\;a \cdot \left(b \cdot z\right)\\
\mathbf{elif}\;a \leq 1.25 \cdot 10^{+52}:\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
if a < -3.2000000000000001e-25Initial program 92.1%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6449.9%
Applied rewrites49.9%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f6426.7%
Applied rewrites26.7%
if -3.2000000000000001e-25 < a < 1.25e52Initial program 92.1%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6495.0%
Applied rewrites95.0%
Taylor expanded in y around inf
lower-*.f6427.3%
Applied rewrites27.3%
if 1.25e52 < a Initial program 92.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.5%
Applied rewrites50.5%
Taylor expanded in z around 0
Applied rewrites28.1%
(FPCore (x y z t a b) :precision binary64 (if (<= a -2.3e+95) (* a t) (if (<= a 1.25e+52) (* y z) (* a t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -2.3e+95) {
tmp = a * t;
} else if (a <= 1.25e+52) {
tmp = y * z;
} else {
tmp = a * t;
}
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 (a <= (-2.3d+95)) then
tmp = a * t
else if (a <= 1.25d+52) then
tmp = y * z
else
tmp = a * t
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 (a <= -2.3e+95) {
tmp = a * t;
} else if (a <= 1.25e+52) {
tmp = y * z;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if a <= -2.3e+95: tmp = a * t elif a <= 1.25e+52: tmp = y * z else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -2.3e+95) tmp = Float64(a * t); elseif (a <= 1.25e+52) tmp = Float64(y * z); else tmp = Float64(a * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (a <= -2.3e+95) tmp = a * t; elseif (a <= 1.25e+52) tmp = y * z; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -2.3e+95], N[(a * t), $MachinePrecision], If[LessEqual[a, 1.25e+52], N[(y * z), $MachinePrecision], N[(a * t), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;a \leq -2.3 \cdot 10^{+95}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;a \leq 1.25 \cdot 10^{+52}:\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
if a < -2.3e95 or 1.25e52 < a Initial program 92.1%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.5%
Applied rewrites50.5%
Taylor expanded in z around 0
Applied rewrites28.1%
if -2.3e95 < a < 1.25e52Initial program 92.1%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6495.0%
Applied rewrites95.0%
Taylor expanded in y around inf
lower-*.f6427.3%
Applied rewrites27.3%
(FPCore (x y z t a b) :precision binary64 (* y z))
double code(double x, double y, double z, double t, double a, double b) {
return y * z;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, 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 = y * z
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return y * z;
}
def code(x, y, z, t, a, b): return y * z
function code(x, y, z, t, a, b) return Float64(y * z) end
function tmp = code(x, y, z, t, a, b) tmp = y * z; end
code[x_, y_, z_, t_, a_, b_] := N[(y * z), $MachinePrecision]
y \cdot z
Initial program 92.1%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6495.0%
Applied rewrites95.0%
Taylor expanded in y around inf
lower-*.f6427.3%
Applied rewrites27.3%
herbie shell --seed 2025193
(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)))