
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
real(8) function code(x, y, z, t, a)
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
code = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
real(8) function code(x, y, z, t, a)
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
code = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
:precision binary64
(*
a_s
(if (<= a_m 6.9e-29)
(/ (fma y x (* z (- t))) a_m)
(fma (- z) (/ t a_m) (* y (/ x a_m))))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
double tmp;
if (a_m <= 6.9e-29) {
tmp = fma(y, x, (z * -t)) / a_m;
} else {
tmp = fma(-z, (t / a_m), (y * (x / a_m)));
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) x, y, z, t, a_m = sort([x, y, z, t, a_m]) function code(a_s, x, y, z, t, a_m) tmp = 0.0 if (a_m <= 6.9e-29) tmp = Float64(fma(y, x, Float64(z * Float64(-t))) / a_m); else tmp = fma(Float64(-z), Float64(t / a_m), Float64(y * Float64(x / a_m))); end return Float64(a_s * tmp) end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[a$95$m, 6.9e-29], N[(N[(y * x + N[(z * (-t)), $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision], N[((-z) * N[(t / a$95$m), $MachinePrecision] + N[(y * N[(x / a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;a\_m \leq 6.9 \cdot 10^{-29}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, z \cdot \left(-t\right)\right)}{a\_m}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-z, \frac{t}{a\_m}, y \cdot \frac{x}{a\_m}\right)\\
\end{array}
\end{array}
if a < 6.9e-29Initial program 92.9%
sub-negN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
*-lowering-*.f6493.5
Applied egg-rr93.5%
if 6.9e-29 < a Initial program 88.0%
div-subN/A
sub-negN/A
+-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6489.1
Applied egg-rr89.1%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6493.6
Applied egg-rr93.6%
Final simplification93.5%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
:precision binary64
(*
a_s
(if (<= t 1.56e+224)
(/ (fma y x (* z (- t))) a_m)
(fma (- t) (/ z a_m) (/ (* y x) a_m)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
double tmp;
if (t <= 1.56e+224) {
tmp = fma(y, x, (z * -t)) / a_m;
} else {
tmp = fma(-t, (z / a_m), ((y * x) / a_m));
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) x, y, z, t, a_m = sort([x, y, z, t, a_m]) function code(a_s, x, y, z, t, a_m) tmp = 0.0 if (t <= 1.56e+224) tmp = Float64(fma(y, x, Float64(z * Float64(-t))) / a_m); else tmp = fma(Float64(-t), Float64(z / a_m), Float64(Float64(y * x) / a_m)); end return Float64(a_s * tmp) end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[t, 1.56e+224], N[(N[(y * x + N[(z * (-t)), $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision], N[((-t) * N[(z / a$95$m), $MachinePrecision] + N[(N[(y * x), $MachinePrecision] / a$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq 1.56 \cdot 10^{+224}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, z \cdot \left(-t\right)\right)}{a\_m}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-t, \frac{z}{a\_m}, \frac{y \cdot x}{a\_m}\right)\\
\end{array}
\end{array}
if t < 1.5599999999999999e224Initial program 93.0%
sub-negN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
*-lowering-*.f6493.5
Applied egg-rr93.5%
if 1.5599999999999999e224 < t Initial program 66.3%
div-subN/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6493.2
Applied egg-rr93.2%
Final simplification93.4%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
:precision binary64
(*
a_s
(if (<= (* y x) -4e-8)
(* x (/ y a_m))
(if (<= (* y x) 1e-13) (/ (* z (- t)) a_m) (/ (* y x) a_m)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
double tmp;
if ((y * x) <= -4e-8) {
tmp = x * (y / a_m);
} else if ((y * x) <= 1e-13) {
tmp = (z * -t) / a_m;
} else {
tmp = (y * x) / a_m;
}
return a_s * tmp;
}
a\_m = abs(a)
a\_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
real(8), intent (in) :: a_s
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_m
real(8) :: tmp
if ((y * x) <= (-4d-8)) then
tmp = x * (y / a_m)
else if ((y * x) <= 1d-13) then
tmp = (z * -t) / a_m
else
tmp = (y * x) / a_m
end if
code = a_s * tmp
end function
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
double tmp;
if ((y * x) <= -4e-8) {
tmp = x * (y / a_m);
} else if ((y * x) <= 1e-13) {
tmp = (z * -t) / a_m;
} else {
tmp = (y * x) / a_m;
}
return a_s * tmp;
}
a\_m = math.fabs(a) a\_s = math.copysign(1.0, a) [x, y, z, t, a_m] = sort([x, y, z, t, a_m]) def code(a_s, x, y, z, t, a_m): tmp = 0 if (y * x) <= -4e-8: tmp = x * (y / a_m) elif (y * x) <= 1e-13: tmp = (z * -t) / a_m else: tmp = (y * x) / a_m return a_s * tmp
a\_m = abs(a) a\_s = copysign(1.0, a) x, y, z, t, a_m = sort([x, y, z, t, a_m]) function code(a_s, x, y, z, t, a_m) tmp = 0.0 if (Float64(y * x) <= -4e-8) tmp = Float64(x * Float64(y / a_m)); elseif (Float64(y * x) <= 1e-13) tmp = Float64(Float64(z * Float64(-t)) / a_m); else tmp = Float64(Float64(y * x) / a_m); end return Float64(a_s * tmp) end
a\_m = abs(a);
a\_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp_2 = code(a_s, x, y, z, t, a_m)
tmp = 0.0;
if ((y * x) <= -4e-8)
tmp = x * (y / a_m);
elseif ((y * x) <= 1e-13)
tmp = (z * -t) / a_m;
else
tmp = (y * x) / a_m;
end
tmp_2 = a_s * tmp;
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[N[(y * x), $MachinePrecision], -4e-8], N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 1e-13], N[(N[(z * (-t)), $MachinePrecision] / a$95$m), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / a$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot x \leq -4 \cdot 10^{-8}:\\
\;\;\;\;x \cdot \frac{y}{a\_m}\\
\mathbf{elif}\;y \cdot x \leq 10^{-13}:\\
\;\;\;\;\frac{z \cdot \left(-t\right)}{a\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{a\_m}\\
\end{array}
\end{array}
if (*.f64 x y) < -4.0000000000000001e-8Initial program 86.4%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6470.6
Simplified70.6%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6473.9
Applied egg-rr73.9%
if -4.0000000000000001e-8 < (*.f64 x y) < 1e-13Initial program 95.5%
Taylor expanded in x around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f6481.8
Simplified81.8%
if 1e-13 < (*.f64 x y) Initial program 90.4%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6475.8
Simplified75.8%
Final simplification78.0%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
:precision binary64
(*
a_s
(if (<= (* y x) -4e-8)
(* x (/ y a_m))
(if (<= (* y x) 1e-13) (* t (/ z (- a_m))) (/ (* y x) a_m)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
double tmp;
if ((y * x) <= -4e-8) {
tmp = x * (y / a_m);
} else if ((y * x) <= 1e-13) {
tmp = t * (z / -a_m);
} else {
tmp = (y * x) / a_m;
}
return a_s * tmp;
}
a\_m = abs(a)
a\_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
real(8), intent (in) :: a_s
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_m
real(8) :: tmp
if ((y * x) <= (-4d-8)) then
tmp = x * (y / a_m)
else if ((y * x) <= 1d-13) then
tmp = t * (z / -a_m)
else
tmp = (y * x) / a_m
end if
code = a_s * tmp
end function
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
double tmp;
if ((y * x) <= -4e-8) {
tmp = x * (y / a_m);
} else if ((y * x) <= 1e-13) {
tmp = t * (z / -a_m);
} else {
tmp = (y * x) / a_m;
}
return a_s * tmp;
}
a\_m = math.fabs(a) a\_s = math.copysign(1.0, a) [x, y, z, t, a_m] = sort([x, y, z, t, a_m]) def code(a_s, x, y, z, t, a_m): tmp = 0 if (y * x) <= -4e-8: tmp = x * (y / a_m) elif (y * x) <= 1e-13: tmp = t * (z / -a_m) else: tmp = (y * x) / a_m return a_s * tmp
a\_m = abs(a) a\_s = copysign(1.0, a) x, y, z, t, a_m = sort([x, y, z, t, a_m]) function code(a_s, x, y, z, t, a_m) tmp = 0.0 if (Float64(y * x) <= -4e-8) tmp = Float64(x * Float64(y / a_m)); elseif (Float64(y * x) <= 1e-13) tmp = Float64(t * Float64(z / Float64(-a_m))); else tmp = Float64(Float64(y * x) / a_m); end return Float64(a_s * tmp) end
a\_m = abs(a);
a\_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp_2 = code(a_s, x, y, z, t, a_m)
tmp = 0.0;
if ((y * x) <= -4e-8)
tmp = x * (y / a_m);
elseif ((y * x) <= 1e-13)
tmp = t * (z / -a_m);
else
tmp = (y * x) / a_m;
end
tmp_2 = a_s * tmp;
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[N[(y * x), $MachinePrecision], -4e-8], N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 1e-13], N[(t * N[(z / (-a$95$m)), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / a$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot x \leq -4 \cdot 10^{-8}:\\
\;\;\;\;x \cdot \frac{y}{a\_m}\\
\mathbf{elif}\;y \cdot x \leq 10^{-13}:\\
\;\;\;\;t \cdot \frac{z}{-a\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{a\_m}\\
\end{array}
\end{array}
if (*.f64 x y) < -4.0000000000000001e-8Initial program 86.4%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6470.6
Simplified70.6%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6473.9
Applied egg-rr73.9%
if -4.0000000000000001e-8 < (*.f64 x y) < 1e-13Initial program 95.5%
div-invN/A
*-lowering-*.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6495.4
Applied egg-rr95.4%
Taylor expanded in t around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f6481.7
Simplified81.7%
associate-*l*N/A
div-invN/A
*-commutativeN/A
*-lowering-*.f64N/A
remove-double-negN/A
frac-2negN/A
/-lowering-/.f64N/A
neg-lowering-neg.f6481.6
Applied egg-rr81.6%
if 1e-13 < (*.f64 x y) Initial program 90.4%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6475.8
Simplified75.8%
Final simplification77.8%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
:precision binary64
(*
a_s
(if (<= (* y x) -4e-8)
(* x (/ y a_m))
(if (<= (* y x) 1e-13) (* (- z) (/ t a_m)) (/ (* y x) a_m)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
double tmp;
if ((y * x) <= -4e-8) {
tmp = x * (y / a_m);
} else if ((y * x) <= 1e-13) {
tmp = -z * (t / a_m);
} else {
tmp = (y * x) / a_m;
}
return a_s * tmp;
}
a\_m = abs(a)
a\_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
real(8), intent (in) :: a_s
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_m
real(8) :: tmp
if ((y * x) <= (-4d-8)) then
tmp = x * (y / a_m)
else if ((y * x) <= 1d-13) then
tmp = -z * (t / a_m)
else
tmp = (y * x) / a_m
end if
code = a_s * tmp
end function
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
double tmp;
if ((y * x) <= -4e-8) {
tmp = x * (y / a_m);
} else if ((y * x) <= 1e-13) {
tmp = -z * (t / a_m);
} else {
tmp = (y * x) / a_m;
}
return a_s * tmp;
}
a\_m = math.fabs(a) a\_s = math.copysign(1.0, a) [x, y, z, t, a_m] = sort([x, y, z, t, a_m]) def code(a_s, x, y, z, t, a_m): tmp = 0 if (y * x) <= -4e-8: tmp = x * (y / a_m) elif (y * x) <= 1e-13: tmp = -z * (t / a_m) else: tmp = (y * x) / a_m return a_s * tmp
a\_m = abs(a) a\_s = copysign(1.0, a) x, y, z, t, a_m = sort([x, y, z, t, a_m]) function code(a_s, x, y, z, t, a_m) tmp = 0.0 if (Float64(y * x) <= -4e-8) tmp = Float64(x * Float64(y / a_m)); elseif (Float64(y * x) <= 1e-13) tmp = Float64(Float64(-z) * Float64(t / a_m)); else tmp = Float64(Float64(y * x) / a_m); end return Float64(a_s * tmp) end
a\_m = abs(a);
a\_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp_2 = code(a_s, x, y, z, t, a_m)
tmp = 0.0;
if ((y * x) <= -4e-8)
tmp = x * (y / a_m);
elseif ((y * x) <= 1e-13)
tmp = -z * (t / a_m);
else
tmp = (y * x) / a_m;
end
tmp_2 = a_s * tmp;
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[N[(y * x), $MachinePrecision], -4e-8], N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 1e-13], N[((-z) * N[(t / a$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / a$95$m), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot x \leq -4 \cdot 10^{-8}:\\
\;\;\;\;x \cdot \frac{y}{a\_m}\\
\mathbf{elif}\;y \cdot x \leq 10^{-13}:\\
\;\;\;\;\left(-z\right) \cdot \frac{t}{a\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{a\_m}\\
\end{array}
\end{array}
if (*.f64 x y) < -4.0000000000000001e-8Initial program 86.4%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6470.6
Simplified70.6%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6473.9
Applied egg-rr73.9%
if -4.0000000000000001e-8 < (*.f64 x y) < 1e-13Initial program 95.5%
div-invN/A
*-lowering-*.f64N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6495.4
Applied egg-rr95.4%
Taylor expanded in t around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f6481.7
Simplified81.7%
un-div-invN/A
associate-*l/N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
distribute-frac-neg2N/A
/-lowering-/.f64N/A
neg-lowering-neg.f6477.0
Applied egg-rr77.0%
if 1e-13 < (*.f64 x y) Initial program 90.4%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6475.8
Simplified75.8%
Final simplification75.8%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
(FPCore (a_s x y z t a_m)
:precision binary64
(*
a_s
(if (<= (* y x) (- INFINITY))
(/ y (/ a_m x))
(/ (fma y x (* z (- t))) a_m))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
double tmp;
if ((y * x) <= -((double) INFINITY)) {
tmp = y / (a_m / x);
} else {
tmp = fma(y, x, (z * -t)) / a_m;
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) x, y, z, t, a_m = sort([x, y, z, t, a_m]) function code(a_s, x, y, z, t, a_m) tmp = 0.0 if (Float64(y * x) <= Float64(-Inf)) tmp = Float64(y / Float64(a_m / x)); else tmp = Float64(fma(y, x, Float64(z * Float64(-t))) / a_m); end return Float64(a_s * tmp) end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[N[(y * x), $MachinePrecision], (-Infinity)], N[(y / N[(a$95$m / x), $MachinePrecision]), $MachinePrecision], N[(N[(y * x + N[(z * (-t)), $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot x \leq -\infty:\\
\;\;\;\;\frac{y}{\frac{a\_m}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, z \cdot \left(-t\right)\right)}{a\_m}\\
\end{array}
\end{array}
if (*.f64 x y) < -inf.0Initial program 67.5%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6467.7
Simplified67.7%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6498.3
Applied egg-rr98.3%
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6498.3
Applied egg-rr98.3%
if -inf.0 < (*.f64 x y) Initial program 93.6%
sub-negN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
*-lowering-*.f6494.0
Applied egg-rr94.0%
Final simplification94.4%
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function. (FPCore (a_s x y z t a_m) :precision binary64 (* a_s (if (<= (* y x) (- INFINITY)) (/ y (/ a_m x)) (/ (- (* y x) (* z t)) a_m))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
double tmp;
if ((y * x) <= -((double) INFINITY)) {
tmp = y / (a_m / x);
} else {
tmp = ((y * x) - (z * t)) / a_m;
}
return a_s * tmp;
}
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
double tmp;
if ((y * x) <= -Double.POSITIVE_INFINITY) {
tmp = y / (a_m / x);
} else {
tmp = ((y * x) - (z * t)) / a_m;
}
return a_s * tmp;
}
a\_m = math.fabs(a) a\_s = math.copysign(1.0, a) [x, y, z, t, a_m] = sort([x, y, z, t, a_m]) def code(a_s, x, y, z, t, a_m): tmp = 0 if (y * x) <= -math.inf: tmp = y / (a_m / x) else: tmp = ((y * x) - (z * t)) / a_m return a_s * tmp
a\_m = abs(a) a\_s = copysign(1.0, a) x, y, z, t, a_m = sort([x, y, z, t, a_m]) function code(a_s, x, y, z, t, a_m) tmp = 0.0 if (Float64(y * x) <= Float64(-Inf)) tmp = Float64(y / Float64(a_m / x)); else tmp = Float64(Float64(Float64(y * x) - Float64(z * t)) / a_m); end return Float64(a_s * tmp) end
a\_m = abs(a);
a\_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp_2 = code(a_s, x, y, z, t, a_m)
tmp = 0.0;
if ((y * x) <= -Inf)
tmp = y / (a_m / x);
else
tmp = ((y * x) - (z * t)) / a_m;
end
tmp_2 = a_s * tmp;
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * If[LessEqual[N[(y * x), $MachinePrecision], (-Infinity)], N[(y / N[(a$95$m / x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * x), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot x \leq -\infty:\\
\;\;\;\;\frac{y}{\frac{a\_m}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x - z \cdot t}{a\_m}\\
\end{array}
\end{array}
if (*.f64 x y) < -inf.0Initial program 67.5%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6467.7
Simplified67.7%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6498.3
Applied egg-rr98.3%
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6498.3
Applied egg-rr98.3%
if -inf.0 < (*.f64 x y) Initial program 93.6%
Final simplification94.0%
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function. (FPCore (a_s x y z t a_m) :precision binary64 (* a_s (* x (/ y a_m))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
return a_s * (x * (y / a_m));
}
a\_m = abs(a)
a\_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
real(8), intent (in) :: a_s
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_m
code = a_s * (x * (y / a_m))
end function
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
return a_s * (x * (y / a_m));
}
a\_m = math.fabs(a) a\_s = math.copysign(1.0, a) [x, y, z, t, a_m] = sort([x, y, z, t, a_m]) def code(a_s, x, y, z, t, a_m): return a_s * (x * (y / a_m))
a\_m = abs(a) a\_s = copysign(1.0, a) x, y, z, t, a_m = sort([x, y, z, t, a_m]) function code(a_s, x, y, z, t, a_m) return Float64(a_s * Float64(x * Float64(y / a_m))) end
a\_m = abs(a);
a\_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp = code(a_s, x, y, z, t, a_m)
tmp = a_s * (x * (y / a_m));
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * N[(x * N[(y / a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \left(x \cdot \frac{y}{a\_m}\right)
\end{array}
Initial program 91.6%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6453.3
Simplified53.3%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6454.0
Applied egg-rr54.0%
Final simplification54.0%
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function. (FPCore (a_s x y z t a_m) :precision binary64 (* a_s (* y (/ x a_m))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
assert(x < y && y < z && z < t && t < a_m);
double code(double a_s, double x, double y, double z, double t, double a_m) {
return a_s * (y * (x / a_m));
}
a\_m = abs(a)
a\_s = copysign(1.0d0, a)
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
real(8) function code(a_s, x, y, z, t, a_m)
real(8), intent (in) :: a_s
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_m
code = a_s * (y * (x / a_m))
end function
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
assert x < y && y < z && z < t && t < a_m;
public static double code(double a_s, double x, double y, double z, double t, double a_m) {
return a_s * (y * (x / a_m));
}
a\_m = math.fabs(a) a\_s = math.copysign(1.0, a) [x, y, z, t, a_m] = sort([x, y, z, t, a_m]) def code(a_s, x, y, z, t, a_m): return a_s * (y * (x / a_m))
a\_m = abs(a) a\_s = copysign(1.0, a) x, y, z, t, a_m = sort([x, y, z, t, a_m]) function code(a_s, x, y, z, t, a_m) return Float64(a_s * Float64(y * Float64(x / a_m))) end
a\_m = abs(a);
a\_s = sign(a) * abs(1.0);
x, y, z, t, a_m = num2cell(sort([x, y, z, t, a_m])){:}
function tmp = code(a_s, x, y, z, t, a_m)
tmp = a_s * (y * (x / a_m));
end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, and a_m should be sorted in increasing order before calling this function.
code[a$95$s_, x_, y_, z_, t_, a$95$m_] := N[(a$95$s * N[(y * N[(x / a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
[x, y, z, t, a_m] = \mathsf{sort}([x, y, z, t, a_m])\\
\\
a\_s \cdot \left(y \cdot \frac{x}{a\_m}\right)
\end{array}
Initial program 91.6%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6453.3
Simplified53.3%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6453.3
Applied egg-rr53.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (* (/ y a) x) (* (/ t a) z))))
(if (< z -2.468684968699548e+170)
t_1
(if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((y / a) * x) - ((t / a) * z);
double tmp;
if (z < -2.468684968699548e+170) {
tmp = t_1;
} else if (z < 6.309831121978371e-71) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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) :: t_1
real(8) :: tmp
t_1 = ((y / a) * x) - ((t / a) * z)
if (z < (-2.468684968699548d+170)) then
tmp = t_1
else if (z < 6.309831121978371d-71) then
tmp = ((x * y) - (z * t)) / a
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = ((y / a) * x) - ((t / a) * z);
double tmp;
if (z < -2.468684968699548e+170) {
tmp = t_1;
} else if (z < 6.309831121978371e-71) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = ((y / a) * x) - ((t / a) * z) tmp = 0 if z < -2.468684968699548e+170: tmp = t_1 elif z < 6.309831121978371e-71: tmp = ((x * y) - (z * t)) / a else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(y / a) * x) - Float64(Float64(t / a) * z)) tmp = 0.0 if (z < -2.468684968699548e+170) tmp = t_1; elseif (z < 6.309831121978371e-71) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = ((y / a) * x) - ((t / a) * z); tmp = 0.0; if (z < -2.468684968699548e+170) tmp = t_1; elseif (z < 6.309831121978371e-71) tmp = ((x * y) - (z * t)) / a; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision] - N[(N[(t / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -2.468684968699548e+170], t$95$1, If[Less[z, 6.309831121978371e-71], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\
\mathbf{if}\;z < -2.468684968699548 \cdot 10^{+170}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 6.309831121978371 \cdot 10^{-71}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024204
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
:alt
(! :herbie-platform default (if (< z -246868496869954800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6309831121978371/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z)))))
(/ (- (* x y) (* z t)) a))