Falkner and Boettcher, Appendix B, 1

Percentage Accurate: 99.2% → 98.9%
Time: 9.4s
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)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(v)
use fmin_fmax_functions
    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.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)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(v)
use fmin_fmax_functions
    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: 98.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{PI}\left(\right)}{2}\\ t_1 := \mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\\ t_2 := \sin^{-1} t\_1\\ t_3 := \cos^{-1} t\_1\\ \frac{{t\_0}^{3} - {\left(\frac{{t\_0}^{2} - t\_3 \cdot t\_3}{t\_0 + t\_3}\right)}^{3}}{\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{4}, {t\_2}^{2}\right) - \frac{\mathsf{PI}\left(\right)}{-2} \cdot t\_2} \end{array} \end{array} \]
(FPCore (v)
 :precision binary64
 (let* ((t_0 (/ (PI) 2.0))
        (t_1 (fma (fma 4.0 (* v v) 4.0) (* v v) -1.0))
        (t_2 (asin t_1))
        (t_3 (acos t_1)))
   (/
    (- (pow t_0 3.0) (pow (/ (- (pow t_0 2.0) (* t_3 t_3)) (+ t_0 t_3)) 3.0))
    (- (fma (PI) (/ (PI) 4.0) (pow t_2 2.0)) (* (/ (PI) -2.0) t_2)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{2}\\
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\\
t_2 := \sin^{-1} t\_1\\
t_3 := \cos^{-1} t\_1\\
\frac{{t\_0}^{3} - {\left(\frac{{t\_0}^{2} - t\_3 \cdot t\_3}{t\_0 + t\_3}\right)}^{3}}{\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{4}, {t\_2}^{2}\right) - \frac{\mathsf{PI}\left(\right)}{-2} \cdot t\_2}
\end{array}
\end{array}
Derivation
  1. Initial program 99.2%

    \[\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({v}^{2} \cdot \left(4 + 4 \cdot {v}^{2}\right) - 1\right)} \]
  4. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto \cos^{-1} \left({v}^{2} \cdot \left(4 + 4 \cdot {v}^{2}\right) - 1 \cdot \color{blue}{1}\right) \]
    2. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), {v}^{2}, -1\right)\right) \]
    10. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), {v}^{2}, -1\right)\right) \]
    11. pow2N/A

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

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

    \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)} \]
  6. Step-by-step derivation
    1. lift-acos.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{{\left(\frac{\mathsf{PI}\left(\right)}{2}\right)}^{3} - {\left(\frac{{\left(\frac{\mathsf{PI}\left(\right)}{2}\right)}^{2} - \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right) \cdot \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)}{\frac{\mathsf{PI}\left(\right)}{2} + \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)}\right)}^{3}}{\color{blue}{\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{4}, {\sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)}^{2}\right) - \frac{\mathsf{PI}\left(\right)}{-2} \cdot \sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)}} \]
  12. Add Preprocessing

Alternative 2: 98.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{PI}\left(\right)}{2}\\ t_1 := \mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\\ t_2 := \sin^{-1} t\_1\\ t_3 := \cos^{-1} t\_1\\ \frac{{t\_0}^{3} - {\left(\frac{{t\_0}^{2} - t\_3 \cdot t\_3}{t\_0 + t\_3}\right)}^{3}}{\mathsf{fma}\left(\frac{\mathsf{PI}\left(\right)}{4}, \mathsf{PI}\left(\right), \left(t\_2 - \frac{\mathsf{PI}\left(\right)}{-2}\right) \cdot t\_2\right)} \end{array} \end{array} \]
(FPCore (v)
 :precision binary64
 (let* ((t_0 (/ (PI) 2.0))
        (t_1 (fma (fma 4.0 (* v v) 4.0) (* v v) -1.0))
        (t_2 (asin t_1))
        (t_3 (acos t_1)))
   (/
    (- (pow t_0 3.0) (pow (/ (- (pow t_0 2.0) (* t_3 t_3)) (+ t_0 t_3)) 3.0))
    (fma (/ (PI) 4.0) (PI) (* (- t_2 (/ (PI) -2.0)) t_2)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{2}\\
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\\
t_2 := \sin^{-1} t\_1\\
t_3 := \cos^{-1} t\_1\\
\frac{{t\_0}^{3} - {\left(\frac{{t\_0}^{2} - t\_3 \cdot t\_3}{t\_0 + t\_3}\right)}^{3}}{\mathsf{fma}\left(\frac{\mathsf{PI}\left(\right)}{4}, \mathsf{PI}\left(\right), \left(t\_2 - \frac{\mathsf{PI}\left(\right)}{-2}\right) \cdot t\_2\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 99.2%

    \[\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({v}^{2} \cdot \left(4 + 4 \cdot {v}^{2}\right) - 1\right)} \]
  4. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto \cos^{-1} \left({v}^{2} \cdot \left(4 + 4 \cdot {v}^{2}\right) - 1 \cdot \color{blue}{1}\right) \]
    2. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), {v}^{2}, -1\right)\right) \]
    10. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), {v}^{2}, -1\right)\right) \]
    11. pow2N/A

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

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

    \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)} \]
  6. Step-by-step derivation
    1. lift-acos.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{{\left(\frac{\mathsf{PI}\left(\right)}{2}\right)}^{3} - {\left(\frac{{\left(\frac{\mathsf{PI}\left(\right)}{2}\right)}^{2} - \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right) \cdot \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)}{\frac{\mathsf{PI}\left(\right)}{2} + \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)}\right)}^{3}}{\color{blue}{\mathsf{fma}\left(\frac{\mathsf{PI}\left(\right)}{4}, \mathsf{PI}\left(\right), \left(\sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right) - \frac{\mathsf{PI}\left(\right)}{-2}\right) \cdot \sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)\right)}} \]
  11. Add Preprocessing

Alternative 3: 98.9% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{PI}\left(\right)}{2}\\ t_1 := \sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)\\ \frac{{t\_0}^{3} - {t\_1}^{3}}{\mathsf{fma}\left(t\_0, t\_1, \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{4}, {t\_1}^{2}\right)\right)} \end{array} \end{array} \]
(FPCore (v)
 :precision binary64
 (let* ((t_0 (/ (PI) 2.0))
        (t_1 (asin (fma (fma 4.0 (* v v) 4.0) (* v v) -1.0))))
   (/
    (- (pow t_0 3.0) (pow t_1 3.0))
    (fma t_0 t_1 (fma (PI) (/ (PI) 4.0) (pow t_1 2.0))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{2}\\
t_1 := \sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)\\
\frac{{t\_0}^{3} - {t\_1}^{3}}{\mathsf{fma}\left(t\_0, t\_1, \mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{4}, {t\_1}^{2}\right)\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 99.2%

    \[\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({v}^{2} \cdot \left(4 + 4 \cdot {v}^{2}\right) - 1\right)} \]
  4. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto \cos^{-1} \left({v}^{2} \cdot \left(4 + 4 \cdot {v}^{2}\right) - 1 \cdot \color{blue}{1}\right) \]
    2. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), {v}^{2}, -1\right)\right) \]
    10. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), {v}^{2}, -1\right)\right) \]
    11. pow2N/A

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

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

    \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)} \]
  6. Step-by-step derivation
    1. lift-acos.f64N/A

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

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

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

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

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

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

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

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

Alternative 4: 98.9% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{PI}\left(\right)}{2}\\ t_1 := \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)\\ t_2 := t\_1 - \frac{\mathsf{PI}\left(\right)}{-2}\\ \left(t\_0 - \frac{{t\_0}^{2}}{t\_2}\right) + \frac{{t\_1}^{2}}{t\_2} \end{array} \end{array} \]
(FPCore (v)
 :precision binary64
 (let* ((t_0 (/ (PI) 2.0))
        (t_1 (acos (fma (fma 4.0 (* v v) 4.0) (* v v) -1.0)))
        (t_2 (- t_1 (/ (PI) -2.0))))
   (+ (- t_0 (/ (pow t_0 2.0) t_2)) (/ (pow t_1 2.0) t_2))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{2}\\
t_1 := \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)\\
t_2 := t\_1 - \frac{\mathsf{PI}\left(\right)}{-2}\\
\left(t\_0 - \frac{{t\_0}^{2}}{t\_2}\right) + \frac{{t\_1}^{2}}{t\_2}
\end{array}
\end{array}
Derivation
  1. Initial program 99.2%

    \[\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({v}^{2} \cdot \left(4 + 4 \cdot {v}^{2}\right) - 1\right)} \]
  4. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto \cos^{-1} \left({v}^{2} \cdot \left(4 + 4 \cdot {v}^{2}\right) - 1 \cdot \color{blue}{1}\right) \]
    2. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), {v}^{2}, -1\right)\right) \]
    10. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), {v}^{2}, -1\right)\right) \]
    11. pow2N/A

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

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

    \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)} \]
  6. Step-by-step derivation
    1. lift-acos.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 98.9% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)\\ \frac{\frac{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)}{--8} - {t\_0}^{3}}{\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{4}, \left(t\_0 + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot t\_0\right)} \end{array} \end{array} \]
(FPCore (v)
 :precision binary64
 (let* ((t_0 (asin (fma (fma 4.0 (* v v) 4.0) (* v v) -1.0))))
   (/
    (- (/ (* (* (PI) (PI)) (PI)) (- -8.0)) (pow t_0 3.0))
    (fma (PI) (/ (PI) 4.0) (* (+ t_0 (/ (PI) 2.0)) t_0)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)\\
\frac{\frac{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)}{--8} - {t\_0}^{3}}{\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{4}, \left(t\_0 + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot t\_0\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 99.2%

    \[\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({v}^{2} \cdot \left(4 + 4 \cdot {v}^{2}\right) - 1\right)} \]
  4. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto \cos^{-1} \left({v}^{2} \cdot \left(4 + 4 \cdot {v}^{2}\right) - 1 \cdot \color{blue}{1}\right) \]
    2. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), {v}^{2}, -1\right)\right) \]
    10. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), {v}^{2}, -1\right)\right) \]
    11. pow2N/A

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

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

    \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)} \]
  6. Step-by-step derivation
    1. lift-acos.f64N/A

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{{\left(\frac{\mathsf{PI}\left(\right)}{2}\right)}^{3} - {\sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)}^{3}}{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{\color{blue}{4}} + \mathsf{fma}\left(\sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right), \sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right), \frac{\mathsf{PI}\left(\right)}{2} \cdot \sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)\right)} \]
    8. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(-\mathsf{PI}\left(\right)\right)}{-8}} - {\sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)}^{3}}{\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{4}, \left(\sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)\right)} \]
  12. Final simplification99.2%

    \[\leadsto \frac{\frac{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)}{--8} - {\sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)}^{3}}{\mathsf{fma}\left(\mathsf{PI}\left(\right), \frac{\mathsf{PI}\left(\right)}{4}, \left(\sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot \sin^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), v \cdot v, -1\right)\right)\right)} \]
  13. Add Preprocessing

Alternative 6: 98.9% accurate, 1.1× speedup?

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

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

    \[\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({v}^{2} \cdot \left(4 + 4 \cdot {v}^{2}\right) - 1\right)} \]
  4. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto \cos^{-1} \left({v}^{2} \cdot \left(4 + 4 \cdot {v}^{2}\right) - 1 \cdot \color{blue}{1}\right) \]
    2. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), {v}^{2}, -1\right)\right) \]
    10. lift-*.f64N/A

      \[\leadsto \cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(4, v \cdot v, 4\right), {v}^{2}, -1\right)\right) \]
    11. pow2N/A

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

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

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

Alternative 7: 98.7% 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.2%

    \[\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. metadata-evalN/A

      \[\leadsto \cos^{-1} \left(4 \cdot {v}^{2} - 1 \cdot \color{blue}{1}\right) \]
    2. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

Alternative 8: 98.0% 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(v)
use fmin_fmax_functions
    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.2%

    \[\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}{-1} \]
  4. Step-by-step derivation
    1. Applied rewrites98.6%

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

    Reproduce

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