Ian Simplification

Percentage Accurate: 6.8% → 8.3%
Time: 5.8s
Alternatives: 6
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))
double code(double x) {
	return (((double) M_PI) / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
}
public static double code(double x) {
	return (Math.PI / 2.0) - (2.0 * Math.asin(Math.sqrt(((1.0 - x) / 2.0))));
}
def code(x):
	return (math.pi / 2.0) - (2.0 * math.asin(math.sqrt(((1.0 - x) / 2.0))))
function code(x)
	return Float64(Float64(pi / 2.0) - Float64(2.0 * asin(sqrt(Float64(Float64(1.0 - x) / 2.0)))))
end
function tmp = code(x)
	tmp = (pi / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
end
code[x_] := N[(N[(Pi / 2.0), $MachinePrecision] - N[(2.0 * N[ArcSin[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)
\end{array}

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 6 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?

\[\begin{array}{l} \\ \frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))
double code(double x) {
	return (((double) M_PI) / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
}
public static double code(double x) {
	return (Math.PI / 2.0) - (2.0 * Math.asin(Math.sqrt(((1.0 - x) / 2.0))));
}
def code(x):
	return (math.pi / 2.0) - (2.0 * math.asin(math.sqrt(((1.0 - x) / 2.0))))
function code(x)
	return Float64(Float64(pi / 2.0) - Float64(2.0 * asin(sqrt(Float64(Float64(1.0 - x) / 2.0)))))
end
function tmp = code(x)
	tmp = (pi / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
end
code[x_] := N[(N[(Pi / 2.0), $MachinePrecision] - N[(2.0 * N[ArcSin[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)
\end{array}

Alternative 1: 8.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \cos^{-1} \left(\frac{\sin \cos^{-1} x}{\sqrt{\mathsf{fma}\left(x, 2, 2\right)}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (-
  (acos (/ (sin (acos x)) (sqrt (fma x 2.0 2.0))))
  (asin (sqrt (/ (- 1.0 x) 2.0)))))
double code(double x) {
	return acos((sin(acos(x)) / sqrt(fma(x, 2.0, 2.0)))) - asin(sqrt(((1.0 - x) / 2.0)));
}
function code(x)
	return Float64(acos(Float64(sin(acos(x)) / sqrt(fma(x, 2.0, 2.0)))) - asin(sqrt(Float64(Float64(1.0 - x) / 2.0))))
end
code[x_] := N[(N[ArcCos[N[(N[Sin[N[ArcCos[x], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(x * 2.0 + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[ArcSin[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\cos^{-1} \left(\frac{\sin \cos^{-1} x}{\sqrt{\mathsf{fma}\left(x, 2, 2\right)}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)
\end{array}
Derivation
  1. Initial program 6.8%

    \[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
  2. Step-by-step derivation
    1. lift--.f64N/A

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)} - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    9. lower--.f64N/A

      \[\leadsto \color{blue}{\cos^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)} \]
    10. lower-acos.f646.8

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

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

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

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

      \[\leadsto \cos^{-1} \left(\sqrt{\frac{\color{blue}{1 - x}}{2}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    4. flip--N/A

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\sqrt{1 - \color{blue}{x \cdot x}}}{\sqrt{\left(x + 1\right) \cdot 2}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    16. sin-acos-revN/A

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

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

      \[\leadsto \cos^{-1} \left(\frac{\sin \color{blue}{\cos^{-1} x}}{\sqrt{\left(x + 1\right) \cdot 2}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    19. lower-sqrt.f648.3

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\sin \cos^{-1} x}{\sqrt{2 \cdot \color{blue}{\left(x + 1\right)}}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    23. distribute-rgt-inN/A

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

      \[\leadsto \cos^{-1} \left(\frac{\sin \cos^{-1} x}{\sqrt{x \cdot 2 + \color{blue}{2}}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    25. lower-fma.f648.3

      \[\leadsto \cos^{-1} \left(\frac{\sin \cos^{-1} x}{\sqrt{\color{blue}{\mathsf{fma}\left(x, 2, 2\right)}}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
  5. Applied rewrites8.3%

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

Alternative 2: 8.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \cos^{-1} \left(\frac{\sqrt{1 - x \cdot x}}{\sqrt{\mathsf{fma}\left(x, 2, 2\right)}}\right) - \sin^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (-
  (acos (/ (sqrt (- 1.0 (* x x))) (sqrt (fma x 2.0 2.0))))
  (asin (sqrt (fma -0.5 x 0.5)))))
double code(double x) {
	return acos((sqrt((1.0 - (x * x))) / sqrt(fma(x, 2.0, 2.0)))) - asin(sqrt(fma(-0.5, x, 0.5)));
}
function code(x)
	return Float64(acos(Float64(sqrt(Float64(1.0 - Float64(x * x))) / sqrt(fma(x, 2.0, 2.0)))) - asin(sqrt(fma(-0.5, x, 0.5))))
end
code[x_] := N[(N[ArcCos[N[(N[Sqrt[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(x * 2.0 + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[ArcSin[N[Sqrt[N[(-0.5 * x + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\cos^{-1} \left(\frac{\sqrt{1 - x \cdot x}}{\sqrt{\mathsf{fma}\left(x, 2, 2\right)}}\right) - \sin^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)
\end{array}
Derivation
  1. Initial program 6.8%

    \[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
  2. Step-by-step derivation
    1. lift--.f64N/A

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)} - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    9. lower--.f64N/A

      \[\leadsto \color{blue}{\cos^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)} \]
    10. lower-acos.f646.8

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

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

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

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

      \[\leadsto \cos^{-1} \left(\sqrt{\frac{\color{blue}{1 - x}}{2}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    4. flip--N/A

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\sqrt{1 - \color{blue}{x \cdot x}}}{\sqrt{\left(x + 1\right) \cdot 2}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    16. sin-acos-revN/A

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

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

      \[\leadsto \cos^{-1} \left(\frac{\sin \color{blue}{\cos^{-1} x}}{\sqrt{\left(x + 1\right) \cdot 2}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    19. lower-sqrt.f648.3

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

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

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

      \[\leadsto \cos^{-1} \left(\frac{\sin \cos^{-1} x}{\sqrt{2 \cdot \color{blue}{\left(x + 1\right)}}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    23. distribute-rgt-inN/A

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

      \[\leadsto \cos^{-1} \left(\frac{\sin \cos^{-1} x}{\sqrt{x \cdot 2 + \color{blue}{2}}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    25. lower-fma.f648.3

      \[\leadsto \cos^{-1} \left(\frac{\sin \cos^{-1} x}{\sqrt{\color{blue}{\mathsf{fma}\left(x, 2, 2\right)}}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
  5. Applied rewrites8.3%

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

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

      \[\leadsto \cos^{-1} \left(\frac{\sin \color{blue}{\cos^{-1} x}}{\sqrt{\mathsf{fma}\left(x, 2, 2\right)}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    3. sin-acosN/A

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

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

      \[\leadsto \cos^{-1} \left(\frac{\sqrt{\color{blue}{1 - x \cdot x}}}{\sqrt{\mathsf{fma}\left(x, 2, 2\right)}}\right) - \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
    6. lower-*.f648.3

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

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

    \[\leadsto \cos^{-1} \left(\frac{\sqrt{1 - x \cdot x}}{\sqrt{\mathsf{fma}\left(x, 2, 2\right)}}\right) - \sin^{-1} \left(\sqrt{\color{blue}{\frac{1}{2} + \frac{-1}{2} \cdot x}}\right) \]
  9. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \cos^{-1} \left(\frac{\sqrt{1 - x \cdot x}}{\sqrt{\mathsf{fma}\left(x, 2, 2\right)}}\right) - \sin^{-1} \left(\sqrt{\frac{-1}{2} \cdot x + \color{blue}{\frac{1}{2}}}\right) \]
    2. lower-fma.f648.3

      \[\leadsto \cos^{-1} \left(\frac{\sqrt{1 - x \cdot x}}{\sqrt{\mathsf{fma}\left(x, 2, 2\right)}}\right) - \sin^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, \color{blue}{x}, 0.5\right)}\right) \]
  10. Applied rewrites8.3%

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

Alternative 3: 8.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \frac{\pi}{2} - 2 \cdot \left(\frac{\pi}{2} - \cos^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (- (/ PI 2.0) (* 2.0 (- (/ PI 2.0) (acos (sqrt (/ (- 1.0 x) 2.0)))))))
double code(double x) {
	return (((double) M_PI) / 2.0) - (2.0 * ((((double) M_PI) / 2.0) - acos(sqrt(((1.0 - x) / 2.0)))));
}
public static double code(double x) {
	return (Math.PI / 2.0) - (2.0 * ((Math.PI / 2.0) - Math.acos(Math.sqrt(((1.0 - x) / 2.0)))));
}
def code(x):
	return (math.pi / 2.0) - (2.0 * ((math.pi / 2.0) - math.acos(math.sqrt(((1.0 - x) / 2.0)))))
function code(x)
	return Float64(Float64(pi / 2.0) - Float64(2.0 * Float64(Float64(pi / 2.0) - acos(sqrt(Float64(Float64(1.0 - x) / 2.0))))))
end
function tmp = code(x)
	tmp = (pi / 2.0) - (2.0 * ((pi / 2.0) - acos(sqrt(((1.0 - x) / 2.0)))));
end
code[x_] := N[(N[(Pi / 2.0), $MachinePrecision] - N[(2.0 * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcCos[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\pi}{2} - 2 \cdot \left(\frac{\pi}{2} - \cos^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)\right)
\end{array}
Derivation
  1. Initial program 6.8%

    \[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
  2. Step-by-step derivation
    1. lift-asin.f64N/A

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

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

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

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

      \[\leadsto \frac{\pi}{2} - 2 \cdot \color{blue}{\left(\frac{\pi}{2} - \cos^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)\right)} \]
    6. lower-acos.f648.3

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

    \[\leadsto \frac{\pi}{2} - 2 \cdot \color{blue}{\left(\frac{\pi}{2} - \cos^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)\right)} \]
  4. Add Preprocessing

Alternative 4: 6.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\sin^{-1} \left(\frac{\sqrt{1 - x}}{\sqrt{2}}\right), -2, \frac{\pi}{2}\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (fma (asin (/ (sqrt (- 1.0 x)) (sqrt 2.0))) -2.0 (/ PI 2.0)))
double code(double x) {
	return fma(asin((sqrt((1.0 - x)) / sqrt(2.0))), -2.0, (((double) M_PI) / 2.0));
}
function code(x)
	return fma(asin(Float64(sqrt(Float64(1.0 - x)) / sqrt(2.0))), -2.0, Float64(pi / 2.0))
end
code[x_] := N[(N[ArcSin[N[(N[Sqrt[N[(1.0 - x), $MachinePrecision]], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -2.0 + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\sin^{-1} \left(\frac{\sqrt{1 - x}}{\sqrt{2}}\right), -2, \frac{\pi}{2}\right)
\end{array}
Derivation
  1. Initial program 6.8%

    \[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
  2. Step-by-step derivation
    1. lift--.f64N/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right), \mathsf{neg}\left(2\right), \frac{\pi}{2}\right)} \]
    8. metadata-eval6.8

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\sin^{-1} \left(\frac{\color{blue}{\sqrt{1 - x}}}{\sqrt{2}}\right), -2, \frac{\pi}{2}\right) \]
    6. lower-sqrt.f646.7

      \[\leadsto \mathsf{fma}\left(\sin^{-1} \left(\frac{\sqrt{1 - x}}{\color{blue}{\sqrt{2}}}\right), -2, \frac{\pi}{2}\right) \]
  5. Applied rewrites6.7%

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

Alternative 5: 6.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\sin^{-1} \left(\sqrt{0.5 \cdot \left(1 - x\right)}\right), -2, \pi \cdot 0.5\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (fma (asin (sqrt (* 0.5 (- 1.0 x)))) -2.0 (* PI 0.5)))
double code(double x) {
	return fma(asin(sqrt((0.5 * (1.0 - x)))), -2.0, (((double) M_PI) * 0.5));
}
function code(x)
	return fma(asin(sqrt(Float64(0.5 * Float64(1.0 - x)))), -2.0, Float64(pi * 0.5))
end
code[x_] := N[(N[ArcSin[N[Sqrt[N[(0.5 * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * -2.0 + N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\sin^{-1} \left(\sqrt{0.5 \cdot \left(1 - x\right)}\right), -2, \pi \cdot 0.5\right)
\end{array}
Derivation
  1. Initial program 6.8%

    \[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
  2. Step-by-step derivation
    1. lift--.f64N/A

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

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

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

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

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

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

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

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

      \[\leadsto \frac{{\left(\frac{\pi}{2}\right)}^{3} - {\sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)}^{3} \cdot \color{blue}{{2}^{3}}}{\mathsf{fma}\left(\sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \cdot 2, \mathsf{fma}\left(\sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right), 2, \frac{\pi}{2}\right), {\left(\frac{\pi}{2}\right)}^{2}\right)} \]
    6. unpow-prod-downN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right), 2, \frac{\pi}{2}\right), \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \cdot 2, {\left(\frac{\pi}{2}\right)}^{2}\right) \cdot \mathsf{fma}\left(-2, \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right), \frac{\pi}{2}\right)}{\mathsf{fma}\left(\sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \cdot 2, \mathsf{fma}\left(\sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right), 2, \frac{\pi}{2}\right), \frac{\color{blue}{\pi \cdot \pi}}{2 \cdot 2}\right)} \]
    12. metadata-eval6.8

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right), 2, \frac{\pi}{2}\right), \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \cdot 2, {\left(\frac{\pi}{2}\right)}^{2}\right) \cdot \mathsf{fma}\left(-2, \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right), \frac{\pi}{2}\right)}{\mathsf{fma}\left(\sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \cdot 2, \mathsf{fma}\left(\sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right), 2, \frac{\pi}{2}\right), \frac{\pi \cdot \pi}{\color{blue}{4}}\right)} \]
  7. Applied rewrites6.8%

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

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

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

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

Alternative 6: 4.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\sin^{-1} \left(\sqrt{0.5}\right), -2, \frac{\pi}{2}\right) \end{array} \]
(FPCore (x) :precision binary64 (fma (asin (sqrt 0.5)) -2.0 (/ PI 2.0)))
double code(double x) {
	return fma(asin(sqrt(0.5)), -2.0, (((double) M_PI) / 2.0));
}
function code(x)
	return fma(asin(sqrt(0.5)), -2.0, Float64(pi / 2.0))
end
code[x_] := N[(N[ArcSin[N[Sqrt[0.5], $MachinePrecision]], $MachinePrecision] * -2.0 + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
  2. Step-by-step derivation
    1. lift--.f64N/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right), \mathsf{neg}\left(2\right), \frac{\pi}{2}\right)} \]
    8. metadata-eval6.8

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

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

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

      \[\leadsto \mathsf{fma}\left(\sin^{-1} \left(\sqrt{\frac{\color{blue}{1 - x}}{2}}\right), -2, \frac{\pi}{2}\right) \]
    3. flip--N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\sin^{-1} \left(\sqrt{\frac{1 - x \cdot x}{x \cdot 2 + \color{blue}{2}}}\right), -2, \frac{\pi}{2}\right) \]
    17. lower-fma.f646.8

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

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

    \[\leadsto \mathsf{fma}\left(\sin^{-1} \left(\sqrt{\color{blue}{\frac{1}{2}}}\right), -2, \frac{\pi}{2}\right) \]
  7. Step-by-step derivation
    1. Applied rewrites4.1%

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

    Developer Target 1: 100.0% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \sin^{-1} x \end{array} \]
    (FPCore (x) :precision binary64 (asin x))
    double code(double x) {
    	return asin(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 = asin(x)
    end function
    
    public static double code(double x) {
    	return Math.asin(x);
    }
    
    def code(x):
    	return math.asin(x)
    
    function code(x)
    	return asin(x)
    end
    
    function tmp = code(x)
    	tmp = asin(x);
    end
    
    code[x_] := N[ArcSin[x], $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \sin^{-1} x
    \end{array}
    

    Reproduce

    ?
    herbie shell --seed 2025106 
    (FPCore (x)
      :name "Ian Simplification"
      :precision binary64
    
      :alt
      (! :herbie-platform default (asin x))
    
      (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))