
(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 (fma (fma b z t) a (fma z y x)))
double code(double x, double y, double z, double t, double a, double b) {
return fma(fma(b, z, t), a, fma(z, y, x));
}
function code(x, y, z, t, a, b) return fma(fma(b, z, t), a, fma(z, y, x)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(b * z + t), $MachinePrecision] * a + N[(z * y + x), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, \mathsf{fma}\left(z, y, x\right)\right)
Initial program 92.4%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.4%
Applied rewrites94.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (+ x (* a t)) (* (* a z) b))))
(if (<= b -3.5e+70)
t_1
(if (<= b 1.05e+101) (fma t a (fma z y x)) t_1))))double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + (a * t)) + ((a * z) * b);
double tmp;
if (b <= -3.5e+70) {
tmp = t_1;
} else if (b <= 1.05e+101) {
tmp = fma(t, a, fma(z, y, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x + Float64(a * t)) + Float64(Float64(a * z) * b)) tmp = 0.0 if (b <= -3.5e+70) tmp = t_1; elseif (b <= 1.05e+101) tmp = fma(t, a, 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[(x + N[(a * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.5e+70], t$95$1, If[LessEqual[b, 1.05e+101], N[(t * a + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \left(x + a \cdot t\right) + \left(a \cdot z\right) \cdot b\\
\mathbf{if}\;b \leq -3.5 \cdot 10^{+70}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{+101}:\\
\;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if b < -3.5e70 or 1.05e101 < b Initial program 92.4%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6472.0%
Applied rewrites72.0%
if -3.5e70 < b < 1.05e101Initial program 92.4%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.4%
Applied rewrites94.4%
Taylor expanded in z around 0
Applied rewrites77.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ x (fma a t (* a (* b z))))))
(if (<= b -5.8)
t_1
(if (<= b 1.05e+101) (fma t a (fma z y x)) t_1))))double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x + fma(a, t, (a * (b * z)));
double tmp;
if (b <= -5.8) {
tmp = t_1;
} else if (b <= 1.05e+101) {
tmp = fma(t, a, fma(z, y, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(x + fma(a, t, Float64(a * Float64(b * z)))) tmp = 0.0 if (b <= -5.8) tmp = t_1; elseif (b <= 1.05e+101) tmp = fma(t, a, fma(z, y, x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x + N[(a * t + N[(a * N[(b * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -5.8], t$95$1, If[LessEqual[b, 1.05e+101], N[(t * a + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := x + \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right)\\
\mathbf{if}\;b \leq -5.8:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{+101}:\\
\;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if b < -5.7999999999999998 or 1.05e101 < b Initial program 92.4%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6473.9%
Applied rewrites73.9%
if -5.7999999999999998 < b < 1.05e101Initial program 92.4%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.4%
Applied rewrites94.4%
Taylor expanded in z around 0
Applied rewrites77.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (* a z) b x)))
(if (<= b -4.2e+70)
t_1
(if (<= b 1.5e+132) (fma t a (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 <= -4.2e+70) {
tmp = t_1;
} else if (b <= 1.5e+132) {
tmp = fma(t, a, 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 <= -4.2e+70) tmp = t_1; elseif (b <= 1.5e+132) tmp = fma(t, a, 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, -4.2e+70], t$95$1, If[LessEqual[b, 1.5e+132], N[(t * a + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(a \cdot z, b, x\right)\\
\mathbf{if}\;b \leq -4.2 \cdot 10^{+70}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 1.5 \cdot 10^{+132}:\\
\;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if b < -4.2000000000000002e70 or 1.4999999999999999e132 < b Initial program 92.4%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6471.5%
Applied rewrites71.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6451.3%
Applied rewrites51.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6452.8%
Applied rewrites52.8%
if -4.2000000000000002e70 < b < 1.4999999999999999e132Initial program 92.4%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.4%
Applied rewrites94.4%
Taylor expanded in z around 0
Applied rewrites77.1%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma a b y) z))) (if (<= z -2.3e+79) t_1 (if (<= z 1.02e-76) (fma a t x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(a, b, y) * z;
double tmp;
if (z <= -2.3e+79) {
tmp = t_1;
} else if (z <= 1.02e-76) {
tmp = fma(a, t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(a, b, y) * z) tmp = 0.0 if (z <= -2.3e+79) tmp = t_1; elseif (z <= 1.02e-76) 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[(a * b + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -2.3e+79], t$95$1, If[LessEqual[z, 1.02e-76], N[(a * t + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, y\right) \cdot z\\
\mathbf{if}\;z \leq -2.3 \cdot 10^{+79}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.02 \cdot 10^{-76}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -2.3e79 or 1.0200000000000001e-76 < z Initial program 92.4%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.7%
Applied rewrites50.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6450.7%
Applied rewrites50.7%
if -2.3e79 < z < 1.0200000000000001e-76Initial program 92.4%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.4%
Applied rewrites94.4%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
*-commutative52.1%
distribute-rgt-in52.1%
*-commutative52.1%
*-commutative52.1%
associate-*l*52.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
associate-+r+N/A
+-commutativeN/A
+-commutativeN/A
lift-*.f6452.1%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.1%
Applied rewrites52.1%
(FPCore (x y z t a b) :precision binary64 (if (<= t -16000.0) (fma a t x) (if (<= t 6e+76) (fma (* a z) b x) (fma a t x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -16000.0) {
tmp = fma(a, t, x);
} else if (t <= 6e+76) {
tmp = fma((a * z), b, x);
} else {
tmp = fma(a, t, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -16000.0) tmp = fma(a, t, x); elseif (t <= 6e+76) tmp = fma(Float64(a * z), b, x); else tmp = fma(a, t, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -16000.0], N[(a * t + x), $MachinePrecision], If[LessEqual[t, 6e+76], N[(N[(a * z), $MachinePrecision] * b + x), $MachinePrecision], N[(a * t + x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;t \leq -16000:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;t \leq 6 \cdot 10^{+76}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot z, b, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\end{array}
if t < -16000 or 5.9999999999999996e76 < t Initial program 92.4%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.4%
Applied rewrites94.4%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
*-commutative52.1%
distribute-rgt-in52.1%
*-commutative52.1%
*-commutative52.1%
associate-*l*52.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
associate-+r+N/A
+-commutativeN/A
+-commutativeN/A
lift-*.f6452.1%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.1%
Applied rewrites52.1%
if -16000 < t < 5.9999999999999996e76Initial program 92.4%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6471.5%
Applied rewrites71.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6451.3%
Applied rewrites51.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6452.8%
Applied rewrites52.8%
(FPCore (x y z t a b) :precision binary64 (if (<= b -4.2e+70) (* z (* a b)) (if (<= b 1.6e+162) (fma a t x) (* (* a z) b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -4.2e+70) {
tmp = z * (a * b);
} else if (b <= 1.6e+162) {
tmp = fma(a, t, x);
} else {
tmp = (a * z) * b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -4.2e+70) tmp = Float64(z * Float64(a * b)); elseif (b <= 1.6e+162) tmp = fma(a, t, x); else tmp = Float64(Float64(a * z) * b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -4.2e+70], N[(z * N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.6e+162], N[(a * t + x), $MachinePrecision], N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -4.2 \cdot 10^{+70}:\\
\;\;\;\;z \cdot \left(a \cdot b\right)\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{+162}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot z\right) \cdot b\\
\end{array}
if b < -4.2000000000000002e70Initial program 92.4%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.7%
Applied rewrites50.7%
Taylor expanded in y around 0
lower-*.f6426.9%
Applied rewrites26.9%
if -4.2000000000000002e70 < b < 1.6000000000000001e162Initial program 92.4%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.4%
Applied rewrites94.4%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
*-commutative52.1%
distribute-rgt-in52.1%
*-commutative52.1%
*-commutative52.1%
associate-*l*52.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
associate-+r+N/A
+-commutativeN/A
+-commutativeN/A
lift-*.f6452.1%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.1%
Applied rewrites52.1%
if 1.6000000000000001e162 < b Initial program 92.4%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.7%
Applied rewrites50.7%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f6427.1%
Applied rewrites27.1%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6428.5%
Applied rewrites28.5%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (* a z) b))) (if (<= b -4.2e+70) t_1 (if (<= b 1.6e+162) (fma a t x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * z) * b;
double tmp;
if (b <= -4.2e+70) {
tmp = t_1;
} else if (b <= 1.6e+162) {
tmp = fma(a, t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * z) * b) tmp = 0.0 if (b <= -4.2e+70) tmp = t_1; elseif (b <= 1.6e+162) 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[(a * z), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[b, -4.2e+70], t$95$1, If[LessEqual[b, 1.6e+162], N[(a * t + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \left(a \cdot z\right) \cdot b\\
\mathbf{if}\;b \leq -4.2 \cdot 10^{+70}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{+162}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if b < -4.2000000000000002e70 or 1.6000000000000001e162 < b Initial program 92.4%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.7%
Applied rewrites50.7%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f6427.1%
Applied rewrites27.1%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6428.5%
Applied rewrites28.5%
if -4.2000000000000002e70 < b < 1.6000000000000001e162Initial program 92.4%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.4%
Applied rewrites94.4%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
*-commutative52.1%
distribute-rgt-in52.1%
*-commutative52.1%
*-commutative52.1%
associate-*l*52.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
associate-+r+N/A
+-commutativeN/A
+-commutativeN/A
lift-*.f6452.1%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.1%
Applied rewrites52.1%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* a (* b z)))) (if (<= b -9.5e+112) t_1 (if (<= b 1.6e+162) (fma a t x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a * (b * z);
double tmp;
if (b <= -9.5e+112) {
tmp = t_1;
} else if (b <= 1.6e+162) {
tmp = fma(a, t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(a * Float64(b * z)) tmp = 0.0 if (b <= -9.5e+112) tmp = t_1; elseif (b <= 1.6e+162) 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[(a * N[(b * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -9.5e+112], t$95$1, If[LessEqual[b, 1.6e+162], N[(a * t + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := a \cdot \left(b \cdot z\right)\\
\mathbf{if}\;b \leq -9.5 \cdot 10^{+112}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{+162}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if b < -9.5000000000000008e112 or 1.6000000000000001e162 < b Initial program 92.4%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.7%
Applied rewrites50.7%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f6427.1%
Applied rewrites27.1%
if -9.5000000000000008e112 < b < 1.6000000000000001e162Initial program 92.4%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.4%
Applied rewrites94.4%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
*-commutative52.1%
distribute-rgt-in52.1%
*-commutative52.1%
*-commutative52.1%
associate-*l*52.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
associate-+r+N/A
+-commutativeN/A
+-commutativeN/A
lift-*.f6452.1%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.1%
Applied rewrites52.1%
(FPCore (x y z t a b) :precision binary64 (fma a t x))
double code(double x, double y, double z, double t, double a, double b) {
return fma(a, t, x);
}
function code(x, y, z, t, a, b) return fma(a, t, x) end
code[x_, y_, z_, t_, a_, b_] := N[(a * t + x), $MachinePrecision]
\mathsf{fma}\left(a, t, x\right)
Initial program 92.4%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f6494.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6494.4%
Applied rewrites94.4%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
*-commutative52.1%
distribute-rgt-in52.1%
*-commutative52.1%
*-commutative52.1%
associate-*l*52.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
associate-+r+N/A
+-commutativeN/A
+-commutativeN/A
lift-*.f6452.1%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.1%
Applied rewrites52.1%
(FPCore (x y z t a b) :precision binary64 (* a t))
double code(double x, double y, double z, double t, double a, double b) {
return a * t;
}
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 = a * t
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a * t;
}
def code(x, y, z, t, a, b): return a * t
function code(x, y, z, t, a, b) return Float64(a * t) end
function tmp = code(x, y, z, t, a, b) tmp = a * t; end
code[x_, y_, z_, t_, a_, b_] := N[(a * t), $MachinePrecision]
a \cdot t
Initial program 92.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.1%
Applied rewrites50.1%
Taylor expanded in z around 0
lower-*.f6427.3%
Applied rewrites27.3%
herbie shell --seed 2025212
(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)))