Falkner and Boettcher, Appendix B, 1

Percentage Accurate: 99.1% → 99.1%
Time: 16.6s
Alternatives: 9
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 9 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.1% 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} \\ \mathsf{expm1}\left(2 \cdot \log \left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)\right) \end{array} \]
(FPCore (v)
 :precision binary64
 (expm1
  (*
   2.0
   (log (sqrt (+ 1.0 (acos (/ (fma (* v v) -5.0 1.0) (fma v v -1.0)))))))))
double code(double v) {
	return expm1((2.0 * log(sqrt((1.0 + acos((fma((v * v), -5.0, 1.0) / fma(v, v, -1.0))))))));
}
function code(v)
	return expm1(Float64(2.0 * log(sqrt(Float64(1.0 + acos(Float64(fma(Float64(v * v), -5.0, 1.0) / fma(v, v, -1.0))))))))
end
code[v_] := N[(Exp[N[(2.0 * N[Log[N[Sqrt[N[(1.0 + N[ArcCos[N[(N[(N[(v * v), $MachinePrecision] * -5.0 + 1.0), $MachinePrecision] / N[(v * v + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{expm1}\left(2 \cdot \log \left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)\right)
\end{array}
Derivation
  1. Initial program 99.0%

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\color{blue}{\left(\left(-v\right) \cdot \left(-v\right)\right) \cdot \left(-5\right)} + 1}{v \cdot v - 1}\right) \]
    6. fma-define99.0%

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, \color{blue}{-1}\right)}\right) \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. metadata-eval99.0%

      \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, \color{blue}{-1}\right)}\right) \]
    2. fmm-def99.0%

      \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\color{blue}{v \cdot v - 1}}\right) \]
    3. fma-undefine99.0%

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\color{blue}{1 - 5 \cdot \left(v \cdot v\right)}}{v \cdot v - 1}\right) \]
    9. expm1-log1p-u99.0%

      \[\leadsto \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)} \]
    10. expm1-undefine99.0%

      \[\leadsto \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} \]
  6. Applied egg-rr99.0%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)} - 1} \]
  7. Step-by-step derivation
    1. expm1-define99.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right)} \]
  8. Simplified99.0%

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right)} \]
  9. Step-by-step derivation
    1. add-sqr-sqrt99.0%

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

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

    \[\leadsto \mathsf{expm1}\left(\color{blue}{{\left(\sqrt{\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)}\right)}^{2}}\right) \]
  11. Step-by-step derivation
    1. unpow299.0%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\sqrt{\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)} \cdot \sqrt{\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)}}\right) \]
    2. add-sqr-sqrt99.0%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)}\right) \]
    3. log1p-undefine99.0%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(1 + \cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)}\right) \]
    4. add-sqr-sqrt99.0%

      \[\leadsto \mathsf{expm1}\left(\log \color{blue}{\left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \cdot \sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)}\right) \]
    5. log-prod99.0%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right) + \log \left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)}\right) \]
  12. Applied egg-rr99.0%

    \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right) + \log \left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)}\right) \]
  13. Step-by-step derivation
    1. count-299.0%

      \[\leadsto \mathsf{expm1}\left(\color{blue}{2 \cdot \log \left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)}\right) \]
  14. Simplified99.0%

    \[\leadsto \mathsf{expm1}\left(\color{blue}{2 \cdot \log \left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)}\right) \]
  15. Step-by-step derivation
    1. unpow299.0%

      \[\leadsto \mathsf{expm1}\left(2 \cdot \log \left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left(\color{blue}{v \cdot v}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)\right) \]
  16. Applied egg-rr99.0%

    \[\leadsto \mathsf{expm1}\left(2 \cdot \log \left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left(\color{blue}{v \cdot v}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)\right) \]
  17. Add Preprocessing

Alternative 2: 99.1% accurate, 0.3× speedup?

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

\\
\pi \cdot 0.5 - \mathsf{log1p}\left(\mathsf{expm1}\left(\sin^{-1} \left(\frac{1 - \left(v \cdot v\right) \cdot 5}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right)
\end{array}
Derivation
  1. Initial program 99.0%

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\color{blue}{\left(\left(-v\right) \cdot \left(-v\right)\right) \cdot \left(-5\right)} + 1}{v \cdot v - 1}\right) \]
    6. fma-define99.0%

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, \color{blue}{-1}\right)}\right) \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. acos-asin99.0%

      \[\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)} \]
    2. sub-neg99.0%

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

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

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

      \[\leadsto \frac{\pi}{2} + \left(-\sin^{-1} \left(\frac{\color{blue}{\left(v \cdot v\right) \cdot -5 + 1}}{v \cdot v - 1}\right)\right) \]
    6. metadata-eval99.0%

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

      \[\leadsto \frac{\pi}{2} + \left(-\sin^{-1} \left(\frac{\color{blue}{\left(-\left(v \cdot v\right) \cdot 5\right)} + 1}{v \cdot v - 1}\right)\right) \]
    8. *-commutative99.0%

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

      \[\leadsto \frac{\pi}{2} + \left(-\sin^{-1} \left(\frac{\color{blue}{1 + \left(-5 \cdot \left(v \cdot v\right)\right)}}{v \cdot v - 1}\right)\right) \]
    10. sub-neg99.0%

      \[\leadsto \frac{\pi}{2} + \left(-\sin^{-1} \left(\frac{\color{blue}{1 - 5 \cdot \left(v \cdot v\right)}}{v \cdot v - 1}\right)\right) \]
    11. div-inv99.0%

      \[\leadsto \color{blue}{\pi \cdot \frac{1}{2}} + \left(-\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right) \]
    12. metadata-eval99.0%

      \[\leadsto \pi \cdot \color{blue}{0.5} + \left(-\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right) \]
  6. Applied egg-rr99.0%

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

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

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

      \[\leadsto \pi \cdot 0.5 - \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sin^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right)} \]
  10. Applied egg-rr99.0%

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

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

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

      \[\leadsto \pi \cdot 0.5 - \mathsf{log1p}\left(\mathsf{expm1}\left(\sin^{-1} \left(\frac{\left(v \cdot v\right) \cdot \color{blue}{\left(-5\right)} + 1}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right) \]
    4. distribute-rgt-neg-in99.0%

      \[\leadsto \pi \cdot 0.5 - \mathsf{log1p}\left(\mathsf{expm1}\left(\sin^{-1} \left(\frac{\color{blue}{\left(-\left(v \cdot v\right) \cdot 5\right)} + 1}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right) \]
    5. *-commutative99.0%

      \[\leadsto \pi \cdot 0.5 - \mathsf{log1p}\left(\mathsf{expm1}\left(\sin^{-1} \left(\frac{\left(-\color{blue}{5 \cdot \left(v \cdot v\right)}\right) + 1}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right) \]
    6. +-commutative99.0%

      \[\leadsto \pi \cdot 0.5 - \mathsf{log1p}\left(\mathsf{expm1}\left(\sin^{-1} \left(\frac{\color{blue}{1 + \left(-5 \cdot \left(v \cdot v\right)\right)}}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right) \]
    7. sub-neg99.0%

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

      \[\leadsto \pi \cdot 0.5 - \mathsf{log1p}\left(\mathsf{expm1}\left(\sin^{-1} \left(\frac{1 - 5 \cdot \color{blue}{{v}^{2}}}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right) \]
  12. Applied egg-rr99.0%

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

      \[\leadsto \mathsf{expm1}\left(2 \cdot \log \left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left(\color{blue}{v \cdot v}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)\right) \]
  14. Applied egg-rr99.0%

    \[\leadsto \pi \cdot 0.5 - \mathsf{log1p}\left(\mathsf{expm1}\left(\sin^{-1} \left(\frac{1 - 5 \cdot \color{blue}{\left(v \cdot v\right)}}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right) \]
  15. Final simplification99.0%

    \[\leadsto \pi \cdot 0.5 - \mathsf{log1p}\left(\mathsf{expm1}\left(\sin^{-1} \left(\frac{1 - \left(v \cdot v\right) \cdot 5}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)\right) \]
  16. Add Preprocessing

Alternative 3: 99.1% accurate, 0.3× speedup?

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

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

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\color{blue}{\left(\left(-v\right) \cdot \left(-v\right)\right) \cdot \left(-5\right)} + 1}{v \cdot v - 1}\right) \]
    6. fma-define99.0%

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, \color{blue}{-1}\right)}\right) \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. acos-asin99.0%

      \[\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)} \]
    2. sub-neg99.0%

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

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

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

      \[\leadsto \frac{\pi}{2} + \left(-\sin^{-1} \left(\frac{\color{blue}{\left(v \cdot v\right) \cdot -5 + 1}}{v \cdot v - 1}\right)\right) \]
    6. metadata-eval99.0%

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

      \[\leadsto \frac{\pi}{2} + \left(-\sin^{-1} \left(\frac{\color{blue}{\left(-\left(v \cdot v\right) \cdot 5\right)} + 1}{v \cdot v - 1}\right)\right) \]
    8. *-commutative99.0%

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

      \[\leadsto \frac{\pi}{2} + \left(-\sin^{-1} \left(\frac{\color{blue}{1 + \left(-5 \cdot \left(v \cdot v\right)\right)}}{v \cdot v - 1}\right)\right) \]
    10. sub-neg99.0%

      \[\leadsto \frac{\pi}{2} + \left(-\sin^{-1} \left(\frac{\color{blue}{1 - 5 \cdot \left(v \cdot v\right)}}{v \cdot v - 1}\right)\right) \]
    11. div-inv99.0%

      \[\leadsto \color{blue}{\pi \cdot \frac{1}{2}} + \left(-\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right) \]
    12. metadata-eval99.0%

      \[\leadsto \pi \cdot \color{blue}{0.5} + \left(-\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right) \]
  6. Applied egg-rr99.0%

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

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

    \[\leadsto \color{blue}{\pi \cdot 0.5 - \sin^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \]
  9. Add Preprocessing

Alternative 4: 99.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \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
 (acos (/ (fma (* v v) -5.0 1.0) (fma 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(fma(Float64(v * v), -5.0, 1.0) / fma(v, v, -1.0)))
end
code[v_] := N[ArcCos[N[(N[(N[(v * v), $MachinePrecision] * -5.0 + 1.0), $MachinePrecision] / N[(v * v + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\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.0%

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\color{blue}{\left(\left(-v\right) \cdot \left(-v\right)\right) \cdot \left(-5\right)} + 1}{v \cdot v - 1}\right) \]
    6. fma-define99.0%

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, \color{blue}{-1}\right)}\right) \]
  3. Simplified99.0%

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

Alternative 5: 99.1% 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.0%

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

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

Alternative 6: 98.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \pi \cdot 0.5 - \sin^{-1} \left(-1 + \left(v \cdot v\right) \cdot 4\right) \end{array} \]
(FPCore (v) :precision binary64 (- (* PI 0.5) (asin (+ -1.0 (* (* v v) 4.0)))))
double code(double v) {
	return (((double) M_PI) * 0.5) - asin((-1.0 + ((v * v) * 4.0)));
}
public static double code(double v) {
	return (Math.PI * 0.5) - Math.asin((-1.0 + ((v * v) * 4.0)));
}
def code(v):
	return (math.pi * 0.5) - math.asin((-1.0 + ((v * v) * 4.0)))
function code(v)
	return Float64(Float64(pi * 0.5) - asin(Float64(-1.0 + Float64(Float64(v * v) * 4.0))))
end
function tmp = code(v)
	tmp = (pi * 0.5) - asin((-1.0 + ((v * v) * 4.0)));
end
code[v_] := N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(-1.0 + N[(N[(v * v), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\pi \cdot 0.5 - \sin^{-1} \left(-1 + \left(v \cdot v\right) \cdot 4\right)
\end{array}
Derivation
  1. Initial program 99.0%

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\color{blue}{\left(\left(-v\right) \cdot \left(-v\right)\right) \cdot \left(-5\right)} + 1}{v \cdot v - 1}\right) \]
    6. fma-define99.0%

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, \color{blue}{-1}\right)}\right) \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. acos-asin99.0%

      \[\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)} \]
    2. sub-neg99.0%

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

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

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

      \[\leadsto \frac{\pi}{2} + \left(-\sin^{-1} \left(\frac{\color{blue}{\left(v \cdot v\right) \cdot -5 + 1}}{v \cdot v - 1}\right)\right) \]
    6. metadata-eval99.0%

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

      \[\leadsto \frac{\pi}{2} + \left(-\sin^{-1} \left(\frac{\color{blue}{\left(-\left(v \cdot v\right) \cdot 5\right)} + 1}{v \cdot v - 1}\right)\right) \]
    8. *-commutative99.0%

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

      \[\leadsto \frac{\pi}{2} + \left(-\sin^{-1} \left(\frac{\color{blue}{1 + \left(-5 \cdot \left(v \cdot v\right)\right)}}{v \cdot v - 1}\right)\right) \]
    10. sub-neg99.0%

      \[\leadsto \frac{\pi}{2} + \left(-\sin^{-1} \left(\frac{\color{blue}{1 - 5 \cdot \left(v \cdot v\right)}}{v \cdot v - 1}\right)\right) \]
    11. div-inv99.0%

      \[\leadsto \color{blue}{\pi \cdot \frac{1}{2}} + \left(-\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right) \]
    12. metadata-eval99.0%

      \[\leadsto \pi \cdot \color{blue}{0.5} + \left(-\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right) \]
  6. Applied egg-rr99.0%

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

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

    \[\leadsto \color{blue}{\pi \cdot 0.5 - \sin^{-1} \left(\frac{\mathsf{fma}\left({v}^{2}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \]
  9. Taylor expanded in v around 0 97.9%

    \[\leadsto \pi \cdot 0.5 - \sin^{-1} \color{blue}{\left(4 \cdot {v}^{2} - 1\right)} \]
  10. Step-by-step derivation
    1. unpow299.0%

      \[\leadsto \mathsf{expm1}\left(2 \cdot \log \left(\sqrt{1 + \cos^{-1} \left(\frac{\mathsf{fma}\left(\color{blue}{v \cdot v}, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)}\right)\right) \]
  11. Applied egg-rr97.9%

    \[\leadsto \pi \cdot 0.5 - \sin^{-1} \left(4 \cdot \color{blue}{\left(v \cdot v\right)} - 1\right) \]
  12. Final simplification97.9%

    \[\leadsto \pi \cdot 0.5 - \sin^{-1} \left(-1 + \left(v \cdot v\right) \cdot 4\right) \]
  13. Add Preprocessing

Alternative 7: 98.2% accurate, 1.0× speedup?

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

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

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in v around 0 97.3%

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

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

Alternative 8: 98.0% accurate, 1.1× speedup?

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

\\
\cos^{-1} -1
\end{array}
Derivation
  1. Initial program 99.0%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in v around 0 97.3%

    \[\leadsto \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\color{blue}{-1}}\right) \]
  4. Taylor expanded in v around 0 97.1%

    \[\leadsto \cos^{-1} \color{blue}{-1} \]
  5. Add Preprocessing

Alternative 9: 0.0% accurate, 1.1× speedup?

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

\\
\cos^{-1} -5
\end{array}
Derivation
  1. Initial program 99.0%

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\color{blue}{\left(\left(-v\right) \cdot \left(-v\right)\right) \cdot \left(-5\right)} + 1}{v \cdot v - 1}\right) \]
    6. fma-define99.0%

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, \color{blue}{-1}\right)}\right) \]
  3. Simplified99.0%

    \[\leadsto \color{blue}{\cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in v around inf 0.0%

    \[\leadsto \cos^{-1} \color{blue}{-5} \]
  6. Add Preprocessing

Reproduce

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