
(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}
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (- (* (* (* a a) b) b)))
a = abs(a);
b = abs(b);
assert(a < b);
double code(double a, double b) {
return -(((a * a) * b) * b);
}
NOTE: a should be positive before calling this function
NOTE: b should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = -(((a * a) * b) * b)
end function
a = Math.abs(a);
b = Math.abs(b);
assert a < b;
public static double code(double a, double b) {
return -(((a * a) * b) * b);
}
a = abs(a) b = abs(b) [a, b] = sort([a, b]) def code(a, b): return -(((a * a) * b) * b)
a = abs(a) b = abs(b) a, b = sort([a, b]) function code(a, b) return Float64(-Float64(Float64(Float64(a * a) * b) * b)) end
a = abs(a)
b = abs(b)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = -(((a * a) * b) * b);
end
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := (-N[(N[(N[(a * a), $MachinePrecision] * b), $MachinePrecision] * b), $MachinePrecision])
\begin{array}{l}
a = |a|\\
b = |b|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
-\left(\left(a \cdot a\right) \cdot b\right) \cdot b
\end{array}
Initial program 81.4%
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (* a (* a b)) (- b)))
a = abs(a);
b = abs(b);
assert(a < b);
double code(double a, double b) {
return (a * (a * b)) * -b;
}
NOTE: a should be positive before calling this function
NOTE: b should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (a * (a * b)) * -b
end function
a = Math.abs(a);
b = Math.abs(b);
assert a < b;
public static double code(double a, double b) {
return (a * (a * b)) * -b;
}
a = abs(a) b = abs(b) [a, b] = sort([a, b]) def code(a, b): return (a * (a * b)) * -b
a = abs(a) b = abs(b) a, b = sort([a, b]) function code(a, b) return Float64(Float64(a * Float64(a * b)) * Float64(-b)) end
a = abs(a)
b = abs(b)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (a * (a * b)) * -b;
end
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(a * N[(a * b), $MachinePrecision]), $MachinePrecision] * (-b)), $MachinePrecision]
\begin{array}{l}
a = |a|\\
b = |b|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\left(a \cdot \left(a \cdot b\right)\right) \cdot \left(-b\right)
\end{array}
Initial program 96.3%
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (* a a) (* b (- b))))
a = abs(a);
b = abs(b);
assert(a < b);
double code(double a, double b) {
return (a * a) * (b * -b);
}
NOTE: a should be positive before calling this function
NOTE: b should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (a * a) * (b * -b)
end function
a = Math.abs(a);
b = Math.abs(b);
assert a < b;
public static double code(double a, double b) {
return (a * a) * (b * -b);
}
a = abs(a) b = abs(b) [a, b] = sort([a, b]) def code(a, b): return (a * a) * (b * -b)
a = abs(a) b = abs(b) a, b = sort([a, b]) function code(a, b) return Float64(Float64(a * a) * Float64(b * Float64(-b))) end
a = abs(a)
b = abs(b)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (a * a) * (b * -b);
end
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(a * a), $MachinePrecision] * N[(b * (-b)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
b = |b|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\left(a \cdot a\right) \cdot \left(b \cdot \left(-b\right)\right)
\end{array}
Initial program 73.9%
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (* (* a a) b) (- b)))
a = abs(a);
b = abs(b);
assert(a < b);
double code(double a, double b) {
return ((a * a) * b) * -b;
}
NOTE: a should be positive before calling this function
NOTE: b should be positive before calling this function
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((a * a) * b) * -b
end function
a = Math.abs(a);
b = Math.abs(b);
assert a < b;
public static double code(double a, double b) {
return ((a * a) * b) * -b;
}
a = abs(a) b = abs(b) [a, b] = sort([a, b]) def code(a, b): return ((a * a) * b) * -b
a = abs(a) b = abs(b) a, b = sort([a, b]) function code(a, b) return Float64(Float64(Float64(a * a) * b) * Float64(-b)) end
a = abs(a)
b = abs(b)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = ((a * a) * b) * -b;
end
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(N[(a * a), $MachinePrecision] * b), $MachinePrecision] * (-b)), $MachinePrecision]
\begin{array}{l}
a = |a|\\
b = |b|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\left(\left(a \cdot a\right) \cdot b\right) \cdot \left(-b\right)
\end{array}
Initial program 81.4%
herbie shell --seed 2023276
(FPCore (a b)
:name "ab-angle->ABCF D"
:precision binary64
(- (* (* (* a a) b) b)))