
(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 13 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 (* (- i) (fma j y (* (- b) t))))))
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 = -i * fma(j, y, (-b * t));
}
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(Float64(-i) * fma(j, y, Float64(Float64(-b) * t))); 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[((-i) * N[(j * y + N[((-b) * t), $MachinePrecision]), $MachinePrecision]), $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}:\\
\;\;\;\;\left(-i\right) \cdot \mathsf{fma}\left(j, y, \left(-b\right) \cdot t\right)\\
\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 93.6%
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 i around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6462.0
Applied rewrites62.0%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (* (- i) (fma j y (* (- b) t)))))
(if (<= i -6.8e+140)
t_1
(if (<= i -5.4e+50)
(* (fma (- i) y (* c a)) j)
(if (<= i -8.2e-208)
(* (fma y x (* (- b) c)) z)
(if (<= i -1.9e-267)
(* (fma (- t) x (* j c)) a)
(if (<= i 3e-8) (* (fma (- a) t (* z y)) x) 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 = -i * fma(j, y, (-b * t));
double tmp;
if (i <= -6.8e+140) {
tmp = t_1;
} else if (i <= -5.4e+50) {
tmp = fma(-i, y, (c * a)) * j;
} else if (i <= -8.2e-208) {
tmp = fma(y, x, (-b * c)) * z;
} else if (i <= -1.9e-267) {
tmp = fma(-t, x, (j * c)) * a;
} else if (i <= 3e-8) {
tmp = fma(-a, t, (z * y)) * x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(Float64(-i) * fma(j, y, Float64(Float64(-b) * t))) tmp = 0.0 if (i <= -6.8e+140) tmp = t_1; elseif (i <= -5.4e+50) tmp = Float64(fma(Float64(-i), y, Float64(c * a)) * j); elseif (i <= -8.2e-208) tmp = Float64(fma(y, x, Float64(Float64(-b) * c)) * z); elseif (i <= -1.9e-267) tmp = Float64(fma(Float64(-t), x, Float64(j * c)) * a); elseif (i <= 3e-8) tmp = Float64(fma(Float64(-a), t, Float64(z * y)) * x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[((-i) * N[(j * y + N[((-b) * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -6.8e+140], t$95$1, If[LessEqual[i, -5.4e+50], N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision], If[LessEqual[i, -8.2e-208], N[(N[(y * x + N[((-b) * c), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[i, -1.9e-267], N[(N[((-t) * x + N[(j * c), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[i, 3e-8], N[(N[((-a) * t + N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-i\right) \cdot \mathsf{fma}\left(j, y, \left(-b\right) \cdot t\right)\\
\mathbf{if}\;i \leq -6.8 \cdot 10^{+140}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;i \leq -5.4 \cdot 10^{+50}:\\
\;\;\;\;\mathsf{fma}\left(-i, y, c \cdot a\right) \cdot j\\
\mathbf{elif}\;i \leq -8.2 \cdot 10^{-208}:\\
\;\;\;\;\mathsf{fma}\left(y, x, \left(-b\right) \cdot c\right) \cdot z\\
\mathbf{elif}\;i \leq -1.9 \cdot 10^{-267}:\\
\;\;\;\;\mathsf{fma}\left(-t, x, j \cdot c\right) \cdot a\\
\mathbf{elif}\;i \leq 3 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(-a, t, z \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if i < -6.8e140 or 2.99999999999999973e-8 < i Initial program 58.7%
Taylor expanded in i around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6473.0
Applied rewrites73.0%
if -6.8e140 < i < -5.4e50Initial program 86.7%
Taylor expanded in j around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lift-*.f6477.5
Applied rewrites77.5%
if -5.4e50 < i < -8.1999999999999998e-208Initial program 85.1%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6468.6
Applied rewrites68.6%
if -8.1999999999999998e-208 < i < -1.90000000000000001e-267Initial program 86.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6479.3
Applied rewrites79.3%
if -1.90000000000000001e-267 < i < 2.99999999999999973e-8Initial program 90.1%
Taylor expanded in x around inf
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6456.3
Applied rewrites56.3%
(FPCore (x y z t a b c i j) :precision binary64 (if (or (<= i -6.5e+170) (not (<= i 5.9e-8))) (* (- i) (fma j y (* (- b) t))) (fma (fma (- i) y (* c a)) j (* (fma (- a) t (* 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 ((i <= -6.5e+170) || !(i <= 5.9e-8)) {
tmp = -i * fma(j, y, (-b * t));
} else {
tmp = fma(fma(-i, y, (c * a)), j, (fma(-a, t, (z * y)) * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((i <= -6.5e+170) || !(i <= 5.9e-8)) tmp = Float64(Float64(-i) * fma(j, y, Float64(Float64(-b) * t))); else tmp = fma(fma(Float64(-i), y, Float64(c * a)), j, Float64(fma(Float64(-a), t, Float64(z * y)) * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[i, -6.5e+170], N[Not[LessEqual[i, 5.9e-8]], $MachinePrecision]], N[((-i) * N[(j * y + N[((-b) * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j + N[(N[((-a) * t + N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -6.5 \cdot 10^{+170} \lor \neg \left(i \leq 5.9 \cdot 10^{-8}\right):\\
\;\;\;\;\left(-i\right) \cdot \mathsf{fma}\left(j, y, \left(-b\right) \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-i, y, c \cdot a\right), j, \mathsf{fma}\left(-a, t, z \cdot y\right) \cdot x\right)\\
\end{array}
\end{array}
if i < -6.5e170 or 5.8999999999999999e-8 < i Initial program 58.5%
Taylor expanded in i around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6473.7
Applied rewrites73.7%
if -6.5e170 < i < 5.8999999999999999e-8Initial program 87.1%
Taylor expanded in b around 0
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites72.6%
Final simplification73.0%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (* (fma i t (* (- c) z)) b)) (t_2 (* (fma (- i) y (* c a)) j)))
(if (<= j -1.4e+65)
t_2
(if (<= j -9.2e-122)
(* (fma (- i) j (* z x)) y)
(if (<= j -7.3e-298)
t_1
(if (<= j 1.2e-194)
(* (fma (- a) t (* z y)) x)
(if (<= j 9e+27) 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 = fma(i, t, (-c * z)) * b;
double t_2 = fma(-i, y, (c * a)) * j;
double tmp;
if (j <= -1.4e+65) {
tmp = t_2;
} else if (j <= -9.2e-122) {
tmp = fma(-i, j, (z * x)) * y;
} else if (j <= -7.3e-298) {
tmp = t_1;
} else if (j <= 1.2e-194) {
tmp = fma(-a, t, (z * y)) * x;
} else if (j <= 9e+27) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(fma(i, t, Float64(Float64(-c) * z)) * b) t_2 = Float64(fma(Float64(-i), y, Float64(c * a)) * j) tmp = 0.0 if (j <= -1.4e+65) tmp = t_2; elseif (j <= -9.2e-122) tmp = Float64(fma(Float64(-i), j, Float64(z * x)) * y); elseif (j <= -7.3e-298) tmp = t_1; elseif (j <= 1.2e-194) tmp = Float64(fma(Float64(-a), t, Float64(z * y)) * x); elseif (j <= 9e+27) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[(i * t + N[((-c) * z), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(N[((-i) * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision]}, If[LessEqual[j, -1.4e+65], t$95$2, If[LessEqual[j, -9.2e-122], N[(N[((-i) * j + N[(z * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[j, -7.3e-298], t$95$1, If[LessEqual[j, 1.2e-194], N[(N[((-a) * t + N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[j, 9e+27], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, t, \left(-c\right) \cdot z\right) \cdot b\\
t_2 := \mathsf{fma}\left(-i, y, c \cdot a\right) \cdot j\\
\mathbf{if}\;j \leq -1.4 \cdot 10^{+65}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;j \leq -9.2 \cdot 10^{-122}:\\
\;\;\;\;\mathsf{fma}\left(-i, j, z \cdot x\right) \cdot y\\
\mathbf{elif}\;j \leq -7.3 \cdot 10^{-298}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;j \leq 1.2 \cdot 10^{-194}:\\
\;\;\;\;\mathsf{fma}\left(-a, t, z \cdot y\right) \cdot x\\
\mathbf{elif}\;j \leq 9 \cdot 10^{+27}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if j < -1.3999999999999999e65 or 8.9999999999999998e27 < j Initial program 77.8%
Taylor expanded in j around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lift-*.f6470.5
Applied rewrites70.5%
if -1.3999999999999999e65 < j < -9.20000000000000028e-122Initial program 78.5%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6452.9
Applied rewrites52.9%
if -9.20000000000000028e-122 < j < -7.3000000000000003e-298 or 1.2e-194 < j < 8.9999999999999998e27Initial program 78.8%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6457.0
Applied rewrites57.0%
if -7.3000000000000003e-298 < j < 1.2e-194Initial program 61.0%
Taylor expanded in x around inf
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6471.4
Applied rewrites71.4%
(FPCore (x y z t a b c i j) :precision binary64 (if (or (<= z -5.5e+17) (not (<= z 5.4e+86))) (* (fma y x (* (- b) c)) z) (+ (* (* i t) b) (* 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) {
double tmp;
if ((z <= -5.5e+17) || !(z <= 5.4e+86)) {
tmp = fma(y, x, (-b * c)) * z;
} else {
tmp = ((i * t) * b) + (j * ((c * a) - (y * i)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((z <= -5.5e+17) || !(z <= 5.4e+86)) tmp = Float64(fma(y, x, Float64(Float64(-b) * c)) * z); else tmp = Float64(Float64(Float64(i * t) * b) + Float64(j * Float64(Float64(c * a) - Float64(y * i)))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[z, -5.5e+17], N[Not[LessEqual[z, 5.4e+86]], $MachinePrecision]], N[(N[(y * x + N[((-b) * c), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(N[(i * t), $MachinePrecision] * b), $MachinePrecision] + N[(j * N[(N[(c * a), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+17} \lor \neg \left(z \leq 5.4 \cdot 10^{+86}\right):\\
\;\;\;\;\mathsf{fma}\left(y, x, \left(-b\right) \cdot c\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left(i \cdot t\right) \cdot b + j \cdot \left(c \cdot a - y \cdot i\right)\\
\end{array}
\end{array}
if z < -5.5e17 or 5.40000000000000036e86 < z Initial program 72.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6469.4
Applied rewrites69.4%
if -5.5e17 < z < 5.40000000000000036e86Initial program 79.2%
Taylor expanded in i around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6462.2
Applied rewrites62.2%
Final simplification65.1%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (* a (* c j))) (t_2 (* (* i t) b)))
(if (<= i -3.8e+164)
t_2
(if (<= i -8.5e+67)
t_1
(if (<= i 2.4e-128) (* (* y x) z) (if (<= i 3.2e-7) 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 = a * (c * j);
double t_2 = (i * t) * b;
double tmp;
if (i <= -3.8e+164) {
tmp = t_2;
} else if (i <= -8.5e+67) {
tmp = t_1;
} else if (i <= 2.4e-128) {
tmp = (y * x) * z;
} else if (i <= 3.2e-7) {
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 = a * (c * j)
t_2 = (i * t) * b
if (i <= (-3.8d+164)) then
tmp = t_2
else if (i <= (-8.5d+67)) then
tmp = t_1
else if (i <= 2.4d-128) then
tmp = (y * x) * z
else if (i <= 3.2d-7) 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 = a * (c * j);
double t_2 = (i * t) * b;
double tmp;
if (i <= -3.8e+164) {
tmp = t_2;
} else if (i <= -8.5e+67) {
tmp = t_1;
} else if (i <= 2.4e-128) {
tmp = (y * x) * z;
} else if (i <= 3.2e-7) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i, j): t_1 = a * (c * j) t_2 = (i * t) * b tmp = 0 if i <= -3.8e+164: tmp = t_2 elif i <= -8.5e+67: tmp = t_1 elif i <= 2.4e-128: tmp = (y * x) * z elif i <= 3.2e-7: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(a * Float64(c * j)) t_2 = Float64(Float64(i * t) * b) tmp = 0.0 if (i <= -3.8e+164) tmp = t_2; elseif (i <= -8.5e+67) tmp = t_1; elseif (i <= 2.4e-128) tmp = Float64(Float64(y * x) * z); elseif (i <= 3.2e-7) 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 = a * (c * j); t_2 = (i * t) * b; tmp = 0.0; if (i <= -3.8e+164) tmp = t_2; elseif (i <= -8.5e+67) tmp = t_1; elseif (i <= 2.4e-128) tmp = (y * x) * z; elseif (i <= 3.2e-7) 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[(a * N[(c * j), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(i * t), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[i, -3.8e+164], t$95$2, If[LessEqual[i, -8.5e+67], t$95$1, If[LessEqual[i, 2.4e-128], N[(N[(y * x), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[i, 3.2e-7], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot \left(c \cdot j\right)\\
t_2 := \left(i \cdot t\right) \cdot b\\
\mathbf{if}\;i \leq -3.8 \cdot 10^{+164}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;i \leq -8.5 \cdot 10^{+67}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;i \leq 2.4 \cdot 10^{-128}:\\
\;\;\;\;\left(y \cdot x\right) \cdot z\\
\mathbf{elif}\;i \leq 3.2 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if i < -3.80000000000000021e164 or 3.2000000000000001e-7 < i Initial program 58.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6453.3
Applied rewrites53.3%
Taylor expanded in z around 0
lower-*.f6443.0
Applied rewrites43.0%
if -3.80000000000000021e164 < i < -8.50000000000000038e67 or 2.3999999999999998e-128 < i < 3.2000000000000001e-7Initial program 85.5%
Taylor expanded in j around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lift-*.f6451.0
Applied rewrites51.0%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f6446.5
Applied rewrites46.5%
if -8.50000000000000038e67 < i < 2.3999999999999998e-128Initial program 87.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6456.2
Applied rewrites56.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6437.2
Applied rewrites37.2%
(FPCore (x y z t a b c i j) :precision binary64 (if (or (<= y -1.36e-38) (not (<= y 58000000000000.0))) (* (fma (- i) j (* z x)) y) (* (fma i t (* (- c) z)) b)))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if ((y <= -1.36e-38) || !(y <= 58000000000000.0)) {
tmp = fma(-i, j, (z * x)) * y;
} else {
tmp = fma(i, t, (-c * z)) * b;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((y <= -1.36e-38) || !(y <= 58000000000000.0)) tmp = Float64(fma(Float64(-i), j, Float64(z * x)) * y); else tmp = Float64(fma(i, t, Float64(Float64(-c) * z)) * b); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[y, -1.36e-38], N[Not[LessEqual[y, 58000000000000.0]], $MachinePrecision]], N[(N[((-i) * j + N[(z * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(i * t + N[((-c) * z), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.36 \cdot 10^{-38} \lor \neg \left(y \leq 58000000000000\right):\\
\;\;\;\;\mathsf{fma}\left(-i, j, z \cdot x\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, t, \left(-c\right) \cdot z\right) \cdot b\\
\end{array}
\end{array}
if y < -1.36e-38 or 5.8e13 < y Initial program 69.2%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6459.9
Applied rewrites59.9%
if -1.36e-38 < y < 5.8e13Initial program 85.2%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6453.5
Applied rewrites53.5%
Final simplification57.0%
(FPCore (x y z t a b c i j) :precision binary64 (if (or (<= x -1.15e-13) (not (<= x 5e-36))) (* (fma (- a) t (* z y)) x) (* (fma i t (* (- c) z)) b)))
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.15e-13) || !(x <= 5e-36)) {
tmp = fma(-a, t, (z * y)) * x;
} else {
tmp = fma(i, t, (-c * z)) * b;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((x <= -1.15e-13) || !(x <= 5e-36)) tmp = Float64(fma(Float64(-a), t, Float64(z * y)) * x); else tmp = Float64(fma(i, t, Float64(Float64(-c) * z)) * b); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[x, -1.15e-13], N[Not[LessEqual[x, 5e-36]], $MachinePrecision]], N[(N[((-a) * t + N[(z * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(i * t + N[((-c) * z), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{-13} \lor \neg \left(x \leq 5 \cdot 10^{-36}\right):\\
\;\;\;\;\mathsf{fma}\left(-a, t, z \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, t, \left(-c\right) \cdot z\right) \cdot b\\
\end{array}
\end{array}
if x < -1.1499999999999999e-13 or 5.00000000000000004e-36 < x Initial program 78.7%
Taylor expanded in x around inf
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6461.7
Applied rewrites61.7%
if -1.1499999999999999e-13 < x < 5.00000000000000004e-36Initial program 73.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6449.8
Applied rewrites49.8%
Final simplification56.3%
(FPCore (x y z t a b c i j) :precision binary64 (if (<= i -2.8e+52) (* (* (- i) y) j) (if (<= i 3.5e-7) (* (fma y x (* (- b) c)) z) (* (fma i t (* (- c) z)) b))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if (i <= -2.8e+52) {
tmp = (-i * y) * j;
} else if (i <= 3.5e-7) {
tmp = fma(y, x, (-b * c)) * z;
} else {
tmp = fma(i, t, (-c * z)) * b;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if (i <= -2.8e+52) tmp = Float64(Float64(Float64(-i) * y) * j); elseif (i <= 3.5e-7) tmp = Float64(fma(y, x, Float64(Float64(-b) * c)) * z); else tmp = Float64(fma(i, t, Float64(Float64(-c) * z)) * b); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[LessEqual[i, -2.8e+52], N[(N[((-i) * y), $MachinePrecision] * j), $MachinePrecision], If[LessEqual[i, 3.5e-7], N[(N[(y * x + N[((-b) * c), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(i * t + N[((-c) * z), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2.8 \cdot 10^{+52}:\\
\;\;\;\;\left(\left(-i\right) \cdot y\right) \cdot j\\
\mathbf{elif}\;i \leq 3.5 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(y, x, \left(-b\right) \cdot c\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, t, \left(-c\right) \cdot z\right) \cdot b\\
\end{array}
\end{array}
if i < -2.8e52Initial program 61.2%
Taylor expanded in j around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lift-*.f6455.4
Applied rewrites55.4%
Taylor expanded in y around inf
lower-*.f64N/A
lower-*.f6444.6
Applied rewrites44.6%
lift-*.f64N/A
lift-*.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lift-neg.f6444.6
Applied rewrites44.6%
if -2.8e52 < i < 3.49999999999999984e-7Initial program 88.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6454.4
Applied rewrites54.4%
if 3.49999999999999984e-7 < i Initial program 62.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6457.3
Applied rewrites57.3%
(FPCore (x y z t a b c i j) :precision binary64 (if (<= j -1.35e+72) (* (* a c) j) (if (<= j 1.15e+28) (* (fma i t (* (- c) z)) b) (* (- i) (* j y)))))
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.35e+72) {
tmp = (a * c) * j;
} else if (j <= 1.15e+28) {
tmp = fma(i, t, (-c * z)) * b;
} else {
tmp = -i * (j * y);
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if (j <= -1.35e+72) tmp = Float64(Float64(a * c) * j); elseif (j <= 1.15e+28) tmp = Float64(fma(i, t, Float64(Float64(-c) * z)) * b); else tmp = Float64(Float64(-i) * Float64(j * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[LessEqual[j, -1.35e+72], N[(N[(a * c), $MachinePrecision] * j), $MachinePrecision], If[LessEqual[j, 1.15e+28], N[(N[(i * t + N[((-c) * z), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], N[((-i) * N[(j * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;j \leq -1.35 \cdot 10^{+72}:\\
\;\;\;\;\left(a \cdot c\right) \cdot j\\
\mathbf{elif}\;j \leq 1.15 \cdot 10^{+28}:\\
\;\;\;\;\mathsf{fma}\left(i, t, \left(-c\right) \cdot z\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\left(-i\right) \cdot \left(j \cdot y\right)\\
\end{array}
\end{array}
if j < -1.35e72Initial program 75.0%
Taylor expanded in j around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lift-*.f6469.9
Applied rewrites69.9%
Taylor expanded in y around 0
lower-*.f6450.5
Applied rewrites50.5%
if -1.35e72 < j < 1.14999999999999992e28Initial program 75.4%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6447.2
Applied rewrites47.2%
if 1.14999999999999992e28 < j Initial program 80.0%
Taylor expanded in i around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6456.0
Applied rewrites56.0%
Taylor expanded in y around inf
lower-*.f6446.2
Applied rewrites46.2%
(FPCore (x y z t a b c i j)
:precision binary64
(if (<= i -5.4e+50)
(* (* (- i) y) j)
(if (<= i 2.4e-128)
(* (* y x) z)
(if (<= i 3.2e-7) (* a (* c j)) (* (* i t) b)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if (i <= -5.4e+50) {
tmp = (-i * y) * j;
} else if (i <= 2.4e-128) {
tmp = (y * x) * z;
} else if (i <= 3.2e-7) {
tmp = a * (c * j);
} else {
tmp = (i * t) * b;
}
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 (i <= (-5.4d+50)) then
tmp = (-i * y) * j
else if (i <= 2.4d-128) then
tmp = (y * x) * z
else if (i <= 3.2d-7) then
tmp = a * (c * j)
else
tmp = (i * t) * b
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 (i <= -5.4e+50) {
tmp = (-i * y) * j;
} else if (i <= 2.4e-128) {
tmp = (y * x) * z;
} else if (i <= 3.2e-7) {
tmp = a * (c * j);
} else {
tmp = (i * t) * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i, j): tmp = 0 if i <= -5.4e+50: tmp = (-i * y) * j elif i <= 2.4e-128: tmp = (y * x) * z elif i <= 3.2e-7: tmp = a * (c * j) else: tmp = (i * t) * b return tmp
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if (i <= -5.4e+50) tmp = Float64(Float64(Float64(-i) * y) * j); elseif (i <= 2.4e-128) tmp = Float64(Float64(y * x) * z); elseif (i <= 3.2e-7) tmp = Float64(a * Float64(c * j)); else tmp = Float64(Float64(i * t) * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i, j) tmp = 0.0; if (i <= -5.4e+50) tmp = (-i * y) * j; elseif (i <= 2.4e-128) tmp = (y * x) * z; elseif (i <= 3.2e-7) tmp = a * (c * j); else tmp = (i * t) * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[LessEqual[i, -5.4e+50], N[(N[((-i) * y), $MachinePrecision] * j), $MachinePrecision], If[LessEqual[i, 2.4e-128], N[(N[(y * x), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[i, 3.2e-7], N[(a * N[(c * j), $MachinePrecision]), $MachinePrecision], N[(N[(i * t), $MachinePrecision] * b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -5.4 \cdot 10^{+50}:\\
\;\;\;\;\left(\left(-i\right) \cdot y\right) \cdot j\\
\mathbf{elif}\;i \leq 2.4 \cdot 10^{-128}:\\
\;\;\;\;\left(y \cdot x\right) \cdot z\\
\mathbf{elif}\;i \leq 3.2 \cdot 10^{-7}:\\
\;\;\;\;a \cdot \left(c \cdot j\right)\\
\mathbf{else}:\\
\;\;\;\;\left(i \cdot t\right) \cdot b\\
\end{array}
\end{array}
if i < -5.4e50Initial program 61.2%
Taylor expanded in j around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lift-*.f6455.4
Applied rewrites55.4%
Taylor expanded in y around inf
lower-*.f64N/A
lower-*.f6444.6
Applied rewrites44.6%
lift-*.f64N/A
lift-*.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lift-neg.f6444.6
Applied rewrites44.6%
if -5.4e50 < i < 2.3999999999999998e-128Initial program 87.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6457.6
Applied rewrites57.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6438.1
Applied rewrites38.1%
if 2.3999999999999998e-128 < i < 3.2000000000000001e-7Initial program 90.6%
Taylor expanded in j around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f6445.5
Applied rewrites45.5%
if 3.2000000000000001e-7 < i Initial program 62.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6457.3
Applied rewrites57.3%
Taylor expanded in z around 0
lower-*.f6446.4
Applied rewrites46.4%
(FPCore (x y z t a b c i j) :precision binary64 (if (or (<= j -7.6e+45) (not (<= j 3.5e+28))) (* a (* c j)) (* (* i t) b)))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if ((j <= -7.6e+45) || !(j <= 3.5e+28)) {
tmp = a * (c * j);
} else {
tmp = (i * t) * b;
}
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 ((j <= (-7.6d+45)) .or. (.not. (j <= 3.5d+28))) then
tmp = a * (c * j)
else
tmp = (i * t) * b
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 ((j <= -7.6e+45) || !(j <= 3.5e+28)) {
tmp = a * (c * j);
} else {
tmp = (i * t) * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i, j): tmp = 0 if (j <= -7.6e+45) or not (j <= 3.5e+28): tmp = a * (c * j) else: tmp = (i * t) * b return tmp
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((j <= -7.6e+45) || !(j <= 3.5e+28)) tmp = Float64(a * Float64(c * j)); else tmp = Float64(Float64(i * t) * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i, j) tmp = 0.0; if ((j <= -7.6e+45) || ~((j <= 3.5e+28))) tmp = a * (c * j); else tmp = (i * t) * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[j, -7.6e+45], N[Not[LessEqual[j, 3.5e+28]], $MachinePrecision]], N[(a * N[(c * j), $MachinePrecision]), $MachinePrecision], N[(N[(i * t), $MachinePrecision] * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;j \leq -7.6 \cdot 10^{+45} \lor \neg \left(j \leq 3.5 \cdot 10^{+28}\right):\\
\;\;\;\;a \cdot \left(c \cdot j\right)\\
\mathbf{else}:\\
\;\;\;\;\left(i \cdot t\right) \cdot b\\
\end{array}
\end{array}
if j < -7.6000000000000004e45 or 3.5e28 < j Initial program 77.8%
Taylor expanded in j around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lift-*.f6467.8
Applied rewrites67.8%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f6442.3
Applied rewrites42.3%
if -7.6000000000000004e45 < j < 3.5e28Initial program 75.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6448.0
Applied rewrites48.0%
Taylor expanded in z around 0
lower-*.f6430.1
Applied rewrites30.1%
Final simplification35.0%
(FPCore (x y z t a b c i j) :precision binary64 (* a (* c j)))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
return a * (c * j);
}
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 = a * (c * j)
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 a * (c * j);
}
def code(x, y, z, t, a, b, c, i, j): return a * (c * j)
function code(x, y, z, t, a, b, c, i, j) return Float64(a * Float64(c * j)) end
function tmp = code(x, y, z, t, a, b, c, i, j) tmp = a * (c * j); end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := N[(a * N[(c * j), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot \left(c \cdot j\right)
\end{array}
Initial program 76.4%
Taylor expanded in j around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lift-*.f6437.4
Applied rewrites37.4%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f6421.7
Applied rewrites21.7%
herbie shell --seed 2025085
(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)))))