
(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 11 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 (+ (+ (+ 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}
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}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < +inf.0Initial program 92.0%
if +inf.0 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 92.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6449.6%
Applied rewrites49.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6449.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6449.6%
Applied rewrites49.6%
(FPCore (x y z t a b) :precision binary64 (fma z (fma b a y) (fma a t x)))
double code(double x, double y, double z, double t, double a, double b) {
return fma(z, fma(b, a, y), fma(a, t, x));
}
function code(x, y, z, t, a, b) return fma(z, fma(b, a, y), fma(a, t, x)) end
code[x_, y_, z_, t_, a_, b_] := N[(z * N[(b * a + y), $MachinePrecision] + N[(a * t + x), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(z, \mathsf{fma}\left(b, a, y\right), \mathsf{fma}\left(a, t, x\right)\right)
Initial program 92.0%
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.f6494.8%
Applied rewrites94.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma z y (fma a t x)))) (if (<= y -850000.0) t_1 (if (<= y 1.15e+31) (fma (fma b z t) a x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(z, y, fma(a, t, x));
double tmp;
if (y <= -850000.0) {
tmp = t_1;
} else if (y <= 1.15e+31) {
tmp = fma(fma(b, z, t), a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(z, y, fma(a, t, x)) tmp = 0.0 if (y <= -850000.0) tmp = t_1; elseif (y <= 1.15e+31) tmp = fma(fma(b, z, t), a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(z * y + N[(a * t + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -850000.0], t$95$1, If[LessEqual[y, 1.15e+31], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, y, \mathsf{fma}\left(a, t, x\right)\right)\\
\mathbf{if}\;y \leq -850000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{+31}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -8.5e5 or 1.15e31 < y Initial program 92.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6473.2%
Applied rewrites73.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.1%
Applied rewrites74.1%
Taylor expanded in b around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f6478.0%
Applied rewrites78.0%
lift-+.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+r+N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6477.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6477.8%
Applied rewrites77.8%
if -8.5e5 < y < 1.15e31Initial program 92.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6473.2%
Applied rewrites73.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.1%
Applied rewrites74.1%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b z t) a))) (if (<= a -9e+96) t_1 (if (<= a 3.3e+148) (fma z 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(b, z, t) * a;
double tmp;
if (a <= -9e+96) {
tmp = t_1;
} else if (a <= 3.3e+148) {
tmp = fma(z, y, fma(a, t, 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 <= -9e+96) tmp = t_1; elseif (a <= 3.3e+148) tmp = fma(z, 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), $MachinePrecision]}, If[LessEqual[a, -9e+96], t$95$1, If[LessEqual[a, 3.3e+148], N[(z * y + N[(a * t + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{if}\;a \leq -9 \cdot 10^{+96}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 3.3 \cdot 10^{+148}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(a, t, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if a < -8.9999999999999991e96 or 3.3000000000000001e148 < a Initial program 92.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6449.6%
Applied rewrites49.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6449.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6449.6%
Applied rewrites49.6%
if -8.9999999999999991e96 < a < 3.3000000000000001e148Initial program 92.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6473.2%
Applied rewrites73.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.1%
Applied rewrites74.1%
Taylor expanded in b around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f6478.0%
Applied rewrites78.0%
lift-+.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+r+N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6477.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6477.8%
Applied rewrites77.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b z t) a))) (if (<= a -3e+69) t_1 (if (<= a 6.5e-6) (+ x (* 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 <= -3e+69) {
tmp = t_1;
} else if (a <= 6.5e-6) {
tmp = x + (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 <= -3e+69) tmp = t_1; elseif (a <= 6.5e-6) tmp = Float64(x + Float64(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, -3e+69], t$95$1, If[LessEqual[a, 6.5e-6], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{if}\;a \leq -3 \cdot 10^{+69}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 6.5 \cdot 10^{-6}:\\
\;\;\;\;x + y \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if a < -2.9999999999999998e69 or 6.4999999999999996e-6 < a Initial program 92.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6449.6%
Applied rewrites49.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6449.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6449.6%
Applied rewrites49.6%
if -2.9999999999999998e69 < a < 6.4999999999999996e-6Initial program 92.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6473.2%
Applied rewrites73.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.1%
Applied rewrites74.1%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f6453.6%
Applied rewrites53.6%
(FPCore (x y z t a b)
:precision binary64
(if (<= t -5.9e+88)
(fma t a x)
(if (<= t -5.7e-61)
(* (fma a b y) z)
(if (<= t 2e-77) (+ x (* y z)) (fma t a x)))))double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -5.9e+88) {
tmp = fma(t, a, x);
} else if (t <= -5.7e-61) {
tmp = fma(a, b, y) * z;
} else if (t <= 2e-77) {
tmp = x + (y * z);
} else {
tmp = fma(t, a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -5.9e+88) tmp = fma(t, a, x); elseif (t <= -5.7e-61) tmp = Float64(fma(a, b, y) * z); elseif (t <= 2e-77) tmp = Float64(x + Float64(y * z)); else tmp = fma(t, a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -5.9e+88], N[(t * a + x), $MachinePrecision], If[LessEqual[t, -5.7e-61], N[(N[(a * b + y), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t, 2e-77], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision], N[(t * a + x), $MachinePrecision]]]]
\begin{array}{l}
\mathbf{if}\;t \leq -5.9 \cdot 10^{+88}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{elif}\;t \leq -5.7 \cdot 10^{-61}:\\
\;\;\;\;\mathsf{fma}\left(a, b, y\right) \cdot z\\
\mathbf{elif}\;t \leq 2 \cdot 10^{-77}:\\
\;\;\;\;x + y \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\end{array}
if t < -5.8999999999999997e88 or 1.9999999999999999e-77 < t Initial program 92.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6473.2%
Applied rewrites73.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.1%
Applied rewrites74.1%
Taylor expanded in z around 0
Applied rewrites52.1%
if -5.8999999999999997e88 < t < -5.7000000000000001e-61Initial program 92.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6451.0%
Applied rewrites51.0%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f64N/A
lower-*.f6451.0%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6451.0%
Applied rewrites51.0%
if -5.7000000000000001e-61 < t < 1.9999999999999999e-77Initial program 92.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6473.2%
Applied rewrites73.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.1%
Applied rewrites74.1%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f6453.6%
Applied rewrites53.6%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma a t (* y z)))) (if (<= y -31.0) t_1 (if (<= y 9.2e+50) (fma t a x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(a, t, (y * z));
double tmp;
if (y <= -31.0) {
tmp = t_1;
} else if (y <= 9.2e+50) {
tmp = fma(t, a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(a, t, Float64(y * z)) tmp = 0.0 if (y <= -31.0) tmp = t_1; elseif (y <= 9.2e+50) tmp = fma(t, a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a * t + N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -31.0], t$95$1, If[LessEqual[y, 9.2e+50], N[(t * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, t, y \cdot z\right)\\
\mathbf{if}\;y \leq -31:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+50}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -31 or 9.1999999999999999e50 < y Initial program 92.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6473.2%
Applied rewrites73.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.1%
Applied rewrites74.1%
Taylor expanded in b around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f6478.0%
Applied rewrites78.0%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6453.1%
Applied rewrites53.1%
if -31 < y < 9.1999999999999999e50Initial program 92.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6473.2%
Applied rewrites73.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.1%
Applied rewrites74.1%
Taylor expanded in z around 0
Applied rewrites52.1%
(FPCore (x y z t a b) :precision binary64 (if (<= t -5.8e+71) (fma t a x) (if (<= t 2e-77) (+ x (* y z)) (fma t a x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -5.8e+71) {
tmp = fma(t, a, x);
} else if (t <= 2e-77) {
tmp = x + (y * z);
} else {
tmp = fma(t, a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -5.8e+71) tmp = fma(t, a, x); elseif (t <= 2e-77) tmp = Float64(x + Float64(y * z)); else tmp = fma(t, a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -5.8e+71], N[(t * a + x), $MachinePrecision], If[LessEqual[t, 2e-77], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision], N[(t * a + x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;t \leq -5.8 \cdot 10^{+71}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{elif}\;t \leq 2 \cdot 10^{-77}:\\
\;\;\;\;x + y \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\end{array}
if t < -5.8000000000000001e71 or 1.9999999999999999e-77 < t Initial program 92.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6473.2%
Applied rewrites73.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.1%
Applied rewrites74.1%
Taylor expanded in z around 0
Applied rewrites52.1%
if -5.8000000000000001e71 < t < 1.9999999999999999e-77Initial program 92.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6473.2%
Applied rewrites73.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.1%
Applied rewrites74.1%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f6453.6%
Applied rewrites53.6%
(FPCore (x y z t a b) :precision binary64 (if (<= y -31.0) (* y z) (if (<= y 6.5e+139) (fma t a x) (* y z))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -31.0) {
tmp = y * z;
} else if (y <= 6.5e+139) {
tmp = fma(t, a, x);
} else {
tmp = y * z;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -31.0) tmp = Float64(y * z); elseif (y <= 6.5e+139) tmp = fma(t, a, x); else tmp = Float64(y * z); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -31.0], N[(y * z), $MachinePrecision], If[LessEqual[y, 6.5e+139], N[(t * a + x), $MachinePrecision], N[(y * z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -31:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+139}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
if y < -31 or 6.5000000000000003e139 < y Initial program 92.0%
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.f6494.8%
Applied rewrites94.8%
Taylor expanded in y around inf
lower-*.f6429.0%
Applied rewrites29.0%
if -31 < y < 6.5000000000000003e139Initial program 92.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6473.2%
Applied rewrites73.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
*-commutativeN/A
lower-fma.f6474.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6474.1%
Applied rewrites74.1%
Taylor expanded in z around 0
Applied rewrites52.1%
(FPCore (x y z t a b) :precision binary64 (if (<= t -5.8e+71) (* a t) (if (<= t 2e-77) (* y z) (* a t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -5.8e+71) {
tmp = a * t;
} else if (t <= 2e-77) {
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 (t <= (-5.8d+71)) then
tmp = a * t
else if (t <= 2d-77) 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 (t <= -5.8e+71) {
tmp = a * t;
} else if (t <= 2e-77) {
tmp = y * z;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -5.8e+71: tmp = a * t elif t <= 2e-77: tmp = y * z else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -5.8e+71) tmp = Float64(a * t); elseif (t <= 2e-77) 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 (t <= -5.8e+71) tmp = a * t; elseif (t <= 2e-77) tmp = y * z; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -5.8e+71], N[(a * t), $MachinePrecision], If[LessEqual[t, 2e-77], N[(y * z), $MachinePrecision], N[(a * t), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;t \leq -5.8 \cdot 10^{+71}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;t \leq 2 \cdot 10^{-77}:\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
if t < -5.8000000000000001e71 or 1.9999999999999999e-77 < t Initial program 92.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6449.6%
Applied rewrites49.6%
Taylor expanded in z around 0
Applied rewrites27.4%
if -5.8000000000000001e71 < t < 1.9999999999999999e-77Initial program 92.0%
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.f6494.8%
Applied rewrites94.8%
Taylor expanded in y around inf
lower-*.f6429.0%
Applied rewrites29.0%
(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.0%
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.f6494.8%
Applied rewrites94.8%
Taylor expanded in y around inf
lower-*.f6429.0%
Applied rewrites29.0%
herbie shell --seed 2025191
(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)))