Average Error: 0.6 → 0.6
Time: 17.2s
Precision: binary64
Cost: 19776
\[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
\[\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right) \]
(FPCore (v)
 :precision binary64
 (acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))
(FPCore (v)
 :precision binary64
 (acos (/ (fma (* v v) -5.0 1.0) (fma v v -1.0))))
double code(double v) {
	return acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
double code(double v) {
	return acos((fma((v * v), -5.0, 1.0) / fma(v, v, -1.0)));
}
function code(v)
	return acos(Float64(Float64(1.0 - Float64(5.0 * Float64(v * v))) / Float64(Float64(v * v) - 1.0)))
end
function code(v)
	return acos(Float64(fma(Float64(v * v), -5.0, 1.0) / fma(v, v, -1.0)))
end
code[v_] := N[ArcCos[N[(N[(1.0 - N[(5.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(v * v), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[v_] := N[ArcCos[N[(N[(N[(v * v), $MachinePrecision] * -5.0 + 1.0), $MachinePrecision] / N[(v * v + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)
\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)

Error

Derivation

  1. Initial program 0.6

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Simplified0.6

    \[\leadsto \color{blue}{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \]
    Proof

    [Start]0.6

    \[ \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]

    difference-of-sqr-1 [=>]0.9

    \[ \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\color{blue}{\left(v + 1\right) \cdot \left(v - 1\right)}}\right) \]

    *-commutative [=>]0.9

    \[ \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\color{blue}{\left(v - 1\right) \cdot \left(v + 1\right)}}\right) \]

    cancel-sign-sub-inv [=>]0.9

    \[ \cos^{-1} \left(\frac{\color{blue}{1 + \left(-5\right) \cdot \left(v \cdot v\right)}}{\left(v - 1\right) \cdot \left(v + 1\right)}\right) \]

    +-commutative [=>]0.9

    \[ \cos^{-1} \left(\frac{\color{blue}{\left(-5\right) \cdot \left(v \cdot v\right) + 1}}{\left(v - 1\right) \cdot \left(v + 1\right)}\right) \]

    *-commutative [=>]0.9

    \[ \cos^{-1} \left(\frac{\color{blue}{\left(v \cdot v\right) \cdot \left(-5\right)} + 1}{\left(v - 1\right) \cdot \left(v + 1\right)}\right) \]

    fma-def [=>]0.9

    \[ \cos^{-1} \left(\frac{\color{blue}{\mathsf{fma}\left(v \cdot v, -5, 1\right)}}{\left(v - 1\right) \cdot \left(v + 1\right)}\right) \]

    metadata-eval [=>]0.9

    \[ \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{-5}, 1\right)}{\left(v - 1\right) \cdot \left(v + 1\right)}\right) \]

    *-commutative [<=]0.9

    \[ \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\color{blue}{\left(v + 1\right) \cdot \left(v - 1\right)}}\right) \]

    difference-of-sqr-1 [<=]0.6

    \[ \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\color{blue}{v \cdot v - 1}}\right) \]

    fma-neg [=>]0.6

    \[ \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\color{blue}{\mathsf{fma}\left(v, v, -1\right)}}\right) \]

    metadata-eval [=>]0.6

    \[ \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, \color{blue}{-1}\right)}\right) \]
  3. Final simplification0.6

    \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right) \]

Alternatives

Alternative 1
Error0.6
Cost7232
\[\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \]
Alternative 2
Error1.3
Cost6848
\[\cos^{-1} \left(-1 + \left(v \cdot v\right) \cdot 5\right) \]
Alternative 3
Error1.4
Cost6464
\[\cos^{-1} -1 \]

Error

Reproduce

herbie shell --seed 2022354 
(FPCore (v)
  :name "Falkner and Boettcher, Appendix B, 1"
  :precision binary64
  (acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))