
(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 INFINITY) t_1 (* (fma b z t) a))))
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(b, z, t) * a;
}
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 = Float64(fma(b, z, t) * a); 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), $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(b, z, t\right) \cdot a\\
\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 a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6474.8
Applied rewrites74.8%
(FPCore (x y z t a b)
:precision binary64
(if (<= z -1.85e+138)
(* (fma b a y) z)
(if (<= z 9.6e-67)
(fma a t (fma z y x))
(* (+ (/ (fma (fma b a y) z x) t) a) t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -1.85e+138) {
tmp = fma(b, a, y) * z;
} else if (z <= 9.6e-67) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = ((fma(fma(b, a, y), z, x) / t) + a) * t;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -1.85e+138) tmp = Float64(fma(b, a, y) * z); elseif (z <= 9.6e-67) tmp = fma(a, t, fma(z, y, x)); else tmp = Float64(Float64(Float64(fma(fma(b, a, y), z, x) / t) + a) * t); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -1.85e+138], N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 9.6e-67], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision] / t), $MachinePrecision] + a), $MachinePrecision] * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.85 \cdot 10^{+138}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{elif}\;z \leq 9.6 \cdot 10^{-67}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)}{t} + a\right) \cdot t\\
\end{array}
\end{array}
if z < -1.8499999999999999e138Initial program 81.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6484.6
Applied rewrites84.6%
if -1.8499999999999999e138 < z < 9.6e-67Initial program 97.4%
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.f6484.4
Applied rewrites84.4%
if 9.6e-67 < z Initial program 88.1%
Taylor expanded in t around inf
*-commutativeN/A
div-add-revN/A
div-addN/A
lower-*.f64N/A
Applied rewrites83.5%
(FPCore (x y z t a b) :precision binary64 (if (<= z -1.85e+138) (* (fma b a y) z) (if (<= z 4.0) (fma a t (fma z y x)) (fma (fma b z t) a (* z y)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -1.85e+138) {
tmp = fma(b, a, y) * z;
} else if (z <= 4.0) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = fma(fma(b, z, t), a, (z * y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -1.85e+138) tmp = Float64(fma(b, a, y) * z); elseif (z <= 4.0) tmp = fma(a, t, fma(z, y, x)); else tmp = fma(fma(b, z, t), a, Float64(z * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -1.85e+138], N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 4.0], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], N[(N[(b * z + t), $MachinePrecision] * a + N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.85 \cdot 10^{+138}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{elif}\;z \leq 4:\\
\;\;\;\;\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, z \cdot y\right)\\
\end{array}
\end{array}
if z < -1.8499999999999999e138Initial program 81.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6484.6
Applied rewrites84.6%
if -1.8499999999999999e138 < z < 4Initial program 97.5%
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.f6483.9
Applied rewrites83.9%
if 4 < z Initial program 85.8%
Taylor expanded in x around 0
associate-+r+N/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6476.7
Applied rewrites76.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b a y) z))) (if (<= z -1.85e+138) t_1 (if (<= z 5.3e+27) (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(b, a, y) * z;
double tmp;
if (z <= -1.85e+138) {
tmp = t_1;
} else if (z <= 5.3e+27) {
tmp = fma(a, t, fma(z, y, 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 <= -1.85e+138) tmp = t_1; elseif (z <= 5.3e+27) tmp = fma(a, t, fma(z, y, x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1.85e+138], t$95$1, If[LessEqual[z, 5.3e+27], N[(a * t + N[(z * y + x), $MachinePrecision]), $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 -1.85 \cdot 10^{+138}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5.3 \cdot 10^{+27}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.8499999999999999e138 or 5.3000000000000004e27 < z Initial program 83.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6479.9
Applied rewrites79.9%
if -1.8499999999999999e138 < z < 5.3000000000000004e27Initial program 97.4%
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.f6483.6
Applied rewrites83.6%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b z t) a))) (if (<= a -4.5e-42) t_1 (if (<= a 6e-112) (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 <= -4.5e-42) {
tmp = t_1;
} else if (a <= 6e-112) {
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 <= -4.5e-42) tmp = t_1; elseif (a <= 6e-112) 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, -4.5e-42], t$95$1, If[LessEqual[a, 6e-112], 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 -4.5 \cdot 10^{-42}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 6 \cdot 10^{-112}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -4.5e-42 or 6.0000000000000002e-112 < a Initial program 88.3%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6468.3
Applied rewrites68.3%
if -4.5e-42 < a < 6.0000000000000002e-112Initial program 99.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6479.1
Applied rewrites79.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (fma b a y) z)))
(if (<= z -3e+57)
t_1
(if (<= z -2e-230)
(fma z y x)
(if (<= z 1.45e-145) (* a t) (if (<= z 0.0009) (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, a, y) * z;
double tmp;
if (z <= -3e+57) {
tmp = t_1;
} else if (z <= -2e-230) {
tmp = fma(z, y, x);
} else if (z <= 1.45e-145) {
tmp = a * t;
} else if (z <= 0.0009) {
tmp = fma(z, y, 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 <= -3e+57) tmp = t_1; elseif (z <= -2e-230) tmp = fma(z, y, x); elseif (z <= 1.45e-145) tmp = Float64(a * t); elseif (z <= 0.0009) 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 * a + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -3e+57], t$95$1, If[LessEqual[z, -2e-230], N[(z * y + x), $MachinePrecision], If[LessEqual[z, 1.45e-145], N[(a * t), $MachinePrecision], If[LessEqual[z, 0.0009], N[(z * y + 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 \cdot 10^{+57}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -2 \cdot 10^{-230}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{-145}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;z \leq 0.0009:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3e57 or 8.9999999999999998e-4 < z Initial program 85.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6476.9
Applied rewrites76.9%
if -3e57 < z < -2.00000000000000009e-230 or 1.44999999999999992e-145 < z < 8.9999999999999998e-4Initial program 98.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6450.0
Applied rewrites50.0%
if -2.00000000000000009e-230 < z < 1.44999999999999992e-145Initial program 99.3%
Taylor expanded in t around inf
lower-*.f6442.2
Applied rewrites42.2%
(FPCore (x y z t a b)
:precision binary64
(if (<= a -1.9e+213)
(* (* b z) a)
(if (<= a -1.35e-32)
(* a t)
(if (<= a 7.6e+83)
(fma z y x)
(if (<= a 1.75e+268) (* (* a z) b) (* a t))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -1.9e+213) {
tmp = (b * z) * a;
} else if (a <= -1.35e-32) {
tmp = a * t;
} else if (a <= 7.6e+83) {
tmp = fma(z, y, x);
} else if (a <= 1.75e+268) {
tmp = (a * z) * b;
} else {
tmp = a * t;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -1.9e+213) tmp = Float64(Float64(b * z) * a); elseif (a <= -1.35e-32) tmp = Float64(a * t); elseif (a <= 7.6e+83) tmp = fma(z, y, x); elseif (a <= 1.75e+268) tmp = Float64(Float64(a * z) * b); else tmp = Float64(a * t); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -1.9e+213], N[(N[(b * z), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[a, -1.35e-32], N[(a * t), $MachinePrecision], If[LessEqual[a, 7.6e+83], N[(z * y + x), $MachinePrecision], If[LessEqual[a, 1.75e+268], N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision], N[(a * t), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.9 \cdot 10^{+213}:\\
\;\;\;\;\left(b \cdot z\right) \cdot a\\
\mathbf{elif}\;a \leq -1.35 \cdot 10^{-32}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;a \leq 7.6 \cdot 10^{+83}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;a \leq 1.75 \cdot 10^{+268}:\\
\;\;\;\;\left(a \cdot z\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if a < -1.8999999999999999e213Initial program 76.2%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6449.4
Applied rewrites49.4%
if -1.8999999999999999e213 < a < -1.3499999999999999e-32 or 1.74999999999999986e268 < a Initial program 88.8%
Taylor expanded in t around inf
lower-*.f6437.7
Applied rewrites37.7%
if -1.3499999999999999e-32 < a < 7.6000000000000004e83Initial program 98.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6471.3
Applied rewrites71.3%
if 7.6000000000000004e83 < a < 1.74999999999999986e268Initial program 84.0%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6443.1
Applied rewrites43.1%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f6444.5
Applied rewrites44.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (* a z) b)))
(if (<= a -1.9e+213)
t_1
(if (<= a -1.35e-32)
(* a t)
(if (<= a 7.6e+83) (fma z y x) (if (<= a 1.75e+268) t_1 (* a t)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * z) * b;
double tmp;
if (a <= -1.9e+213) {
tmp = t_1;
} else if (a <= -1.35e-32) {
tmp = a * t;
} else if (a <= 7.6e+83) {
tmp = fma(z, y, x);
} else if (a <= 1.75e+268) {
tmp = t_1;
} else {
tmp = a * t;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * z) * b) tmp = 0.0 if (a <= -1.9e+213) tmp = t_1; elseif (a <= -1.35e-32) tmp = Float64(a * t); elseif (a <= 7.6e+83) tmp = fma(z, y, x); elseif (a <= 1.75e+268) tmp = t_1; else tmp = Float64(a * t); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[a, -1.9e+213], t$95$1, If[LessEqual[a, -1.35e-32], N[(a * t), $MachinePrecision], If[LessEqual[a, 7.6e+83], N[(z * y + x), $MachinePrecision], If[LessEqual[a, 1.75e+268], t$95$1, N[(a * t), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a \cdot z\right) \cdot b\\
\mathbf{if}\;a \leq -1.9 \cdot 10^{+213}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq -1.35 \cdot 10^{-32}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;a \leq 7.6 \cdot 10^{+83}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;a \leq 1.75 \cdot 10^{+268}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if a < -1.8999999999999999e213 or 7.6000000000000004e83 < a < 1.74999999999999986e268Initial program 81.3%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6445.3
Applied rewrites45.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f6446.5
Applied rewrites46.5%
if -1.8999999999999999e213 < a < -1.3499999999999999e-32 or 1.74999999999999986e268 < a Initial program 88.8%
Taylor expanded in t around inf
lower-*.f6437.7
Applied rewrites37.7%
if -1.3499999999999999e-32 < a < 7.6000000000000004e83Initial program 98.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6471.3
Applied rewrites71.3%
(FPCore (x y z t a b) :precision binary64 (if (<= t -3.2e+88) (* a t) (if (<= t 2.5e+119) (fma z y x) (* a t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -3.2e+88) {
tmp = a * t;
} else if (t <= 2.5e+119) {
tmp = fma(z, y, x);
} else {
tmp = a * t;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -3.2e+88) tmp = Float64(a * t); elseif (t <= 2.5e+119) tmp = fma(z, y, x); else tmp = Float64(a * t); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -3.2e+88], N[(a * t), $MachinePrecision], If[LessEqual[t, 2.5e+119], N[(z * y + x), $MachinePrecision], N[(a * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.2 \cdot 10^{+88}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;t \leq 2.5 \cdot 10^{+119}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if t < -3.1999999999999999e88 or 2.5e119 < t Initial program 90.1%
Taylor expanded in t around inf
lower-*.f6456.1
Applied rewrites56.1%
if -3.1999999999999999e88 < t < 2.5e119Initial program 93.4%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6460.3
Applied rewrites60.3%
(FPCore (x y z t a b) :precision binary64 (if (<= a -2.6e-53) (* a t) (if (<= a 1.06e-106) (* z y) (* a t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -2.6e-53) {
tmp = a * t;
} else if (a <= 1.06e-106) {
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 (a <= (-2.6d-53)) then
tmp = a * t
else if (a <= 1.06d-106) 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 (a <= -2.6e-53) {
tmp = a * t;
} else if (a <= 1.06e-106) {
tmp = z * y;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if a <= -2.6e-53: tmp = a * t elif a <= 1.06e-106: tmp = z * y else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -2.6e-53) tmp = Float64(a * t); elseif (a <= 1.06e-106) 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 (a <= -2.6e-53) tmp = a * t; elseif (a <= 1.06e-106) tmp = z * y; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -2.6e-53], N[(a * t), $MachinePrecision], If[LessEqual[a, 1.06e-106], N[(z * y), $MachinePrecision], N[(a * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.6 \cdot 10^{-53}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;a \leq 1.06 \cdot 10^{-106}:\\
\;\;\;\;z \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if a < -2.59999999999999996e-53 or 1.06e-106 < a Initial program 88.4%
Taylor expanded in t around inf
lower-*.f6436.8
Applied rewrites36.8%
if -2.59999999999999996e-53 < a < 1.06e-106Initial program 99.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6440.8
Applied rewrites40.8%
(FPCore (x y z t a b) :precision binary64 (if (<= t -4.1e+22) (* a t) (if (<= t 1.8e-48) x (* a t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -4.1e+22) {
tmp = a * t;
} else if (t <= 1.8e-48) {
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 <= (-4.1d+22)) then
tmp = a * t
else if (t <= 1.8d-48) 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 <= -4.1e+22) {
tmp = a * t;
} else if (t <= 1.8e-48) {
tmp = x;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -4.1e+22: tmp = a * t elif t <= 1.8e-48: tmp = x else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -4.1e+22) tmp = Float64(a * t); elseif (t <= 1.8e-48) 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 <= -4.1e+22) tmp = a * t; elseif (t <= 1.8e-48) tmp = x; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -4.1e+22], N[(a * t), $MachinePrecision], If[LessEqual[t, 1.8e-48], x, N[(a * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.1 \cdot 10^{+22}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;t \leq 1.8 \cdot 10^{-48}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if t < -4.09999999999999979e22 or 1.8000000000000001e-48 < t Initial program 91.0%
Taylor expanded in t around inf
lower-*.f6445.4
Applied rewrites45.4%
if -4.09999999999999979e22 < t < 1.8000000000000001e-48Initial program 93.8%
Taylor expanded in x around inf
Applied rewrites33.6%
(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.3%
Taylor expanded in x around inf
Applied rewrites26.5%
herbie shell --seed 2025120
(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)))