| Alternative 1 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 7488 |
\[-1 + \left(1 + \cos^{-1} \left(\frac{-1 + v \cdot \left(v \cdot 5\right)}{1 - v \cdot v}\right)\right)
\]
(FPCore (v) :precision binary64 (acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))
(FPCore (v) :precision binary64 (+ -1.0 (pow (sqrt (+ 1.0 (acos (/ (fma v (* v -5.0) 1.0) (fma v v -1.0))))) 2.0)))
double code(double v) {
return acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
double code(double v) {
return -1.0 + pow(sqrt((1.0 + acos((fma(v, (v * -5.0), 1.0) / fma(v, v, -1.0))))), 2.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 + (sqrt(Float64(1.0 + acos(Float64(fma(v, Float64(v * -5.0), 1.0) / fma(v, v, -1.0))))) ^ 2.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[Power[N[Sqrt[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], 2.0], $MachinePrecision]), $MachinePrecision]
\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)
-1 + {\left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left(v, v \cdot -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)}^{2}
Initial program 99.2%
Applied egg-rr99.2%
[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)}
\] |
expm1-udef [=>]99.2 | \[ \color{blue}{e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right)} - 1}
\] |
cancel-sign-sub-inv [=>]99.2 | \[ e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{\color{blue}{1 + \left(-5\right) \cdot \left(v \cdot v\right)}}{v \cdot v - 1}\right)\right)} - 1
\] |
*-commutative [=>]99.2 | \[ e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{1 + \color{blue}{\left(v \cdot v\right) \cdot \left(-5\right)}}{v \cdot v - 1}\right)\right)} - 1
\] |
metadata-eval [=>]99.2 | \[ e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot \color{blue}{-5}}{v \cdot v - 1}\right)\right)} - 1
\] |
fma-neg [=>]99.2 | \[ e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\mathsf{fma}\left(v, v, -1\right)}}\right)\right)} - 1
\] |
metadata-eval [=>]99.2 | \[ e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{\mathsf{fma}\left(v, v, \color{blue}{-1}\right)}\right)\right)} - 1
\] |
Applied egg-rr99.2%
[Start]99.2 | \[ e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)} - 1
\] |
|---|---|
add-sqr-sqrt [=>]99.2 | \[ \color{blue}{\sqrt{e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)}} \cdot \sqrt{e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)}}} - 1
\] |
pow2 [=>]99.2 | \[ \color{blue}{{\left(\sqrt{e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)}}\right)}^{2}} - 1
\] |
log1p-udef [=>]99.2 | \[ {\left(\sqrt{e^{\color{blue}{\log \left(1 + \cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)}}}\right)}^{2} - 1
\] |
add-exp-log [<=]99.2 | \[ {\left(\sqrt{\color{blue}{1 + \cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{\mathsf{fma}\left(v, v, -1\right)}\right)}}\right)}^{2} - 1
\] |
+-commutative [=>]99.2 | \[ {\left(\sqrt{1 + \cos^{-1} \left(\frac{\color{blue}{\left(v \cdot v\right) \cdot -5 + 1}}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)}^{2} - 1
\] |
associate-*l* [=>]99.2 | \[ {\left(\sqrt{1 + \cos^{-1} \left(\frac{\color{blue}{v \cdot \left(v \cdot -5\right)} + 1}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)}^{2} - 1
\] |
fma-def [=>]99.2 | \[ {\left(\sqrt{1 + \cos^{-1} \left(\frac{\color{blue}{\mathsf{fma}\left(v, v \cdot -5, 1\right)}}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)}^{2} - 1
\] |
Final simplification99.2%
| Alternative 1 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 7488 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 7232 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.1% |
| Cost | 6464 |
herbie shell --seed 2023131
(FPCore (v)
:name "Falkner and Boettcher, Appendix B, 1"
:precision binary64
(acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))