
(FPCore (x y z t a b c i j) :precision binary64 (+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* t i)))) (* j (- (* c a) (* y i)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)));
}
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, c, i, j)
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), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
code = ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)));
}
def code(x, y, z, t, a, b, c, i, j): return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)))
function code(x, y, z, t, a, b, c, i, j) return Float64(Float64(Float64(x * Float64(Float64(y * z) - Float64(t * a))) - Float64(b * Float64(Float64(c * z) - Float64(t * i)))) + Float64(j * Float64(Float64(c * a) - Float64(y * i)))) end
function tmp = code(x, y, z, t, a, b, c, i, j) tmp = ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i))); end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := N[(N[(N[(x * N[(N[(y * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * N[(N[(c * z), $MachinePrecision] - N[(t * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(j * N[(N[(c * a), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 20 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i j) :precision binary64 (+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* t i)))) (* j (- (* c a) (* y i)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)));
}
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, c, i, j)
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), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
code = ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)));
}
def code(x, y, z, t, a, b, c, i, j): return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)))
function code(x, y, z, t, a, b, c, i, j) return Float64(Float64(Float64(x * Float64(Float64(y * z) - Float64(t * a))) - Float64(b * Float64(Float64(c * z) - Float64(t * i)))) + Float64(j * Float64(Float64(c * a) - Float64(y * i)))) end
function tmp = code(x, y, z, t, a, b, c, i, j) tmp = ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i))); end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := N[(N[(N[(x * N[(N[(y * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * N[(N[(c * z), $MachinePrecision] - N[(t * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(j * N[(N[(c * a), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right)
\end{array}
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1
(+
(- (* x (- (* y z) (* t a))) (* b (- (* c z) (* t i))))
(* j (- (* c a) (* y i))))))
(if (<= t_1 INFINITY) t_1 (* (fma z y (* (- (/ (* i b) x) a) t)) x))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = ((x * ((y * z) - (t * a))) - (b * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(z, y, ((((i * b) / x) - a) * t)) * x;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(Float64(Float64(x * Float64(Float64(y * z) - Float64(t * a))) - Float64(b * Float64(Float64(c * z) - Float64(t * i)))) + Float64(j * Float64(Float64(c * a) - Float64(y * i)))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(fma(z, y, Float64(Float64(Float64(Float64(i * b) / x) - a) * t)) * x); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[(N[(x * N[(N[(y * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * N[(N[(c * z), $MachinePrecision] - N[(t * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(j * N[(N[(c * a), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(N[(z * y + N[(N[(N[(N[(i * b), $MachinePrecision] / x), $MachinePrecision] - a), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \left(\frac{i \cdot b}{x} - a\right) \cdot t\right) \cdot x\\
\end{array}
\end{array}
if (+.f64 (-.f64 (*.f64 x (-.f64 (*.f64 y z) (*.f64 t a))) (*.f64 b (-.f64 (*.f64 c z) (*.f64 t i)))) (*.f64 j (-.f64 (*.f64 c a) (*.f64 y i)))) < +inf.0Initial program 89.7%
if +inf.0 < (+.f64 (-.f64 (*.f64 x (-.f64 (*.f64 y z) (*.f64 t a))) (*.f64 b (-.f64 (*.f64 c z) (*.f64 t i)))) (*.f64 j (-.f64 (*.f64 c a) (*.f64 y i)))) Initial program 0.0%
Taylor expanded in x around inf
Applied rewrites28.7%
Taylor expanded in t around inf
Applied rewrites63.4%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (+ (* (* z x) y) (* j (- (* c a) (* y i))))))
(if (<= j -4.4e+107)
t_1
(if (<= j -2.3e+58)
(* (* (- (/ (* y x) c) b) z) c)
(if (<= j -8.5e-67)
t_1
(if (<= j 2.85e+82)
(* (fma z y (* (- (/ (* i b) x) a) t)) x)
(fma (fma (- y) i (* c a)) j (* (* (- a) t) x))))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = ((z * x) * y) + (j * ((c * a) - (y * i)));
double tmp;
if (j <= -4.4e+107) {
tmp = t_1;
} else if (j <= -2.3e+58) {
tmp = ((((y * x) / c) - b) * z) * c;
} else if (j <= -8.5e-67) {
tmp = t_1;
} else if (j <= 2.85e+82) {
tmp = fma(z, y, ((((i * b) / x) - a) * t)) * x;
} else {
tmp = fma(fma(-y, i, (c * a)), j, ((-a * t) * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(Float64(Float64(z * x) * y) + Float64(j * Float64(Float64(c * a) - Float64(y * i)))) tmp = 0.0 if (j <= -4.4e+107) tmp = t_1; elseif (j <= -2.3e+58) tmp = Float64(Float64(Float64(Float64(Float64(y * x) / c) - b) * z) * c); elseif (j <= -8.5e-67) tmp = t_1; elseif (j <= 2.85e+82) tmp = Float64(fma(z, y, Float64(Float64(Float64(Float64(i * b) / x) - a) * t)) * x); else tmp = fma(fma(Float64(-y), i, Float64(c * a)), j, Float64(Float64(Float64(-a) * t) * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[(N[(z * x), $MachinePrecision] * y), $MachinePrecision] + N[(j * N[(N[(c * a), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[j, -4.4e+107], t$95$1, If[LessEqual[j, -2.3e+58], N[(N[(N[(N[(N[(y * x), $MachinePrecision] / c), $MachinePrecision] - b), $MachinePrecision] * z), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[j, -8.5e-67], t$95$1, If[LessEqual[j, 2.85e+82], N[(N[(z * y + N[(N[(N[(N[(i * b), $MachinePrecision] / x), $MachinePrecision] - a), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[((-y) * i + N[(c * a), $MachinePrecision]), $MachinePrecision] * j + N[(N[((-a) * t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z \cdot x\right) \cdot y + j \cdot \left(c \cdot a - y \cdot i\right)\\
\mathbf{if}\;j \leq -4.4 \cdot 10^{+107}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;j \leq -2.3 \cdot 10^{+58}:\\
\;\;\;\;\left(\left(\frac{y \cdot x}{c} - b\right) \cdot z\right) \cdot c\\
\mathbf{elif}\;j \leq -8.5 \cdot 10^{-67}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;j \leq 2.85 \cdot 10^{+82}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \left(\frac{i \cdot b}{x} - a\right) \cdot t\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-y, i, c \cdot a\right), j, \left(\left(-a\right) \cdot t\right) \cdot x\right)\\
\end{array}
\end{array}
if j < -4.4e107 or -2.30000000000000002e58 < j < -8.49999999999999993e-67Initial program 71.9%
Taylor expanded in y around inf
Applied rewrites64.6%
if -4.4e107 < j < -2.30000000000000002e58Initial program 60.5%
Taylor expanded in c around inf
Applied rewrites79.8%
Taylor expanded in z around inf
Applied rewrites99.8%
if -8.49999999999999993e-67 < j < 2.85000000000000008e82Initial program 76.6%
Taylor expanded in x around inf
Applied rewrites71.5%
Taylor expanded in t around inf
Applied rewrites66.5%
if 2.85000000000000008e82 < j Initial program 63.0%
Taylor expanded in a around inf
Applied rewrites81.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6483.8
Applied rewrites83.8%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (fma (- z) c (* i t)))
(t_2 (fma t_1 b (* (fma (- t) x (* j c)) a))))
(if (<= b -4e+15)
t_2
(if (<= b 7e-20)
(fma (fma (- t) a (* z y)) x (* (fma (- i) y (* c a)) j))
(if (<= b 1.6e+192) t_2 (fma t_1 b (* (fma (- j) i (* z x)) y)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = fma(-z, c, (i * t));
double t_2 = fma(t_1, b, (fma(-t, x, (j * c)) * a));
double tmp;
if (b <= -4e+15) {
tmp = t_2;
} else if (b <= 7e-20) {
tmp = fma(fma(-t, a, (z * y)), x, (fma(-i, y, (c * a)) * j));
} else if (b <= 1.6e+192) {
tmp = t_2;
} else {
tmp = fma(t_1, b, (fma(-j, i, (z * x)) * y));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = fma(Float64(-z), c, Float64(i * t)) t_2 = fma(t_1, b, Float64(fma(Float64(-t), x, Float64(j * c)) * a)) tmp = 0.0 if (b <= -4e+15) tmp = t_2; elseif (b <= 7e-20) tmp = fma(fma(Float64(-t), a, Float64(z * y)), x, Float64(fma(Float64(-i), y, Float64(c * a)) * j)); elseif (b <= 1.6e+192) tmp = t_2; else tmp = fma(t_1, b, Float64(fma(Float64(-j), i, Float64(z * x)) * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[((-z) * c + N[(i * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * b + N[(N[((-t) * x + N[(j * c), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -4e+15], t$95$2, If[LessEqual[b, 7e-20], N[(N[((-t) * a + N[(z * y), $MachinePrecision]), $MachinePrecision] * x + N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.6e+192], t$95$2, N[(t$95$1 * b + N[(N[((-j) * i + N[(z * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-z, c, i \cdot t\right)\\
t_2 := \mathsf{fma}\left(t\_1, b, \mathsf{fma}\left(-t, x, j \cdot c\right) \cdot a\right)\\
\mathbf{if}\;b \leq -4 \cdot 10^{+15}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \leq 7 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-t, a, z \cdot y\right), x, \mathsf{fma}\left(-i, y, c \cdot a\right) \cdot j\right)\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{+192}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, b, \mathsf{fma}\left(-j, i, z \cdot x\right) \cdot y\right)\\
\end{array}
\end{array}
if b < -4e15 or 7.00000000000000007e-20 < b < 1.60000000000000012e192Initial program 71.8%
Taylor expanded in y around 0
Applied rewrites79.6%
if -4e15 < b < 7.00000000000000007e-20Initial program 74.4%
Taylor expanded in b around 0
Applied rewrites80.4%
if 1.60000000000000012e192 < b Initial program 65.3%
Taylor expanded in a around 0
Applied rewrites92.8%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (* (fma (- y) j (* b t)) i)))
(if (<= i -1.42e+104)
t_1
(if (<= i 6.2e-144)
(fma (fma (- z) b (* a j)) c (* (fma (- a) t (* z y)) x))
(if (<= i 3.4e+136)
(fma (fma (- t) a (* z y)) x (* (fma (- i) y (* c a)) j))
t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = fma(-y, j, (b * t)) * i;
double tmp;
if (i <= -1.42e+104) {
tmp = t_1;
} else if (i <= 6.2e-144) {
tmp = fma(fma(-z, b, (a * j)), c, (fma(-a, t, (z * y)) * x));
} else if (i <= 3.4e+136) {
tmp = fma(fma(-t, a, (z * y)), x, (fma(-i, y, (c * a)) * j));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(fma(Float64(-y), j, Float64(b * t)) * i) tmp = 0.0 if (i <= -1.42e+104) tmp = t_1; elseif (i <= 6.2e-144) tmp = fma(fma(Float64(-z), b, Float64(a * j)), c, Float64(fma(Float64(-a), t, Float64(z * y)) * x)); elseif (i <= 3.4e+136) tmp = fma(fma(Float64(-t), a, Float64(z * y)), x, Float64(fma(Float64(-i), y, Float64(c * a)) * j)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[((-y) * j + N[(b * t), $MachinePrecision]), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[i, -1.42e+104], t$95$1, If[LessEqual[i, 6.2e-144], N[(N[((-z) * b + N[(a * j), $MachinePrecision]), $MachinePrecision] * c + N[(N[((-a) * t + N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 3.4e+136], N[(N[((-t) * a + N[(z * y), $MachinePrecision]), $MachinePrecision] * x + N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-y, j, b \cdot t\right) \cdot i\\
\mathbf{if}\;i \leq -1.42 \cdot 10^{+104}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;i \leq 6.2 \cdot 10^{-144}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-z, b, a \cdot j\right), c, \mathsf{fma}\left(-a, t, z \cdot y\right) \cdot x\right)\\
\mathbf{elif}\;i \leq 3.4 \cdot 10^{+136}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-t, a, z \cdot y\right), x, \mathsf{fma}\left(-i, y, c \cdot a\right) \cdot j\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if i < -1.42e104 or 3.39999999999999997e136 < i Initial program 55.8%
Taylor expanded in i around inf
Applied rewrites74.3%
if -1.42e104 < i < 6.2000000000000001e-144Initial program 76.8%
Taylor expanded in y around inf
Applied rewrites66.6%
Taylor expanded in i around 0
Applied rewrites80.1%
if 6.2000000000000001e-144 < i < 3.39999999999999997e136Initial program 88.5%
Taylor expanded in b around 0
Applied rewrites79.2%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (fma (- t) a (* z y))) (t_2 (* (fma (- y) j (* b t)) i)))
(if (<= i -8.9e+102)
t_2
(if (<= i 6.2e-144)
(fma t_1 x (* (fma (- z) b (* j a)) c))
(if (<= i 3.4e+136) (fma t_1 x (* (fma (- i) y (* c a)) j)) t_2)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = fma(-t, a, (z * y));
double t_2 = fma(-y, j, (b * t)) * i;
double tmp;
if (i <= -8.9e+102) {
tmp = t_2;
} else if (i <= 6.2e-144) {
tmp = fma(t_1, x, (fma(-z, b, (j * a)) * c));
} else if (i <= 3.4e+136) {
tmp = fma(t_1, x, (fma(-i, y, (c * a)) * j));
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = fma(Float64(-t), a, Float64(z * y)) t_2 = Float64(fma(Float64(-y), j, Float64(b * t)) * i) tmp = 0.0 if (i <= -8.9e+102) tmp = t_2; elseif (i <= 6.2e-144) tmp = fma(t_1, x, Float64(fma(Float64(-z), b, Float64(j * a)) * c)); elseif (i <= 3.4e+136) tmp = fma(t_1, x, Float64(fma(Float64(-i), y, Float64(c * a)) * j)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[((-t) * a + N[(z * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[((-y) * j + N[(b * t), $MachinePrecision]), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[i, -8.9e+102], t$95$2, If[LessEqual[i, 6.2e-144], N[(t$95$1 * x + N[(N[((-z) * b + N[(j * a), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 3.4e+136], N[(t$95$1 * x + N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-t, a, z \cdot y\right)\\
t_2 := \mathsf{fma}\left(-y, j, b \cdot t\right) \cdot i\\
\mathbf{if}\;i \leq -8.9 \cdot 10^{+102}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;i \leq 6.2 \cdot 10^{-144}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, x, \mathsf{fma}\left(-z, b, j \cdot a\right) \cdot c\right)\\
\mathbf{elif}\;i \leq 3.4 \cdot 10^{+136}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, x, \mathsf{fma}\left(-i, y, c \cdot a\right) \cdot j\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if i < -8.8999999999999999e102 or 3.39999999999999997e136 < i Initial program 55.8%
Taylor expanded in i around inf
Applied rewrites74.3%
if -8.8999999999999999e102 < i < 6.2000000000000001e-144Initial program 76.8%
Taylor expanded in i around 0
Applied rewrites77.7%
if 6.2000000000000001e-144 < i < 3.39999999999999997e136Initial program 88.5%
Taylor expanded in b around 0
Applied rewrites79.2%
(FPCore (x y z t a b c i j)
:precision binary64
(if (<= b -1.06e+35)
(* (* (- (/ (* i t) c) z) c) b)
(if (<= b 1.15e+121)
(fma (fma (- t) a (* z y)) x (* (fma (- i) y (* c a)) j))
(* (fma (- y) j (* b t)) i))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if (b <= -1.06e+35) {
tmp = ((((i * t) / c) - z) * c) * b;
} else if (b <= 1.15e+121) {
tmp = fma(fma(-t, a, (z * y)), x, (fma(-i, y, (c * a)) * j));
} else {
tmp = fma(-y, j, (b * t)) * i;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if (b <= -1.06e+35) tmp = Float64(Float64(Float64(Float64(Float64(i * t) / c) - z) * c) * b); elseif (b <= 1.15e+121) tmp = fma(fma(Float64(-t), a, Float64(z * y)), x, Float64(fma(Float64(-i), y, Float64(c * a)) * j)); else tmp = Float64(fma(Float64(-y), j, Float64(b * t)) * i); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[LessEqual[b, -1.06e+35], N[(N[(N[(N[(N[(i * t), $MachinePrecision] / c), $MachinePrecision] - z), $MachinePrecision] * c), $MachinePrecision] * b), $MachinePrecision], If[LessEqual[b, 1.15e+121], N[(N[((-t) * a + N[(z * y), $MachinePrecision]), $MachinePrecision] * x + N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision]), $MachinePrecision], N[(N[((-y) * j + N[(b * t), $MachinePrecision]), $MachinePrecision] * i), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.06 \cdot 10^{+35}:\\
\;\;\;\;\left(\left(\frac{i \cdot t}{c} - z\right) \cdot c\right) \cdot b\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{+121}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-t, a, z \cdot y\right), x, \mathsf{fma}\left(-i, y, c \cdot a\right) \cdot j\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, j, b \cdot t\right) \cdot i\\
\end{array}
\end{array}
if b < -1.0600000000000001e35Initial program 70.0%
Taylor expanded in c around inf
Applied rewrites72.2%
Taylor expanded in b around inf
Applied rewrites70.7%
if -1.0600000000000001e35 < b < 1.1499999999999999e121Initial program 74.2%
Taylor expanded in b around 0
Applied rewrites76.4%
if 1.1499999999999999e121 < b Initial program 68.4%
Taylor expanded in i around inf
Applied rewrites74.6%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (* (fma (- c) b (* y x)) z)))
(if (<= z -7.2e+246)
t_1
(if (<= z -4.2e+14)
(* (fma (- j) i (* z x)) y)
(if (<= z 1.9e-172)
(* (fma (- t) x (* j c)) a)
(if (<= z 2.6e-140)
(* (fma (- a) x (* i b)) t)
(if (<= z 5.3e+73) (* (fma (- i) y (* c a)) j) t_1)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = fma(-c, b, (y * x)) * z;
double tmp;
if (z <= -7.2e+246) {
tmp = t_1;
} else if (z <= -4.2e+14) {
tmp = fma(-j, i, (z * x)) * y;
} else if (z <= 1.9e-172) {
tmp = fma(-t, x, (j * c)) * a;
} else if (z <= 2.6e-140) {
tmp = fma(-a, x, (i * b)) * t;
} else if (z <= 5.3e+73) {
tmp = fma(-i, y, (c * a)) * j;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(fma(Float64(-c), b, Float64(y * x)) * z) tmp = 0.0 if (z <= -7.2e+246) tmp = t_1; elseif (z <= -4.2e+14) tmp = Float64(fma(Float64(-j), i, Float64(z * x)) * y); elseif (z <= 1.9e-172) tmp = Float64(fma(Float64(-t), x, Float64(j * c)) * a); elseif (z <= 2.6e-140) tmp = Float64(fma(Float64(-a), x, Float64(i * b)) * t); elseif (z <= 5.3e+73) tmp = Float64(fma(Float64(-i), y, Float64(c * a)) * j); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[((-c) * b + N[(y * x), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -7.2e+246], t$95$1, If[LessEqual[z, -4.2e+14], N[(N[((-j) * i + N[(z * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, 1.9e-172], N[(N[((-t) * x + N[(j * c), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[z, 2.6e-140], N[(N[((-a) * x + N[(i * b), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[z, 5.3e+73], N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-c, b, y \cdot x\right) \cdot z\\
\mathbf{if}\;z \leq -7.2 \cdot 10^{+246}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -4.2 \cdot 10^{+14}:\\
\;\;\;\;\mathsf{fma}\left(-j, i, z \cdot x\right) \cdot y\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{-172}:\\
\;\;\;\;\mathsf{fma}\left(-t, x, j \cdot c\right) \cdot a\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-140}:\\
\;\;\;\;\mathsf{fma}\left(-a, x, i \cdot b\right) \cdot t\\
\mathbf{elif}\;z \leq 5.3 \cdot 10^{+73}:\\
\;\;\;\;\mathsf{fma}\left(-i, y, c \cdot a\right) \cdot j\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -7.2e246 or 5.29999999999999996e73 < z Initial program 63.6%
Taylor expanded in z around inf
Applied rewrites74.2%
if -7.2e246 < z < -4.2e14Initial program 58.0%
Taylor expanded in y around inf
Applied rewrites68.6%
if -4.2e14 < z < 1.89999999999999993e-172Initial program 82.1%
Taylor expanded in a around inf
Applied rewrites53.1%
if 1.89999999999999993e-172 < z < 2.5999999999999998e-140Initial program 81.7%
Taylor expanded in t around inf
Applied rewrites78.3%
if 2.5999999999999998e-140 < z < 5.29999999999999996e73Initial program 77.3%
Taylor expanded in j around inf
Applied rewrites47.6%
(FPCore (x y z t a b c i j) :precision binary64 (if (or (<= z -1.5e+140) (not (<= z 3.7e+74))) (* (fma (- c) b (* y x)) z) (fma (fma (- y) i (* c a)) j (* (* (- a) t) x))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if ((z <= -1.5e+140) || !(z <= 3.7e+74)) {
tmp = fma(-c, b, (y * x)) * z;
} else {
tmp = fma(fma(-y, i, (c * a)), j, ((-a * t) * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((z <= -1.5e+140) || !(z <= 3.7e+74)) tmp = Float64(fma(Float64(-c), b, Float64(y * x)) * z); else tmp = fma(fma(Float64(-y), i, Float64(c * a)), j, Float64(Float64(Float64(-a) * t) * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[z, -1.5e+140], N[Not[LessEqual[z, 3.7e+74]], $MachinePrecision]], N[(N[((-c) * b + N[(y * x), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[((-y) * i + N[(c * a), $MachinePrecision]), $MachinePrecision] * j + N[(N[((-a) * t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+140} \lor \neg \left(z \leq 3.7 \cdot 10^{+74}\right):\\
\;\;\;\;\mathsf{fma}\left(-c, b, y \cdot x\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-y, i, c \cdot a\right), j, \left(\left(-a\right) \cdot t\right) \cdot x\right)\\
\end{array}
\end{array}
if z < -1.49999999999999998e140 or 3.7000000000000001e74 < z Initial program 60.4%
Taylor expanded in z around inf
Applied rewrites72.4%
if -1.49999999999999998e140 < z < 3.7000000000000001e74Initial program 78.8%
Taylor expanded in a around inf
Applied rewrites56.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6457.1
Applied rewrites59.9%
Final simplification64.2%
(FPCore (x y z t a b c i j)
:precision binary64
(if (<= b -2e+38)
(* (* (- (/ (* i t) c) z) c) b)
(if (<= b 3.8e+104)
(+ (* (* z x) y) (* j (- (* c a) (* y i))))
(* (fma (- y) j (* b t)) i))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if (b <= -2e+38) {
tmp = ((((i * t) / c) - z) * c) * b;
} else if (b <= 3.8e+104) {
tmp = ((z * x) * y) + (j * ((c * a) - (y * i)));
} else {
tmp = fma(-y, j, (b * t)) * i;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if (b <= -2e+38) tmp = Float64(Float64(Float64(Float64(Float64(i * t) / c) - z) * c) * b); elseif (b <= 3.8e+104) tmp = Float64(Float64(Float64(z * x) * y) + Float64(j * Float64(Float64(c * a) - Float64(y * i)))); else tmp = Float64(fma(Float64(-y), j, Float64(b * t)) * i); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[LessEqual[b, -2e+38], N[(N[(N[(N[(N[(i * t), $MachinePrecision] / c), $MachinePrecision] - z), $MachinePrecision] * c), $MachinePrecision] * b), $MachinePrecision], If[LessEqual[b, 3.8e+104], N[(N[(N[(z * x), $MachinePrecision] * y), $MachinePrecision] + N[(j * N[(N[(c * a), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-y) * j + N[(b * t), $MachinePrecision]), $MachinePrecision] * i), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+38}:\\
\;\;\;\;\left(\left(\frac{i \cdot t}{c} - z\right) \cdot c\right) \cdot b\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{+104}:\\
\;\;\;\;\left(z \cdot x\right) \cdot y + j \cdot \left(c \cdot a - y \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, j, b \cdot t\right) \cdot i\\
\end{array}
\end{array}
if b < -1.99999999999999995e38Initial program 71.3%
Taylor expanded in c around inf
Applied rewrites73.6%
Taylor expanded in b around inf
Applied rewrites70.2%
if -1.99999999999999995e38 < b < 3.79999999999999969e104Initial program 73.9%
Taylor expanded in y around inf
Applied rewrites61.1%
if 3.79999999999999969e104 < b Initial program 68.3%
Taylor expanded in i around inf
Applied rewrites68.9%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (* (* z y) x)) (t_2 (* (* b t) i)))
(if (<= b -3.5e+23)
t_2
(if (<= b -1.8e-106)
t_1
(if (<= b -2.25e-190)
(* (* (- t) x) a)
(if (<= b 4.2e-130) (* (* (- y) j) i) (if (<= b 5e+115) t_1 t_2)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = (z * y) * x;
double t_2 = (b * t) * i;
double tmp;
if (b <= -3.5e+23) {
tmp = t_2;
} else if (b <= -1.8e-106) {
tmp = t_1;
} else if (b <= -2.25e-190) {
tmp = (-t * x) * a;
} else if (b <= 4.2e-130) {
tmp = (-y * j) * i;
} else if (b <= 5e+115) {
tmp = t_1;
} else {
tmp = t_2;
}
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, c, i, j)
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), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (z * y) * x
t_2 = (b * t) * i
if (b <= (-3.5d+23)) then
tmp = t_2
else if (b <= (-1.8d-106)) then
tmp = t_1
else if (b <= (-2.25d-190)) then
tmp = (-t * x) * a
else if (b <= 4.2d-130) then
tmp = (-y * j) * i
else if (b <= 5d+115) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = (z * y) * x;
double t_2 = (b * t) * i;
double tmp;
if (b <= -3.5e+23) {
tmp = t_2;
} else if (b <= -1.8e-106) {
tmp = t_1;
} else if (b <= -2.25e-190) {
tmp = (-t * x) * a;
} else if (b <= 4.2e-130) {
tmp = (-y * j) * i;
} else if (b <= 5e+115) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i, j): t_1 = (z * y) * x t_2 = (b * t) * i tmp = 0 if b <= -3.5e+23: tmp = t_2 elif b <= -1.8e-106: tmp = t_1 elif b <= -2.25e-190: tmp = (-t * x) * a elif b <= 4.2e-130: tmp = (-y * j) * i elif b <= 5e+115: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(Float64(z * y) * x) t_2 = Float64(Float64(b * t) * i) tmp = 0.0 if (b <= -3.5e+23) tmp = t_2; elseif (b <= -1.8e-106) tmp = t_1; elseif (b <= -2.25e-190) tmp = Float64(Float64(Float64(-t) * x) * a); elseif (b <= 4.2e-130) tmp = Float64(Float64(Float64(-y) * j) * i); elseif (b <= 5e+115) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i, j) t_1 = (z * y) * x; t_2 = (b * t) * i; tmp = 0.0; if (b <= -3.5e+23) tmp = t_2; elseif (b <= -1.8e-106) tmp = t_1; elseif (b <= -2.25e-190) tmp = (-t * x) * a; elseif (b <= 4.2e-130) tmp = (-y * j) * i; elseif (b <= 5e+115) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[(z * y), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b * t), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[b, -3.5e+23], t$95$2, If[LessEqual[b, -1.8e-106], t$95$1, If[LessEqual[b, -2.25e-190], N[(N[((-t) * x), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[b, 4.2e-130], N[(N[((-y) * j), $MachinePrecision] * i), $MachinePrecision], If[LessEqual[b, 5e+115], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z \cdot y\right) \cdot x\\
t_2 := \left(b \cdot t\right) \cdot i\\
\mathbf{if}\;b \leq -3.5 \cdot 10^{+23}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \leq -1.8 \cdot 10^{-106}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -2.25 \cdot 10^{-190}:\\
\;\;\;\;\left(\left(-t\right) \cdot x\right) \cdot a\\
\mathbf{elif}\;b \leq 4.2 \cdot 10^{-130}:\\
\;\;\;\;\left(\left(-y\right) \cdot j\right) \cdot i\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+115}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if b < -3.5000000000000002e23 or 5.00000000000000008e115 < b Initial program 70.0%
Taylor expanded in t around inf
Applied rewrites47.2%
Taylor expanded in x around 0
Applied rewrites46.7%
Applied rewrites47.7%
if -3.5000000000000002e23 < b < -1.80000000000000006e-106 or 4.20000000000000004e-130 < b < 5.00000000000000008e115Initial program 76.6%
Taylor expanded in y around inf
Applied rewrites66.1%
Taylor expanded in b around 0
Applied rewrites68.1%
Taylor expanded in z around inf
Applied rewrites38.3%
if -1.80000000000000006e-106 < b < -2.2500000000000001e-190Initial program 67.5%
Taylor expanded in a around inf
Applied rewrites51.0%
Taylor expanded in x around inf
Applied rewrites49.5%
if -2.2500000000000001e-190 < b < 4.20000000000000004e-130Initial program 72.4%
Taylor expanded in j around inf
Applied rewrites49.3%
Taylor expanded in y around inf
Applied rewrites37.3%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (* (fma (- t) a (* z y)) x)))
(if (<= x -3.1e+71)
t_1
(if (<= x -5e-175)
(* (fma (- z) b (* j a)) c)
(if (<= x 1.6e+28) (* (fma (- y) j (* b t)) i) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = fma(-t, a, (z * y)) * x;
double tmp;
if (x <= -3.1e+71) {
tmp = t_1;
} else if (x <= -5e-175) {
tmp = fma(-z, b, (j * a)) * c;
} else if (x <= 1.6e+28) {
tmp = fma(-y, j, (b * t)) * i;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(fma(Float64(-t), a, Float64(z * y)) * x) tmp = 0.0 if (x <= -3.1e+71) tmp = t_1; elseif (x <= -5e-175) tmp = Float64(fma(Float64(-z), b, Float64(j * a)) * c); elseif (x <= 1.6e+28) tmp = Float64(fma(Float64(-y), j, Float64(b * t)) * i); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[((-t) * a + N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -3.1e+71], t$95$1, If[LessEqual[x, -5e-175], N[(N[((-z) * b + N[(j * a), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[x, 1.6e+28], N[(N[((-y) * j + N[(b * t), $MachinePrecision]), $MachinePrecision] * i), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-t, a, z \cdot y\right) \cdot x\\
\mathbf{if}\;x \leq -3.1 \cdot 10^{+71}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-175}:\\
\;\;\;\;\mathsf{fma}\left(-z, b, j \cdot a\right) \cdot c\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+28}:\\
\;\;\;\;\mathsf{fma}\left(-y, j, b \cdot t\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.10000000000000018e71 or 1.6e28 < x Initial program 73.6%
Taylor expanded in x around inf
Applied rewrites67.9%
if -3.10000000000000018e71 < x < -5e-175Initial program 74.8%
Taylor expanded in c around inf
Applied rewrites50.2%
if -5e-175 < x < 1.6e28Initial program 70.4%
Taylor expanded in i around inf
Applied rewrites61.8%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (* (fma (- c) b (* y x)) z)))
(if (<= z -7.2e+246)
t_1
(if (<= z -1.15e+26)
(* (fma (- j) i (* z x)) y)
(if (<= z 5.3e+73) (* (fma (- i) y (* c a)) j) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = fma(-c, b, (y * x)) * z;
double tmp;
if (z <= -7.2e+246) {
tmp = t_1;
} else if (z <= -1.15e+26) {
tmp = fma(-j, i, (z * x)) * y;
} else if (z <= 5.3e+73) {
tmp = fma(-i, y, (c * a)) * j;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(fma(Float64(-c), b, Float64(y * x)) * z) tmp = 0.0 if (z <= -7.2e+246) tmp = t_1; elseif (z <= -1.15e+26) tmp = Float64(fma(Float64(-j), i, Float64(z * x)) * y); elseif (z <= 5.3e+73) tmp = Float64(fma(Float64(-i), y, Float64(c * a)) * j); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[((-c) * b + N[(y * x), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -7.2e+246], t$95$1, If[LessEqual[z, -1.15e+26], N[(N[((-j) * i + N[(z * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, 5.3e+73], N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-c, b, y \cdot x\right) \cdot z\\
\mathbf{if}\;z \leq -7.2 \cdot 10^{+246}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1.15 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{fma}\left(-j, i, z \cdot x\right) \cdot y\\
\mathbf{elif}\;z \leq 5.3 \cdot 10^{+73}:\\
\;\;\;\;\mathsf{fma}\left(-i, y, c \cdot a\right) \cdot j\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -7.2e246 or 5.29999999999999996e73 < z Initial program 63.6%
Taylor expanded in z around inf
Applied rewrites74.2%
if -7.2e246 < z < -1.15e26Initial program 55.8%
Taylor expanded in y around inf
Applied rewrites67.0%
if -1.15e26 < z < 5.29999999999999996e73Initial program 80.8%
Taylor expanded in j around inf
Applied rewrites46.1%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (* (fma (- a) x (* i b)) t)))
(if (<= t -4e-13)
t_1
(if (<= t -1.02e-177)
(* (* j c) a)
(if (<= t 1.26e-130) (* (* (- y) j) i) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = fma(-a, x, (i * b)) * t;
double tmp;
if (t <= -4e-13) {
tmp = t_1;
} else if (t <= -1.02e-177) {
tmp = (j * c) * a;
} else if (t <= 1.26e-130) {
tmp = (-y * j) * i;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(fma(Float64(-a), x, Float64(i * b)) * t) tmp = 0.0 if (t <= -4e-13) tmp = t_1; elseif (t <= -1.02e-177) tmp = Float64(Float64(j * c) * a); elseif (t <= 1.26e-130) tmp = Float64(Float64(Float64(-y) * j) * i); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[((-a) * x + N[(i * b), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t, -4e-13], t$95$1, If[LessEqual[t, -1.02e-177], N[(N[(j * c), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[t, 1.26e-130], N[(N[((-y) * j), $MachinePrecision] * i), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-a, x, i \cdot b\right) \cdot t\\
\mathbf{if}\;t \leq -4 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq -1.02 \cdot 10^{-177}:\\
\;\;\;\;\left(j \cdot c\right) \cdot a\\
\mathbf{elif}\;t \leq 1.26 \cdot 10^{-130}:\\
\;\;\;\;\left(\left(-y\right) \cdot j\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -4.0000000000000001e-13 or 1.2599999999999999e-130 < t Initial program 69.0%
Taylor expanded in t around inf
Applied rewrites52.7%
if -4.0000000000000001e-13 < t < -1.01999999999999997e-177Initial program 78.1%
Taylor expanded in a around inf
Applied rewrites41.3%
Taylor expanded in x around 0
Applied rewrites35.3%
if -1.01999999999999997e-177 < t < 1.2599999999999999e-130Initial program 76.7%
Taylor expanded in j around inf
Applied rewrites51.3%
Taylor expanded in y around inf
Applied rewrites38.0%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (* (* z y) x)) (t_2 (* (* b t) i)))
(if (<= b -3.5e+23)
t_2
(if (<= b -4.7e-222)
t_1
(if (<= b 4.2e-130) (* (* (- y) j) i) (if (<= b 5e+115) t_1 t_2))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = (z * y) * x;
double t_2 = (b * t) * i;
double tmp;
if (b <= -3.5e+23) {
tmp = t_2;
} else if (b <= -4.7e-222) {
tmp = t_1;
} else if (b <= 4.2e-130) {
tmp = (-y * j) * i;
} else if (b <= 5e+115) {
tmp = t_1;
} else {
tmp = t_2;
}
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, c, i, j)
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), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (z * y) * x
t_2 = (b * t) * i
if (b <= (-3.5d+23)) then
tmp = t_2
else if (b <= (-4.7d-222)) then
tmp = t_1
else if (b <= 4.2d-130) then
tmp = (-y * j) * i
else if (b <= 5d+115) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = (z * y) * x;
double t_2 = (b * t) * i;
double tmp;
if (b <= -3.5e+23) {
tmp = t_2;
} else if (b <= -4.7e-222) {
tmp = t_1;
} else if (b <= 4.2e-130) {
tmp = (-y * j) * i;
} else if (b <= 5e+115) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i, j): t_1 = (z * y) * x t_2 = (b * t) * i tmp = 0 if b <= -3.5e+23: tmp = t_2 elif b <= -4.7e-222: tmp = t_1 elif b <= 4.2e-130: tmp = (-y * j) * i elif b <= 5e+115: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(Float64(z * y) * x) t_2 = Float64(Float64(b * t) * i) tmp = 0.0 if (b <= -3.5e+23) tmp = t_2; elseif (b <= -4.7e-222) tmp = t_1; elseif (b <= 4.2e-130) tmp = Float64(Float64(Float64(-y) * j) * i); elseif (b <= 5e+115) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i, j) t_1 = (z * y) * x; t_2 = (b * t) * i; tmp = 0.0; if (b <= -3.5e+23) tmp = t_2; elseif (b <= -4.7e-222) tmp = t_1; elseif (b <= 4.2e-130) tmp = (-y * j) * i; elseif (b <= 5e+115) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[(z * y), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b * t), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[b, -3.5e+23], t$95$2, If[LessEqual[b, -4.7e-222], t$95$1, If[LessEqual[b, 4.2e-130], N[(N[((-y) * j), $MachinePrecision] * i), $MachinePrecision], If[LessEqual[b, 5e+115], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z \cdot y\right) \cdot x\\
t_2 := \left(b \cdot t\right) \cdot i\\
\mathbf{if}\;b \leq -3.5 \cdot 10^{+23}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \leq -4.7 \cdot 10^{-222}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 4.2 \cdot 10^{-130}:\\
\;\;\;\;\left(\left(-y\right) \cdot j\right) \cdot i\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+115}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if b < -3.5000000000000002e23 or 5.00000000000000008e115 < b Initial program 70.0%
Taylor expanded in t around inf
Applied rewrites47.2%
Taylor expanded in x around 0
Applied rewrites46.7%
Applied rewrites47.7%
if -3.5000000000000002e23 < b < -4.6999999999999997e-222 or 4.20000000000000004e-130 < b < 5.00000000000000008e115Initial program 75.1%
Taylor expanded in y around inf
Applied rewrites65.4%
Taylor expanded in b around 0
Applied rewrites65.5%
Taylor expanded in z around inf
Applied rewrites34.8%
if -4.6999999999999997e-222 < b < 4.20000000000000004e-130Initial program 71.6%
Taylor expanded in j around inf
Applied rewrites51.3%
Taylor expanded in y around inf
Applied rewrites39.2%
(FPCore (x y z t a b c i j) :precision binary64 (if (or (<= x -1.55e+46) (not (<= x 1.6e+28))) (* (fma (- t) a (* z y)) x) (* (fma (- y) j (* b t)) i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if ((x <= -1.55e+46) || !(x <= 1.6e+28)) {
tmp = fma(-t, a, (z * y)) * x;
} else {
tmp = fma(-y, j, (b * t)) * i;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((x <= -1.55e+46) || !(x <= 1.6e+28)) tmp = Float64(fma(Float64(-t), a, Float64(z * y)) * x); else tmp = Float64(fma(Float64(-y), j, Float64(b * t)) * i); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[x, -1.55e+46], N[Not[LessEqual[x, 1.6e+28]], $MachinePrecision]], N[(N[((-t) * a + N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[((-y) * j + N[(b * t), $MachinePrecision]), $MachinePrecision] * i), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{+46} \lor \neg \left(x \leq 1.6 \cdot 10^{+28}\right):\\
\;\;\;\;\mathsf{fma}\left(-t, a, z \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, j, b \cdot t\right) \cdot i\\
\end{array}
\end{array}
if x < -1.54999999999999988e46 or 1.6e28 < x Initial program 73.1%
Taylor expanded in x around inf
Applied rewrites65.9%
if -1.54999999999999988e46 < x < 1.6e28Initial program 72.1%
Taylor expanded in i around inf
Applied rewrites55.9%
Final simplification60.5%
(FPCore (x y z t a b c i j) :precision binary64 (if (or (<= j -1.45e-67) (not (<= j 8.4e+83))) (* (fma (- i) y (* c a)) j) (* (fma (- t) a (* z y)) x)))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if ((j <= -1.45e-67) || !(j <= 8.4e+83)) {
tmp = fma(-i, y, (c * a)) * j;
} else {
tmp = fma(-t, a, (z * y)) * x;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((j <= -1.45e-67) || !(j <= 8.4e+83)) tmp = Float64(fma(Float64(-i), y, Float64(c * a)) * j); else tmp = Float64(fma(Float64(-t), a, Float64(z * y)) * x); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[j, -1.45e-67], N[Not[LessEqual[j, 8.4e+83]], $MachinePrecision]], N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision], N[(N[((-t) * a + N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;j \leq -1.45 \cdot 10^{-67} \lor \neg \left(j \leq 8.4 \cdot 10^{+83}\right):\\
\;\;\;\;\mathsf{fma}\left(-i, y, c \cdot a\right) \cdot j\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-t, a, z \cdot y\right) \cdot x\\
\end{array}
\end{array}
if j < -1.45000000000000002e-67 or 8.4000000000000001e83 < j Initial program 67.0%
Taylor expanded in j around inf
Applied rewrites58.3%
if -1.45000000000000002e-67 < j < 8.4000000000000001e83Initial program 77.2%
Taylor expanded in x around inf
Applied rewrites53.7%
Final simplification55.8%
(FPCore (x y z t a b c i j) :precision binary64 (if (or (<= z -5.8e+84) (not (<= z 5.3e+73))) (* (fma (- c) b (* y x)) z) (* (fma (- i) y (* c a)) j)))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if ((z <= -5.8e+84) || !(z <= 5.3e+73)) {
tmp = fma(-c, b, (y * x)) * z;
} else {
tmp = fma(-i, y, (c * a)) * j;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((z <= -5.8e+84) || !(z <= 5.3e+73)) tmp = Float64(fma(Float64(-c), b, Float64(y * x)) * z); else tmp = Float64(fma(Float64(-i), y, Float64(c * a)) * j); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[z, -5.8e+84], N[Not[LessEqual[z, 5.3e+73]], $MachinePrecision]], N[(N[((-c) * b + N[(y * x), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+84} \lor \neg \left(z \leq 5.3 \cdot 10^{+73}\right):\\
\;\;\;\;\mathsf{fma}\left(-c, b, y \cdot x\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-i, y, c \cdot a\right) \cdot j\\
\end{array}
\end{array}
if z < -5.79999999999999977e84 or 5.29999999999999996e73 < z Initial program 62.7%
Taylor expanded in z around inf
Applied rewrites69.1%
if -5.79999999999999977e84 < z < 5.29999999999999996e73Initial program 78.3%
Taylor expanded in j around inf
Applied rewrites45.5%
Final simplification54.3%
(FPCore (x y z t a b c i j) :precision binary64 (if (or (<= z -7e+60) (not (<= z 3.4e-40))) (* (fma (- c) b (* y x)) z) (* (fma (- a) x (* i b)) t)))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if ((z <= -7e+60) || !(z <= 3.4e-40)) {
tmp = fma(-c, b, (y * x)) * z;
} else {
tmp = fma(-a, x, (i * b)) * t;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((z <= -7e+60) || !(z <= 3.4e-40)) tmp = Float64(fma(Float64(-c), b, Float64(y * x)) * z); else tmp = Float64(fma(Float64(-a), x, Float64(i * b)) * t); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[z, -7e+60], N[Not[LessEqual[z, 3.4e-40]], $MachinePrecision]], N[(N[((-c) * b + N[(y * x), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[((-a) * x + N[(i * b), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7 \cdot 10^{+60} \lor \neg \left(z \leq 3.4 \cdot 10^{-40}\right):\\
\;\;\;\;\mathsf{fma}\left(-c, b, y \cdot x\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-a, x, i \cdot b\right) \cdot t\\
\end{array}
\end{array}
if z < -7.0000000000000004e60 or 3.39999999999999984e-40 < z Initial program 65.1%
Taylor expanded in z around inf
Applied rewrites59.4%
if -7.0000000000000004e60 < z < 3.39999999999999984e-40Initial program 79.9%
Taylor expanded in t around inf
Applied rewrites45.5%
Final simplification52.4%
(FPCore (x y z t a b c i j) :precision binary64 (if (or (<= b -3.5e+23) (not (<= b 5e+115))) (* (* b t) i) (* (* z y) x)))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if ((b <= -3.5e+23) || !(b <= 5e+115)) {
tmp = (b * t) * i;
} else {
tmp = (z * y) * x;
}
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, c, i, j)
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), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
real(8) :: tmp
if ((b <= (-3.5d+23)) .or. (.not. (b <= 5d+115))) then
tmp = (b * t) * i
else
tmp = (z * y) * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if ((b <= -3.5e+23) || !(b <= 5e+115)) {
tmp = (b * t) * i;
} else {
tmp = (z * y) * x;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i, j): tmp = 0 if (b <= -3.5e+23) or not (b <= 5e+115): tmp = (b * t) * i else: tmp = (z * y) * x return tmp
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((b <= -3.5e+23) || !(b <= 5e+115)) tmp = Float64(Float64(b * t) * i); else tmp = Float64(Float64(z * y) * x); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i, j) tmp = 0.0; if ((b <= -3.5e+23) || ~((b <= 5e+115))) tmp = (b * t) * i; else tmp = (z * y) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[b, -3.5e+23], N[Not[LessEqual[b, 5e+115]], $MachinePrecision]], N[(N[(b * t), $MachinePrecision] * i), $MachinePrecision], N[(N[(z * y), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.5 \cdot 10^{+23} \lor \neg \left(b \leq 5 \cdot 10^{+115}\right):\\
\;\;\;\;\left(b \cdot t\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot y\right) \cdot x\\
\end{array}
\end{array}
if b < -3.5000000000000002e23 or 5.00000000000000008e115 < b Initial program 70.0%
Taylor expanded in t around inf
Applied rewrites47.2%
Taylor expanded in x around 0
Applied rewrites46.7%
Applied rewrites47.7%
if -3.5000000000000002e23 < b < 5.00000000000000008e115Initial program 73.9%
Taylor expanded in y around inf
Applied rewrites64.1%
Taylor expanded in b around 0
Applied rewrites70.3%
Taylor expanded in z around inf
Applied rewrites30.8%
Final simplification36.7%
(FPCore (x y z t a b c i j) :precision binary64 (* (* b t) i))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
return (b * t) * i;
}
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, c, i, j)
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), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
code = (b * t) * i
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
return (b * t) * i;
}
def code(x, y, z, t, a, b, c, i, j): return (b * t) * i
function code(x, y, z, t, a, b, c, i, j) return Float64(Float64(b * t) * i) end
function tmp = code(x, y, z, t, a, b, c, i, j) tmp = (b * t) * i; end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := N[(N[(b * t), $MachinePrecision] * i), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot t\right) \cdot i
\end{array}
Initial program 72.5%
Taylor expanded in t around inf
Applied rewrites35.9%
Taylor expanded in x around 0
Applied rewrites22.2%
Applied rewrites22.5%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (* j (- (* c a) (* y i))))
(t_2
(+
(-
(* x (- (* y z) (* t a)))
(/
(* b (- (pow (* c z) 2.0) (pow (* t i) 2.0)))
(+ (* c z) (* t i))))
t_1)))
(if (< x -1.469694296777705e-64)
t_2
(if (< x 3.2113527362226803e-147)
(- (* (- (* b i) (* x a)) t) (- (* z (* c b)) t_1))
t_2))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = j * ((c * a) - (y * i));
double t_2 = ((x * ((y * z) - (t * a))) - ((b * (pow((c * z), 2.0) - pow((t * i), 2.0))) / ((c * z) + (t * i)))) + t_1;
double tmp;
if (x < -1.469694296777705e-64) {
tmp = t_2;
} else if (x < 3.2113527362226803e-147) {
tmp = (((b * i) - (x * a)) * t) - ((z * (c * b)) - t_1);
} else {
tmp = t_2;
}
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, c, i, j)
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), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = j * ((c * a) - (y * i))
t_2 = ((x * ((y * z) - (t * a))) - ((b * (((c * z) ** 2.0d0) - ((t * i) ** 2.0d0))) / ((c * z) + (t * i)))) + t_1
if (x < (-1.469694296777705d-64)) then
tmp = t_2
else if (x < 3.2113527362226803d-147) then
tmp = (((b * i) - (x * a)) * t) - ((z * (c * b)) - t_1)
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = j * ((c * a) - (y * i));
double t_2 = ((x * ((y * z) - (t * a))) - ((b * (Math.pow((c * z), 2.0) - Math.pow((t * i), 2.0))) / ((c * z) + (t * i)))) + t_1;
double tmp;
if (x < -1.469694296777705e-64) {
tmp = t_2;
} else if (x < 3.2113527362226803e-147) {
tmp = (((b * i) - (x * a)) * t) - ((z * (c * b)) - t_1);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i, j): t_1 = j * ((c * a) - (y * i)) t_2 = ((x * ((y * z) - (t * a))) - ((b * (math.pow((c * z), 2.0) - math.pow((t * i), 2.0))) / ((c * z) + (t * i)))) + t_1 tmp = 0 if x < -1.469694296777705e-64: tmp = t_2 elif x < 3.2113527362226803e-147: tmp = (((b * i) - (x * a)) * t) - ((z * (c * b)) - t_1) else: tmp = t_2 return tmp
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(j * Float64(Float64(c * a) - Float64(y * i))) t_2 = Float64(Float64(Float64(x * Float64(Float64(y * z) - Float64(t * a))) - Float64(Float64(b * Float64((Float64(c * z) ^ 2.0) - (Float64(t * i) ^ 2.0))) / Float64(Float64(c * z) + Float64(t * i)))) + t_1) tmp = 0.0 if (x < -1.469694296777705e-64) tmp = t_2; elseif (x < 3.2113527362226803e-147) tmp = Float64(Float64(Float64(Float64(b * i) - Float64(x * a)) * t) - Float64(Float64(z * Float64(c * b)) - t_1)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i, j) t_1 = j * ((c * a) - (y * i)); t_2 = ((x * ((y * z) - (t * a))) - ((b * (((c * z) ^ 2.0) - ((t * i) ^ 2.0))) / ((c * z) + (t * i)))) + t_1; tmp = 0.0; if (x < -1.469694296777705e-64) tmp = t_2; elseif (x < 3.2113527362226803e-147) tmp = (((b * i) - (x * a)) * t) - ((z * (c * b)) - t_1); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(j * N[(N[(c * a), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x * N[(N[(y * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(b * N[(N[Power[N[(c * z), $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[(t * i), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(c * z), $MachinePrecision] + N[(t * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[Less[x, -1.469694296777705e-64], t$95$2, If[Less[x, 3.2113527362226803e-147], N[(N[(N[(N[(b * i), $MachinePrecision] - N[(x * a), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision] - N[(N[(z * N[(c * b), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := j \cdot \left(c \cdot a - y \cdot i\right)\\
t_2 := \left(x \cdot \left(y \cdot z - t \cdot a\right) - \frac{b \cdot \left({\left(c \cdot z\right)}^{2} - {\left(t \cdot i\right)}^{2}\right)}{c \cdot z + t \cdot i}\right) + t\_1\\
\mathbf{if}\;x < -1.469694296777705 \cdot 10^{-64}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x < 3.2113527362226803 \cdot 10^{-147}:\\
\;\;\;\;\left(b \cdot i - x \cdot a\right) \cdot t - \left(z \cdot \left(c \cdot b\right) - t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
herbie shell --seed 2025019
(FPCore (x y z t a b c i j)
:name "Data.Colour.Matrix:determinant from colour-2.3.3, A"
:precision binary64
:alt
(! :herbie-platform default (if (< x -293938859355541/2000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (- (* x (- (* y z) (* t a))) (/ (* b (- (pow (* c z) 2) (pow (* t i) 2))) (+ (* c z) (* t i)))) (* j (- (* c a) (* y i)))) (if (< x 32113527362226803/10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (- (* b i) (* x a)) t) (- (* z (* c b)) (* j (- (* c a) (* y i))))) (+ (- (* x (- (* y z) (* t a))) (/ (* b (- (pow (* c z) 2) (pow (* t i) 2))) (+ (* c z) (* t i)))) (* j (- (* c a) (* y i)))))))
(+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* t i)))) (* j (- (* c a) (* y i)))))