
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b): return ((x + (y * z)) + (t * a)) + ((a * z) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b): return ((x + (y * z)) + (t * a)) + ((a * z) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (fma b z t) a (* z y)))
(t_2 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b))))
(if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 6e+304) t_2 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, (z * y));
double t_2 = ((x + (y * z)) + (t * a)) + ((a * z) * b);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 6e+304) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(fma(b, z, t), a, Float64(z * y)) t_2 = Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 6e+304) tmp = t_2; 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 + N[(z * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 6e+304], t$95$2, t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, z \cdot y\right)\\
t_2 := \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 6 \cdot 10^{+304}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < -inf.0 or 5.9999999999999996e304 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 78.1%
Taylor expanded in x around 0
associate-+r+N/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.6
Applied rewrites90.6%
if -inf.0 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < 5.9999999999999996e304Initial program 99.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (fma b z t) a (* z y)))
(t_2 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
(t_3 (fma a t (fma z y x))))
(if (<= t_2 -2e+304)
t_1
(if (<= t_2 -1e+92)
t_3
(if (<= t_2 2.5e+97)
(* (+ (/ (fma (fma b a y) z x) t) a) t)
(if (<= t_2 6e+304) t_3 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, (z * y));
double t_2 = ((x + (y * z)) + (t * a)) + ((a * z) * b);
double t_3 = fma(a, t, fma(z, y, x));
double tmp;
if (t_2 <= -2e+304) {
tmp = t_1;
} else if (t_2 <= -1e+92) {
tmp = t_3;
} else if (t_2 <= 2.5e+97) {
tmp = ((fma(fma(b, a, y), z, x) / t) + a) * t;
} else if (t_2 <= 6e+304) {
tmp = t_3;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(fma(b, z, t), a, Float64(z * y)) t_2 = Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) t_3 = fma(a, t, fma(z, y, x)) tmp = 0.0 if (t_2 <= -2e+304) tmp = t_1; elseif (t_2 <= -1e+92) tmp = t_3; elseif (t_2 <= 2.5e+97) tmp = Float64(Float64(Float64(fma(fma(b, a, y), z, x) / t) + a) * t); elseif (t_2 <= 6e+304) tmp = t_3; 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 + N[(z * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+304], t$95$1, If[LessEqual[t$95$2, -1e+92], t$95$3, If[LessEqual[t$95$2, 2.5e+97], N[(N[(N[(N[(N[(b * a + y), $MachinePrecision] * z + x), $MachinePrecision] / t), $MachinePrecision] + a), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[t$95$2, 6e+304], t$95$3, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, z \cdot y\right)\\
t_2 := \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\
t_3 := \mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+304}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -1 \cdot 10^{+92}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 2.5 \cdot 10^{+97}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)}{t} + a\right) \cdot t\\
\mathbf{elif}\;t\_2 \leq 6 \cdot 10^{+304}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < -1.9999999999999999e304 or 5.9999999999999996e304 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 78.4%
Taylor expanded in x around 0
associate-+r+N/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.2
Applied rewrites90.2%
if -1.9999999999999999e304 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < -1e92 or 2.49999999999999999e97 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < 5.9999999999999996e304Initial program 99.9%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
associate-+l+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6484.5
Applied rewrites84.5%
if -1e92 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < 2.49999999999999999e97Initial program 98.7%
Taylor expanded in t around inf
*-commutativeN/A
div-add-revN/A
div-addN/A
lower-*.f64N/A
Applied rewrites94.7%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (fma b z t) a (* z y)))
(t_2 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b))))
(if (<= t_2 -2e+304) t_1 (if (<= t_2 6e+304) (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, z, t), a, (z * y));
double t_2 = ((x + (y * z)) + (t * a)) + ((a * z) * b);
double tmp;
if (t_2 <= -2e+304) {
tmp = t_1;
} else if (t_2 <= 6e+304) {
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, z, t), a, Float64(z * y)) t_2 = Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b)) tmp = 0.0 if (t_2 <= -2e+304) tmp = t_1; elseif (t_2 <= 6e+304) 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 + N[(z * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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$2, -2e+304], t$95$1, If[LessEqual[t$95$2, 6e+304], 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, z, t\right), a, z \cdot y\right)\\
t_2 := \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+304}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 6 \cdot 10^{+304}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < -1.9999999999999999e304 or 5.9999999999999996e304 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) Initial program 78.4%
Taylor expanded in x around 0
associate-+r+N/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.2
Applied rewrites90.2%
if -1.9999999999999999e304 < (+.f64 (+.f64 (+.f64 x (*.f64 y z)) (*.f64 t a)) (*.f64 (*.f64 a z) b)) < 5.9999999999999996e304Initial program 99.5%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
associate-+l+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6485.4
Applied rewrites85.4%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (fma b a y) z))) (if (<= z -9.8e+20) t_1 (if (<= z 1.35e+112) (fma a t (fma z y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(b, a, y) * z;
double tmp;
if (z <= -9.8e+20) {
tmp = t_1;
} else if (z <= 1.35e+112) {
tmp = fma(a, t, fma(z, y, x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(b, a, y) * z) tmp = 0.0 if (z <= -9.8e+20) tmp = t_1; elseif (z <= 1.35e+112) tmp = fma(a, t, fma(z, y, x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -9.8e+20], t$95$1, If[LessEqual[z, 1.35e+112], N[(a * t + N[(z * y + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{if}\;z \leq -9.8 \cdot 10^{+20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{+112}:\\
\;\;\;\;\mathsf{fma}\left(a, t, \mathsf{fma}\left(z, y, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -9.8e20 or 1.3500000000000001e112 < z Initial program 83.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6479.2
Applied rewrites79.2%
if -9.8e20 < z < 1.3500000000000001e112Initial program 97.8%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
associate-+l+N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6485.2
Applied rewrites85.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (fma b a y) z)))
(if (<= z -760000000.0)
t_1
(if (<= z 3.9e-151) (fma a t x) (if (<= z 6e+85) (fma z y x) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(b, a, y) * z;
double tmp;
if (z <= -760000000.0) {
tmp = t_1;
} else if (z <= 3.9e-151) {
tmp = fma(a, t, x);
} else if (z <= 6e+85) {
tmp = fma(z, y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(b, a, y) * z) tmp = 0.0 if (z <= -760000000.0) tmp = t_1; elseif (z <= 3.9e-151) tmp = fma(a, t, x); elseif (z <= 6e+85) tmp = fma(z, y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(b * a + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -760000000.0], t$95$1, If[LessEqual[z, 3.9e-151], N[(a * t + x), $MachinePrecision], If[LessEqual[z, 6e+85], N[(z * y + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, y\right) \cdot z\\
\mathbf{if}\;z \leq -760000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.9 \cdot 10^{-151}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+85}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -7.6e8 or 6.0000000000000001e85 < z Initial program 84.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6477.9
Applied rewrites77.9%
if -7.6e8 < z < 3.90000000000000007e-151Initial program 98.6%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6477.5
Applied rewrites77.5%
if 3.90000000000000007e-151 < z < 6.0000000000000001e85Initial program 96.5%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6451.1
Applied rewrites51.1%
(FPCore (x y z t a b)
:precision binary64
(if (<= t -7.6e+78)
(fma a t x)
(if (<= t -6.5e+16)
(fma z y x)
(if (<= t -8e-20)
(* (* a z) b)
(if (<= t 2.55e+75) (fma z y x) (fma a t x))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -7.6e+78) {
tmp = fma(a, t, x);
} else if (t <= -6.5e+16) {
tmp = fma(z, y, x);
} else if (t <= -8e-20) {
tmp = (a * z) * b;
} else if (t <= 2.55e+75) {
tmp = fma(z, y, x);
} else {
tmp = fma(a, t, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -7.6e+78) tmp = fma(a, t, x); elseif (t <= -6.5e+16) tmp = fma(z, y, x); elseif (t <= -8e-20) tmp = Float64(Float64(a * z) * b); elseif (t <= 2.55e+75) tmp = fma(z, y, x); else tmp = fma(a, t, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -7.6e+78], N[(a * t + x), $MachinePrecision], If[LessEqual[t, -6.5e+16], N[(z * y + x), $MachinePrecision], If[LessEqual[t, -8e-20], N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision], If[LessEqual[t, 2.55e+75], N[(z * y + x), $MachinePrecision], N[(a * t + x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7.6 \cdot 10^{+78}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;t \leq -6.5 \cdot 10^{+16}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;t \leq -8 \cdot 10^{-20}:\\
\;\;\;\;\left(a \cdot z\right) \cdot b\\
\mathbf{elif}\;t \leq 2.55 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\end{array}
\end{array}
if t < -7.5999999999999998e78 or 2.55000000000000018e75 < t Initial program 90.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6469.7
Applied rewrites69.7%
if -7.5999999999999998e78 < t < -6.5e16 or -7.99999999999999956e-20 < t < 2.55000000000000018e75Initial program 93.6%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6461.8
Applied rewrites61.8%
if -6.5e16 < t < -7.99999999999999956e-20Initial program 94.3%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6428.1
Applied rewrites28.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6428.9
Applied rewrites28.9%
(FPCore (x y z t a b)
:precision binary64
(if (<= t -7.6e+78)
(fma a t x)
(if (<= t -6.5e+16)
(fma z y x)
(if (<= t -8e-20)
(* (* b a) z)
(if (<= t 2.55e+75) (fma z y x) (fma a t x))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -7.6e+78) {
tmp = fma(a, t, x);
} else if (t <= -6.5e+16) {
tmp = fma(z, y, x);
} else if (t <= -8e-20) {
tmp = (b * a) * z;
} else if (t <= 2.55e+75) {
tmp = fma(z, y, x);
} else {
tmp = fma(a, t, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -7.6e+78) tmp = fma(a, t, x); elseif (t <= -6.5e+16) tmp = fma(z, y, x); elseif (t <= -8e-20) tmp = Float64(Float64(b * a) * z); elseif (t <= 2.55e+75) tmp = fma(z, y, x); else tmp = fma(a, t, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -7.6e+78], N[(a * t + x), $MachinePrecision], If[LessEqual[t, -6.5e+16], N[(z * y + x), $MachinePrecision], If[LessEqual[t, -8e-20], N[(N[(b * a), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t, 2.55e+75], N[(z * y + x), $MachinePrecision], N[(a * t + x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7.6 \cdot 10^{+78}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;t \leq -6.5 \cdot 10^{+16}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{elif}\;t \leq -8 \cdot 10^{-20}:\\
\;\;\;\;\left(b \cdot a\right) \cdot z\\
\mathbf{elif}\;t \leq 2.55 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\end{array}
\end{array}
if t < -7.5999999999999998e78 or 2.55000000000000018e75 < t Initial program 90.0%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6469.7
Applied rewrites69.7%
if -7.5999999999999998e78 < t < -6.5e16 or -7.99999999999999956e-20 < t < 2.55000000000000018e75Initial program 93.6%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6461.8
Applied rewrites61.8%
if -6.5e16 < t < -7.99999999999999956e-20Initial program 94.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6453.5
Applied rewrites53.5%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
(FPCore (x y z t a b) :precision binary64 (if (<= t -2.6e+86) (fma a t x) (if (<= t 2.55e+75) (fma z y x) (fma a t x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -2.6e+86) {
tmp = fma(a, t, x);
} else if (t <= 2.55e+75) {
tmp = fma(z, y, x);
} else {
tmp = fma(a, t, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -2.6e+86) tmp = fma(a, t, x); elseif (t <= 2.55e+75) tmp = fma(z, y, x); else tmp = fma(a, t, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -2.6e+86], N[(a * t + x), $MachinePrecision], If[LessEqual[t, 2.55e+75], N[(z * y + x), $MachinePrecision], N[(a * t + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.6 \cdot 10^{+86}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{elif}\;t \leq 2.55 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\end{array}
\end{array}
if t < -2.5999999999999998e86 or 2.55000000000000018e75 < t Initial program 89.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6469.9
Applied rewrites69.9%
if -2.5999999999999998e86 < t < 2.55000000000000018e75Initial program 93.6%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6461.5
Applied rewrites61.5%
(FPCore (x y z t a b) :precision binary64 (if (<= z -5.8e+57) (* z y) (if (<= z 8.5e+163) (fma a t x) (* z y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -5.8e+57) {
tmp = z * y;
} else if (z <= 8.5e+163) {
tmp = fma(a, t, x);
} else {
tmp = z * y;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -5.8e+57) tmp = Float64(z * y); elseif (z <= 8.5e+163) tmp = fma(a, t, x); else tmp = Float64(z * y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -5.8e+57], N[(z * y), $MachinePrecision], If[LessEqual[z, 8.5e+163], N[(a * t + x), $MachinePrecision], N[(z * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+57}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{+163}:\\
\;\;\;\;\mathsf{fma}\left(a, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot y\\
\end{array}
\end{array}
if z < -5.8000000000000003e57 or 8.5000000000000003e163 < z Initial program 81.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6445.9
Applied rewrites45.9%
if -5.8000000000000003e57 < z < 8.5000000000000003e163Initial program 97.1%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6465.9
Applied rewrites65.9%
(FPCore (x y z t a b)
:precision binary64
(if (<= t -7.6e+78)
(* a t)
(if (<= t -8.8e-17)
(* z y)
(if (<= t 8.2e-81) x (if (<= t 2.55e+75) (* z y) (* a t))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -7.6e+78) {
tmp = a * t;
} else if (t <= -8.8e-17) {
tmp = z * y;
} else if (t <= 8.2e-81) {
tmp = x;
} else if (t <= 2.55e+75) {
tmp = z * y;
} else {
tmp = a * t;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (t <= (-7.6d+78)) then
tmp = a * t
else if (t <= (-8.8d-17)) then
tmp = z * y
else if (t <= 8.2d-81) then
tmp = x
else if (t <= 2.55d+75) then
tmp = z * y
else
tmp = a * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -7.6e+78) {
tmp = a * t;
} else if (t <= -8.8e-17) {
tmp = z * y;
} else if (t <= 8.2e-81) {
tmp = x;
} else if (t <= 2.55e+75) {
tmp = z * y;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -7.6e+78: tmp = a * t elif t <= -8.8e-17: tmp = z * y elif t <= 8.2e-81: tmp = x elif t <= 2.55e+75: tmp = z * y else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -7.6e+78) tmp = Float64(a * t); elseif (t <= -8.8e-17) tmp = Float64(z * y); elseif (t <= 8.2e-81) tmp = x; elseif (t <= 2.55e+75) tmp = Float64(z * y); else tmp = Float64(a * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -7.6e+78) tmp = a * t; elseif (t <= -8.8e-17) tmp = z * y; elseif (t <= 8.2e-81) tmp = x; elseif (t <= 2.55e+75) tmp = z * y; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -7.6e+78], N[(a * t), $MachinePrecision], If[LessEqual[t, -8.8e-17], N[(z * y), $MachinePrecision], If[LessEqual[t, 8.2e-81], x, If[LessEqual[t, 2.55e+75], N[(z * y), $MachinePrecision], N[(a * t), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7.6 \cdot 10^{+78}:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;t \leq -8.8 \cdot 10^{-17}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;t \leq 8.2 \cdot 10^{-81}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 2.55 \cdot 10^{+75}:\\
\;\;\;\;z \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if t < -7.5999999999999998e78 or 2.55000000000000018e75 < t Initial program 90.0%
Taylor expanded in t around inf
lower-*.f6453.3
Applied rewrites53.3%
if -7.5999999999999998e78 < t < -8.8e-17 or 8.19999999999999968e-81 < t < 2.55000000000000018e75Initial program 93.2%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6430.5
Applied rewrites30.5%
if -8.8e-17 < t < 8.19999999999999968e-81Initial program 93.8%
Taylor expanded in x around inf
Applied rewrites34.5%
(FPCore (x y z t a b) :precision binary64 (if (<= t -3900000000000.0) (* a t) (if (<= t 3.3e+74) x (* a t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -3900000000000.0) {
tmp = a * t;
} else if (t <= 3.3e+74) {
tmp = x;
} else {
tmp = a * t;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (t <= (-3900000000000.0d0)) then
tmp = a * t
else if (t <= 3.3d+74) then
tmp = x
else
tmp = a * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -3900000000000.0) {
tmp = a * t;
} else if (t <= 3.3e+74) {
tmp = x;
} else {
tmp = a * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -3900000000000.0: tmp = a * t elif t <= 3.3e+74: tmp = x else: tmp = a * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -3900000000000.0) tmp = Float64(a * t); elseif (t <= 3.3e+74) tmp = x; else tmp = Float64(a * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -3900000000000.0) tmp = a * t; elseif (t <= 3.3e+74) tmp = x; else tmp = a * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -3900000000000.0], N[(a * t), $MachinePrecision], If[LessEqual[t, 3.3e+74], x, N[(a * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3900000000000:\\
\;\;\;\;a \cdot t\\
\mathbf{elif}\;t \leq 3.3 \cdot 10^{+74}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;a \cdot t\\
\end{array}
\end{array}
if t < -3.9e12 or 3.3000000000000002e74 < t Initial program 90.3%
Taylor expanded in t around inf
lower-*.f6450.0
Applied rewrites50.0%
if -3.9e12 < t < 3.3000000000000002e74Initial program 93.7%
Taylor expanded in x around inf
Applied rewrites32.5%
(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.8%
herbie shell --seed 2025115
(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)))