
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b): return ((x + (y * z)) + (t * a)) + ((a * z) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b): return ((x + (y * z)) + (t * a)) + ((a * z) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))) (if (<= t_1 INFINITY) t_1 (* (fma 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.6%
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.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+83)
t_1
(if (<= z 5600000000000.0) (+ x (* (fma b z t) a)) 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+83) {
tmp = t_1;
} else if (z <= 5600000000000.0) {
tmp = x + (fma(b, z, t) * a);
} 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+83) tmp = t_1; elseif (z <= 5600000000000.0) tmp = Float64(x + Float64(fma(b, z, t) * a)); 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+83], t$95$1, If[LessEqual[z, 5600000000000.0], N[(x + N[(N[(b * z + t), $MachinePrecision] * a), $MachinePrecision]), $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^{+83}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5600000000000:\\
\;\;\;\;x + \mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.09999999999999992e83 or 5.6e12 < z Initial program 84.6%
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.f6489.1
Applied rewrites89.1%
if -3.09999999999999992e83 < z < 5.6e12Initial program 97.9%
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6499.3
Applied rewrites99.3%
Taylor expanded in x around inf
Applied rewrites84.8%
(FPCore (x y z t a b) :precision binary64 (if (<= z -1.8e+104) (fma (fma b a y) z x) (+ (fma z y x) (* (fma b z t) a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -1.8e+104) {
tmp = fma(fma(b, a, y), z, x);
} else {
tmp = fma(z, y, x) + (fma(b, z, t) * a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -1.8e+104) tmp = fma(fma(b, a, y), z, x); else tmp = Float64(fma(z, y, x) + Float64(fma(b, z, t) * a)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -1.8e+104], N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(z * y + x), $MachinePrecision] + N[(N[(b * z + t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{+104}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right) + \mathsf{fma}\left(b, z, t\right) \cdot a\\
\end{array}
\end{array}
if z < -1.8e104Initial program 83.4%
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.f6491.1
Applied rewrites91.1%
if -1.8e104 < z Initial program 94.0%
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6495.8
Applied rewrites95.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (fma b a y) z x)))
(if (<= z -3.1e+83)
t_1
(if (<= z 5600000000000.0) (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(fma(b, a, y), z, x);
double tmp;
if (z <= -3.1e+83) {
tmp = t_1;
} else if (z <= 5600000000000.0) {
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(fma(b, a, y), z, x) tmp = 0.0 if (z <= -3.1e+83) tmp = t_1; elseif (z <= 5600000000000.0) 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[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[z, -3.1e+83], t$95$1, If[LessEqual[z, 5600000000000.0], N[(N[(b * z + t), $MachinePrecision] * 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^{+83}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5600000000000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.09999999999999992e83 or 5.6e12 < z Initial program 84.6%
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.f6489.1
Applied rewrites89.1%
if -3.09999999999999992e83 < z < 5.6e12Initial program 97.9%
Taylor expanded in y around 0
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6484.8
Applied rewrites84.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (fma b a y) z x))) (if (<= z -1.25e+24) t_1 (if (<= z 5.6e+42) (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(fma(b, a, y), z, x);
double tmp;
if (z <= -1.25e+24) {
tmp = t_1;
} else if (z <= 5.6e+42) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(fma(b, a, y), z, x) tmp = 0.0 if (z <= -1.25e+24) tmp = t_1; elseif (z <= 5.6e+42) 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 + x), $MachinePrecision]}, If[LessEqual[z, -1.25e+24], t$95$1, If[LessEqual[z, 5.6e+42], N[(a * t + N[(z * y + x), $MachinePrecision]), $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 -1.25 \cdot 10^{+24}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5.6 \cdot 10^{+42}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.25000000000000011e24 or 5.5999999999999999e42 < z Initial program 84.6%
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.f6488.7
Applied rewrites88.7%
if -1.25000000000000011e24 < z < 5.5999999999999999e42Initial program 98.5%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6486.0
Applied rewrites86.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b z t) a))) (if (<= b -5.4e+190) t_1 (if (<= b 1.35e+198) (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, z, t) * a;
double tmp;
if (b <= -5.4e+190) {
tmp = t_1;
} else if (b <= 1.35e+198) {
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, z, t) * a) tmp = 0.0 if (b <= -5.4e+190) tmp = t_1; elseif (b <= 1.35e+198) 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 * z + t), $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[b, -5.4e+190], t$95$1, If[LessEqual[b, 1.35e+198], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, z, t\right) \cdot a\\
\mathbf{if}\;b \leq -5.4 \cdot 10^{+190}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{+198}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -5.40000000000000008e190 or 1.35e198 < b Initial program 90.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6467.5
Applied rewrites67.5%
if -5.40000000000000008e190 < b < 1.35e198Initial program 92.6%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6483.7
Applied rewrites83.7%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b z t) a))) (if (<= a -1.05e-26) t_1 (if (<= a 6.2e-32) (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 <= -1.05e-26) {
tmp = t_1;
} else if (a <= 6.2e-32) {
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 <= -1.05e-26) tmp = t_1; elseif (a <= 6.2e-32) 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, -1.05e-26], t$95$1, If[LessEqual[a, 6.2e-32], 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 -1.05 \cdot 10^{-26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 6.2 \cdot 10^{-32}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -1.05000000000000004e-26 or 6.20000000000000021e-32 < a Initial program 86.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6473.2
Applied rewrites73.2%
if -1.05000000000000004e-26 < a < 6.20000000000000021e-32Initial program 98.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6476.4
Applied rewrites76.4%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b a y) z))) (if (<= z -2.8e-13) t_1 (if (<= z 1.06e+17) (fma a t x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(b, a, y) * z;
double tmp;
if (z <= -2.8e-13) {
tmp = t_1;
} else if (z <= 1.06e+17) {
tmp = fma(a, t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(b, a, y) * z) tmp = 0.0 if (z <= -2.8e-13) tmp = t_1; elseif (z <= 1.06e+17) tmp = fma(a, t, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -2.8e-13], t$95$1, If[LessEqual[z, 1.06e+17], N[(a * t + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{if}\;z \leq -2.8 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.06 \cdot 10^{+17}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.8000000000000002e-13 or 1.06e17 < z Initial program 85.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6475.0
Applied rewrites75.0%
if -2.8000000000000002e-13 < z < 1.06e17Initial program 98.6%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6474.7
Applied rewrites74.7%
(FPCore (x y z t a b) :precision binary64 (if (<= z -3.1e+83) (fma z y x) (if (<= z 6900000000000.0) (fma a t x) (fma z y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -3.1e+83) {
tmp = fma(z, y, x);
} else if (z <= 6900000000000.0) {
tmp = fma(a, t, x);
} else {
tmp = fma(z, y, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -3.1e+83) tmp = fma(z, y, x); elseif (z <= 6900000000000.0) tmp = fma(a, t, x); else tmp = fma(z, y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -3.1e+83], N[(z * y + x), $MachinePrecision], If[LessEqual[z, 6900000000000.0], N[(a * t + x), $MachinePrecision], N[(z * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{+83}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;z \leq 6900000000000:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\end{array}
\end{array}
if z < -3.09999999999999992e83 or 6.9e12 < z Initial program 84.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6453.8
Applied rewrites53.8%
if -3.09999999999999992e83 < z < 6.9e12Initial program 97.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6470.6
Applied rewrites70.6%
(FPCore (x y z t a b) :precision binary64 (if (<= z -8.8e+108) (* z y) (if (<= z 4.5e+18) (fma a t x) (* z y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -8.8e+108) {
tmp = z * y;
} else if (z <= 4.5e+18) {
tmp = fma(a, t, x);
} else {
tmp = z * y;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -8.8e+108) tmp = Float64(z * y); elseif (z <= 4.5e+18) tmp = fma(a, t, x); else tmp = Float64(z * y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -8.8e+108], N[(z * y), $MachinePrecision], If[LessEqual[z, 4.5e+18], N[(a * t + x), $MachinePrecision], N[(z * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.8 \cdot 10^{+108}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+18}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot y\\
\end{array}
\end{array}
if z < -8.8000000000000005e108 or 4.5e18 < z Initial program 84.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6443.1
Applied rewrites43.1%
if -8.8000000000000005e108 < z < 4.5e18Initial program 97.7%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6469.3
Applied rewrites69.3%
(FPCore (x y z t a b) :precision binary64 (if (<= z -3.1e+83) (* z y) (if (<= z 1e+16) (* a t) (* z y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -3.1e+83) {
tmp = z * y;
} else if (z <= 1e+16) {
tmp = a * t;
} else {
tmp = z * y;
}
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 (z <= (-3.1d+83)) then
tmp = z * y
else if (z <= 1d+16) then
tmp = a * t
else
tmp = z * y
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 (z <= -3.1e+83) {
tmp = z * y;
} else if (z <= 1e+16) {
tmp = a * t;
} else {
tmp = z * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if z <= -3.1e+83: tmp = z * y elif z <= 1e+16: tmp = a * t else: tmp = z * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -3.1e+83) tmp = Float64(z * y); elseif (z <= 1e+16) tmp = Float64(a * t); else tmp = Float64(z * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (z <= -3.1e+83) tmp = z * y; elseif (z <= 1e+16) tmp = a * t; else tmp = z * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -3.1e+83], N[(z * y), $MachinePrecision], If[LessEqual[z, 1e+16], N[(a * t), $MachinePrecision], N[(z * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{+83}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;z \leq 10^{+16}:\\
\;\;\;\;a \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot y\\
\end{array}
\end{array}
if z < -3.09999999999999992e83 or 1e16 < z Initial program 84.5%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6442.6
Applied rewrites42.6%
if -3.09999999999999992e83 < z < 1e16Initial program 97.9%
Taylor expanded in t around inf
lower-*.f6436.3
Applied rewrites36.3%
(FPCore (x y z t a b) :precision binary64 (if (<= a -4.6e-27) (* a t) (if (<= a 3.9e-31) x (* a t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -4.6e-27) {
tmp = a * t;
} else if (a <= 3.9e-31) {
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 (a <= (-4.6d-27)) then
tmp = a * t
else if (a <= 3.9d-31) 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 (a <= -4.6e-27) {
tmp = a * t;
} else if (a <= 3.9e-31) {
tmp = x;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if a <= -4.6e-27: tmp = a * t elif a <= 3.9e-31: tmp = x else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -4.6e-27) tmp = Float64(a * t); elseif (a <= 3.9e-31) 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 (a <= -4.6e-27) tmp = a * t; elseif (a <= 3.9e-31) tmp = x; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -4.6e-27], N[(a * t), $MachinePrecision], If[LessEqual[a, 3.9e-31], x, N[(a * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.6 \cdot 10^{-27}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;a \leq 3.9 \cdot 10^{-31}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if a < -4.5999999999999999e-27 or 3.9000000000000001e-31 < a Initial program 86.7%
Taylor expanded in t around inf
lower-*.f6439.7
Applied rewrites39.7%
if -4.5999999999999999e-27 < a < 3.9000000000000001e-31Initial program 98.8%
Taylor expanded in x around inf
Applied rewrites39.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.2%
Taylor expanded in x around inf
Applied rewrites26.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* z (+ (* b a) y)) (+ x (* t a)))))
(if (< z -11820553527347888000.0)
t_1
(if (< z 4.7589743188364287e-122)
(+ (* (+ (* b z) t) a) (+ (* z y) x))
t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z * ((b * a) + y)) + (x + (t * a));
double tmp;
if (z < -11820553527347888000.0) {
tmp = t_1;
} else if (z < 4.7589743188364287e-122) {
tmp = (((b * z) + t) * a) + ((z * y) + x);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = (z * ((b * a) + y)) + (x + (t * a))
if (z < (-11820553527347888000.0d0)) then
tmp = t_1
else if (z < 4.7589743188364287d-122) then
tmp = (((b * z) + t) * a) + ((z * y) + x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (z * ((b * a) + y)) + (x + (t * a));
double tmp;
if (z < -11820553527347888000.0) {
tmp = t_1;
} else if (z < 4.7589743188364287e-122) {
tmp = (((b * z) + t) * a) + ((z * y) + x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (z * ((b * a) + y)) + (x + (t * a)) tmp = 0 if z < -11820553527347888000.0: tmp = t_1 elif z < 4.7589743188364287e-122: tmp = (((b * z) + t) * a) + ((z * y) + x) else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(z * Float64(Float64(b * a) + y)) + Float64(x + Float64(t * a))) tmp = 0.0 if (z < -11820553527347888000.0) tmp = t_1; elseif (z < 4.7589743188364287e-122) tmp = Float64(Float64(Float64(Float64(b * z) + t) * a) + Float64(Float64(z * y) + x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (z * ((b * a) + y)) + (x + (t * a)); tmp = 0.0; if (z < -11820553527347888000.0) tmp = t_1; elseif (z < 4.7589743188364287e-122) tmp = (((b * z) + t) * a) + ((z * y) + x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(z * N[(N[(b * a), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] + N[(x + N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -11820553527347888000.0], t$95$1, If[Less[z, 4.7589743188364287e-122], N[(N[(N[(N[(b * z), $MachinePrecision] + t), $MachinePrecision] * a), $MachinePrecision] + N[(N[(z * y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\
\mathbf{if}\;z < -11820553527347888000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 4.7589743188364287 \cdot 10^{-122}:\\
\;\;\;\;\left(b \cdot z + t\right) \cdot a + \left(z \cdot y + x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2025096
(FPCore (x y z t a b)
:name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
:precision binary64
:alt
(! :herbie-platform default (if (< z -11820553527347888000) (+ (* z (+ (* b a) y)) (+ x (* t a))) (if (< z 47589743188364287/1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a))))))
(+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))