?

Average Accuracy: 99.2% → 99.2%
Time: 23.8s
Precision: binary64
Cost: 20032

?

\[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
\[-1 + \left(1 + \cos^{-1} \left(\frac{\mathsf{fma}\left(v, v \cdot -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right) \]
(FPCore (v)
 :precision binary64
 (acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))
(FPCore (v)
 :precision binary64
 (+ -1.0 (+ 1.0 (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 -1.0 + (1.0 + 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 Float64(-1.0 + Float64(1.0 + acos(Float64(fma(v, Float64(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[(-1.0 + N[(1.0 + N[ArcCos[N[(N[(v * N[(v * -5.0), $MachinePrecision] + 1.0), $MachinePrecision] / N[(v * v + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)
-1 + \left(1 + \cos^{-1} \left(\frac{\mathsf{fma}\left(v, v \cdot -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)

Error?

Derivation?

  1. Initial program 99.2%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Applied egg-rr99.2%

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right)} \]
    Step-by-step derivation

    [Start]99.2

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

    expm1-log1p-u [=>]99.2

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

    sub-neg [=>]99.2

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

    +-commutative [=>]99.2

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

    *-commutative [=>]99.2

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

    distribute-rgt-neg-in [=>]99.2

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

    fma-def [=>]99.2

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

    metadata-eval [=>]99.2

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

    fma-neg [=>]99.2

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

    metadata-eval [=>]99.2

    \[ \mathsf{expm1}\left(\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, \color{blue}{-1}\right)}\right)\right)\right) \]
  3. Applied egg-rr95.0%

    \[\leadsto \mathsf{expm1}\left(\color{blue}{{\left(\sqrt[3]{\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left(v, v \cdot -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)}\right)}^{3}}\right) \]
    Step-by-step derivation

    [Start]99.2

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

    add-cube-cbrt [=>]95.0

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

    pow3 [=>]95.0

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

    fma-udef [=>]95.0

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

    associate-*l* [=>]95.0

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

    fma-def [=>]95.0

    \[ \mathsf{expm1}\left({\left(\sqrt[3]{\mathsf{log1p}\left(\cos^{-1} \left(\frac{\color{blue}{\mathsf{fma}\left(v, v \cdot -5, 1\right)}}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)}\right)}^{3}\right) \]
  4. Applied egg-rr96.8%

    \[\leadsto \mathsf{expm1}\left({\color{blue}{\left({\left({\left(\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left(v, v \cdot -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right)}^{0.16666666666666666}\right)}^{2}\right)}}^{3}\right) \]
    Step-by-step derivation

    [Start]95.0

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

    add-sqr-sqrt [=>]96.8

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

    pow2 [=>]96.8

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

    pow1/3 [=>]96.8

    \[ \mathsf{expm1}\left({\left({\left(\sqrt{\color{blue}{{\left(\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left(v, v \cdot -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right)}^{0.3333333333333333}}}\right)}^{2}\right)}^{3}\right) \]

    sqrt-pow1 [=>]96.8

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

    metadata-eval [=>]96.8

    \[ \mathsf{expm1}\left({\left({\left({\left(\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left(v, v \cdot -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right)}^{\color{blue}{0.16666666666666666}}\right)}^{2}\right)}^{3}\right) \]
  5. Applied egg-rr99.2%

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

    [Start]96.8

    \[ \mathsf{expm1}\left({\left({\left({\left(\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left(v, v \cdot -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right)}^{0.16666666666666666}\right)}^{2}\right)}^{3}\right) \]

    pow-pow [=>]96.8

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

    metadata-eval [=>]96.8

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

    pow1/3 [<=]95.0

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

    rem-cube-cbrt [=>]99.2

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

    expm1-udef [=>]99.2

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

    log1p-udef [=>]99.2

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

    add-exp-log [<=]99.2

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

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

Alternatives

Alternative 1
Accuracy99.2%
Cost7232
\[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{-1 + v \cdot v}\right) \]
Alternative 2
Accuracy97.9%
Cost6464
\[\cos^{-1} -1 \]

Error

Reproduce?

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