
(FPCore (a b) :precision binary64 (- (* (* (* a a) b) b)))
double code(double a, double b) {
return -(((a * a) * b) * b);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = -(((a * a) * b) * b)
end function
public static double code(double a, double b) {
return -(((a * a) * b) * b);
}
def code(a, b): return -(((a * a) * b) * b)
function code(a, b) return Float64(-Float64(Float64(Float64(a * a) * b) * b)) end
function tmp = code(a, b) tmp = -(((a * a) * b) * b); end
code[a_, b_] := (-N[(N[(N[(a * a), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision])
\begin{array}{l}
\\
-\left(\left(a \cdot a\right) \cdot b\right) \cdot b
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (- (* (* (* a a) b) b)))
double code(double a, double b) {
return -(((a * a) * b) * b);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = -(((a * a) * b) * b)
end function
public static double code(double a, double b) {
return -(((a * a) * b) * b);
}
def code(a, b): return -(((a * a) * b) * b)
function code(a, b) return Float64(-Float64(Float64(Float64(a * a) * b) * b)) end
function tmp = code(a, b) tmp = -(((a * a) * b) * b); end
code[a_, b_] := (-N[(N[(N[(a * a), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision])
\begin{array}{l}
\\
-\left(\left(a \cdot a\right) \cdot b\right) \cdot b
\end{array}
b_m = (fabs.f64 b) NOTE: a and b_m should be sorted in increasing order before calling this function. (FPCore (a b_m) :precision binary64 (* (/ a (/ -1.0 b_m)) (* a b_m)))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return (a / (-1.0 / b_m)) * (a * b_m);
}
b_m = abs(b)
NOTE: a and b_m should be sorted in increasing order before calling this function.
real(8) function code(a, b_m)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
code = (a / ((-1.0d0) / b_m)) * (a * b_m)
end function
b_m = Math.abs(b);
assert a < b_m;
public static double code(double a, double b_m) {
return (a / (-1.0 / b_m)) * (a * b_m);
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return (a / (-1.0 / b_m)) * (a * b_m)
b_m = abs(b) a, b_m = sort([a, b_m]) function code(a, b_m) return Float64(Float64(a / Float64(-1.0 / b_m)) * Float64(a * b_m)) end
b_m = abs(b);
a, b_m = num2cell(sort([a, b_m])){:}
function tmp = code(a, b_m)
tmp = (a / (-1.0 / b_m)) * (a * b_m);
end
b_m = N[Abs[b], $MachinePrecision] NOTE: a and b_m should be sorted in increasing order before calling this function. code[a_, b$95$m_] := N[(N[(a / N[(-1.0 / b$95$m), $MachinePrecision]), $MachinePrecision] * N[(a * b$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
\frac{a}{\frac{-1}{b\_m}} \cdot \left(a \cdot b\_m\right)
\end{array}
Initial program 81.4%
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f6499.6
Applied egg-rr99.6%
neg-sub0N/A
flip--N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lift-neg.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-lft-identityN/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
+-lft-identityN/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
Applied egg-rr99.7%
b_m = (fabs.f64 b) NOTE: a and b_m should be sorted in increasing order before calling this function. (FPCore (a b_m) :precision binary64 (* (* a b_m) (- (* a b_m))))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return (a * b_m) * -(a * b_m);
}
b_m = abs(b)
NOTE: a and b_m should be sorted in increasing order before calling this function.
real(8) function code(a, b_m)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
code = (a * b_m) * -(a * b_m)
end function
b_m = Math.abs(b);
assert a < b_m;
public static double code(double a, double b_m) {
return (a * b_m) * -(a * b_m);
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return (a * b_m) * -(a * b_m)
b_m = abs(b) a, b_m = sort([a, b_m]) function code(a, b_m) return Float64(Float64(a * b_m) * Float64(-Float64(a * b_m))) end
b_m = abs(b);
a, b_m = num2cell(sort([a, b_m])){:}
function tmp = code(a, b_m)
tmp = (a * b_m) * -(a * b_m);
end
b_m = N[Abs[b], $MachinePrecision] NOTE: a and b_m should be sorted in increasing order before calling this function. code[a_, b$95$m_] := N[(N[(a * b$95$m), $MachinePrecision] * (-N[(a * b$95$m), $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
\left(a \cdot b\_m\right) \cdot \left(-a \cdot b\_m\right)
\end{array}
Initial program 81.4%
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f6499.6
Applied egg-rr99.6%
Final simplification99.6%
b_m = (fabs.f64 b) NOTE: a and b_m should be sorted in increasing order before calling this function. (FPCore (a b_m) :precision binary64 (* (- b_m) (* a (* a b_m))))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return -b_m * (a * (a * b_m));
}
b_m = abs(b)
NOTE: a and b_m should be sorted in increasing order before calling this function.
real(8) function code(a, b_m)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
code = -b_m * (a * (a * b_m))
end function
b_m = Math.abs(b);
assert a < b_m;
public static double code(double a, double b_m) {
return -b_m * (a * (a * b_m));
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return -b_m * (a * (a * b_m))
b_m = abs(b) a, b_m = sort([a, b_m]) function code(a, b_m) return Float64(Float64(-b_m) * Float64(a * Float64(a * b_m))) end
b_m = abs(b);
a, b_m = num2cell(sort([a, b_m])){:}
function tmp = code(a, b_m)
tmp = -b_m * (a * (a * b_m));
end
b_m = N[Abs[b], $MachinePrecision] NOTE: a and b_m should be sorted in increasing order before calling this function. code[a_, b$95$m_] := N[((-b$95$m) * N[(a * N[(a * b$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
\left(-b\_m\right) \cdot \left(a \cdot \left(a \cdot b\_m\right)\right)
\end{array}
Initial program 81.4%
Taylor expanded in a around 0
mul-1-negN/A
unpow2N/A
associate-*r*N/A
distribute-lft-neg-inN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6494.4
Simplified94.4%
Final simplification94.4%
b_m = (fabs.f64 b) NOTE: a and b_m should be sorted in increasing order before calling this function. (FPCore (a b_m) :precision binary64 (* b_m (* b_m (* a (- a)))))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return b_m * (b_m * (a * -a));
}
b_m = abs(b)
NOTE: a and b_m should be sorted in increasing order before calling this function.
real(8) function code(a, b_m)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
code = b_m * (b_m * (a * -a))
end function
b_m = Math.abs(b);
assert a < b_m;
public static double code(double a, double b_m) {
return b_m * (b_m * (a * -a));
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return b_m * (b_m * (a * -a))
b_m = abs(b) a, b_m = sort([a, b_m]) function code(a, b_m) return Float64(b_m * Float64(b_m * Float64(a * Float64(-a)))) end
b_m = abs(b);
a, b_m = num2cell(sort([a, b_m])){:}
function tmp = code(a, b_m)
tmp = b_m * (b_m * (a * -a));
end
b_m = N[Abs[b], $MachinePrecision] NOTE: a and b_m should be sorted in increasing order before calling this function. code[a_, b$95$m_] := N[(b$95$m * N[(b$95$m * N[(a * (-a)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
b\_m \cdot \left(b\_m \cdot \left(a \cdot \left(-a\right)\right)\right)
\end{array}
Initial program 81.4%
Final simplification81.4%
b_m = (fabs.f64 b) NOTE: a and b_m should be sorted in increasing order before calling this function. (FPCore (a b_m) :precision binary64 (* b_m (* b_m (* a a))))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return b_m * (b_m * (a * a));
}
b_m = abs(b)
NOTE: a and b_m should be sorted in increasing order before calling this function.
real(8) function code(a, b_m)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
code = b_m * (b_m * (a * a))
end function
b_m = Math.abs(b);
assert a < b_m;
public static double code(double a, double b_m) {
return b_m * (b_m * (a * a));
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return b_m * (b_m * (a * a))
b_m = abs(b) a, b_m = sort([a, b_m]) function code(a, b_m) return Float64(b_m * Float64(b_m * Float64(a * a))) end
b_m = abs(b);
a, b_m = num2cell(sort([a, b_m])){:}
function tmp = code(a, b_m)
tmp = b_m * (b_m * (a * a));
end
b_m = N[Abs[b], $MachinePrecision] NOTE: a and b_m should be sorted in increasing order before calling this function. code[a_, b$95$m_] := N[(b$95$m * N[(b$95$m * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
b\_m \cdot \left(b\_m \cdot \left(a \cdot a\right)\right)
\end{array}
Initial program 81.4%
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
+-lft-identityN/A
flip3-+N/A
distribute-neg-fracN/A
Applied egg-rr31.6%
Final simplification31.6%
b_m = (fabs.f64 b) NOTE: a and b_m should be sorted in increasing order before calling this function. (FPCore (a b_m) :precision binary64 (* b_m (* a (* a b_m))))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return b_m * (a * (a * b_m));
}
b_m = abs(b)
NOTE: a and b_m should be sorted in increasing order before calling this function.
real(8) function code(a, b_m)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
code = b_m * (a * (a * b_m))
end function
b_m = Math.abs(b);
assert a < b_m;
public static double code(double a, double b_m) {
return b_m * (a * (a * b_m));
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return b_m * (a * (a * b_m))
b_m = abs(b) a, b_m = sort([a, b_m]) function code(a, b_m) return Float64(b_m * Float64(a * Float64(a * b_m))) end
b_m = abs(b);
a, b_m = num2cell(sort([a, b_m])){:}
function tmp = code(a, b_m)
tmp = b_m * (a * (a * b_m));
end
b_m = N[Abs[b], $MachinePrecision] NOTE: a and b_m should be sorted in increasing order before calling this function. code[a_, b$95$m_] := N[(b$95$m * N[(a * N[(a * b$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
b\_m \cdot \left(a \cdot \left(a \cdot b\_m\right)\right)
\end{array}
Initial program 81.4%
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
+-lft-identityN/A
flip3-+N/A
distribute-neg-fracN/A
Applied egg-rr31.5%
swap-sqrN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6431.5
Applied egg-rr31.5%
Final simplification31.5%
b_m = (fabs.f64 b) NOTE: a and b_m should be sorted in increasing order before calling this function. (FPCore (a b_m) :precision binary64 (* (* a b_m) (* a b_m)))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return (a * b_m) * (a * b_m);
}
b_m = abs(b)
NOTE: a and b_m should be sorted in increasing order before calling this function.
real(8) function code(a, b_m)
real(8), intent (in) :: a
real(8), intent (in) :: b_m
code = (a * b_m) * (a * b_m)
end function
b_m = Math.abs(b);
assert a < b_m;
public static double code(double a, double b_m) {
return (a * b_m) * (a * b_m);
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return (a * b_m) * (a * b_m)
b_m = abs(b) a, b_m = sort([a, b_m]) function code(a, b_m) return Float64(Float64(a * b_m) * Float64(a * b_m)) end
b_m = abs(b);
a, b_m = num2cell(sort([a, b_m])){:}
function tmp = code(a, b_m)
tmp = (a * b_m) * (a * b_m);
end
b_m = N[Abs[b], $MachinePrecision] NOTE: a and b_m should be sorted in increasing order before calling this function. code[a_, b$95$m_] := N[(N[(a * b$95$m), $MachinePrecision] * N[(a * b$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
\left(a \cdot b\_m\right) \cdot \left(a \cdot b\_m\right)
\end{array}
Initial program 81.4%
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
+-lft-identityN/A
flip3-+N/A
distribute-neg-fracN/A
Applied egg-rr31.5%
herbie shell --seed 2024207
(FPCore (a b)
:name "ab-angle->ABCF D"
:precision binary64
(- (* (* (* a a) b) b)))