bug323 (missed optimization)

Percentage Accurate: 6.8% → 10.4%
Time: 4.2s
Alternatives: 11
Speedup: 1.3×

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: 6.8% 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.4% accurate, 0.0× speedup?

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

    \[\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--.f646.8%

      \[\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 rewrites6.8%

    \[\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.4%

      \[\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.4%

    \[\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-+.f64N/A

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(-\cos^{-1} \left(x - 1\right), \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \left(\frac{\mathsf{PI}\left(\right)}{2} - \color{blue}{\sin^{-1} \left(x - 1\right)}\right)} \]
    5. associate-+r-N/A

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

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

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

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

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

Alternative 2: 10.4% accurate, 0.3× speedup?

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin^{-1} \left(x - 1\right), \frac{2}{\pi}, 1\right) \cdot \left(0.5 \cdot \pi\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 7.0000000000000003e-16

    1. Initial program 6.8%

      \[\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--.f646.8%

        \[\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 rewrites6.8%

      \[\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.4%

        \[\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.4%

      \[\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.1%

        \[\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}} \]
          2. Evaluated real constant7.7%

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

          if 7.0000000000000003e-16 < x

          1. Initial program 6.8%

            \[\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.f646.8%

              \[\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 rewrites6.8%

            \[\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. sub-flipN/A

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

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

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

              \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\sin^{-1} \left(1 - x\right) \cdot \frac{1}{\frac{1}{2} \cdot \pi}}\right)\right) + 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            6. distribute-lft-neg-inN/A

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

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\sin^{-1} \left(1 - x\right)}\right), \frac{1}{\frac{1}{2} \cdot \pi}, 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            10. asin-neg-revN/A

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\sin^{-1} \left(x - 1\right), \frac{1}{\color{blue}{\frac{\pi}{2}}}, 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            18. div-flip-revN/A

              \[\leadsto \mathsf{fma}\left(\sin^{-1} \left(x - 1\right), \color{blue}{\frac{2}{\pi}}, 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            19. lower-/.f645.0%

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

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

        Alternative 3: 10.4% accurate, 0.1× speedup?

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

          \[\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--.f646.8%

            \[\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 rewrites6.8%

          \[\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.4%

            \[\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.4%

          \[\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-+.f64N/A

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

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

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

            \[\leadsto \frac{\mathsf{fma}\left(-\cos^{-1} \left(x - 1\right), \cos^{-1} \left(x - 1\right), \pi \cdot \pi\right)}{\pi + \left(\frac{\mathsf{PI}\left(\right)}{2} - \color{blue}{\sin^{-1} \left(x - 1\right)}\right)} \]
          5. associate-+r-N/A

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

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

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

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

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

        Alternative 4: 10.3% 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 6.8%

          \[\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--.f646.8%

            \[\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 rewrites6.8%

          \[\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.4%

            \[\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.4%

          \[\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.3% 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 6.8%

          \[\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.f646.8%

            \[\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 rewrites6.8%

          \[\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.3%

          \[\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: 10.3% accurate, 0.3× speedup?

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

          \[\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-flipN/A

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(1 + \frac{\frac{1}{2} \cdot \color{blue}{\pi}}{\mathsf{neg}\left(\sin^{-1} \left(1 - x\right)\right)}\right) \cdot \left(\mathsf{neg}\left(\sin^{-1} \left(1 - x\right)\right)\right) \]
          14. asin-neg-revN/A

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

            \[\leadsto \left(1 + \frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(\mathsf{neg}\left(\color{blue}{\left(1 - x\right)}\right)\right)}\right) \cdot \left(\mathsf{neg}\left(\sin^{-1} \left(1 - x\right)\right)\right) \]
          16. sub-negate-revN/A

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

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

            \[\leadsto \left(1 + \frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \color{blue}{\left(x - 1\right)}}\right) \cdot \left(\mathsf{neg}\left(\sin^{-1} \left(1 - x\right)\right)\right) \]
          19. asin-neg-revN/A

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

            \[\leadsto \left(1 + \frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(x - 1\right)}\right) \cdot \sin^{-1} \left(\mathsf{neg}\left(\color{blue}{\left(1 - x\right)}\right)\right) \]
          21. sub-negate-revN/A

            \[\leadsto \left(1 + \frac{\frac{1}{2} \cdot \pi}{\sin^{-1} \left(x - 1\right)}\right) \cdot \sin^{-1} \color{blue}{\left(x - 1\right)} \]
        3. Applied rewrites6.8%

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\pi, \frac{\frac{-1}{2}}{\mathsf{neg}\left(\color{blue}{\sin^{-1} \left(x - 1\right)}\right)}, 1\right) \cdot \sin^{-1} \left(x - 1\right) \]
          12. asin-neg-revN/A

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

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

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

            \[\leadsto \mathsf{fma}\left(\pi, \frac{\frac{-1}{2}}{\color{blue}{\sin^{-1} \left(1 - x\right)}}, 1\right) \cdot \sin^{-1} \left(x - 1\right) \]
          16. lower--.f6410.3%

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

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

        Alternative 7: 9.4% 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(\sin^{-1} \left(x - 1\right), \frac{2}{\pi}, 1\right) \cdot \left(0.5 \cdot \pi\right)\\ \end{array} \]
        (FPCore (x)
         :precision binary64
         (if (<= x 5.5e-17)
           (acos (- x))
           (* (fma (asin (- x 1.0)) (/ 2.0 PI) 1.0) (* 0.5 PI))))
        double code(double x) {
        	double tmp;
        	if (x <= 5.5e-17) {
        		tmp = acos(-x);
        	} else {
        		tmp = fma(asin((x - 1.0)), (2.0 / ((double) M_PI)), 1.0) * (0.5 * ((double) M_PI));
        	}
        	return tmp;
        }
        
        function code(x)
        	tmp = 0.0
        	if (x <= 5.5e-17)
        		tmp = acos(Float64(-x));
        	else
        		tmp = Float64(fma(asin(Float64(x - 1.0)), Float64(2.0 / pi), 1.0) * Float64(0.5 * pi));
        	end
        	return tmp
        end
        
        code[x_] := If[LessEqual[x, 5.5e-17], N[ArcCos[(-x)], $MachinePrecision], N[(N[(N[ArcSin[N[(x - 1.0), $MachinePrecision]], $MachinePrecision] * N[(2.0 / Pi), $MachinePrecision] + 1.0), $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}:\\
        \;\;\;\;\mathsf{fma}\left(\sin^{-1} \left(x - 1\right), \frac{2}{\pi}, 1\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 6.8%

            \[\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} \color{blue}{\left(-x\right)} \]

          if 5.5e-17 < x

          1. Initial program 6.8%

            \[\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.f646.8%

              \[\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 rewrites6.8%

            \[\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. sub-flipN/A

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

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

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

              \[\leadsto \left(\left(\mathsf{neg}\left(\color{blue}{\sin^{-1} \left(1 - x\right) \cdot \frac{1}{\frac{1}{2} \cdot \pi}}\right)\right) + 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            6. distribute-lft-neg-inN/A

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

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\sin^{-1} \left(1 - x\right)}\right), \frac{1}{\frac{1}{2} \cdot \pi}, 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            10. asin-neg-revN/A

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\sin^{-1} \left(x - 1\right), \frac{1}{\color{blue}{\frac{\pi}{2}}}, 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            18. div-flip-revN/A

              \[\leadsto \mathsf{fma}\left(\sin^{-1} \left(x - 1\right), \color{blue}{\frac{2}{\pi}}, 1\right) \cdot \left(\frac{1}{2} \cdot \pi\right) \]
            19. lower-/.f645.0%

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

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

        Alternative 8: 9.4% accurate, 0.5× speedup?

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

          1. Initial program 6.8%

            \[\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} \color{blue}{\left(-x\right)} \]

          if 5.5e-17 < x

          1. Initial program 6.8%

            \[\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--.f646.8%

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

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

        Alternative 9: 9.4% 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 6.8%

            \[\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} \color{blue}{\left(-x\right)} \]

          if 5.5e-17 < x

          1. Initial program 6.8%

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

          \[\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} \color{blue}{\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 6.8%

          \[\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 2025192 
          (FPCore (x)
            :name "bug323 (missed optimization)"
            :precision binary64
            :pre (and (<= 0.0 x) (<= x 0.5))
            (acos (- 1.0 x)))