bug323 (missed optimization)

Percentage Accurate: 7.0% → 10.6%
Time: 3.8s
Alternatives: 11
Speedup: 0.7×

Specification

?
\[0 \leq x \land x \leq 0.5\]
\[\cos^{-1} \left(1 - x\right) \]
(FPCore (x)
  :precision binary64
  (acos (- 1.0 x)))
double code(double x) {
	return acos((1.0 - x));
}
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(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = acos((1.0d0 - x))
end function
public static double code(double x) {
	return Math.acos((1.0 - x));
}
def code(x):
	return math.acos((1.0 - x))
function code(x)
	return acos(Float64(1.0 - x))
end
function tmp = code(x)
	tmp = acos((1.0 - x));
end
code[x_] := N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
\cos^{-1} \left(1 - x\right)

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 11 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: 7.0% accurate, 1.0× speedup?

\[\cos^{-1} \left(1 - x\right) \]
(FPCore (x)
  :precision binary64
  (acos (- 1.0 x)))
double code(double x) {
	return acos((1.0 - x));
}
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(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = acos((1.0d0 - x))
end function
public static double code(double x) {
	return Math.acos((1.0 - x));
}
def code(x):
	return math.acos((1.0 - x))
function code(x)
	return acos(Float64(1.0 - x))
end
function tmp = code(x)
	tmp = acos((1.0 - x));
end
code[x_] := N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
\cos^{-1} \left(1 - x\right)

Alternative 1: 10.6% accurate, 0.0× speedup?

\[\begin{array}{l} t_0 := \left(\pi \cdot \pi\right) \cdot \pi\\ t_1 := \cos^{-1} \left(1 - x\right)\\ t_2 := {t\_1}^{3}\\ t_3 := t\_0 - t\_2\\ t_4 := \mathsf{fma}\left(t\_1 + \pi, t\_1, \pi \cdot \pi\right)\\ \frac{\mathsf{fma}\left(t\_3, \frac{1}{t\_4} \cdot \frac{t\_2 - t\_0}{t\_4}, \pi \cdot \pi\right)}{\pi + \frac{t\_3}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(t\_1, t\_1, \pi \cdot t\_1\right)\right)}} \end{array} \]
(FPCore (x)
  :precision binary64
  (let* ((t_0 (* (* PI PI) PI))
       (t_1 (acos (- 1.0 x)))
       (t_2 (pow t_1 3.0))
       (t_3 (- t_0 t_2))
       (t_4 (fma (+ t_1 PI) t_1 (* PI PI))))
  (/
   (fma t_3 (* (/ 1.0 t_4) (/ (- t_2 t_0) t_4)) (* PI PI))
   (+ PI (/ t_3 (fma PI PI (fma t_1 t_1 (* PI t_1))))))))
double code(double x) {
	double t_0 = (((double) M_PI) * ((double) M_PI)) * ((double) M_PI);
	double t_1 = acos((1.0 - x));
	double t_2 = pow(t_1, 3.0);
	double t_3 = t_0 - t_2;
	double t_4 = fma((t_1 + ((double) M_PI)), t_1, (((double) M_PI) * ((double) M_PI)));
	return fma(t_3, ((1.0 / t_4) * ((t_2 - t_0) / t_4)), (((double) M_PI) * ((double) M_PI))) / (((double) M_PI) + (t_3 / fma(((double) M_PI), ((double) M_PI), fma(t_1, t_1, (((double) M_PI) * t_1)))));
}
function code(x)
	t_0 = Float64(Float64(pi * pi) * pi)
	t_1 = acos(Float64(1.0 - x))
	t_2 = t_1 ^ 3.0
	t_3 = Float64(t_0 - t_2)
	t_4 = fma(Float64(t_1 + pi), t_1, Float64(pi * pi))
	return Float64(fma(t_3, Float64(Float64(1.0 / t_4) * Float64(Float64(t_2 - t_0) / t_4)), Float64(pi * pi)) / Float64(pi + Float64(t_3 / fma(pi, pi, fma(t_1, t_1, Float64(pi * t_1))))))
end
code[x_] := Block[{t$95$0 = N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision]}, Block[{t$95$1 = N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$1, 3.0], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 - t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[(t$95$1 + Pi), $MachinePrecision] * t$95$1 + N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$3 * N[(N[(1.0 / t$95$4), $MachinePrecision] * N[(N[(t$95$2 - t$95$0), $MachinePrecision] / t$95$4), $MachinePrecision]), $MachinePrecision] + N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] / N[(Pi + N[(t$95$3 / N[(Pi * Pi + N[(t$95$1 * t$95$1 + N[(Pi * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \left(\pi \cdot \pi\right) \cdot \pi\\
t_1 := \cos^{-1} \left(1 - x\right)\\
t_2 := {t\_1}^{3}\\
t_3 := t\_0 - t\_2\\
t_4 := \mathsf{fma}\left(t\_1 + \pi, t\_1, \pi \cdot \pi\right)\\
\frac{\mathsf{fma}\left(t\_3, \frac{1}{t\_4} \cdot \frac{t\_2 - t\_0}{t\_4}, \pi \cdot \pi\right)}{\pi + \frac{t\_3}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(t\_1, t\_1, \pi \cdot t\_1\right)\right)}}
\end{array}
Derivation
  1. Initial program 7.0%

    \[\cos^{-1} \left(1 - x\right) \]
  2. Step-by-step derivation
    1. lift-acos.f64N/A

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

      \[\leadsto \cos^{-1} \color{blue}{\left(1 - x\right)} \]
    3. sub-negate-revN/A

      \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{neg}\left(\left(x - 1\right)\right)\right)} \]
    4. acos-negN/A

      \[\leadsto \color{blue}{\mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right)} \]
    5. flip--N/A

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

      \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)}} \]
    7. lower-unsound-*.f32N/A

      \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)} - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
    8. lower-*.f32N/A

      \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)} - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
    9. lower-unsound--.f64N/A

      \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
    10. lower-*.f64N/A

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

      \[\leadsto \frac{\color{blue}{\pi} \cdot \mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
    12. lower-PI.f64N/A

      \[\leadsto \frac{\pi \cdot \color{blue}{\pi} - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
    13. lower-unsound-*.f64N/A

      \[\leadsto \frac{\pi \cdot \pi - \color{blue}{\cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
    14. lower-acos.f64N/A

      \[\leadsto \frac{\pi \cdot \pi - \color{blue}{\cos^{-1} \left(x - 1\right)} \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
    15. lower--.f64N/A

      \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \color{blue}{\left(x - 1\right)} \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
    16. lower-acos.f64N/A

      \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \color{blue}{\cos^{-1} \left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
    17. lower--.f64N/A

      \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \color{blue}{\left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
    18. lower-unsound-+.f64N/A

      \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\color{blue}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)}} \]
    19. lower-PI.f64N/A

      \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\color{blue}{\pi} + \cos^{-1} \left(x - 1\right)} \]
    20. lower-acos.f64N/A

      \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\pi + \color{blue}{\cos^{-1} \left(x - 1\right)}} \]
    21. lower--.f647.0%

      \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\pi + \cos^{-1} \color{blue}{\left(x - 1\right)}} \]
  3. Applied rewrites7.0%

    \[\leadsto \color{blue}{\frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\pi + \cos^{-1} \left(x - 1\right)}} \]
  4. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \frac{\color{blue}{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}}{\pi + \cos^{-1} \left(x - 1\right)} \]
    2. sub-flipN/A

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

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

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

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\cos^{-1} \left(x - 1\right)\right), \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}}{\pi + \cos^{-1} \left(x - 1\right)} \]
    7. lower-neg.f6410.6%

      \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-\cos^{-1} \left(x - 1\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
  5. Applied rewrites10.6%

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

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

      \[\leadsto \frac{\mathsf{fma}\left(-\cos^{-1} \color{blue}{\left(x - 1\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    3. sub-negate-revN/A

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

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

      \[\leadsto \frac{\mathsf{fma}\left(-\color{blue}{\left(\mathsf{PI}\left(\right) - \cos^{-1} \left(1 - x\right)\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    6. lift-PI.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\left(\color{blue}{\pi} - \cos^{-1} \left(1 - x\right)\right), \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    7. flip3--N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\color{blue}{\frac{{\pi}^{3} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    8. lower-unsound-/.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\color{blue}{\frac{{\pi}^{3} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    9. lower-unsound--.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\color{blue}{{\pi}^{3} - {\cos^{-1} \left(1 - x\right)}^{3}}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    10. lower-unsound-pow.f32N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\color{blue}{{\pi}^{3}} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    11. lower-pow.f32N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\color{blue}{{\pi}^{3}} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    12. pow3N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\color{blue}{\left(\pi \cdot \pi\right) \cdot \pi} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    13. lift-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\color{blue}{\left(\pi \cdot \pi\right)} \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    14. lift-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\color{blue}{\left(\pi \cdot \pi\right) \cdot \pi} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    15. lower-unsound-pow.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - \color{blue}{{\cos^{-1} \left(1 - x\right)}^{3}}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    16. lower-acos.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\color{blue}{\cos^{-1} \left(1 - x\right)}}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
  7. Applied rewrites10.6%

    \[\leadsto \frac{\mathsf{fma}\left(-\color{blue}{\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
  8. Step-by-step derivation
    1. lift-acos.f64N/A

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

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \cos^{-1} \color{blue}{\left(x - 1\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    3. sub-negate-revN/A

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

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \cos^{-1} \left(\mathsf{neg}\left(\color{blue}{\left(1 - x\right)}\right)\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    5. acos-negN/A

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

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \color{blue}{\pi} - \cos^{-1} \left(1 - x\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    7. flip3--N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \color{blue}{\frac{{\pi}^{3} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    8. lower-unsound-/.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \color{blue}{\frac{{\pi}^{3} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    9. lower-unsound--.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\color{blue}{{\pi}^{3} - {\cos^{-1} \left(1 - x\right)}^{3}}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    10. lower-unsound-pow.f32N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\color{blue}{{\pi}^{3}} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    11. lower-pow.f32N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\color{blue}{{\pi}^{3}} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    12. pow3N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\color{blue}{\left(\pi \cdot \pi\right) \cdot \pi} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    13. lift-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\color{blue}{\left(\pi \cdot \pi\right)} \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    14. lift-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\color{blue}{\left(\pi \cdot \pi\right) \cdot \pi} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    15. lower-unsound-pow.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - \color{blue}{{\cos^{-1} \left(1 - x\right)}^{3}}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    16. lower-acos.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\color{blue}{\cos^{-1} \left(1 - x\right)}}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
  9. Applied rewrites10.6%

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

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

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \color{blue}{\left(x - 1\right)}} \]
    3. sub-negate-revN/A

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

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(\mathsf{neg}\left(\color{blue}{\left(1 - x\right)}\right)\right)} \]
    5. acos-negN/A

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

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \left(\color{blue}{\pi} - \cos^{-1} \left(1 - x\right)\right)} \]
    7. flip3--N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \color{blue}{\frac{{\pi}^{3} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}}} \]
    8. lower-unsound-/.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \color{blue}{\frac{{\pi}^{3} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}}} \]
    9. lower-unsound--.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \frac{\color{blue}{{\pi}^{3} - {\cos^{-1} \left(1 - x\right)}^{3}}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}} \]
    10. lower-unsound-pow.f32N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \frac{\color{blue}{{\pi}^{3}} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}} \]
    11. lower-pow.f32N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \frac{\color{blue}{{\pi}^{3}} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}} \]
    12. pow3N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \frac{\color{blue}{\left(\pi \cdot \pi\right) \cdot \pi} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}} \]
    13. lift-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \frac{\color{blue}{\left(\pi \cdot \pi\right)} \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}} \]
    14. lift-*.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \frac{\color{blue}{\left(\pi \cdot \pi\right) \cdot \pi} - {\cos^{-1} \left(1 - x\right)}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}} \]
    15. lower-unsound-pow.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \frac{\left(\pi \cdot \pi\right) \cdot \pi - \color{blue}{{\cos^{-1} \left(1 - x\right)}^{3}}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}} \]
    16. lower-acos.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\color{blue}{\cos^{-1} \left(1 - x\right)}}^{3}}{\pi \cdot \pi + \left(\cos^{-1} \left(1 - x\right) \cdot \cos^{-1} \left(1 - x\right) + \pi \cdot \cos^{-1} \left(1 - x\right)\right)}} \]
  11. Applied rewrites10.6%

    \[\leadsto \frac{\mathsf{fma}\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}, \pi \cdot \pi\right)}{\pi + \color{blue}{\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}}} \]
  12. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \frac{\color{blue}{\left(-\frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}\right) \cdot \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)} + \pi \cdot \pi}}{\pi + \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}} \]
  13. Applied rewrites10.6%

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}, \frac{1}{\mathsf{fma}\left(\cos^{-1} \left(1 - x\right) + \pi, \cos^{-1} \left(1 - x\right), \pi \cdot \pi\right)} \cdot \frac{{\cos^{-1} \left(1 - x\right)}^{3} - \left(\pi \cdot \pi\right) \cdot \pi}{\mathsf{fma}\left(\cos^{-1} \left(1 - x\right) + \pi, \cos^{-1} \left(1 - x\right), \pi \cdot \pi\right)}, \pi \cdot \pi\right)}}{\pi + \frac{\left(\pi \cdot \pi\right) \cdot \pi - {\cos^{-1} \left(1 - x\right)}^{3}}{\mathsf{fma}\left(\pi, \pi, \mathsf{fma}\left(\cos^{-1} \left(1 - x\right), \cos^{-1} \left(1 - x\right), \pi \cdot \cos^{-1} \left(1 - x\right)\right)\right)}} \]
  14. Add Preprocessing

Alternative 2: 10.6% accurate, 0.2× speedup?

\[\begin{array}{l} \mathbf{if}\;\cos^{-1} \left(1 - x\right) \leq 0:\\ \;\;\;\;\frac{\mathsf{fma}\left(-\cos^{-1} -1, \cos^{-1} -1, \pi \cdot \pi\right)}{\pi + \cos^{-1} -1}\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{6}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}\right) \cdot \left(0.5 \cdot \pi\right)\\ \end{array} \]
(FPCore (x)
  :precision binary64
  (if (<= (acos (- 1.0 x)) 0.0)
  (/ (fma (- (acos -1.0)) (acos -1.0) (* PI PI)) (+ PI (acos -1.0)))
  (* (- 1.0 (/ 6.0 (* (/ PI (asin (- 1.0 x))) 3.0))) (* 0.5 PI))))
double code(double x) {
	double tmp;
	if (acos((1.0 - x)) <= 0.0) {
		tmp = fma(-acos(-1.0), acos(-1.0), (((double) M_PI) * ((double) M_PI))) / (((double) M_PI) + acos(-1.0));
	} else {
		tmp = (1.0 - (6.0 / ((((double) M_PI) / asin((1.0 - x))) * 3.0))) * (0.5 * ((double) M_PI));
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (acos(Float64(1.0 - x)) <= 0.0)
		tmp = Float64(fma(Float64(-acos(-1.0)), acos(-1.0), Float64(pi * pi)) / Float64(pi + acos(-1.0)));
	else
		tmp = Float64(Float64(1.0 - Float64(6.0 / Float64(Float64(pi / asin(Float64(1.0 - x))) * 3.0))) * Float64(0.5 * pi));
	end
	return tmp
end
code[x_] := If[LessEqual[N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision], 0.0], N[(N[((-N[ArcCos[-1.0], $MachinePrecision]) * N[ArcCos[-1.0], $MachinePrecision] + N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] / N[(Pi + N[ArcCos[-1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(6.0 / N[(N[(Pi / N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\cos^{-1} \left(1 - x\right) \leq 0:\\
\;\;\;\;\frac{\mathsf{fma}\left(-\cos^{-1} -1, \cos^{-1} -1, \pi \cdot \pi\right)}{\pi + \cos^{-1} -1}\\

\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{6}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}\right) \cdot \left(0.5 \cdot \pi\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (acos.f64 (-.f64 #s(literal 1 binary64) x)) < 0.0

    1. Initial program 7.0%

      \[\cos^{-1} \left(1 - x\right) \]
    2. Step-by-step derivation
      1. lift-acos.f64N/A

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

        \[\leadsto \cos^{-1} \color{blue}{\left(1 - x\right)} \]
      3. sub-negate-revN/A

        \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{neg}\left(\left(x - 1\right)\right)\right)} \]
      4. acos-negN/A

        \[\leadsto \color{blue}{\mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right)} \]
      5. flip--N/A

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

        \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)}} \]
      7. lower-unsound-*.f32N/A

        \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)} - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
      8. lower-*.f32N/A

        \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)} - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
      9. lower-unsound--.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
      10. lower-*.f64N/A

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

        \[\leadsto \frac{\color{blue}{\pi} \cdot \mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
      12. lower-PI.f64N/A

        \[\leadsto \frac{\pi \cdot \color{blue}{\pi} - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
      13. lower-unsound-*.f64N/A

        \[\leadsto \frac{\pi \cdot \pi - \color{blue}{\cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
      14. lower-acos.f64N/A

        \[\leadsto \frac{\pi \cdot \pi - \color{blue}{\cos^{-1} \left(x - 1\right)} \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
      15. lower--.f64N/A

        \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \color{blue}{\left(x - 1\right)} \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
      16. lower-acos.f64N/A

        \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \color{blue}{\cos^{-1} \left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
      17. lower--.f64N/A

        \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \color{blue}{\left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
      18. lower-unsound-+.f64N/A

        \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\color{blue}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)}} \]
      19. lower-PI.f64N/A

        \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\color{blue}{\pi} + \cos^{-1} \left(x - 1\right)} \]
      20. lower-acos.f64N/A

        \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\pi + \color{blue}{\cos^{-1} \left(x - 1\right)}} \]
      21. lower--.f647.0%

        \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\pi + \cos^{-1} \color{blue}{\left(x - 1\right)}} \]
    3. Applied rewrites7.0%

      \[\leadsto \color{blue}{\frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\pi + \cos^{-1} \left(x - 1\right)}} \]
    4. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}}{\pi + \cos^{-1} \left(x - 1\right)} \]
      2. sub-flipN/A

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\cos^{-1} \left(x - 1\right)\right), \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}}{\pi + \cos^{-1} \left(x - 1\right)} \]
      7. lower-neg.f6410.6%

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-\cos^{-1} \left(x - 1\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    5. Applied rewrites10.6%

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

      \[\leadsto \frac{\mathsf{fma}\left(-\cos^{-1} \color{blue}{-1}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
    7. Step-by-step derivation
      1. Applied rewrites8.2%

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

        \[\leadsto \frac{\mathsf{fma}\left(-\cos^{-1} -1, \cos^{-1} \color{blue}{-1}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
      3. Step-by-step derivation
        1. Applied rewrites7.7%

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

          \[\leadsto \frac{\mathsf{fma}\left(-\cos^{-1} -1, \cos^{-1} -1, \pi \cdot \pi\right)}{\pi + \cos^{-1} \color{blue}{-1}} \]
        3. Step-by-step derivation
          1. Applied rewrites7.7%

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

          if 0.0 < (acos.f64 (-.f64 #s(literal 1 binary64) x))

          1. Initial program 7.0%

            \[\cos^{-1} \left(1 - x\right) \]
          2. Step-by-step derivation
            1. lift-acos.f64N/A

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

              \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{2} - \sin^{-1} \left(1 - x\right)} \]
            3. sub-to-multN/A

              \[\leadsto \color{blue}{\left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{\mathsf{PI}\left(\right)}{2}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2}} \]
            4. lower-unsound-*.f64N/A

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

              \[\leadsto \color{blue}{\left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{\mathsf{PI}\left(\right)}{2}}\right)} \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            6. lower-unsound-/.f64N/A

              \[\leadsto \left(1 - \color{blue}{\frac{\sin^{-1} \left(1 - x\right)}{\frac{\mathsf{PI}\left(\right)}{2}}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            7. lower-asin.f64N/A

              \[\leadsto \left(1 - \frac{\color{blue}{\sin^{-1} \left(1 - x\right)}}{\frac{\mathsf{PI}\left(\right)}{2}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            8. mult-flipN/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            9. *-commutativeN/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\color{blue}{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            10. lower-*.f64N/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\color{blue}{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            11. metadata-evalN/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\color{blue}{\frac{1}{2}} \cdot \mathsf{PI}\left(\right)}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            12. lower-PI.f64N/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \color{blue}{\pi}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            13. mult-flipN/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \frac{1}{2}\right)} \]
            14. *-commutativeN/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)} \]
            15. lower-*.f64N/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)} \]
            16. metadata-evalN/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \left(\color{blue}{\frac{1}{2}} \cdot \mathsf{PI}\left(\right)\right) \]
            17. lower-PI.f647.0%

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{0.5 \cdot \pi}\right) \cdot \left(0.5 \cdot \color{blue}{\pi}\right) \]
          3. Applied rewrites7.0%

            \[\leadsto \color{blue}{\left(1 - \frac{\sin^{-1} \left(1 - x\right)}{0.5 \cdot \pi}\right) \cdot \left(0.5 \cdot \pi\right)} \]
          4. Step-by-step derivation
            1. lift-/.f64N/A

              \[\leadsto \left(1 - \color{blue}{\frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            2. div-flipN/A

              \[\leadsto \left(1 - \color{blue}{\frac{1}{\frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(1 - x\right)}}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            3. lower-unsound-/.f64N/A

              \[\leadsto \left(1 - \color{blue}{\frac{1}{\frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(1 - x\right)}}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            4. lift-*.f64N/A

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot \pi}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            5. *-commutativeN/A

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{\pi \cdot \frac{1}{2}}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            6. metadata-evalN/A

              \[\leadsto \left(1 - \frac{1}{\frac{\pi \cdot \color{blue}{\frac{1}{2}}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            7. mult-flipN/A

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{\frac{\pi}{2}}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            8. lift-PI.f64N/A

              \[\leadsto \left(1 - \frac{1}{\frac{\frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            9. lower-unsound-/.f64N/A

              \[\leadsto \left(1 - \frac{1}{\color{blue}{\frac{\frac{\mathsf{PI}\left(\right)}{2}}{\sin^{-1} \left(1 - x\right)}}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            10. lift-PI.f64N/A

              \[\leadsto \left(1 - \frac{1}{\frac{\frac{\color{blue}{\pi}}{2}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            11. mult-flipN/A

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{\pi \cdot \frac{1}{2}}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            12. metadata-evalN/A

              \[\leadsto \left(1 - \frac{1}{\frac{\pi \cdot \color{blue}{\frac{1}{2}}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            13. *-commutativeN/A

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot \pi}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            14. lift-*.f647.0%

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{0.5 \cdot \pi}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(0.5 \cdot \pi\right) \]
          5. Applied rewrites7.0%

            \[\leadsto \left(1 - \color{blue}{\frac{1}{\frac{0.5 \cdot \pi}{\sin^{-1} \left(1 - x\right)}}}\right) \cdot \left(0.5 \cdot \pi\right) \]
          6. Step-by-step derivation
            1. *-lft-identityN/A

              \[\leadsto \left(1 - \color{blue}{1 \cdot \frac{1}{\frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(1 - x\right)}}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            2. *-commutativeN/A

              \[\leadsto \left(1 - \color{blue}{\frac{1}{\frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(1 - x\right)}} \cdot 1}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            3. lift-/.f64N/A

              \[\leadsto \left(1 - \color{blue}{\frac{1}{\frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(1 - x\right)}}} \cdot 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            4. lift-/.f64N/A

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

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot \pi}}{\sin^{-1} \left(1 - x\right)}} \cdot 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            6. associate-/l*N/A

              \[\leadsto \left(1 - \frac{1}{\color{blue}{\frac{1}{2} \cdot \frac{\pi}{\sin^{-1} \left(1 - x\right)}}} \cdot 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            7. associate-/r*N/A

              \[\leadsto \left(1 - \color{blue}{\frac{\frac{1}{\frac{1}{2}}}{\frac{\pi}{\sin^{-1} \left(1 - x\right)}}} \cdot 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            8. metadata-evalN/A

              \[\leadsto \left(1 - \frac{\color{blue}{2}}{\frac{\pi}{\sin^{-1} \left(1 - x\right)}} \cdot 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            9. metadata-evalN/A

              \[\leadsto \left(1 - \frac{2}{\frac{\pi}{\sin^{-1} \left(1 - x\right)}} \cdot \color{blue}{\frac{3}{3}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            10. frac-timesN/A

              \[\leadsto \left(1 - \color{blue}{\frac{2 \cdot 3}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            11. metadata-evalN/A

              \[\leadsto \left(1 - \frac{\color{blue}{6}}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            12. metadata-evalN/A

              \[\leadsto \left(1 - \frac{\color{blue}{3 + 3}}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            13. lower-/.f64N/A

              \[\leadsto \left(1 - \color{blue}{\frac{3 + 3}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            14. metadata-evalN/A

              \[\leadsto \left(1 - \frac{\color{blue}{6}}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            15. lower-*.f64N/A

              \[\leadsto \left(1 - \frac{6}{\color{blue}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            16. lower-/.f647.0%

              \[\leadsto \left(1 - \frac{6}{\color{blue}{\frac{\pi}{\sin^{-1} \left(1 - x\right)}} \cdot 3}\right) \cdot \left(0.5 \cdot \pi\right) \]
          7. Applied rewrites7.0%

            \[\leadsto \left(1 - \color{blue}{\frac{6}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}}\right) \cdot \left(0.5 \cdot \pi\right) \]
        4. Recombined 2 regimes into one program.
        5. Add Preprocessing

        Alternative 3: 10.6% accurate, 0.2× speedup?

        \[\begin{array}{l} t_0 := \pi - \cos^{-1} \left(1 - x\right)\\ \frac{\mathsf{fma}\left(-t\_0, t\_0, \pi \cdot \pi\right)}{\pi + t\_0} \end{array} \]
        (FPCore (x)
          :precision binary64
          (let* ((t_0 (- PI (acos (- 1.0 x)))))
          (/ (fma (- t_0) t_0 (* PI PI)) (+ PI t_0))))
        double code(double x) {
        	double t_0 = ((double) M_PI) - acos((1.0 - x));
        	return fma(-t_0, t_0, (((double) M_PI) * ((double) M_PI))) / (((double) M_PI) + t_0);
        }
        
        function code(x)
        	t_0 = Float64(pi - acos(Float64(1.0 - x)))
        	return Float64(fma(Float64(-t_0), t_0, Float64(pi * pi)) / Float64(pi + t_0))
        end
        
        code[x_] := Block[{t$95$0 = N[(Pi - N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[((-t$95$0) * t$95$0 + N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] / N[(Pi + t$95$0), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        t_0 := \pi - \cos^{-1} \left(1 - x\right)\\
        \frac{\mathsf{fma}\left(-t\_0, t\_0, \pi \cdot \pi\right)}{\pi + t\_0}
        \end{array}
        
        Derivation
        1. Initial program 7.0%

          \[\cos^{-1} \left(1 - x\right) \]
        2. Step-by-step derivation
          1. lift-acos.f64N/A

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

            \[\leadsto \cos^{-1} \color{blue}{\left(1 - x\right)} \]
          3. sub-negate-revN/A

            \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{neg}\left(\left(x - 1\right)\right)\right)} \]
          4. acos-negN/A

            \[\leadsto \color{blue}{\mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right)} \]
          5. flip--N/A

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

            \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)}} \]
          7. lower-unsound-*.f32N/A

            \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)} - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          8. lower-*.f32N/A

            \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)} - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          9. lower-unsound--.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          10. lower-*.f64N/A

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

            \[\leadsto \frac{\color{blue}{\pi} \cdot \mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          12. lower-PI.f64N/A

            \[\leadsto \frac{\pi \cdot \color{blue}{\pi} - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          13. lower-unsound-*.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \color{blue}{\cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          14. lower-acos.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \color{blue}{\cos^{-1} \left(x - 1\right)} \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          15. lower--.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \color{blue}{\left(x - 1\right)} \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          16. lower-acos.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \color{blue}{\cos^{-1} \left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          17. lower--.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \color{blue}{\left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          18. lower-unsound-+.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\color{blue}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)}} \]
          19. lower-PI.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\color{blue}{\pi} + \cos^{-1} \left(x - 1\right)} \]
          20. lower-acos.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\pi + \color{blue}{\cos^{-1} \left(x - 1\right)}} \]
          21. lower--.f647.0%

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\pi + \cos^{-1} \color{blue}{\left(x - 1\right)}} \]
        3. Applied rewrites7.0%

          \[\leadsto \color{blue}{\frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\pi + \cos^{-1} \left(x - 1\right)}} \]
        4. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \frac{\color{blue}{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}}{\pi + \cos^{-1} \left(x - 1\right)} \]
          2. sub-flipN/A

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

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

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

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

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\cos^{-1} \left(x - 1\right)\right), \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}}{\pi + \cos^{-1} \left(x - 1\right)} \]
          7. lower-neg.f6410.6%

            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-\cos^{-1} \left(x - 1\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
        5. Applied rewrites10.6%

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

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

            \[\leadsto \frac{\mathsf{fma}\left(-\cos^{-1} \color{blue}{\left(x - 1\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
          3. sub-negate-revN/A

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

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

            \[\leadsto \frac{\mathsf{fma}\left(-\color{blue}{\left(\mathsf{PI}\left(\right) - \cos^{-1} \left(1 - x\right)\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
          6. lift-PI.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(-\left(\color{blue}{\pi} - \cos^{-1} \left(1 - x\right)\right), \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
          7. lower--.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(-\color{blue}{\left(\pi - \cos^{-1} \left(1 - x\right)\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
          8. lower-acos.f6410.6%

            \[\leadsto \frac{\mathsf{fma}\left(-\left(\pi - \color{blue}{\cos^{-1} \left(1 - x\right)}\right), \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
        7. Applied rewrites10.6%

          \[\leadsto \frac{\mathsf{fma}\left(-\color{blue}{\left(\pi - \cos^{-1} \left(1 - x\right)\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
        8. Step-by-step derivation
          1. lift-acos.f64N/A

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

            \[\leadsto \frac{\mathsf{fma}\left(-\left(\pi - \cos^{-1} \left(1 - x\right)\right), \cos^{-1} \color{blue}{\left(x - 1\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
          3. sub-negate-revN/A

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

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

            \[\leadsto \frac{\mathsf{fma}\left(-\left(\pi - \cos^{-1} \left(1 - x\right)\right), \color{blue}{\mathsf{PI}\left(\right) - \cos^{-1} \left(1 - x\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
          6. lift-PI.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(-\left(\pi - \cos^{-1} \left(1 - x\right)\right), \color{blue}{\pi} - \cos^{-1} \left(1 - x\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
          7. lower--.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(-\left(\pi - \cos^{-1} \left(1 - x\right)\right), \color{blue}{\pi - \cos^{-1} \left(1 - x\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
          8. lower-acos.f6410.6%

            \[\leadsto \frac{\mathsf{fma}\left(-\left(\pi - \cos^{-1} \left(1 - x\right)\right), \pi - \color{blue}{\cos^{-1} \left(1 - x\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
        9. Applied rewrites10.6%

          \[\leadsto \frac{\mathsf{fma}\left(-\left(\pi - \cos^{-1} \left(1 - x\right)\right), \color{blue}{\pi - \cos^{-1} \left(1 - x\right)}, \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
        10. Step-by-step derivation
          1. lift-acos.f64N/A

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

            \[\leadsto \frac{\mathsf{fma}\left(-\left(\pi - \cos^{-1} \left(1 - x\right)\right), \pi - \cos^{-1} \left(1 - x\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \color{blue}{\left(x - 1\right)}} \]
          3. sub-negate-revN/A

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

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

            \[\leadsto \frac{\mathsf{fma}\left(-\left(\pi - \cos^{-1} \left(1 - x\right)\right), \pi - \cos^{-1} \left(1 - x\right), \pi \cdot \pi\right)}{\pi + \color{blue}{\left(\mathsf{PI}\left(\right) - \cos^{-1} \left(1 - x\right)\right)}} \]
          6. lift-PI.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(-\left(\pi - \cos^{-1} \left(1 - x\right)\right), \pi - \cos^{-1} \left(1 - x\right), \pi \cdot \pi\right)}{\pi + \left(\color{blue}{\pi} - \cos^{-1} \left(1 - x\right)\right)} \]
          7. lower--.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(-\left(\pi - \cos^{-1} \left(1 - x\right)\right), \pi - \cos^{-1} \left(1 - x\right), \pi \cdot \pi\right)}{\pi + \color{blue}{\left(\pi - \cos^{-1} \left(1 - x\right)\right)}} \]
          8. lower-acos.f6410.6%

            \[\leadsto \frac{\mathsf{fma}\left(-\left(\pi - \cos^{-1} \left(1 - x\right)\right), \pi - \cos^{-1} \left(1 - x\right), \pi \cdot \pi\right)}{\pi + \left(\pi - \color{blue}{\cos^{-1} \left(1 - x\right)}\right)} \]
        11. Applied rewrites10.6%

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

        Alternative 4: 10.6% accurate, 0.2× speedup?

        \[\begin{array}{l} t_0 := \cos^{-1} \left(x - 1\right)\\ \frac{\mathsf{fma}\left(-t\_0, t\_0, \pi \cdot \pi\right)}{\pi + t\_0} \end{array} \]
        (FPCore (x)
          :precision binary64
          (let* ((t_0 (acos (- x 1.0))))
          (/ (fma (- t_0) t_0 (* PI PI)) (+ PI t_0))))
        double code(double x) {
        	double t_0 = acos((x - 1.0));
        	return fma(-t_0, t_0, (((double) M_PI) * ((double) M_PI))) / (((double) M_PI) + t_0);
        }
        
        function code(x)
        	t_0 = acos(Float64(x - 1.0))
        	return Float64(fma(Float64(-t_0), t_0, Float64(pi * pi)) / Float64(pi + t_0))
        end
        
        code[x_] := Block[{t$95$0 = N[ArcCos[N[(x - 1.0), $MachinePrecision]], $MachinePrecision]}, N[(N[((-t$95$0) * t$95$0 + N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] / N[(Pi + t$95$0), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        t_0 := \cos^{-1} \left(x - 1\right)\\
        \frac{\mathsf{fma}\left(-t\_0, t\_0, \pi \cdot \pi\right)}{\pi + t\_0}
        \end{array}
        
        Derivation
        1. Initial program 7.0%

          \[\cos^{-1} \left(1 - x\right) \]
        2. Step-by-step derivation
          1. lift-acos.f64N/A

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

            \[\leadsto \cos^{-1} \color{blue}{\left(1 - x\right)} \]
          3. sub-negate-revN/A

            \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{neg}\left(\left(x - 1\right)\right)\right)} \]
          4. acos-negN/A

            \[\leadsto \color{blue}{\mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right)} \]
          5. flip--N/A

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

            \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)}} \]
          7. lower-unsound-*.f32N/A

            \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)} - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          8. lower-*.f32N/A

            \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)} - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          9. lower-unsound--.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          10. lower-*.f64N/A

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

            \[\leadsto \frac{\color{blue}{\pi} \cdot \mathsf{PI}\left(\right) - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          12. lower-PI.f64N/A

            \[\leadsto \frac{\pi \cdot \color{blue}{\pi} - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          13. lower-unsound-*.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \color{blue}{\cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          14. lower-acos.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \color{blue}{\cos^{-1} \left(x - 1\right)} \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          15. lower--.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \color{blue}{\left(x - 1\right)} \cdot \cos^{-1} \left(x - 1\right)}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          16. lower-acos.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \color{blue}{\cos^{-1} \left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          17. lower--.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \color{blue}{\left(x - 1\right)}}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)} \]
          18. lower-unsound-+.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\color{blue}{\mathsf{PI}\left(\right) + \cos^{-1} \left(x - 1\right)}} \]
          19. lower-PI.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\color{blue}{\pi} + \cos^{-1} \left(x - 1\right)} \]
          20. lower-acos.f64N/A

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\pi + \color{blue}{\cos^{-1} \left(x - 1\right)}} \]
          21. lower--.f647.0%

            \[\leadsto \frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\pi + \cos^{-1} \color{blue}{\left(x - 1\right)}} \]
        3. Applied rewrites7.0%

          \[\leadsto \color{blue}{\frac{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}{\pi + \cos^{-1} \left(x - 1\right)}} \]
        4. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \frac{\color{blue}{\pi \cdot \pi - \cos^{-1} \left(x - 1\right) \cdot \cos^{-1} \left(x - 1\right)}}{\pi + \cos^{-1} \left(x - 1\right)} \]
          2. sub-flipN/A

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

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

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

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

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\cos^{-1} \left(x - 1\right)\right), \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}}{\pi + \cos^{-1} \left(x - 1\right)} \]
          7. lower-neg.f6410.6%

            \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{-\cos^{-1} \left(x - 1\right)}, \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \cos^{-1} \left(x - 1\right)} \]
        5. Applied rewrites10.6%

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

        Alternative 5: 10.5% accurate, 0.2× speedup?

        \[\mathsf{fma}\left(0.5 \cdot \pi, \frac{2}{\pi}, \sin^{-1} \left(x - 1\right) \cdot \frac{2}{\pi}\right) \cdot \left(0.5 \cdot \pi\right) \]
        (FPCore (x)
          :precision binary64
          (*
         (fma (* 0.5 PI) (/ 2.0 PI) (* (asin (- x 1.0)) (/ 2.0 PI)))
         (* 0.5 PI)))
        double code(double x) {
        	return fma((0.5 * ((double) M_PI)), (2.0 / ((double) M_PI)), (asin((x - 1.0)) * (2.0 / ((double) M_PI)))) * (0.5 * ((double) M_PI));
        }
        
        function code(x)
        	return Float64(fma(Float64(0.5 * pi), Float64(2.0 / pi), Float64(asin(Float64(x - 1.0)) * Float64(2.0 / pi))) * Float64(0.5 * pi))
        end
        
        code[x_] := N[(N[(N[(0.5 * Pi), $MachinePrecision] * N[(2.0 / Pi), $MachinePrecision] + N[(N[ArcSin[N[(x - 1.0), $MachinePrecision]], $MachinePrecision] * N[(2.0 / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]
        
        \mathsf{fma}\left(0.5 \cdot \pi, \frac{2}{\pi}, \sin^{-1} \left(x - 1\right) \cdot \frac{2}{\pi}\right) \cdot \left(0.5 \cdot \pi\right)
        
        Derivation
        1. Initial program 7.0%

          \[\cos^{-1} \left(1 - x\right) \]
        2. Step-by-step derivation
          1. lift-acos.f64N/A

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

            \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{2} - \sin^{-1} \left(1 - x\right)} \]
          3. sub-to-multN/A

            \[\leadsto \color{blue}{\left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{\mathsf{PI}\left(\right)}{2}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2}} \]
          4. lower-unsound-*.f64N/A

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

            \[\leadsto \color{blue}{\left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{\mathsf{PI}\left(\right)}{2}}\right)} \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
          6. lower-unsound-/.f64N/A

            \[\leadsto \left(1 - \color{blue}{\frac{\sin^{-1} \left(1 - x\right)}{\frac{\mathsf{PI}\left(\right)}{2}}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
          7. lower-asin.f64N/A

            \[\leadsto \left(1 - \frac{\color{blue}{\sin^{-1} \left(1 - x\right)}}{\frac{\mathsf{PI}\left(\right)}{2}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
          8. mult-flipN/A

            \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
          9. *-commutativeN/A

            \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\color{blue}{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
          10. lower-*.f64N/A

            \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\color{blue}{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
          11. metadata-evalN/A

            \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\color{blue}{\frac{1}{2}} \cdot \mathsf{PI}\left(\right)}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
          12. lower-PI.f64N/A

            \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \color{blue}{\pi}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
          13. mult-flipN/A

            \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \frac{1}{2}\right)} \]
          14. *-commutativeN/A

            \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)} \]
          15. lower-*.f64N/A

            \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)} \]
          16. metadata-evalN/A

            \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \left(\color{blue}{\frac{1}{2}} \cdot \mathsf{PI}\left(\right)\right) \]
          17. lower-PI.f647.0%

            \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{0.5 \cdot \pi}\right) \cdot \left(0.5 \cdot \color{blue}{\pi}\right) \]
        3. Applied rewrites7.0%

          \[\leadsto \color{blue}{\left(1 - \frac{\sin^{-1} \left(1 - x\right)}{0.5 \cdot \pi}\right) \cdot \left(0.5 \cdot \pi\right)} \]
        4. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \color{blue}{\left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right)} \cdot \left(\frac{1}{2} \cdot \pi\right) \]
          2. lift-/.f64N/A

            \[\leadsto \left(1 - \color{blue}{\frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
          3. mult-flipN/A

            \[\leadsto \left(1 - \color{blue}{\sin^{-1} \left(1 - x\right) \cdot \frac{1}{\frac{1}{2} \cdot \pi}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
          4. lift-*.f64N/A

            \[\leadsto \left(1 - \sin^{-1} \left(1 - x\right) \cdot \frac{1}{\color{blue}{\frac{1}{2} \cdot \pi}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
          5. *-commutativeN/A

            \[\leadsto \left(1 - \sin^{-1} \left(1 - x\right) \cdot \frac{1}{\color{blue}{\pi \cdot \frac{1}{2}}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
          6. metadata-evalN/A

            \[\leadsto \left(1 - \sin^{-1} \left(1 - x\right) \cdot \frac{1}{\pi \cdot \color{blue}{\frac{1}{2}}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
          7. mult-flipN/A

            \[\leadsto \left(1 - \sin^{-1} \left(1 - x\right) \cdot \frac{1}{\color{blue}{\frac{\pi}{2}}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
          8. lift-PI.f64N/A

            \[\leadsto \left(1 - \sin^{-1} \left(1 - x\right) \cdot \frac{1}{\frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
          9. mult-flipN/A

            \[\leadsto \left(1 - \color{blue}{\frac{\sin^{-1} \left(1 - x\right)}{\frac{\mathsf{PI}\left(\right)}{2}}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
          10. sub-to-fraction-revN/A

            \[\leadsto \color{blue}{\frac{1 \cdot \frac{\mathsf{PI}\left(\right)}{2} - \sin^{-1} \left(1 - x\right)}{\frac{\mathsf{PI}\left(\right)}{2}}} \cdot \left(\frac{1}{2} \cdot \pi\right) \]
          11. *-lft-identityN/A

            \[\leadsto \frac{\color{blue}{\frac{\mathsf{PI}\left(\right)}{2}} - \sin^{-1} \left(1 - x\right)}{\frac{\mathsf{PI}\left(\right)}{2}} \cdot \left(\frac{1}{2} \cdot \pi\right) \]
          12. sub-flipN/A

            \[\leadsto \frac{\color{blue}{\frac{\mathsf{PI}\left(\right)}{2} + \left(\mathsf{neg}\left(\sin^{-1} \left(1 - x\right)\right)\right)}}{\frac{\mathsf{PI}\left(\right)}{2}} \cdot \left(\frac{1}{2} \cdot \pi\right) \]
          13. div-addN/A

            \[\leadsto \color{blue}{\left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{\frac{\mathsf{PI}\left(\right)}{2}} + \frac{\mathsf{neg}\left(\sin^{-1} \left(1 - x\right)\right)}{\frac{\mathsf{PI}\left(\right)}{2}}\right)} \cdot \left(\frac{1}{2} \cdot \pi\right) \]
        5. Applied rewrites10.5%

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

        Alternative 6: 9.6% accurate, 0.2× speedup?

        \[\begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\ \;\;\;\;\cos^{-1} \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{6}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}\right) \cdot \left(0.5 \cdot \pi\right)\\ \end{array} \]
        (FPCore (x)
          :precision binary64
          (if (<= x 5.5e-17)
          (acos (- x))
          (* (- 1.0 (/ 6.0 (* (/ PI (asin (- 1.0 x))) 3.0))) (* 0.5 PI))))
        double code(double x) {
        	double tmp;
        	if (x <= 5.5e-17) {
        		tmp = acos(-x);
        	} else {
        		tmp = (1.0 - (6.0 / ((((double) M_PI) / asin((1.0 - x))) * 3.0))) * (0.5 * ((double) M_PI));
        	}
        	return tmp;
        }
        
        public static double code(double x) {
        	double tmp;
        	if (x <= 5.5e-17) {
        		tmp = Math.acos(-x);
        	} else {
        		tmp = (1.0 - (6.0 / ((Math.PI / Math.asin((1.0 - x))) * 3.0))) * (0.5 * Math.PI);
        	}
        	return tmp;
        }
        
        def code(x):
        	tmp = 0
        	if x <= 5.5e-17:
        		tmp = math.acos(-x)
        	else:
        		tmp = (1.0 - (6.0 / ((math.pi / math.asin((1.0 - x))) * 3.0))) * (0.5 * math.pi)
        	return tmp
        
        function code(x)
        	tmp = 0.0
        	if (x <= 5.5e-17)
        		tmp = acos(Float64(-x));
        	else
        		tmp = Float64(Float64(1.0 - Float64(6.0 / Float64(Float64(pi / asin(Float64(1.0 - x))) * 3.0))) * Float64(0.5 * pi));
        	end
        	return tmp
        end
        
        function tmp_2 = code(x)
        	tmp = 0.0;
        	if (x <= 5.5e-17)
        		tmp = acos(-x);
        	else
        		tmp = (1.0 - (6.0 / ((pi / asin((1.0 - x))) * 3.0))) * (0.5 * pi);
        	end
        	tmp_2 = tmp;
        end
        
        code[x_] := If[LessEqual[x, 5.5e-17], N[ArcCos[(-x)], $MachinePrecision], N[(N[(1.0 - N[(6.0 / N[(N[(Pi / N[ArcSin[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        \mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\
        \;\;\;\;\cos^{-1} \left(-x\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(1 - \frac{6}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}\right) \cdot \left(0.5 \cdot \pi\right)\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < 5.5e-17

          1. Initial program 7.0%

            \[\cos^{-1} \left(1 - x\right) \]
          2. Taylor expanded in x around inf

            \[\leadsto \cos^{-1} \color{blue}{\left(-1 \cdot x\right)} \]
          3. Step-by-step derivation
            1. lower-*.f646.9%

              \[\leadsto \cos^{-1} \left(-1 \cdot \color{blue}{x}\right) \]
          4. Applied rewrites6.9%

            \[\leadsto \cos^{-1} \color{blue}{\left(-1 \cdot x\right)} \]
          5. Step-by-step derivation
            1. lift-*.f64N/A

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

              \[\leadsto \cos^{-1} \left(\mathsf{neg}\left(x\right)\right) \]
            3. lower-neg.f646.9%

              \[\leadsto \cos^{-1} \left(-x\right) \]
          6. Applied rewrites6.9%

            \[\leadsto \cos^{-1} \left(-x\right) \]

          if 5.5e-17 < x

          1. Initial program 7.0%

            \[\cos^{-1} \left(1 - x\right) \]
          2. Step-by-step derivation
            1. lift-acos.f64N/A

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

              \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{2} - \sin^{-1} \left(1 - x\right)} \]
            3. sub-to-multN/A

              \[\leadsto \color{blue}{\left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{\mathsf{PI}\left(\right)}{2}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2}} \]
            4. lower-unsound-*.f64N/A

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

              \[\leadsto \color{blue}{\left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{\mathsf{PI}\left(\right)}{2}}\right)} \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            6. lower-unsound-/.f64N/A

              \[\leadsto \left(1 - \color{blue}{\frac{\sin^{-1} \left(1 - x\right)}{\frac{\mathsf{PI}\left(\right)}{2}}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            7. lower-asin.f64N/A

              \[\leadsto \left(1 - \frac{\color{blue}{\sin^{-1} \left(1 - x\right)}}{\frac{\mathsf{PI}\left(\right)}{2}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            8. mult-flipN/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            9. *-commutativeN/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\color{blue}{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            10. lower-*.f64N/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\color{blue}{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            11. metadata-evalN/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\color{blue}{\frac{1}{2}} \cdot \mathsf{PI}\left(\right)}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            12. lower-PI.f64N/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \color{blue}{\pi}}\right) \cdot \frac{\mathsf{PI}\left(\right)}{2} \]
            13. mult-flipN/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \frac{1}{2}\right)} \]
            14. *-commutativeN/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)} \]
            15. lower-*.f64N/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot \mathsf{PI}\left(\right)\right)} \]
            16. metadata-evalN/A

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \left(\color{blue}{\frac{1}{2}} \cdot \mathsf{PI}\left(\right)\right) \]
            17. lower-PI.f647.0%

              \[\leadsto \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{0.5 \cdot \pi}\right) \cdot \left(0.5 \cdot \color{blue}{\pi}\right) \]
          3. Applied rewrites7.0%

            \[\leadsto \color{blue}{\left(1 - \frac{\sin^{-1} \left(1 - x\right)}{0.5 \cdot \pi}\right) \cdot \left(0.5 \cdot \pi\right)} \]
          4. Step-by-step derivation
            1. lift-/.f64N/A

              \[\leadsto \left(1 - \color{blue}{\frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            2. div-flipN/A

              \[\leadsto \left(1 - \color{blue}{\frac{1}{\frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(1 - x\right)}}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            3. lower-unsound-/.f64N/A

              \[\leadsto \left(1 - \color{blue}{\frac{1}{\frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(1 - x\right)}}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            4. lift-*.f64N/A

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot \pi}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            5. *-commutativeN/A

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{\pi \cdot \frac{1}{2}}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            6. metadata-evalN/A

              \[\leadsto \left(1 - \frac{1}{\frac{\pi \cdot \color{blue}{\frac{1}{2}}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            7. mult-flipN/A

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{\frac{\pi}{2}}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            8. lift-PI.f64N/A

              \[\leadsto \left(1 - \frac{1}{\frac{\frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            9. lower-unsound-/.f64N/A

              \[\leadsto \left(1 - \frac{1}{\color{blue}{\frac{\frac{\mathsf{PI}\left(\right)}{2}}{\sin^{-1} \left(1 - x\right)}}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            10. lift-PI.f64N/A

              \[\leadsto \left(1 - \frac{1}{\frac{\frac{\color{blue}{\pi}}{2}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            11. mult-flipN/A

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{\pi \cdot \frac{1}{2}}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            12. metadata-evalN/A

              \[\leadsto \left(1 - \frac{1}{\frac{\pi \cdot \color{blue}{\frac{1}{2}}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            13. *-commutativeN/A

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot \pi}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            14. lift-*.f647.0%

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{0.5 \cdot \pi}}{\sin^{-1} \left(1 - x\right)}}\right) \cdot \left(0.5 \cdot \pi\right) \]
          5. Applied rewrites7.0%

            \[\leadsto \left(1 - \color{blue}{\frac{1}{\frac{0.5 \cdot \pi}{\sin^{-1} \left(1 - x\right)}}}\right) \cdot \left(0.5 \cdot \pi\right) \]
          6. Step-by-step derivation
            1. *-lft-identityN/A

              \[\leadsto \left(1 - \color{blue}{1 \cdot \frac{1}{\frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(1 - x\right)}}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            2. *-commutativeN/A

              \[\leadsto \left(1 - \color{blue}{\frac{1}{\frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(1 - x\right)}} \cdot 1}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            3. lift-/.f64N/A

              \[\leadsto \left(1 - \color{blue}{\frac{1}{\frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(1 - x\right)}}} \cdot 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            4. lift-/.f64N/A

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

              \[\leadsto \left(1 - \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot \pi}}{\sin^{-1} \left(1 - x\right)}} \cdot 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            6. associate-/l*N/A

              \[\leadsto \left(1 - \frac{1}{\color{blue}{\frac{1}{2} \cdot \frac{\pi}{\sin^{-1} \left(1 - x\right)}}} \cdot 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            7. associate-/r*N/A

              \[\leadsto \left(1 - \color{blue}{\frac{\frac{1}{\frac{1}{2}}}{\frac{\pi}{\sin^{-1} \left(1 - x\right)}}} \cdot 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            8. metadata-evalN/A

              \[\leadsto \left(1 - \frac{\color{blue}{2}}{\frac{\pi}{\sin^{-1} \left(1 - x\right)}} \cdot 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            9. metadata-evalN/A

              \[\leadsto \left(1 - \frac{2}{\frac{\pi}{\sin^{-1} \left(1 - x\right)}} \cdot \color{blue}{\frac{3}{3}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            10. frac-timesN/A

              \[\leadsto \left(1 - \color{blue}{\frac{2 \cdot 3}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            11. metadata-evalN/A

              \[\leadsto \left(1 - \frac{\color{blue}{6}}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            12. metadata-evalN/A

              \[\leadsto \left(1 - \frac{\color{blue}{3 + 3}}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            13. lower-/.f64N/A

              \[\leadsto \left(1 - \color{blue}{\frac{3 + 3}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            14. metadata-evalN/A

              \[\leadsto \left(1 - \frac{\color{blue}{6}}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            15. lower-*.f64N/A

              \[\leadsto \left(1 - \frac{6}{\color{blue}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            16. lower-/.f647.0%

              \[\leadsto \left(1 - \frac{6}{\color{blue}{\frac{\pi}{\sin^{-1} \left(1 - x\right)}} \cdot 3}\right) \cdot \left(0.5 \cdot \pi\right) \]
          7. Applied rewrites7.0%

            \[\leadsto \left(1 - \color{blue}{\frac{6}{\frac{\pi}{\sin^{-1} \left(1 - x\right)} \cdot 3}}\right) \cdot \left(0.5 \cdot \pi\right) \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 7: 9.6% accurate, 0.3× speedup?

        \[\begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\ \;\;\;\;\cos^{-1} \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\pi, 0.5, \left(0.5 \cdot \pi\right) \cdot \left(\sin^{-1} \left(x - 1\right) \cdot \frac{2}{\pi}\right)\right)\\ \end{array} \]
        (FPCore (x)
          :precision binary64
          (if (<= x 5.5e-17)
          (acos (- x))
          (fma PI 0.5 (* (* 0.5 PI) (* (asin (- x 1.0)) (/ 2.0 PI))))))
        double code(double x) {
        	double tmp;
        	if (x <= 5.5e-17) {
        		tmp = acos(-x);
        	} else {
        		tmp = fma(((double) M_PI), 0.5, ((0.5 * ((double) M_PI)) * (asin((x - 1.0)) * (2.0 / ((double) M_PI)))));
        	}
        	return tmp;
        }
        
        function code(x)
        	tmp = 0.0
        	if (x <= 5.5e-17)
        		tmp = acos(Float64(-x));
        	else
        		tmp = fma(pi, 0.5, Float64(Float64(0.5 * pi) * Float64(asin(Float64(x - 1.0)) * Float64(2.0 / pi))));
        	end
        	return tmp
        end
        
        code[x_] := If[LessEqual[x, 5.5e-17], N[ArcCos[(-x)], $MachinePrecision], N[(Pi * 0.5 + N[(N[(0.5 * Pi), $MachinePrecision] * N[(N[ArcSin[N[(x - 1.0), $MachinePrecision]], $MachinePrecision] * N[(2.0 / Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        \mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\
        \;\;\;\;\cos^{-1} \left(-x\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(\pi, 0.5, \left(0.5 \cdot \pi\right) \cdot \left(\sin^{-1} \left(x - 1\right) \cdot \frac{2}{\pi}\right)\right)\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < 5.5e-17

          1. Initial program 7.0%

            \[\cos^{-1} \left(1 - x\right) \]
          2. Taylor expanded in x around inf

            \[\leadsto \cos^{-1} \color{blue}{\left(-1 \cdot x\right)} \]
          3. Step-by-step derivation
            1. lower-*.f646.9%

              \[\leadsto \cos^{-1} \left(-1 \cdot \color{blue}{x}\right) \]
          4. Applied rewrites6.9%

            \[\leadsto \cos^{-1} \color{blue}{\left(-1 \cdot x\right)} \]
          5. Step-by-step derivation
            1. lift-*.f64N/A

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

              \[\leadsto \cos^{-1} \left(\mathsf{neg}\left(x\right)\right) \]
            3. lower-neg.f646.9%

              \[\leadsto \cos^{-1} \left(-x\right) \]
          6. Applied rewrites6.9%

            \[\leadsto \cos^{-1} \left(-x\right) \]

          if 5.5e-17 < x

          1. Initial program 7.0%

            \[\cos^{-1} \left(1 - x\right) \]
          2. Step-by-step derivation
            1. lift-acos.f64N/A

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

              \[\leadsto \cos^{-1} \color{blue}{\left(1 - x\right)} \]
            3. sub-negate-revN/A

              \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{neg}\left(\left(x - 1\right)\right)\right)} \]
            4. acos-negN/A

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

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

              \[\leadsto \color{blue}{\pi} - \cos^{-1} \left(x - 1\right) \]
            7. lower-acos.f64N/A

              \[\leadsto \pi - \color{blue}{\cos^{-1} \left(x - 1\right)} \]
            8. lower--.f647.0%

              \[\leadsto \pi - \cos^{-1} \color{blue}{\left(x - 1\right)} \]
          3. Applied rewrites7.0%

            \[\leadsto \color{blue}{\pi - \cos^{-1} \left(x - 1\right)} \]
          4. Step-by-step derivation
            1. lift--.f64N/A

              \[\leadsto \color{blue}{\pi - \cos^{-1} \left(x - 1\right)} \]
            2. lift-PI.f64N/A

              \[\leadsto \color{blue}{\mathsf{PI}\left(\right)} - \cos^{-1} \left(x - 1\right) \]
            3. lift-acos.f64N/A

              \[\leadsto \mathsf{PI}\left(\right) - \color{blue}{\cos^{-1} \left(x - 1\right)} \]
            4. acos-neg-revN/A

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

              \[\leadsto \cos^{-1} \left(\mathsf{neg}\left(\color{blue}{\left(x - 1\right)}\right)\right) \]
            6. sub-negate-revN/A

              \[\leadsto \cos^{-1} \color{blue}{\left(1 - x\right)} \]
            7. acos-asinN/A

              \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{2} - \sin^{-1} \left(1 - x\right)} \]
            8. lift-PI.f64N/A

              \[\leadsto \frac{\color{blue}{\pi}}{2} - \sin^{-1} \left(1 - x\right) \]
            9. mult-flipN/A

              \[\leadsto \color{blue}{\pi \cdot \frac{1}{2}} - \sin^{-1} \left(1 - x\right) \]
            10. metadata-evalN/A

              \[\leadsto \pi \cdot \color{blue}{\frac{1}{2}} - \sin^{-1} \left(1 - x\right) \]
            11. lift-asin.f64N/A

              \[\leadsto \pi \cdot \frac{1}{2} - \color{blue}{\sin^{-1} \left(1 - x\right)} \]
            12. lift--.f64N/A

              \[\leadsto \pi \cdot \frac{1}{2} - \sin^{-1} \color{blue}{\left(1 - x\right)} \]
            13. *-commutativeN/A

              \[\leadsto \color{blue}{\frac{1}{2} \cdot \pi} - \sin^{-1} \left(1 - x\right) \]
            14. lift-*.f64N/A

              \[\leadsto \color{blue}{\frac{1}{2} \cdot \pi} - \sin^{-1} \left(1 - x\right) \]
            15. sub-to-mult-revN/A

              \[\leadsto \color{blue}{\left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \cdot \left(\frac{1}{2} \cdot \pi\right)} \]
            16. lift-/.f64N/A

              \[\leadsto \left(1 - \color{blue}{\frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}}\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            17. lift--.f64N/A

              \[\leadsto \color{blue}{\left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right)} \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            18. *-commutativeN/A

              \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \pi\right) \cdot \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right)} \]
            19. lift-*.f64N/A

              \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \pi\right)} \cdot \left(1 - \frac{\sin^{-1} \left(1 - x\right)}{\frac{1}{2} \cdot \pi}\right) \]
          5. Applied rewrites7.0%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\pi, 0.5, \left(0.5 \cdot \pi\right) \cdot \left(\sin^{-1} \left(x - 1\right) \cdot \frac{2}{\pi}\right)\right)} \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 8: 9.6% accurate, 0.5× speedup?

        \[\begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\ \;\;\;\;\cos^{-1} \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;\pi - \left(\pi - \cos^{-1} \left(1 - x\right)\right)\\ \end{array} \]
        (FPCore (x)
          :precision binary64
          (if (<= x 5.5e-17) (acos (- x)) (- PI (- PI (acos (- 1.0 x))))))
        double code(double x) {
        	double tmp;
        	if (x <= 5.5e-17) {
        		tmp = acos(-x);
        	} else {
        		tmp = ((double) M_PI) - (((double) M_PI) - acos((1.0 - x)));
        	}
        	return tmp;
        }
        
        public static double code(double x) {
        	double tmp;
        	if (x <= 5.5e-17) {
        		tmp = Math.acos(-x);
        	} else {
        		tmp = Math.PI - (Math.PI - Math.acos((1.0 - x)));
        	}
        	return tmp;
        }
        
        def code(x):
        	tmp = 0
        	if x <= 5.5e-17:
        		tmp = math.acos(-x)
        	else:
        		tmp = math.pi - (math.pi - math.acos((1.0 - x)))
        	return tmp
        
        function code(x)
        	tmp = 0.0
        	if (x <= 5.5e-17)
        		tmp = acos(Float64(-x));
        	else
        		tmp = Float64(pi - Float64(pi - acos(Float64(1.0 - x))));
        	end
        	return tmp
        end
        
        function tmp_2 = code(x)
        	tmp = 0.0;
        	if (x <= 5.5e-17)
        		tmp = acos(-x);
        	else
        		tmp = pi - (pi - acos((1.0 - x)));
        	end
        	tmp_2 = tmp;
        end
        
        code[x_] := If[LessEqual[x, 5.5e-17], N[ArcCos[(-x)], $MachinePrecision], N[(Pi - N[(Pi - N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        \mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\
        \;\;\;\;\cos^{-1} \left(-x\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\pi - \left(\pi - \cos^{-1} \left(1 - x\right)\right)\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < 5.5e-17

          1. Initial program 7.0%

            \[\cos^{-1} \left(1 - x\right) \]
          2. Taylor expanded in x around inf

            \[\leadsto \cos^{-1} \color{blue}{\left(-1 \cdot x\right)} \]
          3. Step-by-step derivation
            1. lower-*.f646.9%

              \[\leadsto \cos^{-1} \left(-1 \cdot \color{blue}{x}\right) \]
          4. Applied rewrites6.9%

            \[\leadsto \cos^{-1} \color{blue}{\left(-1 \cdot x\right)} \]
          5. Step-by-step derivation
            1. lift-*.f64N/A

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

              \[\leadsto \cos^{-1} \left(\mathsf{neg}\left(x\right)\right) \]
            3. lower-neg.f646.9%

              \[\leadsto \cos^{-1} \left(-x\right) \]
          6. Applied rewrites6.9%

            \[\leadsto \cos^{-1} \left(-x\right) \]

          if 5.5e-17 < x

          1. Initial program 7.0%

            \[\cos^{-1} \left(1 - x\right) \]
          2. Step-by-step derivation
            1. lift-acos.f64N/A

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

              \[\leadsto \cos^{-1} \color{blue}{\left(1 - x\right)} \]
            3. sub-negate-revN/A

              \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{neg}\left(\left(x - 1\right)\right)\right)} \]
            4. acos-negN/A

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

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

              \[\leadsto \color{blue}{\pi} - \cos^{-1} \left(x - 1\right) \]
            7. lower-acos.f64N/A

              \[\leadsto \pi - \color{blue}{\cos^{-1} \left(x - 1\right)} \]
            8. lower--.f647.0%

              \[\leadsto \pi - \cos^{-1} \color{blue}{\left(x - 1\right)} \]
          3. Applied rewrites7.0%

            \[\leadsto \color{blue}{\pi - \cos^{-1} \left(x - 1\right)} \]
          4. Step-by-step derivation
            1. lift-acos.f64N/A

              \[\leadsto \pi - \color{blue}{\cos^{-1} \left(x - 1\right)} \]
            2. lift--.f64N/A

              \[\leadsto \pi - \cos^{-1} \color{blue}{\left(x - 1\right)} \]
            3. sub-negate-revN/A

              \[\leadsto \pi - \cos^{-1} \color{blue}{\left(\mathsf{neg}\left(\left(1 - x\right)\right)\right)} \]
            4. acos-negN/A

              \[\leadsto \pi - \color{blue}{\left(\mathsf{PI}\left(\right) - \cos^{-1} \left(1 - x\right)\right)} \]
            5. lift-PI.f64N/A

              \[\leadsto \pi - \left(\color{blue}{\pi} - \cos^{-1} \left(1 - x\right)\right) \]
            6. lower--.f64N/A

              \[\leadsto \pi - \color{blue}{\left(\pi - \cos^{-1} \left(1 - x\right)\right)} \]
            7. lower-acos.f64N/A

              \[\leadsto \pi - \left(\pi - \color{blue}{\cos^{-1} \left(1 - x\right)}\right) \]
            8. lift--.f647.0%

              \[\leadsto \pi - \left(\pi - \cos^{-1} \color{blue}{\left(1 - x\right)}\right) \]
          5. Applied rewrites7.0%

            \[\leadsto \pi - \color{blue}{\left(\pi - \cos^{-1} \left(1 - x\right)\right)} \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 9: 9.6% accurate, 0.7× speedup?

        \[\begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\ \;\;\;\;\cos^{-1} \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;\cos^{-1} \left(1 - x\right)\\ \end{array} \]
        (FPCore (x)
          :precision binary64
          (if (<= x 5.5e-17) (acos (- x)) (acos (- 1.0 x))))
        double code(double x) {
        	double tmp;
        	if (x <= 5.5e-17) {
        		tmp = acos(-x);
        	} else {
        		tmp = acos((1.0 - x));
        	}
        	return tmp;
        }
        
        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(x)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            real(8) :: tmp
            if (x <= 5.5d-17) then
                tmp = acos(-x)
            else
                tmp = acos((1.0d0 - x))
            end if
            code = tmp
        end function
        
        public static double code(double x) {
        	double tmp;
        	if (x <= 5.5e-17) {
        		tmp = Math.acos(-x);
        	} else {
        		tmp = Math.acos((1.0 - x));
        	}
        	return tmp;
        }
        
        def code(x):
        	tmp = 0
        	if x <= 5.5e-17:
        		tmp = math.acos(-x)
        	else:
        		tmp = math.acos((1.0 - x))
        	return tmp
        
        function code(x)
        	tmp = 0.0
        	if (x <= 5.5e-17)
        		tmp = acos(Float64(-x));
        	else
        		tmp = acos(Float64(1.0 - x));
        	end
        	return tmp
        end
        
        function tmp_2 = code(x)
        	tmp = 0.0;
        	if (x <= 5.5e-17)
        		tmp = acos(-x);
        	else
        		tmp = acos((1.0 - x));
        	end
        	tmp_2 = tmp;
        end
        
        code[x_] := If[LessEqual[x, 5.5e-17], N[ArcCos[(-x)], $MachinePrecision], N[ArcCos[N[(1.0 - x), $MachinePrecision]], $MachinePrecision]]
        
        \begin{array}{l}
        \mathbf{if}\;x \leq 5.5 \cdot 10^{-17}:\\
        \;\;\;\;\cos^{-1} \left(-x\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\cos^{-1} \left(1 - x\right)\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < 5.5e-17

          1. Initial program 7.0%

            \[\cos^{-1} \left(1 - x\right) \]
          2. Taylor expanded in x around inf

            \[\leadsto \cos^{-1} \color{blue}{\left(-1 \cdot x\right)} \]
          3. Step-by-step derivation
            1. lower-*.f646.9%

              \[\leadsto \cos^{-1} \left(-1 \cdot \color{blue}{x}\right) \]
          4. Applied rewrites6.9%

            \[\leadsto \cos^{-1} \color{blue}{\left(-1 \cdot x\right)} \]
          5. Step-by-step derivation
            1. lift-*.f64N/A

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

              \[\leadsto \cos^{-1} \left(\mathsf{neg}\left(x\right)\right) \]
            3. lower-neg.f646.9%

              \[\leadsto \cos^{-1} \left(-x\right) \]
          6. Applied rewrites6.9%

            \[\leadsto \cos^{-1} \left(-x\right) \]

          if 5.5e-17 < x

          1. Initial program 7.0%

            \[\cos^{-1} \left(1 - x\right) \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 10: 6.9% accurate, 1.3× speedup?

        \[\cos^{-1} \left(-x\right) \]
        (FPCore (x)
          :precision binary64
          (acos (- x)))
        double code(double x) {
        	return acos(-x);
        }
        
        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(x)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            code = acos(-x)
        end function
        
        public static double code(double x) {
        	return Math.acos(-x);
        }
        
        def code(x):
        	return math.acos(-x)
        
        function code(x)
        	return acos(Float64(-x))
        end
        
        function tmp = code(x)
        	tmp = acos(-x);
        end
        
        code[x_] := N[ArcCos[(-x)], $MachinePrecision]
        
        \cos^{-1} \left(-x\right)
        
        Derivation
        1. Initial program 7.0%

          \[\cos^{-1} \left(1 - x\right) \]
        2. Taylor expanded in x around inf

          \[\leadsto \cos^{-1} \color{blue}{\left(-1 \cdot x\right)} \]
        3. Step-by-step derivation
          1. lower-*.f646.9%

            \[\leadsto \cos^{-1} \left(-1 \cdot \color{blue}{x}\right) \]
        4. Applied rewrites6.9%

          \[\leadsto \cos^{-1} \color{blue}{\left(-1 \cdot x\right)} \]
        5. Step-by-step derivation
          1. lift-*.f64N/A

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

            \[\leadsto \cos^{-1} \left(\mathsf{neg}\left(x\right)\right) \]
          3. lower-neg.f646.9%

            \[\leadsto \cos^{-1} \left(-x\right) \]
        6. Applied rewrites6.9%

          \[\leadsto \cos^{-1} \left(-x\right) \]
        7. Add Preprocessing

        Alternative 11: 3.8% accurate, 1.5× speedup?

        \[\cos^{-1} 1 \]
        (FPCore (x)
          :precision binary64
          (acos 1.0))
        double code(double x) {
        	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(x)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            code = acos(1.0d0)
        end function
        
        public static double code(double x) {
        	return Math.acos(1.0);
        }
        
        def code(x):
        	return math.acos(1.0)
        
        function code(x)
        	return acos(1.0)
        end
        
        function tmp = code(x)
        	tmp = acos(1.0);
        end
        
        code[x_] := N[ArcCos[1.0], $MachinePrecision]
        
        \cos^{-1} 1
        
        Derivation
        1. Initial program 7.0%

          \[\cos^{-1} \left(1 - x\right) \]
        2. Taylor expanded in x around 0

          \[\leadsto \cos^{-1} \color{blue}{1} \]
        3. Step-by-step derivation
          1. Applied rewrites3.8%

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

          Reproduce

          ?
          herbie shell --seed 2025212 
          (FPCore (x)
            :name "bug323 (missed optimization)"
            :precision binary64
            :pre (and (<= 0.0 x) (<= x 0.5))
            (acos (- 1.0 x)))