
(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 7 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 (* (* -1.0 b) (* i t)))
(t_2 (* a (* t x)))
(t_3
(*
(fma
(* -1.0 a)
x
(-
(/ (fma (fma (* -1.0 i) y (* c a)) j (* (* z y) x)) t)
(* b (fma -1.0 i (/ (* c z) t)))))
t)))
(if (<= t -2.5e+43)
t_3
(if (<= t 2.5e-270)
(-
(fma -1.0 t_2 (fma j (- (* a c) (* i y)) (* z (- (* x y) (* b c)))))
t_1)
(if (<= t 3e-15)
(-
(fma
-1.0
t_2
(fma c (fma -1.0 (* b z) (* a j)) (* y (fma -1.0 (* i j) (* x z)))))
t_1)
t_3)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = (-1.0 * b) * (i * t);
double t_2 = a * (t * x);
double t_3 = fma((-1.0 * a), x, ((fma(fma((-1.0 * i), y, (c * a)), j, ((z * y) * x)) / t) - (b * fma(-1.0, i, ((c * z) / t))))) * t;
double tmp;
if (t <= -2.5e+43) {
tmp = t_3;
} else if (t <= 2.5e-270) {
tmp = fma(-1.0, t_2, fma(j, ((a * c) - (i * y)), (z * ((x * y) - (b * c))))) - t_1;
} else if (t <= 3e-15) {
tmp = fma(-1.0, t_2, fma(c, fma(-1.0, (b * z), (a * j)), (y * fma(-1.0, (i * j), (x * z))))) - t_1;
} else {
tmp = t_3;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(Float64(-1.0 * b) * Float64(i * t)) t_2 = Float64(a * Float64(t * x)) t_3 = Float64(fma(Float64(-1.0 * a), x, Float64(Float64(fma(fma(Float64(-1.0 * i), y, Float64(c * a)), j, Float64(Float64(z * y) * x)) / t) - Float64(b * fma(-1.0, i, Float64(Float64(c * z) / t))))) * t) tmp = 0.0 if (t <= -2.5e+43) tmp = t_3; elseif (t <= 2.5e-270) tmp = Float64(fma(-1.0, t_2, fma(j, Float64(Float64(a * c) - Float64(i * y)), Float64(z * Float64(Float64(x * y) - Float64(b * c))))) - t_1); elseif (t <= 3e-15) tmp = Float64(fma(-1.0, t_2, fma(c, fma(-1.0, Float64(b * z), Float64(a * j)), Float64(y * fma(-1.0, Float64(i * j), Float64(x * z))))) - t_1); else tmp = t_3; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[(-1.0 * b), $MachinePrecision] * N[(i * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a * N[(t * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(-1.0 * a), $MachinePrecision] * x + N[(N[(N[(N[(N[(-1.0 * i), $MachinePrecision] * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j + N[(N[(z * y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] - N[(b * N[(-1.0 * i + N[(N[(c * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t, -2.5e+43], t$95$3, If[LessEqual[t, 2.5e-270], N[(N[(-1.0 * t$95$2 + N[(j * N[(N[(a * c), $MachinePrecision] - N[(i * y), $MachinePrecision]), $MachinePrecision] + N[(z * N[(N[(x * y), $MachinePrecision] - N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[t, 3e-15], N[(N[(-1.0 * t$95$2 + N[(c * N[(-1.0 * N[(b * z), $MachinePrecision] + N[(a * j), $MachinePrecision]), $MachinePrecision] + N[(y * N[(-1.0 * N[(i * j), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-1 \cdot b\right) \cdot \left(i \cdot t\right)\\
t_2 := a \cdot \left(t \cdot x\right)\\
t_3 := \mathsf{fma}\left(-1 \cdot a, x, \frac{\mathsf{fma}\left(\mathsf{fma}\left(-1 \cdot i, y, c \cdot a\right), j, \left(z \cdot y\right) \cdot x\right)}{t} - b \cdot \mathsf{fma}\left(-1, i, \frac{c \cdot z}{t}\right)\right) \cdot t\\
\mathbf{if}\;t \leq -2.5 \cdot 10^{+43}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t \leq 2.5 \cdot 10^{-270}:\\
\;\;\;\;\mathsf{fma}\left(-1, t\_2, \mathsf{fma}\left(j, a \cdot c - i \cdot y, z \cdot \left(x \cdot y - b \cdot c\right)\right)\right) - t\_1\\
\mathbf{elif}\;t \leq 3 \cdot 10^{-15}:\\
\;\;\;\;\mathsf{fma}\left(-1, t\_2, \mathsf{fma}\left(c, \mathsf{fma}\left(-1, b \cdot z, a \cdot j\right), y \cdot \mathsf{fma}\left(-1, i \cdot j, x \cdot z\right)\right)\right) - t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if t < -2.5000000000000002e43 or 3e-15 < t Initial program 71.9%
Taylor expanded in t around inf
Applied rewrites81.9%
Taylor expanded in b around 0
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f6486.8
Applied rewrites86.8%
if -2.5000000000000002e43 < t < 2.4999999999999999e-270Initial program 84.3%
Taylor expanded in c around 0
Applied rewrites87.9%
Taylor expanded in i around 0
Applied rewrites87.9%
Taylor expanded in z around 0
lower--.f64N/A
Applied rewrites90.9%
if 2.4999999999999999e-270 < t < 3e-15Initial program 72.0%
Taylor expanded in c around 0
Applied rewrites84.8%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites88.6%
Final simplification88.5%
(FPCore (x y z t a b c i j)
:precision binary64
(if (or (<= t -1.25e+56) (not (<= t 3e-15)))
(*
(fma
(* -1.0 a)
x
(-
(/ (fma (fma (* -1.0 i) y (* c a)) j (* (* z y) x)) t)
(* b (fma -1.0 i (/ (* c z) t)))))
t)
(-
(fma
-1.0
(* a (* t x))
(fma c (fma -1.0 (* b z) (* a j)) (* y (fma -1.0 (* i j) (* x z)))))
(* (* -1.0 b) (* i t)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if ((t <= -1.25e+56) || !(t <= 3e-15)) {
tmp = fma((-1.0 * a), x, ((fma(fma((-1.0 * i), y, (c * a)), j, ((z * y) * x)) / t) - (b * fma(-1.0, i, ((c * z) / t))))) * t;
} else {
tmp = fma(-1.0, (a * (t * x)), fma(c, fma(-1.0, (b * z), (a * j)), (y * fma(-1.0, (i * j), (x * z))))) - ((-1.0 * b) * (i * t));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((t <= -1.25e+56) || !(t <= 3e-15)) tmp = Float64(fma(Float64(-1.0 * a), x, Float64(Float64(fma(fma(Float64(-1.0 * i), y, Float64(c * a)), j, Float64(Float64(z * y) * x)) / t) - Float64(b * fma(-1.0, i, Float64(Float64(c * z) / t))))) * t); else tmp = Float64(fma(-1.0, Float64(a * Float64(t * x)), fma(c, fma(-1.0, Float64(b * z), Float64(a * j)), Float64(y * fma(-1.0, Float64(i * j), Float64(x * z))))) - Float64(Float64(-1.0 * b) * Float64(i * t))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[t, -1.25e+56], N[Not[LessEqual[t, 3e-15]], $MachinePrecision]], N[(N[(N[(-1.0 * a), $MachinePrecision] * x + N[(N[(N[(N[(N[(-1.0 * i), $MachinePrecision] * y + N[(c * a), $MachinePrecision]), $MachinePrecision] * j + N[(N[(z * y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] - N[(b * N[(-1.0 * i + N[(N[(c * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision], N[(N[(-1.0 * N[(a * N[(t * x), $MachinePrecision]), $MachinePrecision] + N[(c * N[(-1.0 * N[(b * z), $MachinePrecision] + N[(a * j), $MachinePrecision]), $MachinePrecision] + N[(y * N[(-1.0 * N[(i * j), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * b), $MachinePrecision] * N[(i * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.25 \cdot 10^{+56} \lor \neg \left(t \leq 3 \cdot 10^{-15}\right):\\
\;\;\;\;\mathsf{fma}\left(-1 \cdot a, x, \frac{\mathsf{fma}\left(\mathsf{fma}\left(-1 \cdot i, y, c \cdot a\right), j, \left(z \cdot y\right) \cdot x\right)}{t} - b \cdot \mathsf{fma}\left(-1, i, \frac{c \cdot z}{t}\right)\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, a \cdot \left(t \cdot x\right), \mathsf{fma}\left(c, \mathsf{fma}\left(-1, b \cdot z, a \cdot j\right), y \cdot \mathsf{fma}\left(-1, i \cdot j, x \cdot z\right)\right)\right) - \left(-1 \cdot b\right) \cdot \left(i \cdot t\right)\\
\end{array}
\end{array}
if t < -1.25000000000000006e56 or 3e-15 < t Initial program 71.8%
Taylor expanded in t around inf
Applied rewrites82.1%
Taylor expanded in b around 0
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f6487.2
Applied rewrites87.2%
if -1.25000000000000006e56 < t < 3e-15Initial program 79.5%
Taylor expanded in c around 0
Applied rewrites86.4%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites86.4%
Final simplification86.8%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1
(+
(+ (* x (- (* y z) (* t a))) (* (* -1.0 b) (- (* c z) (* t i))))
(* j (- (* c a) (* y i))))))
(if (<= t_1 INFINITY)
t_1
(* (fma (* -1.0 a) x (* b (- i (/ (* c z) t)))) 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))) + ((-1.0 * b) * ((c * z) - (t * i)))) + (j * ((c * a) - (y * i)));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma((-1.0 * a), x, (b * (i - ((c * z) / t)))) * 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(Float64(-1.0 * 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(Float64(-1.0 * a), x, Float64(b * Float64(i - Float64(Float64(c * z) / t)))) * 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[(N[(-1.0 * b), $MachinePrecision] * 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[(N[(-1.0 * a), $MachinePrecision] * x + N[(b * N[(i - N[(N[(c * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot \left(y \cdot z - t \cdot a\right) + \left(-1 \cdot b\right) \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(-1 \cdot a, x, b \cdot \left(i - \frac{c \cdot z}{t}\right)\right) \cdot t\\
\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.5%
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 t around inf
Applied rewrites37.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f6454.2
Applied rewrites54.2%
Final simplification86.1%
(FPCore (x y z t a b c i j)
:precision binary64
(if (or (<= j -1.85e-78) (not (<= j 6.6e-66)))
(*
(-
(fma x (/ (fma (* -1.0 a) t (* z y)) j) (* c a))
(fma i y (/ (* b (fma (* -1.0 i) t (* c z))) j)))
j)
(fma
a
(* c j)
(fma
t
(- (fma -1.0 (* a x) (* -1.0 (/ (* i (* j y)) t))) (* (* -1.0 b) i))
(* z (fma -1.0 (* b c) (* x 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.85e-78) || !(j <= 6.6e-66)) {
tmp = (fma(x, (fma((-1.0 * a), t, (z * y)) / j), (c * a)) - fma(i, y, ((b * fma((-1.0 * i), t, (c * z))) / j))) * j;
} else {
tmp = fma(a, (c * j), fma(t, (fma(-1.0, (a * x), (-1.0 * ((i * (j * y)) / t))) - ((-1.0 * b) * i)), (z * fma(-1.0, (b * c), (x * y)))));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((j <= -1.85e-78) || !(j <= 6.6e-66)) tmp = Float64(Float64(fma(x, Float64(fma(Float64(-1.0 * a), t, Float64(z * y)) / j), Float64(c * a)) - fma(i, y, Float64(Float64(b * fma(Float64(-1.0 * i), t, Float64(c * z))) / j))) * j); else tmp = fma(a, Float64(c * j), fma(t, Float64(fma(-1.0, Float64(a * x), Float64(-1.0 * Float64(Float64(i * Float64(j * y)) / t))) - Float64(Float64(-1.0 * b) * i)), Float64(z * fma(-1.0, Float64(b * c), Float64(x * y))))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[j, -1.85e-78], N[Not[LessEqual[j, 6.6e-66]], $MachinePrecision]], N[(N[(N[(x * N[(N[(N[(-1.0 * a), $MachinePrecision] * t + N[(z * y), $MachinePrecision]), $MachinePrecision] / j), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] - N[(i * y + N[(N[(b * N[(N[(-1.0 * i), $MachinePrecision] * t + N[(c * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / j), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * j), $MachinePrecision], N[(a * N[(c * j), $MachinePrecision] + N[(t * N[(N[(-1.0 * N[(a * x), $MachinePrecision] + N[(-1.0 * N[(N[(i * N[(j * y), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * b), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision] + N[(z * N[(-1.0 * N[(b * c), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;j \leq -1.85 \cdot 10^{-78} \lor \neg \left(j \leq 6.6 \cdot 10^{-66}\right):\\
\;\;\;\;\left(\mathsf{fma}\left(x, \frac{\mathsf{fma}\left(-1 \cdot a, t, z \cdot y\right)}{j}, c \cdot a\right) - \mathsf{fma}\left(i, y, \frac{b \cdot \mathsf{fma}\left(-1 \cdot i, t, c \cdot z\right)}{j}\right)\right) \cdot j\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, c \cdot j, \mathsf{fma}\left(t, \mathsf{fma}\left(-1, a \cdot x, -1 \cdot \frac{i \cdot \left(j \cdot y\right)}{t}\right) - \left(-1 \cdot b\right) \cdot i, z \cdot \mathsf{fma}\left(-1, b \cdot c, x \cdot y\right)\right)\right)\\
\end{array}
\end{array}
if j < -1.85000000000000003e-78 or 6.5999999999999998e-66 < j Initial program 75.8%
Taylor expanded in j around inf
Applied rewrites80.1%
if -1.85000000000000003e-78 < j < 6.5999999999999998e-66Initial program 76.1%
Taylor expanded in t around inf
Applied rewrites71.3%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites77.1%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites88.8%
Final simplification84.0%
(FPCore (x y z t a b c i j)
:precision binary64
(if (or (<= t -1.2e+98) (not (<= t 510000000000.0)))
(fma
a
(* c j)
(fma
t
(- (fma -1.0 (* a x) (* -1.0 (/ (* i (* j y)) t))) (* (* -1.0 b) i))
(* z (fma -1.0 (* b c) (* x y)))))
(-
(fma
-1.0
(* a (* t x))
(fma c (fma -1.0 (* b z) (* a j)) (* y (fma -1.0 (* i j) (* x z)))))
(* (* -1.0 b) (* i t)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double tmp;
if ((t <= -1.2e+98) || !(t <= 510000000000.0)) {
tmp = fma(a, (c * j), fma(t, (fma(-1.0, (a * x), (-1.0 * ((i * (j * y)) / t))) - ((-1.0 * b) * i)), (z * fma(-1.0, (b * c), (x * y)))));
} else {
tmp = fma(-1.0, (a * (t * x)), fma(c, fma(-1.0, (b * z), (a * j)), (y * fma(-1.0, (i * j), (x * z))))) - ((-1.0 * b) * (i * t));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) tmp = 0.0 if ((t <= -1.2e+98) || !(t <= 510000000000.0)) tmp = fma(a, Float64(c * j), fma(t, Float64(fma(-1.0, Float64(a * x), Float64(-1.0 * Float64(Float64(i * Float64(j * y)) / t))) - Float64(Float64(-1.0 * b) * i)), Float64(z * fma(-1.0, Float64(b * c), Float64(x * y))))); else tmp = Float64(fma(-1.0, Float64(a * Float64(t * x)), fma(c, fma(-1.0, Float64(b * z), Float64(a * j)), Float64(y * fma(-1.0, Float64(i * j), Float64(x * z))))) - Float64(Float64(-1.0 * b) * Float64(i * t))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := If[Or[LessEqual[t, -1.2e+98], N[Not[LessEqual[t, 510000000000.0]], $MachinePrecision]], N[(a * N[(c * j), $MachinePrecision] + N[(t * N[(N[(-1.0 * N[(a * x), $MachinePrecision] + N[(-1.0 * N[(N[(i * N[(j * y), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * b), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision] + N[(z * N[(-1.0 * N[(b * c), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[(a * N[(t * x), $MachinePrecision]), $MachinePrecision] + N[(c * N[(-1.0 * N[(b * z), $MachinePrecision] + N[(a * j), $MachinePrecision]), $MachinePrecision] + N[(y * N[(-1.0 * N[(i * j), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * b), $MachinePrecision] * N[(i * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.2 \cdot 10^{+98} \lor \neg \left(t \leq 510000000000\right):\\
\;\;\;\;\mathsf{fma}\left(a, c \cdot j, \mathsf{fma}\left(t, \mathsf{fma}\left(-1, a \cdot x, -1 \cdot \frac{i \cdot \left(j \cdot y\right)}{t}\right) - \left(-1 \cdot b\right) \cdot i, z \cdot \mathsf{fma}\left(-1, b \cdot c, x \cdot y\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, a \cdot \left(t \cdot x\right), \mathsf{fma}\left(c, \mathsf{fma}\left(-1, b \cdot z, a \cdot j\right), y \cdot \mathsf{fma}\left(-1, i \cdot j, x \cdot z\right)\right)\right) - \left(-1 \cdot b\right) \cdot \left(i \cdot t\right)\\
\end{array}
\end{array}
if t < -1.1999999999999999e98 or 5.1e11 < t Initial program 66.4%
Taylor expanded in t around inf
Applied rewrites80.1%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites77.8%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites79.1%
if -1.1999999999999999e98 < t < 5.1e11Initial program 81.6%
Taylor expanded in c around 0
Applied rewrites84.6%
Taylor expanded in y around 0
lower--.f64N/A
Applied rewrites85.3%
Final simplification83.0%
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (/ (* i (* j y)) t)) (t_2 (* (* -1.0 b) i)))
(if (<= c -2.65e+98)
(fma
c
(* t (- (/ (* a j) t) (/ (* b z) t)))
(* t (- (fma -1.0 (* a x) (fma -1.0 t_1 (/ (* x (* y z)) t))) t_2)))
(fma
a
(* c j)
(fma
t
(- (fma -1.0 (* a x) (* -1.0 t_1)) t_2)
(* z (fma -1.0 (* b c) (* 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 = (i * (j * y)) / t;
double t_2 = (-1.0 * b) * i;
double tmp;
if (c <= -2.65e+98) {
tmp = fma(c, (t * (((a * j) / t) - ((b * z) / t))), (t * (fma(-1.0, (a * x), fma(-1.0, t_1, ((x * (y * z)) / t))) - t_2)));
} else {
tmp = fma(a, (c * j), fma(t, (fma(-1.0, (a * x), (-1.0 * t_1)) - t_2), (z * fma(-1.0, (b * c), (x * y)))));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(Float64(i * Float64(j * y)) / t) t_2 = Float64(Float64(-1.0 * b) * i) tmp = 0.0 if (c <= -2.65e+98) tmp = fma(c, Float64(t * Float64(Float64(Float64(a * j) / t) - Float64(Float64(b * z) / t))), Float64(t * Float64(fma(-1.0, Float64(a * x), fma(-1.0, t_1, Float64(Float64(x * Float64(y * z)) / t))) - t_2))); else tmp = fma(a, Float64(c * j), fma(t, Float64(fma(-1.0, Float64(a * x), Float64(-1.0 * t_1)) - t_2), Float64(z * fma(-1.0, Float64(b * c), Float64(x * y))))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[(i * N[(j * y), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-1.0 * b), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[c, -2.65e+98], N[(c * N[(t * N[(N[(N[(a * j), $MachinePrecision] / t), $MachinePrecision] - N[(N[(b * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t * N[(N[(-1.0 * N[(a * x), $MachinePrecision] + N[(-1.0 * t$95$1 + N[(N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[(c * j), $MachinePrecision] + N[(t * N[(N[(-1.0 * N[(a * x), $MachinePrecision] + N[(-1.0 * t$95$1), $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision] + N[(z * N[(-1.0 * N[(b * c), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{i \cdot \left(j \cdot y\right)}{t}\\
t_2 := \left(-1 \cdot b\right) \cdot i\\
\mathbf{if}\;c \leq -2.65 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{fma}\left(c, t \cdot \left(\frac{a \cdot j}{t} - \frac{b \cdot z}{t}\right), t \cdot \left(\mathsf{fma}\left(-1, a \cdot x, \mathsf{fma}\left(-1, t\_1, \frac{x \cdot \left(y \cdot z\right)}{t}\right)\right) - t\_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, c \cdot j, \mathsf{fma}\left(t, \mathsf{fma}\left(-1, a \cdot x, -1 \cdot t\_1\right) - t\_2, z \cdot \mathsf{fma}\left(-1, b \cdot c, x \cdot y\right)\right)\right)\\
\end{array}
\end{array}
if c < -2.64999999999999999e98Initial program 56.0%
Taylor expanded in t around inf
Applied rewrites56.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites76.6%
if -2.64999999999999999e98 < c Initial program 79.4%
Taylor expanded in t around inf
Applied rewrites71.5%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites61.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites75.8%
Final simplification75.9%
(FPCore (x y z t a b c i j) :precision binary64 (fma a (* c j) (fma t (- (fma -1.0 (* a x) (* -1.0 (/ (* i (* j y)) t))) (* (* -1.0 b) i)) (* z (fma -1.0 (* b c) (* x y))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
return fma(a, (c * j), fma(t, (fma(-1.0, (a * x), (-1.0 * ((i * (j * y)) / t))) - ((-1.0 * b) * i)), (z * fma(-1.0, (b * c), (x * y)))));
}
function code(x, y, z, t, a, b, c, i, j) return fma(a, Float64(c * j), fma(t, Float64(fma(-1.0, Float64(a * x), Float64(-1.0 * Float64(Float64(i * Float64(j * y)) / t))) - Float64(Float64(-1.0 * b) * i)), Float64(z * fma(-1.0, Float64(b * c), Float64(x * y))))) end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := N[(a * N[(c * j), $MachinePrecision] + N[(t * N[(N[(-1.0 * N[(a * x), $MachinePrecision] + N[(-1.0 * N[(N[(i * N[(j * y), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * b), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision] + N[(z * N[(-1.0 * N[(b * c), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a, c \cdot j, \mathsf{fma}\left(t, \mathsf{fma}\left(-1, a \cdot x, -1 \cdot \frac{i \cdot \left(j \cdot y\right)}{t}\right) - \left(-1 \cdot b\right) \cdot i, z \cdot \mathsf{fma}\left(-1, b \cdot c, x \cdot y\right)\right)\right)
\end{array}
Initial program 76.0%
Taylor expanded in t around inf
Applied rewrites69.3%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites63.8%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites74.3%
Final simplification74.3%
herbie shell --seed 2025065
(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)))))