
(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 10 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))
(+ (fma a t x) (* (fma b a y) z))
(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 = fma(a, t, x) + (fma(b, a, y) * z);
} else 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 <= Float64(-Inf)) tmp = Float64(fma(a, t, x) + Float64(fma(b, a, y) * z)); elseif (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)], N[(N[(a * t + x), $MachinePrecision] + N[(N[(b * a + y), $MachinePrecision] * z), $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:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right) + \mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{elif}\;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 92.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6494.3
Applied rewrites94.3%
if -inf.0 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < +inf.0Initial program 92.9%
if +inf.0 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 92.9%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.9
Applied rewrites74.9%
(FPCore (x y z t a b) :precision binary64 (if (<= a 1.8e+53) (+ (fma a t x) (* (fma b a y) z)) (fma (fma b z t) a x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= 1.8e+53) {
tmp = fma(a, t, x) + (fma(b, a, y) * z);
} else {
tmp = fma(fma(b, z, t), a, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= 1.8e+53) tmp = Float64(fma(a, t, x) + Float64(fma(b, a, y) * z)); else tmp = fma(fma(b, z, t), a, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, 1.8e+53], N[(N[(a * t + x), $MachinePrecision] + N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.8 \cdot 10^{+53}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right) + \mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\end{array}
\end{array}
if a < 1.8e53Initial program 92.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6494.3
Applied rewrites94.3%
if 1.8e53 < a Initial program 92.9%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.9
Applied rewrites74.9%
(FPCore (x y z t a b) :precision binary64 (if (<= z -8e+28) (fma (fma b a y) z (* a t)) (if (<= z 4000000.0) (fma (fma b z t) a x) (fma (fma b a y) z x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -8e+28) {
tmp = fma(fma(b, a, y), z, (a * t));
} else if (z <= 4000000.0) {
tmp = fma(fma(b, z, t), a, x);
} else {
tmp = fma(fma(b, a, y), z, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -8e+28) tmp = fma(fma(b, a, y), z, Float64(a * t)); elseif (z <= 4000000.0) tmp = fma(fma(b, z, t), a, x); else tmp = fma(fma(b, a, y), z, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -8e+28], N[(N[(b * a + y), $MachinePrecision] * z + N[(a * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4000000.0], N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{+28}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, a \cdot t\right)\\
\mathbf{elif}\;z \leq 4000000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\end{array}
\end{array}
if z < -7.99999999999999967e28Initial program 92.9%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.9
Applied rewrites74.9%
Taylor expanded in x around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-fma.f64N/A
lift-*.f6470.0
Applied rewrites70.0%
if -7.99999999999999967e28 < z < 4e6Initial program 92.9%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.9
Applied rewrites74.9%
if 4e6 < z Initial program 92.9%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6474.5
Applied rewrites74.5%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (fma b z t) a x))) (if (<= a -1e-25) t_1 (if (<= a 0.0105) (fma (fma b a y) z x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(fma(b, z, t), a, x);
double tmp;
if (a <= -1e-25) {
tmp = t_1;
} else if (a <= 0.0105) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(fma(b, z, t), a, x) tmp = 0.0 if (a <= -1e-25) tmp = t_1; elseif (a <= 0.0105) tmp = fma(fma(b, a, y), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * z + t), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[a, -1e-25], t$95$1, If[LessEqual[a, 0.0105], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{if}\;a \leq -1 \cdot 10^{-25}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 0.0105:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -1.00000000000000004e-25 or 0.0105000000000000007 < a Initial program 92.9%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.9
Applied rewrites74.9%
if -1.00000000000000004e-25 < a < 0.0105000000000000007Initial program 92.9%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6474.5
Applied rewrites74.5%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (fma b a y) z x))) (if (<= z -3.1e+21) t_1 (if (<= z 7e-127) (fma t a x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(fma(b, a, y), z, x);
double tmp;
if (z <= -3.1e+21) {
tmp = t_1;
} else if (z <= 7e-127) {
tmp = fma(t, a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(fma(b, a, y), z, x) tmp = 0.0 if (z <= -3.1e+21) tmp = t_1; elseif (z <= 7e-127) tmp = fma(t, a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[z, -3.1e+21], t$95$1, If[LessEqual[z, 7e-127], N[(t * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{if}\;z \leq -3.1 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-127}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.1e21 or 6.99999999999999979e-127 < z Initial program 92.9%
Taylor expanded in t around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6474.5
Applied rewrites74.5%
if -3.1e21 < z < 6.99999999999999979e-127Initial program 92.9%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.9
Applied rewrites74.9%
Taylor expanded in z around 0
Applied rewrites52.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b z t) a))) (if (<= a -1420000000.0) t_1 (if (<= a 0.00046) (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 <= -1420000000.0) {
tmp = t_1;
} else if (a <= 0.00046) {
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 <= -1420000000.0) tmp = t_1; elseif (a <= 0.00046) 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, -1420000000.0], t$95$1, If[LessEqual[a, 0.00046], 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 -1420000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 0.00046:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -1.42e9 or 4.6000000000000001e-4 < a Initial program 92.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6450.6
Applied rewrites50.6%
if -1.42e9 < a < 4.6000000000000001e-4Initial program 92.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6494.3
Applied rewrites94.3%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.0
Applied rewrites52.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b a y) z))) (if (<= z -3.2e+21) t_1 (if (<= z 7.5e-127) (fma t a x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(b, a, y) * z;
double tmp;
if (z <= -3.2e+21) {
tmp = t_1;
} else if (z <= 7.5e-127) {
tmp = fma(t, a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(b, a, y) * z) tmp = 0.0 if (z <= -3.2e+21) tmp = t_1; elseif (z <= 7.5e-127) tmp = fma(t, a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -3.2e+21], t$95$1, If[LessEqual[z, 7.5e-127], N[(t * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{if}\;z \leq -3.2 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{-127}:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.2e21 or 7.5000000000000004e-127 < z Initial program 92.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6450.1
Applied rewrites50.1%
if -3.2e21 < z < 7.5000000000000004e-127Initial program 92.9%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.9
Applied rewrites74.9%
Taylor expanded in z around 0
Applied rewrites52.7%
(FPCore (x y z t a b) :precision binary64 (if (<= z -1.8e+24) (fma z y x) (if (<= z 4000000.0) (fma t a x) (fma z y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -1.8e+24) {
tmp = fma(z, y, x);
} else if (z <= 4000000.0) {
tmp = fma(t, a, x);
} else {
tmp = fma(z, y, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -1.8e+24) tmp = fma(z, y, x); elseif (z <= 4000000.0) tmp = fma(t, a, x); else tmp = fma(z, y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -1.8e+24], N[(z * y + x), $MachinePrecision], If[LessEqual[z, 4000000.0], N[(t * a + x), $MachinePrecision], N[(z * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{+24}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;z \leq 4000000:\\
\;\;\;\;\mathsf{fma}\left(t, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\end{array}
\end{array}
if z < -1.79999999999999992e24 or 4e6 < z Initial program 92.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6494.3
Applied rewrites94.3%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.0
Applied rewrites52.0%
if -1.79999999999999992e24 < z < 4e6Initial program 92.9%
Taylor expanded in y around 0
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6474.9
Applied rewrites74.9%
Taylor expanded in z around 0
Applied rewrites52.7%
(FPCore (x y z t a b) :precision binary64 (fma z y x))
double code(double x, double y, double z, double t, double a, double b) {
return fma(z, y, x);
}
function code(x, y, z, t, a, b) return fma(z, y, x) end
code[x_, y_, z_, t_, a_, b_] := N[(z * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, y, x\right)
\end{array}
Initial program 92.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6494.3
Applied rewrites94.3%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.0
Applied rewrites52.0%
(FPCore (x y z t a b) :precision binary64 (* z y))
double code(double x, double y, double z, double t, double a, double b) {
return z * y;
}
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 = z * y
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return z * y;
}
def code(x, y, z, t, a, b): return z * y
function code(x, y, z, t, a, b) return Float64(z * y) end
function tmp = code(x, y, z, t, a, b) tmp = z * y; end
code[x_, y_, z_, t_, a_, b_] := N[(z * y), $MachinePrecision]
\begin{array}{l}
\\
z \cdot y
\end{array}
Initial program 92.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6494.3
Applied rewrites94.3%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f6427.4
Applied rewrites27.4%
herbie shell --seed 2025139
(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)))