
(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 6 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}
a_m = (fabs.f64 a) NOTE: a_m and b should be sorted in increasing order before calling this function. (FPCore (a_m b) :precision binary64 (* (* a_m b) (/ a_m (/ -1.0 b))))
a_m = fabs(a);
assert(a_m < b);
double code(double a_m, double b) {
return (a_m * b) * (a_m / (-1.0 / b));
}
a_m = abs(a)
NOTE: a_m and b should be sorted in increasing order before calling this function.
real(8) function code(a_m, b)
real(8), intent (in) :: a_m
real(8), intent (in) :: b
code = (a_m * b) * (a_m / ((-1.0d0) / b))
end function
a_m = Math.abs(a);
assert a_m < b;
public static double code(double a_m, double b) {
return (a_m * b) * (a_m / (-1.0 / b));
}
a_m = math.fabs(a) [a_m, b] = sort([a_m, b]) def code(a_m, b): return (a_m * b) * (a_m / (-1.0 / b))
a_m = abs(a) a_m, b = sort([a_m, b]) function code(a_m, b) return Float64(Float64(a_m * b) * Float64(a_m / Float64(-1.0 / b))) end
a_m = abs(a);
a_m, b = num2cell(sort([a_m, b])){:}
function tmp = code(a_m, b)
tmp = (a_m * b) * (a_m / (-1.0 / b));
end
a_m = N[Abs[a], $MachinePrecision] NOTE: a_m and b should be sorted in increasing order before calling this function. code[a$95$m_, b_] := N[(N[(a$95$m * b), $MachinePrecision] * N[(a$95$m / N[(-1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
[a_m, b] = \mathsf{sort}([a_m, b])\\
\\
\left(a\_m \cdot b\right) \cdot \frac{a\_m}{\frac{-1}{b}}
\end{array}
Initial program 81.4%
associate-*l*N/A
unswap-sqrN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
*-lowering-*.f6499.7
Applied egg-rr99.7%
unpow1N/A
metadata-evalN/A
pow-flipN/A
inv-powN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6499.7
Applied egg-rr99.7%
Final simplification99.7%
a_m = (fabs.f64 a) NOTE: a_m and b should be sorted in increasing order before calling this function. (FPCore (a_m b) :precision binary64 (* (* a_m b) (* a_m (- b))))
a_m = fabs(a);
assert(a_m < b);
double code(double a_m, double b) {
return (a_m * b) * (a_m * -b);
}
a_m = abs(a)
NOTE: a_m and b should be sorted in increasing order before calling this function.
real(8) function code(a_m, b)
real(8), intent (in) :: a_m
real(8), intent (in) :: b
code = (a_m * b) * (a_m * -b)
end function
a_m = Math.abs(a);
assert a_m < b;
public static double code(double a_m, double b) {
return (a_m * b) * (a_m * -b);
}
a_m = math.fabs(a) [a_m, b] = sort([a_m, b]) def code(a_m, b): return (a_m * b) * (a_m * -b)
a_m = abs(a) a_m, b = sort([a_m, b]) function code(a_m, b) return Float64(Float64(a_m * b) * Float64(a_m * Float64(-b))) end
a_m = abs(a);
a_m, b = num2cell(sort([a_m, b])){:}
function tmp = code(a_m, b)
tmp = (a_m * b) * (a_m * -b);
end
a_m = N[Abs[a], $MachinePrecision] NOTE: a_m and b should be sorted in increasing order before calling this function. code[a$95$m_, b_] := N[(N[(a$95$m * b), $MachinePrecision] * N[(a$95$m * (-b)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
[a_m, b] = \mathsf{sort}([a_m, b])\\
\\
\left(a\_m \cdot b\right) \cdot \left(a\_m \cdot \left(-b\right)\right)
\end{array}
Initial program 81.4%
associate-*l*N/A
unswap-sqrN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
*-lowering-*.f6499.7
Applied egg-rr99.7%
Final simplification99.7%
a_m = (fabs.f64 a) NOTE: a_m and b should be sorted in increasing order before calling this function. (FPCore (a_m b) :precision binary64 (* b (* b (* a_m (- a_m)))))
a_m = fabs(a);
assert(a_m < b);
double code(double a_m, double b) {
return b * (b * (a_m * -a_m));
}
a_m = abs(a)
NOTE: a_m and b should be sorted in increasing order before calling this function.
real(8) function code(a_m, b)
real(8), intent (in) :: a_m
real(8), intent (in) :: b
code = b * (b * (a_m * -a_m))
end function
a_m = Math.abs(a);
assert a_m < b;
public static double code(double a_m, double b) {
return b * (b * (a_m * -a_m));
}
a_m = math.fabs(a) [a_m, b] = sort([a_m, b]) def code(a_m, b): return b * (b * (a_m * -a_m))
a_m = abs(a) a_m, b = sort([a_m, b]) function code(a_m, b) return Float64(b * Float64(b * Float64(a_m * Float64(-a_m)))) end
a_m = abs(a);
a_m, b = num2cell(sort([a_m, b])){:}
function tmp = code(a_m, b)
tmp = b * (b * (a_m * -a_m));
end
a_m = N[Abs[a], $MachinePrecision] NOTE: a_m and b should be sorted in increasing order before calling this function. code[a$95$m_, b_] := N[(b * N[(b * N[(a$95$m * (-a$95$m)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
[a_m, b] = \mathsf{sort}([a_m, b])\\
\\
b \cdot \left(b \cdot \left(a\_m \cdot \left(-a\_m\right)\right)\right)
\end{array}
Initial program 81.4%
Final simplification81.4%
a_m = (fabs.f64 a) NOTE: a_m and b should be sorted in increasing order before calling this function. (FPCore (a_m b) :precision binary64 (* b (* b (* a_m a_m))))
a_m = fabs(a);
assert(a_m < b);
double code(double a_m, double b) {
return b * (b * (a_m * a_m));
}
a_m = abs(a)
NOTE: a_m and b should be sorted in increasing order before calling this function.
real(8) function code(a_m, b)
real(8), intent (in) :: a_m
real(8), intent (in) :: b
code = b * (b * (a_m * a_m))
end function
a_m = Math.abs(a);
assert a_m < b;
public static double code(double a_m, double b) {
return b * (b * (a_m * a_m));
}
a_m = math.fabs(a) [a_m, b] = sort([a_m, b]) def code(a_m, b): return b * (b * (a_m * a_m))
a_m = abs(a) a_m, b = sort([a_m, b]) function code(a_m, b) return Float64(b * Float64(b * Float64(a_m * a_m))) end
a_m = abs(a);
a_m, b = num2cell(sort([a_m, b])){:}
function tmp = code(a_m, b)
tmp = b * (b * (a_m * a_m));
end
a_m = N[Abs[a], $MachinePrecision] NOTE: a_m and b should be sorted in increasing order before calling this function. code[a$95$m_, b_] := N[(b * N[(b * N[(a$95$m * a$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
[a_m, b] = \mathsf{sort}([a_m, b])\\
\\
b \cdot \left(b \cdot \left(a\_m \cdot a\_m\right)\right)
\end{array}
Initial program 81.4%
+-lft-identityN/A
flip3-+N/A
distribute-neg-fracN/A
Applied egg-rr29.4%
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6429.4
Applied egg-rr29.4%
Final simplification29.4%
a_m = (fabs.f64 a) NOTE: a_m and b should be sorted in increasing order before calling this function. (FPCore (a_m b) :precision binary64 (* b (* a_m (* a_m b))))
a_m = fabs(a);
assert(a_m < b);
double code(double a_m, double b) {
return b * (a_m * (a_m * b));
}
a_m = abs(a)
NOTE: a_m and b should be sorted in increasing order before calling this function.
real(8) function code(a_m, b)
real(8), intent (in) :: a_m
real(8), intent (in) :: b
code = b * (a_m * (a_m * b))
end function
a_m = Math.abs(a);
assert a_m < b;
public static double code(double a_m, double b) {
return b * (a_m * (a_m * b));
}
a_m = math.fabs(a) [a_m, b] = sort([a_m, b]) def code(a_m, b): return b * (a_m * (a_m * b))
a_m = abs(a) a_m, b = sort([a_m, b]) function code(a_m, b) return Float64(b * Float64(a_m * Float64(a_m * b))) end
a_m = abs(a);
a_m, b = num2cell(sort([a_m, b])){:}
function tmp = code(a_m, b)
tmp = b * (a_m * (a_m * b));
end
a_m = N[Abs[a], $MachinePrecision] NOTE: a_m and b should be sorted in increasing order before calling this function. code[a$95$m_, b_] := N[(b * N[(a$95$m * N[(a$95$m * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
[a_m, b] = \mathsf{sort}([a_m, b])\\
\\
b \cdot \left(a\_m \cdot \left(a\_m \cdot b\right)\right)
\end{array}
Initial program 81.4%
+-lft-identityN/A
flip3-+N/A
distribute-neg-fracN/A
Applied egg-rr29.4%
Final simplification29.4%
a_m = (fabs.f64 a) NOTE: a_m and b should be sorted in increasing order before calling this function. (FPCore (a_m b) :precision binary64 (* (* a_m b) (* a_m b)))
a_m = fabs(a);
assert(a_m < b);
double code(double a_m, double b) {
return (a_m * b) * (a_m * b);
}
a_m = abs(a)
NOTE: a_m and b should be sorted in increasing order before calling this function.
real(8) function code(a_m, b)
real(8), intent (in) :: a_m
real(8), intent (in) :: b
code = (a_m * b) * (a_m * b)
end function
a_m = Math.abs(a);
assert a_m < b;
public static double code(double a_m, double b) {
return (a_m * b) * (a_m * b);
}
a_m = math.fabs(a) [a_m, b] = sort([a_m, b]) def code(a_m, b): return (a_m * b) * (a_m * b)
a_m = abs(a) a_m, b = sort([a_m, b]) function code(a_m, b) return Float64(Float64(a_m * b) * Float64(a_m * b)) end
a_m = abs(a);
a_m, b = num2cell(sort([a_m, b])){:}
function tmp = code(a_m, b)
tmp = (a_m * b) * (a_m * b);
end
a_m = N[Abs[a], $MachinePrecision] NOTE: a_m and b should be sorted in increasing order before calling this function. code[a$95$m_, b_] := N[(N[(a$95$m * b), $MachinePrecision] * N[(a$95$m * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
[a_m, b] = \mathsf{sort}([a_m, b])\\
\\
\left(a\_m \cdot b\right) \cdot \left(a\_m \cdot b\right)
\end{array}
Initial program 81.4%
+-lft-identityN/A
flip3-+N/A
distribute-neg-fracN/A
Applied egg-rr29.4%
herbie shell --seed 2024198
(FPCore (a b)
:name "ab-angle->ABCF D"
:precision binary64
(- (* (* (* a a) b) b)))