
(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 4 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 (/ -1.0 a)) (* b_m a)))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return (b_m / (-1.0 / 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 / ((-1.0d0) / 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 / (-1.0 / a)) * (b_m * a);
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return (b_m / (-1.0 / 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 / Float64(-1.0 / 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 / (-1.0 / 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 / N[(-1.0 / a), $MachinePrecision]), $MachinePrecision] * N[(b$95$m * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|
\\
[a, b_m] = \mathsf{sort}([a, b_m])\\
\\
\frac{b\_m}{\frac{-1}{a}} \cdot \left(b\_m \cdot a\right)
\end{array}
Initial program 80.0%
associate-*l*N/A
unswap-sqrN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6499.6%
Applied egg-rr99.6%
unpow1N/A
sqr-powN/A
*-lowering-*.f64N/A
pow-lowering-pow.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
pow-lowering-pow.f64N/A
*-lowering-*.f64N/A
metadata-eval54.4%
Applied egg-rr54.4%
distribute-lft-neg-inN/A
pow-prod-upN/A
metadata-evalN/A
unpow1N/A
*-lowering-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
/-rgt-identityN/A
clear-numN/A
distribute-frac-neg2N/A
un-div-invN/A
/-lowering-/.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
*-lowering-*.f6499.7%
Applied egg-rr99.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 (* (* b_m a) (- 0.0 (* b_m a))))
b_m = fabs(b);
assert(a < b_m);
double code(double a, double b_m) {
return (b_m * a) * (0.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 = (b_m * a) * (0.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 (b_m * a) * (0.0 - (b_m * a));
}
b_m = math.fabs(b) [a, b_m] = sort([a, b_m]) def code(a, b_m): return (b_m * a) * (0.0 - (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(0.0 - 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) * (0.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[(b$95$m * a), $MachinePrecision] * N[(0.0 - N[(b$95$m * a), $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 \left(0 - b\_m \cdot a\right)
\end{array}
Initial program 80.0%
associate-*l*N/A
unswap-sqrN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.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 (* 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 80.0%
associate-*l*N/A
associate-*r*N/A
+-lft-identityN/A
flip3-+N/A
distribute-neg-fracN/A
Applied egg-rr28.0%
Final simplification28.0%
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 80.0%
associate-*l*N/A
associate-*r*N/A
+-lft-identityN/A
flip3-+N/A
distribute-neg-fracN/A
Applied egg-rr27.9%
Final simplification27.9%
herbie shell --seed 2024155
(FPCore (a b)
:name "ab-angle->ABCF D"
:precision binary64
(- (* (* (* a a) b) b)))