
(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 5 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 (* (* b_m a) (/ a (/ -1.0 b_m))))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return (b_m * a) * (a / (-1.0 / 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 / ((-1.0d0) / 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 / (-1.0 / b_m));
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return (b_m * a) * (a / (-1.0 / b_m))
b_m = abs(b) a, b_m = sort([a, b_m]) function code(a, b_m) return Float64(Float64(b_m * a) * Float64(a / Float64(-1.0 / 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 / (-1.0 / 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[(b$95$m * a), $MachinePrecision] * N[(a / N[(-1.0 / 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 \cdot a\right) \cdot \frac{a}{\frac{-1}{b\_m}}
\end{array}
Initial program 83.6%
lift-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
remove-double-divN/A
unpow-1N/A
div-invN/A
remove-double-divN/A
unpow-1N/A
div-invN/A
div-invN/A
unpow-1N/A
remove-double-divN/A
neg-mul-1N/A
distribute-neg-fracN/A
distribute-neg-frac2N/A
lower-/.f64N/A
unpow-1N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f6499.7
Applied rewrites99.7%
Final simplification99.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) (* b_m a)))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return (-a * b_m) * (b_m * 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 = (-a * b_m) * (b_m * a)
end function
b_m = Math.abs(b);
assert a < b_m;
public static double code(double a, double b_m) {
return (-a * b_m) * (b_m * a);
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return (-a * b_m) * (b_m * a)
b_m = abs(b) a, b_m = sort([a, b_m]) function code(a, b_m) return Float64(Float64(Float64(-a) * b_m) * Float64(b_m * a)) end
b_m = abs(b);
a, b_m = num2cell(sort([a, b_m])){:}
function tmp = code(a, b_m)
tmp = (-a * b_m) * (b_m * 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[(N[((-a) * b$95$m), $MachinePrecision] * N[(b$95$m * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
\left(\left(-a\right) \cdot b\_m\right) \cdot \left(b\_m \cdot a\right)
\end{array}
Initial program 83.6%
lift-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.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(Float64(a * 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[(N[(a * a), $MachinePrecision] * b$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
\left(-b\_m\right) \cdot \left(\left(a \cdot a\right) \cdot b\_m\right)
\end{array}
Initial program 83.6%
Final simplification83.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 (* (* (* a a) b_m) b_m))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return ((a * a) * b_m) * 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 * a) * b_m) * b_m
end function
b_m = Math.abs(b);
assert a < b_m;
public static double code(double a, double b_m) {
return ((a * a) * b_m) * b_m;
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return ((a * a) * b_m) * b_m
b_m = abs(b) a, b_m = sort([a, b_m]) function code(a, b_m) return Float64(Float64(Float64(a * a) * b_m) * b_m) end
b_m = abs(b);
a, b_m = num2cell(sort([a, b_m])){:}
function tmp = code(a, b_m)
tmp = ((a * a) * b_m) * 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[(N[(a * a), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
\left(\left(a \cdot a\right) \cdot b\_m\right) \cdot b\_m
\end{array}
Initial program 83.6%
lift-neg.f64N/A
+-lft-identityN/A
flip3-+N/A
distribute-neg-fracN/A
Applied rewrites27.7%
Final simplification27.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 (* (* b_m a) (* b_m a)))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return (b_m * a) * (b_m * 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 * a) * (b_m * a)
end function
b_m = Math.abs(b);
assert a < b_m;
public static double code(double a, double b_m) {
return (b_m * a) * (b_m * a);
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return (b_m * a) * (b_m * a)
b_m = abs(b) a, b_m = sort([a, b_m]) function code(a, b_m) return Float64(Float64(b_m * a) * Float64(b_m * a)) end
b_m = abs(b);
a, b_m = num2cell(sort([a, b_m])){:}
function tmp = code(a, b_m)
tmp = (b_m * a) * (b_m * 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[(N[(b$95$m * a), $MachinePrecision] * N[(b$95$m * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
\left(b\_m \cdot a\right) \cdot \left(b\_m \cdot a\right)
\end{array}
Initial program 83.6%
lift-neg.f64N/A
+-lft-identityN/A
flip3-+N/A
distribute-neg-fracN/A
Applied rewrites27.6%
herbie shell --seed 2024331
(FPCore (a b)
:name "ab-angle->ABCF D"
:precision binary64
(- (* (* (* a a) b) b)))