
(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 3 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 (FPCore (a b) :precision binary64 (* (pow (* a b) 1.25) (- (pow (* a b) 0.75))))
a = abs(a);
b = abs(b);
double code(double a, double b) {
return pow((a * b), 1.25) * -pow((a * b), 0.75);
}
NOTE: a should be positive before calling this function
NOTE: b should be positive before calling this function
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((a * b) ** 1.25d0) * -((a * b) ** 0.75d0)
end function
a = Math.abs(a);
b = Math.abs(b);
public static double code(double a, double b) {
return Math.pow((a * b), 1.25) * -Math.pow((a * b), 0.75);
}
a = abs(a) b = abs(b) def code(a, b): return math.pow((a * b), 1.25) * -math.pow((a * b), 0.75)
a = abs(a) b = abs(b) function code(a, b) return Float64((Float64(a * b) ^ 1.25) * Float64(-(Float64(a * b) ^ 0.75))) end
a = abs(a) b = abs(b) function tmp = code(a, b) tmp = ((a * b) ^ 1.25) * -((a * b) ^ 0.75); end
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function code[a_, b_] := N[(N[Power[N[(a * b), $MachinePrecision], 1.25], $MachinePrecision] * (-N[Power[N[(a * b), $MachinePrecision], 0.75], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
a = |a|\\
b = |b|\\
\\
{\left(a \cdot b\right)}^{1.25} \cdot \left(-{\left(a \cdot b\right)}^{0.75}\right)
\end{array}
Initial program 79.2%
associate-*l*74.5%
Simplified74.5%
add-cbrt-cube63.2%
pow363.2%
add-sqr-sqrt63.1%
pow263.1%
metadata-eval63.1%
pow-pow63.2%
unswap-sqr74.6%
sqrt-prod44.1%
add-sqr-sqrt74.6%
metadata-eval74.6%
metadata-eval74.6%
Applied egg-rr74.6%
pow1/373.5%
pow-pow99.7%
metadata-eval99.7%
metadata-eval99.7%
pow-pow59.6%
pow1/398.6%
Applied egg-rr98.6%
pow1/359.6%
pow-pow99.7%
metadata-eval99.7%
metadata-eval99.7%
pow-prod-up61.6%
pow1/255.3%
add-sqr-sqrt55.3%
associate-*l*55.3%
sqrt-pow155.3%
metadata-eval55.3%
sqrt-pow155.3%
pow1/261.5%
pow-prod-up61.6%
metadata-eval61.6%
metadata-eval61.6%
Applied egg-rr61.6%
*-commutative61.6%
Simplified61.6%
Final simplification61.6%
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function (FPCore (a b) :precision binary64 (* (* b b) (* a (- a))))
a = abs(a);
b = abs(b);
double code(double a, double b) {
return (b * b) * (a * -a);
}
NOTE: a should be positive before calling this function
NOTE: b should be positive before calling this function
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (b * b) * (a * -a)
end function
a = Math.abs(a);
b = Math.abs(b);
public static double code(double a, double b) {
return (b * b) * (a * -a);
}
a = abs(a) b = abs(b) def code(a, b): return (b * b) * (a * -a)
a = abs(a) b = abs(b) function code(a, b) return Float64(Float64(b * b) * Float64(a * Float64(-a))) end
a = abs(a) b = abs(b) function tmp = code(a, b) tmp = (b * b) * (a * -a); end
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function code[a_, b_] := N[(N[(b * b), $MachinePrecision] * N[(a * (-a)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
b = |b|\\
\\
\left(b \cdot b\right) \cdot \left(a \cdot \left(-a\right)\right)
\end{array}
Initial program 79.2%
associate-*l*74.5%
Simplified74.5%
Final simplification74.5%
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function (FPCore (a b) :precision binary64 (* (* a b) (* a (- b))))
a = abs(a);
b = abs(b);
double code(double a, double b) {
return (a * b) * (a * -b);
}
NOTE: a should be positive before calling this function
NOTE: b should be positive before calling this function
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (a * b) * (a * -b)
end function
a = Math.abs(a);
b = Math.abs(b);
public static double code(double a, double b) {
return (a * b) * (a * -b);
}
a = abs(a) b = abs(b) def code(a, b): return (a * b) * (a * -b)
a = abs(a) b = abs(b) function code(a, b) return Float64(Float64(a * b) * Float64(a * Float64(-b))) end
a = abs(a) b = abs(b) function tmp = code(a, b) tmp = (a * b) * (a * -b); end
NOTE: a should be positive before calling this function NOTE: b should be positive before calling this function code[a_, b_] := N[(N[(a * b), $MachinePrecision] * N[(a * (-b)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a = |a|\\
b = |b|\\
\\
\left(a \cdot b\right) \cdot \left(a \cdot \left(-b\right)\right)
\end{array}
Initial program 79.2%
associate-*l*74.5%
Simplified74.5%
add-cbrt-cube63.2%
pow363.2%
add-sqr-sqrt63.1%
pow263.1%
metadata-eval63.1%
pow-pow63.2%
unswap-sqr74.6%
sqrt-prod44.1%
add-sqr-sqrt74.6%
metadata-eval74.6%
metadata-eval74.6%
Applied egg-rr74.6%
pow1/373.5%
pow-pow99.7%
metadata-eval99.7%
unpow299.7%
Applied egg-rr99.7%
Final simplification99.7%
herbie shell --seed 2023311
(FPCore (a b)
:name "ab-angle->ABCF D"
:precision binary64
(- (* (* (* a a) b) b)))