Falkner and Boettcher, Appendix B, 1

Percentage Accurate: 99.2% → 99.1%
Time: 15.9s
Alternatives: 3
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \end{array} \]
(FPCore (v)
 :precision binary64
 (acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))
double code(double v) {
	return acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
real(8) function code(v)
    real(8), intent (in) :: v
    code = acos(((1.0d0 - (5.0d0 * (v * v))) / ((v * v) - 1.0d0)))
end function
public static double code(double v) {
	return Math.acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
def code(v):
	return math.acos(((1.0 - (5.0 * (v * v))) / ((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 tmp = code(v)
	tmp = acos(((1.0 - (5.0 * (v * v))) / ((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]
\begin{array}{l}

\\
\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 3 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \end{array} \]
(FPCore (v)
 :precision binary64
 (acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))
double code(double v) {
	return acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
real(8) function code(v)
    real(8), intent (in) :: v
    code = acos(((1.0d0 - (5.0d0 * (v * v))) / ((v * v) - 1.0d0)))
end function
public static double code(double v) {
	return Math.acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
def code(v):
	return math.acos(((1.0 - (5.0 * (v * v))) / ((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 tmp = code(v)
	tmp = acos(((1.0 - (5.0 * (v * v))) / ((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]
\begin{array}{l}

\\
\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)
\end{array}

Alternative 1: 99.1% accurate, 0.2× speedup?

\[\begin{array}{l} \\ e^{\log \left({\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}^{0.16666666666666666}\right) \cdot 6} \end{array} \]
(FPCore (v)
 :precision binary64
 (exp
  (*
   (log
    (pow (acos (/ (fma (* v v) -5.0 1.0) (fma v v -1.0))) 0.16666666666666666))
   6.0)))
double code(double v) {
	return exp((log(pow(acos((fma((v * v), -5.0, 1.0) / fma(v, v, -1.0))), 0.16666666666666666)) * 6.0));
}
function code(v)
	return exp(Float64(log((acos(Float64(fma(Float64(v * v), -5.0, 1.0) / fma(v, v, -1.0))) ^ 0.16666666666666666)) * 6.0))
end
code[v_] := N[Exp[N[(N[Log[N[Power[N[ArcCos[N[(N[(N[(v * v), $MachinePrecision] * -5.0 + 1.0), $MachinePrecision] / N[(v * v + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.16666666666666666], $MachinePrecision]], $MachinePrecision] * 6.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
e^{\log \left({\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}^{0.16666666666666666}\right) \cdot 6}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Step-by-step derivation
    1. acos-asin99.4%

      \[\leadsto \color{blue}{\frac{\pi}{2} - \sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)} \]
    2. add-cube-cbrt97.0%

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{\pi}{2}} \cdot \sqrt[3]{\frac{\pi}{2}}\right) \cdot \sqrt[3]{\frac{\pi}{2}}} - \sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
    3. fma-neg97.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{\frac{\pi}{2}} \cdot \sqrt[3]{\frac{\pi}{2}}, \sqrt[3]{\frac{\pi}{2}}, -\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right)} \]
    4. div-inv97.0%

      \[\leadsto \mathsf{fma}\left(\sqrt[3]{\color{blue}{\pi \cdot \frac{1}{2}}} \cdot \sqrt[3]{\frac{\pi}{2}}, \sqrt[3]{\frac{\pi}{2}}, -\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right) \]
    5. metadata-eval97.0%

      \[\leadsto \mathsf{fma}\left(\sqrt[3]{\pi \cdot \color{blue}{0.5}} \cdot \sqrt[3]{\frac{\pi}{2}}, \sqrt[3]{\frac{\pi}{2}}, -\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right) \]
    6. div-inv97.0%

      \[\leadsto \mathsf{fma}\left(\sqrt[3]{\pi \cdot 0.5} \cdot \sqrt[3]{\color{blue}{\pi \cdot \frac{1}{2}}}, \sqrt[3]{\frac{\pi}{2}}, -\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right) \]
    7. metadata-eval97.0%

      \[\leadsto \mathsf{fma}\left(\sqrt[3]{\pi \cdot 0.5} \cdot \sqrt[3]{\pi \cdot \color{blue}{0.5}}, \sqrt[3]{\frac{\pi}{2}}, -\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right) \]
    8. div-inv97.0%

      \[\leadsto \mathsf{fma}\left(\sqrt[3]{\pi \cdot 0.5} \cdot \sqrt[3]{\pi \cdot 0.5}, \sqrt[3]{\color{blue}{\pi \cdot \frac{1}{2}}}, -\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right) \]
    9. metadata-eval97.0%

      \[\leadsto \mathsf{fma}\left(\sqrt[3]{\pi \cdot 0.5} \cdot \sqrt[3]{\pi \cdot 0.5}, \sqrt[3]{\pi \cdot \color{blue}{0.5}}, -\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right) \]
  3. Applied egg-rr97.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{\pi \cdot 0.5} \cdot \sqrt[3]{\pi \cdot 0.5}, \sqrt[3]{\pi \cdot 0.5}, -\sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)} \]
  4. Step-by-step derivation
    1. pow1/397.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\pi \cdot 0.5\right)}^{0.3333333333333333}} \cdot \sqrt[3]{\pi \cdot 0.5}, \sqrt[3]{\pi \cdot 0.5}, -\sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right) \]
    2. pow1/399.4%

      \[\leadsto \mathsf{fma}\left({\left(\pi \cdot 0.5\right)}^{0.3333333333333333} \cdot \color{blue}{{\left(\pi \cdot 0.5\right)}^{0.3333333333333333}}, \sqrt[3]{\pi \cdot 0.5}, -\sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right) \]
    3. pow-prod-up97.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\pi \cdot 0.5\right)}^{\left(0.3333333333333333 + 0.3333333333333333\right)}}, \sqrt[3]{\pi \cdot 0.5}, -\sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right) \]
    4. metadata-eval97.9%

      \[\leadsto \mathsf{fma}\left({\left(\pi \cdot 0.5\right)}^{\color{blue}{0.6666666666666666}}, \sqrt[3]{\pi \cdot 0.5}, -\sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right) \]
  5. Applied egg-rr97.9%

    \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\pi \cdot 0.5\right)}^{0.6666666666666666}}, \sqrt[3]{\pi \cdot 0.5}, -\sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right) \]
  6. Step-by-step derivation
    1. metadata-eval97.9%

      \[\leadsto \mathsf{fma}\left({\left(\pi \cdot 0.5\right)}^{\color{blue}{\left(2 \cdot 0.3333333333333333\right)}}, \sqrt[3]{\pi \cdot 0.5}, -\sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right) \]
    2. pow-sqr99.4%

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\pi \cdot 0.5\right)}^{0.3333333333333333} \cdot {\left(\pi \cdot 0.5\right)}^{0.3333333333333333}}, \sqrt[3]{\pi \cdot 0.5}, -\sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right) \]
    3. unpow1/397.9%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt[3]{\pi \cdot 0.5}} \cdot {\left(\pi \cdot 0.5\right)}^{0.3333333333333333}, \sqrt[3]{\pi \cdot 0.5}, -\sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right) \]
    4. unpow1/397.0%

      \[\leadsto \mathsf{fma}\left(\sqrt[3]{\pi \cdot 0.5} \cdot \color{blue}{\sqrt[3]{\pi \cdot 0.5}}, \sqrt[3]{\pi \cdot 0.5}, -\sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right) \]
    5. unpow297.0%

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\sqrt[3]{\pi \cdot 0.5}\right)}^{2}}, \sqrt[3]{\pi \cdot 0.5}, -\sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right) \]
  7. Simplified97.0%

    \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\sqrt[3]{\pi \cdot 0.5}\right)}^{2}}, \sqrt[3]{\pi \cdot 0.5}, -\sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right) \]
  8. Step-by-step derivation
    1. fma-neg97.0%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\pi \cdot 0.5}\right)}^{2} \cdot \sqrt[3]{\pi \cdot 0.5} - \sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \]
    2. unpow297.0%

      \[\leadsto \color{blue}{\left(\sqrt[3]{\pi \cdot 0.5} \cdot \sqrt[3]{\pi \cdot 0.5}\right)} \cdot \sqrt[3]{\pi \cdot 0.5} - \sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right) \]
    3. add-cube-cbrt99.4%

      \[\leadsto \color{blue}{\pi \cdot 0.5} - \sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right) \]
    4. metadata-eval99.4%

      \[\leadsto \pi \cdot \color{blue}{\frac{1}{2}} - \sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right) \]
    5. div-inv99.4%

      \[\leadsto \color{blue}{\frac{\pi}{2}} - \sin^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right) \]
    6. acos-asin99.4%

      \[\leadsto \color{blue}{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \]
    7. add-sqr-sqrt97.9%

      \[\leadsto \color{blue}{\sqrt{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \cdot \sqrt{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}} \]
    8. unpow297.9%

      \[\leadsto \color{blue}{{\left(\sqrt{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)}^{2}} \]
    9. add-cube-cbrt94.6%

      \[\leadsto {\color{blue}{\left(\left(\sqrt[3]{\sqrt{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}} \cdot \sqrt[3]{\sqrt{\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]{\sqrt{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}}\right)}}^{2} \]
    10. unpow395.2%

      \[\leadsto {\color{blue}{\left({\left(\sqrt[3]{\sqrt{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}}\right)}^{3}\right)}}^{2} \]
    11. pow-pow94.9%

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

    \[\leadsto \color{blue}{e^{\log \left({\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}^{0.16666666666666666}\right) \cdot 6}} \]
  10. Final simplification99.4%

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

Alternative 2: 99.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \pi - \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{-\mathsf{fma}\left(v, v, -1\right)}\right) \end{array} \]
(FPCore (v)
 :precision binary64
 (- PI (acos (/ (fma (* v v) -5.0 1.0) (- (fma v v -1.0))))))
double code(double v) {
	return ((double) M_PI) - acos((fma((v * v), -5.0, 1.0) / -fma(v, v, -1.0)));
}
function code(v)
	return Float64(pi - acos(Float64(fma(Float64(v * v), -5.0, 1.0) / Float64(-fma(v, v, -1.0)))))
end
code[v_] := N[(Pi - N[ArcCos[N[(N[(N[(v * v), $MachinePrecision] * -5.0 + 1.0), $MachinePrecision] / (-N[(v * v + -1.0), $MachinePrecision])), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\pi - \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{-\mathsf{fma}\left(v, v, -1\right)}\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Step-by-step derivation
    1. frac-2neg99.4%

      \[\leadsto \cos^{-1} \color{blue}{\left(\frac{-\left(1 - 5 \cdot \left(v \cdot v\right)\right)}{-\left(v \cdot v - 1\right)}\right)} \]
    2. distribute-frac-neg99.4%

      \[\leadsto \cos^{-1} \color{blue}{\left(-\frac{1 - 5 \cdot \left(v \cdot v\right)}{-\left(v \cdot v - 1\right)}\right)} \]
    3. acos-neg99.4%

      \[\leadsto \color{blue}{\pi - \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{-\left(v \cdot v - 1\right)}\right)} \]
    4. sub-neg99.4%

      \[\leadsto \pi - \cos^{-1} \left(\frac{\color{blue}{1 + \left(-5 \cdot \left(v \cdot v\right)\right)}}{-\left(v \cdot v - 1\right)}\right) \]
    5. +-commutative99.4%

      \[\leadsto \pi - \cos^{-1} \left(\frac{\color{blue}{\left(-5 \cdot \left(v \cdot v\right)\right) + 1}}{-\left(v \cdot v - 1\right)}\right) \]
    6. *-commutative99.4%

      \[\leadsto \pi - \cos^{-1} \left(\frac{\left(-\color{blue}{\left(v \cdot v\right) \cdot 5}\right) + 1}{-\left(v \cdot v - 1\right)}\right) \]
    7. distribute-rgt-neg-in99.4%

      \[\leadsto \pi - \cos^{-1} \left(\frac{\color{blue}{\left(v \cdot v\right) \cdot \left(-5\right)} + 1}{-\left(v \cdot v - 1\right)}\right) \]
    8. fma-def99.4%

      \[\leadsto \pi - \cos^{-1} \left(\frac{\color{blue}{\mathsf{fma}\left(v \cdot v, -5, 1\right)}}{-\left(v \cdot v - 1\right)}\right) \]
    9. metadata-eval99.4%

      \[\leadsto \pi - \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{-5}, 1\right)}{-\left(v \cdot v - 1\right)}\right) \]
    10. fma-neg99.4%

      \[\leadsto \pi - \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{-\color{blue}{\mathsf{fma}\left(v, v, -1\right)}}\right) \]
    11. metadata-eval99.4%

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

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

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

Alternative 3: 99.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \cos^{-1} \left(\frac{1 - \left(v \cdot v\right) \cdot 5}{v \cdot v + -1}\right) \end{array} \]
(FPCore (v)
 :precision binary64
 (acos (/ (- 1.0 (* (* v v) 5.0)) (+ (* v v) -1.0))))
double code(double v) {
	return acos(((1.0 - ((v * v) * 5.0)) / ((v * v) + -1.0)));
}
real(8) function code(v)
    real(8), intent (in) :: v
    code = acos(((1.0d0 - ((v * v) * 5.0d0)) / ((v * v) + (-1.0d0))))
end function
public static double code(double v) {
	return Math.acos(((1.0 - ((v * v) * 5.0)) / ((v * v) + -1.0)));
}
def code(v):
	return math.acos(((1.0 - ((v * v) * 5.0)) / ((v * v) + -1.0)))
function code(v)
	return acos(Float64(Float64(1.0 - Float64(Float64(v * v) * 5.0)) / Float64(Float64(v * v) + -1.0)))
end
function tmp = code(v)
	tmp = acos(((1.0 - ((v * v) * 5.0)) / ((v * v) + -1.0)));
end
code[v_] := N[ArcCos[N[(N[(1.0 - N[(N[(v * v), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] / N[(N[(v * v), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\cos^{-1} \left(\frac{1 - \left(v \cdot v\right) \cdot 5}{v \cdot v + -1}\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Final simplification99.4%

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

Reproduce

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