Falkner and Boettcher, Appendix B, 1

Percentage Accurate: 99.1% → 99.0%
Time: 12.1s
Alternatives: 8
Speedup: N/A×

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 8 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.0% accurate, 1.0× speedup?

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

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

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)} \]
    2. frac-2negN/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    3. div-invN/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\left(\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    4. lower-*.f64N/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\left(\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    5. lift--.f64N/A

      \[\leadsto \cos^{-1} \left(\left(\mathsf{neg}\left(\color{blue}{\left(1 - 5 \cdot \left(v \cdot v\right)\right)}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    6. sub-negN/A

      \[\leadsto \cos^{-1} \left(\left(\mathsf{neg}\left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(5 \cdot \left(v \cdot v\right)\right)\right)\right)}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    7. +-commutativeN/A

      \[\leadsto \cos^{-1} \left(\left(\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(5 \cdot \left(v \cdot v\right)\right)\right) + 1\right)}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    8. distribute-neg-inN/A

      \[\leadsto \cos^{-1} \left(\color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(5 \cdot \left(v \cdot v\right)\right)\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    9. remove-double-negN/A

      \[\leadsto \cos^{-1} \left(\left(\color{blue}{5 \cdot \left(v \cdot v\right)} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    10. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\left(\color{blue}{5 \cdot \left(v \cdot v\right)} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    11. *-commutativeN/A

      \[\leadsto \cos^{-1} \left(\left(\color{blue}{\left(v \cdot v\right) \cdot 5} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    12. lower-fma.f64N/A

      \[\leadsto \cos^{-1} \left(\color{blue}{\mathsf{fma}\left(v \cdot v, 5, \mathsf{neg}\left(1\right)\right)} \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    13. metadata-evalN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, \color{blue}{-1}\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    14. frac-2negN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)\right)\right)}}\right) \]
    15. remove-double-negN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{\mathsf{neg}\left(1\right)}{\color{blue}{v \cdot v - 1}}\right) \]
    16. lower-/.f64N/A

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

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{\color{blue}{-1}}{v \cdot v - 1}\right) \]
    18. lift--.f64N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{-1}{\color{blue}{v \cdot v - 1}}\right) \]
    19. sub-negN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{-1}{\color{blue}{v \cdot v + \left(\mathsf{neg}\left(1\right)\right)}}\right) \]
    20. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{-1}{\color{blue}{v \cdot v} + \left(\mathsf{neg}\left(1\right)\right)}\right) \]
    21. lower-fma.f64N/A

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

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

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

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

Alternative 2: 99.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{PI}\left(\right) - \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)))))
\begin{array}{l}

\\
\mathsf{PI}\left(\right) - \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.3%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-acos.f64N/A

      \[\leadsto \color{blue}{\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)} \]
    2. lift-/.f64N/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)} \]
    3. frac-2negN/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    4. distribute-frac-negN/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{neg}\left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)\right)} \]
    5. acos-negN/A

      \[\leadsto \color{blue}{\mathsf{PI}\left(\right) - \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    6. lower--.f64N/A

      \[\leadsto \color{blue}{\mathsf{PI}\left(\right) - \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    7. lower-PI.f64N/A

      \[\leadsto \color{blue}{\mathsf{PI}\left(\right)} - \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    8. lower-acos.f64N/A

      \[\leadsto \mathsf{PI}\left(\right) - \color{blue}{\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    9. distribute-frac-neg2N/A

      \[\leadsto \mathsf{PI}\left(\right) - \cos^{-1} \color{blue}{\left(\mathsf{neg}\left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right)} \]
    10. distribute-frac-negN/A

      \[\leadsto \mathsf{PI}\left(\right) - \cos^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)}{v \cdot v - 1}\right)} \]
    11. lower-/.f64N/A

      \[\leadsto \mathsf{PI}\left(\right) - \cos^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)}{v \cdot v - 1}\right)} \]
  4. Applied rewrites99.3%

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

Alternative 3: 99.1% accurate, 1.0× speedup?

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

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

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \cos^{-1} \left(\frac{\color{blue}{1 - 5 \cdot \left(v \cdot v\right)}}{v \cdot v - 1}\right) \]
    2. sub-negN/A

      \[\leadsto \cos^{-1} \left(\frac{\color{blue}{1 + \left(\mathsf{neg}\left(5 \cdot \left(v \cdot v\right)\right)\right)}}{v \cdot v - 1}\right) \]
    3. +-commutativeN/A

      \[\leadsto \cos^{-1} \left(\frac{\color{blue}{\left(\mathsf{neg}\left(5 \cdot \left(v \cdot v\right)\right)\right) + 1}}{v \cdot v - 1}\right) \]
    4. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\frac{\left(\mathsf{neg}\left(\color{blue}{5 \cdot \left(v \cdot v\right)}\right)\right) + 1}{v \cdot v - 1}\right) \]
    5. distribute-lft-neg-inN/A

      \[\leadsto \cos^{-1} \left(\frac{\color{blue}{\left(\mathsf{neg}\left(5\right)\right) \cdot \left(v \cdot v\right)} + 1}{v \cdot v - 1}\right) \]
    6. lower-fma.f64N/A

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

      \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(\color{blue}{-5}, v \cdot v, 1\right)}{v \cdot v - 1}\right) \]
    8. lift--.f64N/A

      \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(-5, v \cdot v, 1\right)}{\color{blue}{v \cdot v - 1}}\right) \]
    9. sub-negN/A

      \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(-5, v \cdot v, 1\right)}{\color{blue}{v \cdot v + \left(\mathsf{neg}\left(1\right)\right)}}\right) \]
    10. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\frac{\mathsf{fma}\left(-5, v \cdot v, 1\right)}{\color{blue}{v \cdot v} + \left(\mathsf{neg}\left(1\right)\right)}\right) \]
    11. lower-fma.f64N/A

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

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

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

Alternative 4: 98.4% accurate, 1.1× speedup?

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

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

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)} \]
    2. frac-2negN/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    3. div-invN/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\left(\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    4. lower-*.f64N/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\left(\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    5. lift--.f64N/A

      \[\leadsto \cos^{-1} \left(\left(\mathsf{neg}\left(\color{blue}{\left(1 - 5 \cdot \left(v \cdot v\right)\right)}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    6. sub-negN/A

      \[\leadsto \cos^{-1} \left(\left(\mathsf{neg}\left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(5 \cdot \left(v \cdot v\right)\right)\right)\right)}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    7. +-commutativeN/A

      \[\leadsto \cos^{-1} \left(\left(\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(5 \cdot \left(v \cdot v\right)\right)\right) + 1\right)}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    8. distribute-neg-inN/A

      \[\leadsto \cos^{-1} \left(\color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(5 \cdot \left(v \cdot v\right)\right)\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    9. remove-double-negN/A

      \[\leadsto \cos^{-1} \left(\left(\color{blue}{5 \cdot \left(v \cdot v\right)} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    10. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\left(\color{blue}{5 \cdot \left(v \cdot v\right)} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    11. *-commutativeN/A

      \[\leadsto \cos^{-1} \left(\left(\color{blue}{\left(v \cdot v\right) \cdot 5} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    12. lower-fma.f64N/A

      \[\leadsto \cos^{-1} \left(\color{blue}{\mathsf{fma}\left(v \cdot v, 5, \mathsf{neg}\left(1\right)\right)} \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    13. metadata-evalN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, \color{blue}{-1}\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    14. frac-2negN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)\right)\right)}}\right) \]
    15. remove-double-negN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{\mathsf{neg}\left(1\right)}{\color{blue}{v \cdot v - 1}}\right) \]
    16. lower-/.f64N/A

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

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{\color{blue}{-1}}{v \cdot v - 1}\right) \]
    18. lift--.f64N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{-1}{\color{blue}{v \cdot v - 1}}\right) \]
    19. sub-negN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{-1}{\color{blue}{v \cdot v + \left(\mathsf{neg}\left(1\right)\right)}}\right) \]
    20. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{-1}{\color{blue}{v \cdot v} + \left(\mathsf{neg}\left(1\right)\right)}\right) \]
    21. lower-fma.f64N/A

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

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

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

    \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \color{blue}{\left(1 + {v}^{2}\right)}\right) \]
  6. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \color{blue}{\left({v}^{2} + 1\right)}\right) \]
    2. unpow2N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \left(\color{blue}{v \cdot v} + 1\right)\right) \]
    3. lower-fma.f6499.2

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \color{blue}{\mathsf{fma}\left(v, v, 1\right)}\right) \]
  7. Applied rewrites99.2%

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

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

Alternative 5: 98.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{PI}\left(\right), 0.5, \sin^{-1} \left(\mathsf{fma}\left(-4, v \cdot v, 1\right)\right)\right) \end{array} \]
(FPCore (v) :precision binary64 (fma (PI) 0.5 (asin (fma -4.0 (* v v) 1.0))))
\begin{array}{l}

\\
\mathsf{fma}\left(\mathsf{PI}\left(\right), 0.5, \sin^{-1} \left(\mathsf{fma}\left(-4, v \cdot v, 1\right)\right)\right)
\end{array}
Derivation
  1. Initial program 99.3%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-acos.f64N/A

      \[\leadsto \color{blue}{\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)} \]
    2. acos-asinN/A

      \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{2} - \sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)} \]
    3. sub-negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{2} + \left(\mathsf{neg}\left(\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right)\right)} \]
    4. div-invN/A

      \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}} + \left(\mathsf{neg}\left(\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right)\right) \]
    5. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{1}{2}, \mathsf{neg}\left(\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right)\right)} \]
    6. lower-PI.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{PI}\left(\right)}, \frac{1}{2}, \mathsf{neg}\left(\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right)\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \color{blue}{\frac{1}{2}}, \mathsf{neg}\left(\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right)\right) \]
    8. asin-negN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{1}{2}, \color{blue}{\sin^{-1} \left(\mathsf{neg}\left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right)}\right) \]
    9. lift-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{1}{2}, \sin^{-1} \left(\mathsf{neg}\left(\color{blue}{\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}}\right)\right)\right) \]
    10. distribute-frac-neg2N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{1}{2}, \sin^{-1} \color{blue}{\left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)}\right) \]
    11. lower-asin.f64N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{1}{2}, \color{blue}{\sin^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)}\right) \]
    12. distribute-frac-neg2N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{1}{2}, \sin^{-1} \color{blue}{\left(\mathsf{neg}\left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right)}\right) \]
    13. distribute-frac-negN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{1}{2}, \sin^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)}{v \cdot v - 1}\right)}\right) \]
    14. lower-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{1}{2}, \sin^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)}{v \cdot v - 1}\right)}\right) \]
  4. Applied rewrites99.3%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{PI}\left(\right), 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. Taylor expanded in v around 0

    \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{1}{2}, \sin^{-1} \color{blue}{\left(1 + -4 \cdot {v}^{2}\right)}\right) \]
  6. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{1}{2}, \sin^{-1} \color{blue}{\left(-4 \cdot {v}^{2} + 1\right)}\right) \]
    2. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{1}{2}, \sin^{-1} \color{blue}{\left(\mathsf{fma}\left(-4, {v}^{2}, 1\right)\right)}\right) \]
    3. unpow2N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{1}{2}, \sin^{-1} \left(\mathsf{fma}\left(-4, \color{blue}{v \cdot v}, 1\right)\right)\right) \]
    4. lower-*.f6499.2

      \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), 0.5, \sin^{-1} \left(\mathsf{fma}\left(-4, \color{blue}{v \cdot v}, 1\right)\right)\right) \]
  7. Applied rewrites99.2%

    \[\leadsto \mathsf{fma}\left(\mathsf{PI}\left(\right), 0.5, \sin^{-1} \color{blue}{\left(\mathsf{fma}\left(-4, v \cdot v, 1\right)\right)}\right) \]
  8. Add Preprocessing

Alternative 6: 98.4% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \mathsf{PI}\left(\right) - \cos^{-1} \left(\mathsf{fma}\left(-4, v \cdot v, 1\right)\right) \end{array} \]
(FPCore (v) :precision binary64 (- (PI) (acos (fma -4.0 (* v v) 1.0))))
\begin{array}{l}

\\
\mathsf{PI}\left(\right) - \cos^{-1} \left(\mathsf{fma}\left(-4, v \cdot v, 1\right)\right)
\end{array}
Derivation
  1. Initial program 99.3%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-acos.f64N/A

      \[\leadsto \color{blue}{\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)} \]
    2. lift-/.f64N/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)} \]
    3. frac-2negN/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    4. distribute-frac-negN/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{neg}\left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)\right)} \]
    5. acos-negN/A

      \[\leadsto \color{blue}{\mathsf{PI}\left(\right) - \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    6. lower--.f64N/A

      \[\leadsto \color{blue}{\mathsf{PI}\left(\right) - \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    7. lower-PI.f64N/A

      \[\leadsto \color{blue}{\mathsf{PI}\left(\right)} - \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    8. lower-acos.f64N/A

      \[\leadsto \mathsf{PI}\left(\right) - \color{blue}{\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    9. distribute-frac-neg2N/A

      \[\leadsto \mathsf{PI}\left(\right) - \cos^{-1} \color{blue}{\left(\mathsf{neg}\left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)\right)} \]
    10. distribute-frac-negN/A

      \[\leadsto \mathsf{PI}\left(\right) - \cos^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)}{v \cdot v - 1}\right)} \]
    11. lower-/.f64N/A

      \[\leadsto \mathsf{PI}\left(\right) - \cos^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)}{v \cdot v - 1}\right)} \]
  4. Applied rewrites99.3%

    \[\leadsto \color{blue}{\mathsf{PI}\left(\right) - \cos^{-1} \left(\frac{\mathsf{fma}\left(v \cdot v, 5, -1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)} \]
  5. Taylor expanded in v around 0

    \[\leadsto \mathsf{PI}\left(\right) - \cos^{-1} \color{blue}{\left(1 + -4 \cdot {v}^{2}\right)} \]
  6. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{PI}\left(\right) - \cos^{-1} \color{blue}{\left(-4 \cdot {v}^{2} + 1\right)} \]
    2. lower-fma.f64N/A

      \[\leadsto \mathsf{PI}\left(\right) - \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(-4, {v}^{2}, 1\right)\right)} \]
    3. unpow2N/A

      \[\leadsto \mathsf{PI}\left(\right) - \cos^{-1} \left(\mathsf{fma}\left(-4, \color{blue}{v \cdot v}, 1\right)\right) \]
    4. lower-*.f6499.2

      \[\leadsto \mathsf{PI}\left(\right) - \cos^{-1} \left(\mathsf{fma}\left(-4, \color{blue}{v \cdot v}, 1\right)\right) \]
  7. Applied rewrites99.2%

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

Alternative 7: 98.4% accurate, 1.2× speedup?

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

\\
\cos^{-1} \left(\mathsf{fma}\left(4, v \cdot v, -1\right)\right)
\end{array}
Derivation
  1. Initial program 99.3%

    \[\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

    \[\leadsto \cos^{-1} \color{blue}{\left(4 \cdot {v}^{2} - 1\right)} \]
  4. Step-by-step derivation
    1. sub-negN/A

      \[\leadsto \cos^{-1} \color{blue}{\left(4 \cdot {v}^{2} + \left(\mathsf{neg}\left(1\right)\right)\right)} \]
    2. metadata-evalN/A

      \[\leadsto \cos^{-1} \left(4 \cdot {v}^{2} + \color{blue}{-1}\right) \]
    3. lower-fma.f64N/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(4, {v}^{2}, -1\right)\right)} \]
    4. unpow2N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(4, \color{blue}{v \cdot v}, -1\right)\right) \]
    5. lower-*.f6499.2

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(4, \color{blue}{v \cdot v}, -1\right)\right) \]
  5. Applied rewrites99.2%

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

Alternative 8: 97.6% accurate, 1.3× 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.3%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)} \]
    2. frac-2negN/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\frac{\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    3. div-invN/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\left(\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    4. lower-*.f64N/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\left(\mathsf{neg}\left(\left(1 - 5 \cdot \left(v \cdot v\right)\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right)} \]
    5. lift--.f64N/A

      \[\leadsto \cos^{-1} \left(\left(\mathsf{neg}\left(\color{blue}{\left(1 - 5 \cdot \left(v \cdot v\right)\right)}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    6. sub-negN/A

      \[\leadsto \cos^{-1} \left(\left(\mathsf{neg}\left(\color{blue}{\left(1 + \left(\mathsf{neg}\left(5 \cdot \left(v \cdot v\right)\right)\right)\right)}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    7. +-commutativeN/A

      \[\leadsto \cos^{-1} \left(\left(\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(5 \cdot \left(v \cdot v\right)\right)\right) + 1\right)}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    8. distribute-neg-inN/A

      \[\leadsto \cos^{-1} \left(\color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(5 \cdot \left(v \cdot v\right)\right)\right)\right)\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    9. remove-double-negN/A

      \[\leadsto \cos^{-1} \left(\left(\color{blue}{5 \cdot \left(v \cdot v\right)} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    10. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\left(\color{blue}{5 \cdot \left(v \cdot v\right)} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    11. *-commutativeN/A

      \[\leadsto \cos^{-1} \left(\left(\color{blue}{\left(v \cdot v\right) \cdot 5} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    12. lower-fma.f64N/A

      \[\leadsto \cos^{-1} \left(\color{blue}{\mathsf{fma}\left(v \cdot v, 5, \mathsf{neg}\left(1\right)\right)} \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    13. metadata-evalN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, \color{blue}{-1}\right) \cdot \frac{1}{\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)}\right) \]
    14. frac-2negN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(v \cdot v - 1\right)\right)\right)\right)}}\right) \]
    15. remove-double-negN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{\mathsf{neg}\left(1\right)}{\color{blue}{v \cdot v - 1}}\right) \]
    16. lower-/.f64N/A

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

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{\color{blue}{-1}}{v \cdot v - 1}\right) \]
    18. lift--.f64N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{-1}{\color{blue}{v \cdot v - 1}}\right) \]
    19. sub-negN/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{-1}{\color{blue}{v \cdot v + \left(\mathsf{neg}\left(1\right)\right)}}\right) \]
    20. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(v \cdot v, 5, -1\right) \cdot \frac{-1}{\color{blue}{v \cdot v} + \left(\mathsf{neg}\left(1\right)\right)}\right) \]
    21. lower-fma.f64N/A

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

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

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

    \[\leadsto \cos^{-1} \color{blue}{-1} \]
  6. Step-by-step derivation
    1. Applied rewrites98.7%

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

    Reproduce

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