
(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 b_m) (/ (/ -1.0 b_m) a)))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return (a * b_m) / ((-1.0 / 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) / (((-1.0d0) / 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) / ((-1.0 / b_m) / a);
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return (a * b_m) / ((-1.0 / b_m) / a)
b_m = abs(b) a, b_m = sort([a, b_m]) function code(a, b_m) return Float64(Float64(a * b_m) / Float64(Float64(-1.0 / 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) / ((-1.0 / 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[(N[(-1.0 / b$95$m), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
\frac{a \cdot b\_m}{\frac{\frac{-1}{b\_m}}{a}}
\end{array}
Initial program 77.9%
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%
remove-double-divN/A
unpow-1N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
unpow-prod-downN/A
associate-/r*N/A
pow-flipN/A
metadata-evalN/A
unpow1N/A
lower-/.f64N/A
lower-pow.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
frac-2negN/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
neg-mul-1N/A
*-commutativeN/A
associate-*l*N/A
neg-mul-1N/A
lift-neg.f64N/A
remove-double-negN/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
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 (/ -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 77.9%
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%
remove-double-divN/A
unpow-1N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
unpow-prod-downN/A
associate-/r*N/A
pow-flipN/A
metadata-evalN/A
unpow1N/A
lower-/.f64N/A
lower-pow.f6499.6
Applied rewrites99.6%
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-pow.f64N/A
unpow-1N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6499.6
Applied rewrites99.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 (/ (* a b_m) (/ -1.0 (* a b_m))))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return (a * b_m) / (-1.0 / (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) / ((-1.0d0) / (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) / (-1.0 / (a * b_m));
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return (a * b_m) / (-1.0 / (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(-1.0 / 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) / (-1.0 / (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[(-1.0 / N[(a * b$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
\frac{a \cdot b\_m}{\frac{-1}{a \cdot b\_m}}
\end{array}
Initial program 77.9%
Applied rewrites99.6%
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-pow.f64N/A
sqr-powN/A
distribute-rgt-neg-inN/A
associate-/r*N/A
metadata-evalN/A
unpow-1N/A
remove-double-divN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow-1N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6499.6
lift-*.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 (* (* (- 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(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(\left(-a\right) \cdot b\_m\right) \cdot \left(a \cdot b\_m\right)
\end{array}
Initial program 77.9%
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%
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(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 77.9%
Final simplification77.9%
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 77.9%
lift-neg.f64N/A
+-lft-identityN/A
flip3-+N/A
distribute-neg-fracN/A
Applied rewrites29.6%
Final simplification29.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 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(Float64(a * b_m) * 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[(N[(a * b$95$m), $MachinePrecision] * a), $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 b\_m\right) \cdot a\right) \cdot b\_m
\end{array}
Initial program 77.9%
lift-neg.f64N/A
+-lft-identityN/A
flip3-+N/A
distribute-neg-fracN/A
Applied rewrites29.6%
Taylor expanded in b around 0
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6429.6
Applied rewrites29.6%
Final simplification29.6%
herbie shell --seed 2024249
(FPCore (a b)
:name "ab-angle->ABCF D"
:precision binary64
(- (* (* (* a a) b) b)))