
(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 (* (* b (* a (sqrt b))) (* (sqrt (* b a)) (- (sqrt a)))))
a = abs(a);
b = abs(b);
assert(a < b);
double code(double a, double b) {
return (b * (a * sqrt(b))) * (sqrt((b * a)) * -sqrt(a));
}
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 = (b * (a * sqrt(b))) * (sqrt((b * a)) * -sqrt(a))
end function
a = Math.abs(a);
b = Math.abs(b);
assert a < b;
public static double code(double a, double b) {
return (b * (a * Math.sqrt(b))) * (Math.sqrt((b * a)) * -Math.sqrt(a));
}
a = abs(a) b = abs(b) [a, b] = sort([a, b]) def code(a, b): return (b * (a * math.sqrt(b))) * (math.sqrt((b * a)) * -math.sqrt(a))
a = abs(a) b = abs(b) a, b = sort([a, b]) function code(a, b) return Float64(Float64(b * Float64(a * sqrt(b))) * Float64(sqrt(Float64(b * a)) * Float64(-sqrt(a)))) end
a = abs(a)
b = abs(b)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (b * (a * sqrt(b))) * (sqrt((b * a)) * -sqrt(a));
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[(b * N[(a * N[Sqrt[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(b * a), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
b = |b|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\left(b \cdot \left(a \cdot \sqrt{b}\right)\right) \cdot \left(\sqrt{b \cdot a} \cdot \left(-\sqrt{a}\right)\right)
\end{array}
Initial program 84.1%
Taylor expanded in a around 0 78.5%
unpow278.5%
unpow278.5%
swap-sqr99.7%
unpow299.7%
Simplified99.7%
unpow299.7%
*-commutative99.7%
associate-*l*95.4%
associate-*l*84.1%
add-sqr-sqrt40.5%
swap-sqr49.6%
associate-*r*51.4%
Applied egg-rr51.4%
add-cube-cbrt51.1%
pow351.1%
Applied egg-rr51.1%
rem-cube-cbrt51.4%
*-commutative51.4%
add-sqr-sqrt23.3%
associate-*r*23.4%
sqrt-prod23.4%
*-commutative23.4%
Applied egg-rr23.4%
Final simplification23.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 * 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 84.1%
Taylor expanded in a around 0 78.5%
unpow278.5%
unpow278.5%
Simplified78.5%
Final simplification78.5%
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 (* (* b a) (* b (- a))))
a = abs(a);
b = abs(b);
assert(a < b);
double code(double a, double b) {
return (b * a) * (b * -a);
}
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 = (b * a) * (b * -a)
end function
a = Math.abs(a);
b = Math.abs(b);
assert a < b;
public static double code(double a, double b) {
return (b * a) * (b * -a);
}
a = abs(a) b = abs(b) [a, b] = sort([a, b]) def code(a, b): return (b * a) * (b * -a)
a = abs(a) b = abs(b) a, b = sort([a, b]) function code(a, b) return Float64(Float64(b * a) * Float64(b * Float64(-a))) end
a = abs(a)
b = abs(b)
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (b * a) * (b * -a);
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[(b * a), $MachinePrecision] * N[(b * (-a)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
b = |b|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\left(b \cdot a\right) \cdot \left(b \cdot \left(-a\right)\right)
\end{array}
Initial program 84.1%
Taylor expanded in a around 0 78.5%
unpow278.5%
unpow278.5%
swap-sqr99.7%
unpow299.7%
Simplified99.7%
unpow299.7%
Applied egg-rr99.7%
Final simplification99.7%
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(a * Float64(a * Float64(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[(a * N[(a * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
b = |b|\\
[a, b] = \mathsf{sort}([a, b])\\
\\
a \cdot \left(a \cdot \left(b \cdot b\right)\right)
\end{array}
Initial program 84.1%
distribute-rgt-neg-in84.1%
associate-*l*95.4%
associate-*l*93.5%
Simplified93.5%
expm1-log1p-u73.8%
expm1-udef59.7%
log1p-udef59.7%
add-exp-log79.3%
add-sqr-sqrt39.9%
sqrt-unprod57.6%
sqr-neg57.6%
sqrt-unprod18.4%
add-sqr-sqrt34.5%
associate-*l*34.5%
Applied egg-rr34.5%
+-commutative34.5%
associate--l+34.3%
metadata-eval34.3%
+-rgt-identity34.3%
Simplified34.3%
Final simplification34.3%
herbie shell --seed 2023238
(FPCore (a b)
:name "ab-angle->ABCF D"
:precision binary64
(- (* (* (* a a) b) b)))