
(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 (let* ((t_1 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))) (if (<= t_1 INFINITY) t_1 (fma (fma b z t) a x))))
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 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(fma(b, z, t), a, x);
}
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 <= Inf) tmp = t_1; else tmp = fma(fma(b, z, t), a, x); 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, Infinity], t$95$1, N[(N[(b * z + t), $MachinePrecision] * a + x), $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 \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < +inf.0Initial program 97.7%
if +inf.0 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 0.0%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6475.5
Applied rewrites75.5%
(FPCore (x y z t a b) :precision binary64 (if (<= b -1.45e+106) (fma (* a z) b x) (if (<= b 8.6e+144) (fma a t (fma z y 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 (b <= -1.45e+106) {
tmp = fma((a * z), b, x);
} else if (b <= 8.6e+144) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = fma(fma(b, z, t), a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -1.45e+106) tmp = fma(Float64(a * z), b, x); elseif (b <= 8.6e+144) tmp = fma(a, t, fma(z, y, x)); else tmp = fma(fma(b, z, t), a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -1.45e+106], N[(N[(a * z), $MachinePrecision] * b + x), $MachinePrecision], If[LessEqual[b, 8.6e+144], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{+106}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot z, b, x\right)\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{+144}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\end{array}
\end{array}
if b < -1.4500000000000001e106Initial program 92.4%
Taylor expanded in x around inf
Applied rewrites71.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-*.f6471.0
+-commutative71.0
*-commutative71.0
*-commutative71.0
+-commutative71.0
Applied rewrites71.0%
if -1.4500000000000001e106 < b < 8.59999999999999968e144Initial program 92.8%
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
lower-fma.f6486.9
Applied rewrites86.9%
if 8.59999999999999968e144 < b Initial program 90.7%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6484.5
Applied rewrites84.5%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (* a z) b x))) (if (<= b -1.45e+106) t_1 (if (<= b 1.85e+145) (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((a * z), b, x);
double tmp;
if (b <= -1.45e+106) {
tmp = t_1;
} else if (b <= 1.85e+145) {
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(Float64(a * z), b, x) tmp = 0.0 if (b <= -1.45e+106) tmp = t_1; elseif (b <= 1.85e+145) 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[(a * z), $MachinePrecision] * b + x), $MachinePrecision]}, If[LessEqual[b, -1.45e+106], t$95$1, If[LessEqual[b, 1.85e+145], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a \cdot z, b, x\right)\\
\mathbf{if}\;b \leq -1.45 \cdot 10^{+106}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 1.85 \cdot 10^{+145}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -1.4500000000000001e106 or 1.84999999999999997e145 < b Initial program 91.7%
Taylor expanded in x around inf
Applied rewrites72.8%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-*.f6472.8
+-commutative72.8
*-commutative72.8
*-commutative72.8
+-commutative72.8
Applied rewrites72.8%
if -1.4500000000000001e106 < b < 1.84999999999999997e145Initial program 92.8%
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
lower-fma.f6486.8
Applied rewrites86.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b z t) a))) (if (<= a -3.4e-6) t_1 (if (<= a 6.2e-34) (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 <= -3.4e-6) {
tmp = t_1;
} else if (a <= 6.2e-34) {
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 <= -3.4e-6) tmp = t_1; elseif (a <= 6.2e-34) 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, -3.4e-6], t$95$1, If[LessEqual[a, 6.2e-34], 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 -3.4 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 6.2 \cdot 10^{-34}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -3.40000000000000006e-6 or 6.1999999999999996e-34 < a Initial program 86.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6474.0
Applied rewrites74.0%
if -3.40000000000000006e-6 < a < 6.1999999999999996e-34Initial program 99.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6474.9
Applied rewrites74.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b a y) z))) (if (<= z -2.15e-41) t_1 (if (<= z 2.8e-82) (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 <= -2.15e-41) {
tmp = t_1;
} else if (z <= 2.8e-82) {
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 <= -2.15e-41) tmp = t_1; elseif (z <= 2.8e-82) 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, -2.15e-41], t$95$1, If[LessEqual[z, 2.8e-82], 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.15 \cdot 10^{-41}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-82}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.1499999999999999e-41 or 2.80000000000000024e-82 < z Initial program 88.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6470.1
Applied rewrites70.1%
if -2.1499999999999999e-41 < z < 2.80000000000000024e-82Initial program 99.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6479.6
Applied rewrites79.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (* z a) b)))
(if (<= a -1.45e+227)
t_1
(if (<= a -0.3)
(fma a t x)
(if (<= a 0.038) (fma z y x) (if (<= a 3.3e+118) (fma a t x) t_1))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z * a) * b;
double tmp;
if (a <= -1.45e+227) {
tmp = t_1;
} else if (a <= -0.3) {
tmp = fma(a, t, x);
} else if (a <= 0.038) {
tmp = fma(z, y, x);
} else if (a <= 3.3e+118) {
tmp = fma(a, t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(z * a) * b) tmp = 0.0 if (a <= -1.45e+227) tmp = t_1; elseif (a <= -0.3) tmp = fma(a, t, x); elseif (a <= 0.038) tmp = fma(z, y, x); elseif (a <= 3.3e+118) 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[(z * a), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[a, -1.45e+227], t$95$1, If[LessEqual[a, -0.3], N[(a * t + x), $MachinePrecision], If[LessEqual[a, 0.038], N[(z * y + x), $MachinePrecision], If[LessEqual[a, 3.3e+118], N[(a * t + x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z \cdot a\right) \cdot b\\
\mathbf{if}\;a \leq -1.45 \cdot 10^{+227}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -0.3:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;a \leq 0.038:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;a \leq 3.3 \cdot 10^{+118}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -1.4499999999999999e227 or 3.3e118 < a Initial program 80.8%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6447.5
Applied rewrites47.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6447.2
Applied rewrites47.2%
if -1.4499999999999999e227 < a < -0.299999999999999989 or 0.0379999999999999991 < a < 3.3e118Initial program 89.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6453.1
Applied rewrites53.1%
if -0.299999999999999989 < a < 0.0379999999999999991Initial program 99.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6473.4
Applied rewrites73.4%
(FPCore (x y z t a b)
:precision binary64
(if (<= a -1.42e+227)
(* (* b z) a)
(if (<= a -0.3)
(fma a t x)
(if (<= a 0.038)
(fma z y x)
(if (<= a 6e+108) (fma a t x) (* (* b a) z))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -1.42e+227) {
tmp = (b * z) * a;
} else if (a <= -0.3) {
tmp = fma(a, t, x);
} else if (a <= 0.038) {
tmp = fma(z, y, x);
} else if (a <= 6e+108) {
tmp = fma(a, t, x);
} else {
tmp = (b * a) * z;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -1.42e+227) tmp = Float64(Float64(b * z) * a); elseif (a <= -0.3) tmp = fma(a, t, x); elseif (a <= 0.038) tmp = fma(z, y, x); elseif (a <= 6e+108) tmp = fma(a, t, x); else tmp = Float64(Float64(b * a) * z); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -1.42e+227], N[(N[(b * z), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[a, -0.3], N[(a * t + x), $MachinePrecision], If[LessEqual[a, 0.038], N[(z * y + x), $MachinePrecision], If[LessEqual[a, 6e+108], N[(a * t + x), $MachinePrecision], N[(N[(b * a), $MachinePrecision] * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.42 \cdot 10^{+227}:\\
\;\;\;\;\left(b \cdot z\right) \cdot a\\
\mathbf{elif}\;a \leq -0.3:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;a \leq 0.038:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;a \leq 6 \cdot 10^{+108}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot a\right) \cdot z\\
\end{array}
\end{array}
if a < -1.41999999999999992e227Initial program 78.4%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6449.3
Applied rewrites49.3%
if -1.41999999999999992e227 < a < -0.299999999999999989 or 0.0379999999999999991 < a < 5.99999999999999968e108Initial program 90.1%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6453.2
Applied rewrites53.2%
if -0.299999999999999989 < a < 0.0379999999999999991Initial program 99.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6473.4
Applied rewrites73.4%
if 5.99999999999999968e108 < a Initial program 90.1%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6448.8
Applied rewrites48.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6433.5
Applied rewrites33.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (* b a) z)))
(if (<= a -1.45e+227)
t_1
(if (<= a -0.3)
(fma a t x)
(if (<= a 0.038) (fma z y x) (if (<= a 6e+108) (fma a t x) t_1))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (b * a) * z;
double tmp;
if (a <= -1.45e+227) {
tmp = t_1;
} else if (a <= -0.3) {
tmp = fma(a, t, x);
} else if (a <= 0.038) {
tmp = fma(z, y, x);
} else if (a <= 6e+108) {
tmp = fma(a, t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(b * a) * z) tmp = 0.0 if (a <= -1.45e+227) tmp = t_1; elseif (a <= -0.3) tmp = fma(a, t, x); elseif (a <= 0.038) tmp = fma(z, y, x); elseif (a <= 6e+108) 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), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[a, -1.45e+227], t$95$1, If[LessEqual[a, -0.3], N[(a * t + x), $MachinePrecision], If[LessEqual[a, 0.038], N[(z * y + x), $MachinePrecision], If[LessEqual[a, 6e+108], N[(a * t + x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(b \cdot a\right) \cdot z\\
\mathbf{if}\;a \leq -1.45 \cdot 10^{+227}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -0.3:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;a \leq 0.038:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;a \leq 6 \cdot 10^{+108}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -1.4499999999999999e227 or 5.99999999999999968e108 < a Initial program 80.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6453.0
Applied rewrites53.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6446.0
Applied rewrites46.0%
if -1.4499999999999999e227 < a < -0.299999999999999989 or 0.0379999999999999991 < a < 5.99999999999999968e108Initial program 90.1%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6453.2
Applied rewrites53.2%
if -0.299999999999999989 < a < 0.0379999999999999991Initial program 99.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6473.4
Applied rewrites73.4%
(FPCore (x y z t a b) :precision binary64 (if (<= t -4.6e+17) (fma a t x) (if (<= t 1.15e+149) (fma z y x) (fma a t x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -4.6e+17) {
tmp = fma(a, t, x);
} else if (t <= 1.15e+149) {
tmp = fma(z, y, x);
} else {
tmp = fma(a, t, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -4.6e+17) tmp = fma(a, t, x); elseif (t <= 1.15e+149) tmp = fma(z, y, x); else tmp = fma(a, t, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -4.6e+17], N[(a * t + x), $MachinePrecision], If[LessEqual[t, 1.15e+149], N[(z * y + x), $MachinePrecision], N[(a * t + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.6 \cdot 10^{+17}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;t \leq 1.15 \cdot 10^{+149}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\end{array}
\end{array}
if t < -4.6e17 or 1.1499999999999999e149 < t Initial program 90.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6467.9
Applied rewrites67.9%
if -4.6e17 < t < 1.1499999999999999e149Initial program 93.7%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6459.5
Applied rewrites59.5%
(FPCore (x y z t a b) :precision binary64 (if (<= z -7.5e+187) (* z y) (if (<= z 6e+187) (fma a t x) (* z y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -7.5e+187) {
tmp = z * y;
} else if (z <= 6e+187) {
tmp = fma(a, t, x);
} else {
tmp = z * y;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -7.5e+187) tmp = Float64(z * y); elseif (z <= 6e+187) tmp = fma(a, t, x); else tmp = Float64(z * y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -7.5e+187], N[(z * y), $MachinePrecision], If[LessEqual[z, 6e+187], N[(a * t + x), $MachinePrecision], N[(z * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{+187}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+187}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot y\\
\end{array}
\end{array}
if z < -7.5000000000000002e187 or 5.9999999999999998e187 < z Initial program 78.5%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6448.2
Applied rewrites48.2%
if -7.5000000000000002e187 < z < 5.9999999999999998e187Initial program 95.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6460.8
Applied rewrites60.8%
(FPCore (x y z t a b) :precision binary64 (if (<= t -5.2e+17) (* a t) (if (<= t 2.05e-125) x (if (<= t 1.15e+149) (* z y) (* a t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -5.2e+17) {
tmp = a * t;
} else if (t <= 2.05e-125) {
tmp = x;
} else if (t <= 1.15e+149) {
tmp = z * y;
} 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 (t <= (-5.2d+17)) then
tmp = a * t
else if (t <= 2.05d-125) then
tmp = x
else if (t <= 1.15d+149) then
tmp = z * y
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 (t <= -5.2e+17) {
tmp = a * t;
} else if (t <= 2.05e-125) {
tmp = x;
} else if (t <= 1.15e+149) {
tmp = z * y;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -5.2e+17: tmp = a * t elif t <= 2.05e-125: tmp = x elif t <= 1.15e+149: tmp = z * y else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -5.2e+17) tmp = Float64(a * t); elseif (t <= 2.05e-125) tmp = x; elseif (t <= 1.15e+149) tmp = Float64(z * y); else tmp = Float64(a * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -5.2e+17) tmp = a * t; elseif (t <= 2.05e-125) tmp = x; elseif (t <= 1.15e+149) tmp = z * y; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -5.2e+17], N[(a * t), $MachinePrecision], If[LessEqual[t, 2.05e-125], x, If[LessEqual[t, 1.15e+149], N[(z * y), $MachinePrecision], N[(a * t), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.2 \cdot 10^{+17}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;t \leq 2.05 \cdot 10^{-125}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 1.15 \cdot 10^{+149}:\\
\;\;\;\;z \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if t < -5.2e17 or 1.1499999999999999e149 < t Initial program 90.3%
Taylor expanded in t around inf
lower-*.f6451.2
Applied rewrites51.2%
if -5.2e17 < t < 2.0499999999999999e-125Initial program 93.8%
Taylor expanded in x around inf
Applied rewrites33.1%
if 2.0499999999999999e-125 < t < 1.1499999999999999e149Initial program 93.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6428.8
Applied rewrites28.8%
(FPCore (x y z t a b) :precision binary64 (if (<= t -5.2e+17) (* a t) (if (<= t 1.15e+149) x (* a t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -5.2e+17) {
tmp = a * t;
} else if (t <= 1.15e+149) {
tmp = x;
} 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 (t <= (-5.2d+17)) then
tmp = a * t
else if (t <= 1.15d+149) then
tmp = x
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 (t <= -5.2e+17) {
tmp = a * t;
} else if (t <= 1.15e+149) {
tmp = x;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -5.2e+17: tmp = a * t elif t <= 1.15e+149: tmp = x else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -5.2e+17) tmp = Float64(a * t); elseif (t <= 1.15e+149) tmp = x; else tmp = Float64(a * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -5.2e+17) tmp = a * t; elseif (t <= 1.15e+149) tmp = x; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -5.2e+17], N[(a * t), $MachinePrecision], If[LessEqual[t, 1.15e+149], x, N[(a * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.2 \cdot 10^{+17}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;t \leq 1.15 \cdot 10^{+149}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if t < -5.2e17 or 1.1499999999999999e149 < t Initial program 90.3%
Taylor expanded in t around inf
lower-*.f6451.2
Applied rewrites51.2%
if -5.2e17 < t < 1.1499999999999999e149Initial program 93.7%
Taylor expanded in x around inf
Applied rewrites31.1%
(FPCore (x y z t a b) :precision binary64 x)
double code(double x, double y, double z, double t, double a, double b) {
return x;
}
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
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x;
}
def code(x, y, z, t, a, b): return x
function code(x, y, z, t, a, b) return x end
function tmp = code(x, y, z, t, a, b) tmp = x; end
code[x_, y_, z_, t_, a_, b_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 92.4%
Taylor expanded in x around inf
Applied rewrites26.5%
herbie shell --seed 2025117
(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)))