?

Average Accuracy: 6.7% → 8.2%
Time: 27.7s
Precision: binary64
Cost: 175744

?

\[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
\[\begin{array}{l} t_0 := -0.125 \cdot {\pi}^{3}\\ t_1 := \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\\ t_2 := t_1 \cdot -2\\ t_3 := {t_1}^{3} \cdot -8\\ \frac{{t_0}^{2} - t_3 \cdot t_3}{\left(0.25 \cdot {\pi}^{2} + t_2 \cdot \mathsf{fma}\left(\pi, -0.5, t_2\right)\right) \cdot \left(t_0 + t_3\right)} \end{array} \]
(FPCore (x)
 :precision binary64
 (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* -0.125 (pow PI 3.0)))
        (t_1 (acos (sqrt (fma -0.5 x 0.5))))
        (t_2 (* t_1 -2.0))
        (t_3 (* (pow t_1 3.0) -8.0)))
   (/
    (- (pow t_0 2.0) (* t_3 t_3))
    (* (+ (* 0.25 (pow PI 2.0)) (* t_2 (fma PI -0.5 t_2))) (+ t_0 t_3)))))
double code(double x) {
	return (((double) M_PI) / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
}
double code(double x) {
	double t_0 = -0.125 * pow(((double) M_PI), 3.0);
	double t_1 = acos(sqrt(fma(-0.5, x, 0.5)));
	double t_2 = t_1 * -2.0;
	double t_3 = pow(t_1, 3.0) * -8.0;
	return (pow(t_0, 2.0) - (t_3 * t_3)) / (((0.25 * pow(((double) M_PI), 2.0)) + (t_2 * fma(((double) M_PI), -0.5, t_2))) * (t_0 + t_3));
}
function code(x)
	return Float64(Float64(pi / 2.0) - Float64(2.0 * asin(sqrt(Float64(Float64(1.0 - x) / 2.0)))))
end
function code(x)
	t_0 = Float64(-0.125 * (pi ^ 3.0))
	t_1 = acos(sqrt(fma(-0.5, x, 0.5)))
	t_2 = Float64(t_1 * -2.0)
	t_3 = Float64((t_1 ^ 3.0) * -8.0)
	return Float64(Float64((t_0 ^ 2.0) - Float64(t_3 * t_3)) / Float64(Float64(Float64(0.25 * (pi ^ 2.0)) + Float64(t_2 * fma(pi, -0.5, t_2))) * Float64(t_0 + t_3)))
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]
code[x_] := Block[{t$95$0 = N[(-0.125 * N[Power[Pi, 3.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcCos[N[Sqrt[N[(-0.5 * x + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * -2.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[t$95$1, 3.0], $MachinePrecision] * -8.0), $MachinePrecision]}, N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(0.25 * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * N[(Pi * -0.5 + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)
\begin{array}{l}
t_0 := -0.125 \cdot {\pi}^{3}\\
t_1 := \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\\
t_2 := t_1 \cdot -2\\
t_3 := {t_1}^{3} \cdot -8\\
\frac{{t_0}^{2} - t_3 \cdot t_3}{\left(0.25 \cdot {\pi}^{2} + t_2 \cdot \mathsf{fma}\left(\pi, -0.5, t_2\right)\right) \cdot \left(t_0 + t_3\right)}
\end{array}

Error?

Target

Original6.7%
Target100.0%
Herbie8.2%
\[\sin^{-1} x \]

Derivation?

  1. Initial program 6.7%

    \[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
  2. Applied egg-rr8.2%

    \[\leadsto \frac{\pi}{2} - 2 \cdot \color{blue}{\left(\pi \cdot 0.5 - \cos^{-1} \left(\sqrt{0.5 - x \cdot 0.5}\right)\right)} \]
    Proof

    [Start]6.7

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

    asin-acos [=>]8.2

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

    div-inv [=>]8.2

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

    metadata-eval [=>]8.2

    \[ \frac{\pi}{2} - 2 \cdot \left(\pi \cdot \color{blue}{0.5} - \cos^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)\right) \]

    div-sub [=>]8.2

    \[ \frac{\pi}{2} - 2 \cdot \left(\pi \cdot 0.5 - \cos^{-1} \left(\sqrt{\color{blue}{\frac{1}{2} - \frac{x}{2}}}\right)\right) \]

    metadata-eval [=>]8.2

    \[ \frac{\pi}{2} - 2 \cdot \left(\pi \cdot 0.5 - \cos^{-1} \left(\sqrt{\color{blue}{0.5} - \frac{x}{2}}\right)\right) \]

    div-inv [=>]8.2

    \[ \frac{\pi}{2} - 2 \cdot \left(\pi \cdot 0.5 - \cos^{-1} \left(\sqrt{0.5 - \color{blue}{x \cdot \frac{1}{2}}}\right)\right) \]

    metadata-eval [=>]8.2

    \[ \frac{\pi}{2} - 2 \cdot \left(\pi \cdot 0.5 - \cos^{-1} \left(\sqrt{0.5 - x \cdot \color{blue}{0.5}}\right)\right) \]
  3. Taylor expanded in x around 0 8.2%

    \[\leadsto \color{blue}{0.5 \cdot \pi - 2 \cdot \left(0.5 \cdot \pi - \cos^{-1} \left(\sqrt{0.5 - 0.5 \cdot x}\right)\right)} \]
  4. Simplified8.2%

    \[\leadsto \color{blue}{\pi \cdot -0.5 - -2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)} \]
    Proof

    [Start]8.2

    \[ 0.5 \cdot \pi - 2 \cdot \left(0.5 \cdot \pi - \cos^{-1} \left(\sqrt{0.5 - 0.5 \cdot x}\right)\right) \]

    *-commutative [<=]8.2

    \[ \color{blue}{\pi \cdot 0.5} - 2 \cdot \left(0.5 \cdot \pi - \cos^{-1} \left(\sqrt{0.5 - 0.5 \cdot x}\right)\right) \]

    cancel-sign-sub-inv [=>]8.2

    \[ \pi \cdot 0.5 - 2 \cdot \left(0.5 \cdot \pi - \cos^{-1} \left(\sqrt{\color{blue}{0.5 + \left(-0.5\right) \cdot x}}\right)\right) \]

    metadata-eval [=>]8.2

    \[ \pi \cdot 0.5 - 2 \cdot \left(0.5 \cdot \pi - \cos^{-1} \left(\sqrt{0.5 + \color{blue}{-0.5} \cdot x}\right)\right) \]

    cancel-sign-sub-inv [=>]8.2

    \[ \color{blue}{\pi \cdot 0.5 + \left(-2\right) \cdot \left(0.5 \cdot \pi - \cos^{-1} \left(\sqrt{0.5 + -0.5 \cdot x}\right)\right)} \]

    metadata-eval [=>]8.2

    \[ \pi \cdot 0.5 + \color{blue}{-2} \cdot \left(0.5 \cdot \pi - \cos^{-1} \left(\sqrt{0.5 + -0.5 \cdot x}\right)\right) \]

    *-commutative [<=]8.2

    \[ \pi \cdot 0.5 + -2 \cdot \left(\color{blue}{\pi \cdot 0.5} - \cos^{-1} \left(\sqrt{0.5 + -0.5 \cdot x}\right)\right) \]

    metadata-eval [<=]8.2

    \[ \pi \cdot 0.5 + -2 \cdot \left(\pi \cdot 0.5 - \cos^{-1} \left(\sqrt{0.5 + \color{blue}{\left(-0.5\right)} \cdot x}\right)\right) \]

    cancel-sign-sub-inv [<=]8.2

    \[ \pi \cdot 0.5 + -2 \cdot \left(\pi \cdot 0.5 - \cos^{-1} \left(\sqrt{\color{blue}{0.5 - 0.5 \cdot x}}\right)\right) \]

    cancel-sign-sub-inv [=>]8.2

    \[ \pi \cdot 0.5 + -2 \cdot \left(\pi \cdot 0.5 - \cos^{-1} \left(\sqrt{\color{blue}{0.5 + \left(-0.5\right) \cdot x}}\right)\right) \]

    metadata-eval [=>]8.2

    \[ \pi \cdot 0.5 + -2 \cdot \left(\pi \cdot 0.5 - \cos^{-1} \left(\sqrt{0.5 + \color{blue}{-0.5} \cdot x}\right)\right) \]

    *-commutative [<=]8.2

    \[ \pi \cdot 0.5 + -2 \cdot \left(\pi \cdot 0.5 - \cos^{-1} \left(\sqrt{0.5 + \color{blue}{x \cdot -0.5}}\right)\right) \]
  5. Applied egg-rr8.2%

    \[\leadsto \color{blue}{\frac{\left(-0.125 \cdot {\pi}^{3}\right) \cdot \left(-0.125 \cdot {\pi}^{3}\right) - \left({\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right) \cdot \left({\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right)}{\left(0.25 \cdot {\pi}^{2} + \left(-2 \cdot \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\right) \cdot \mathsf{fma}\left(\pi, -0.5, -2 \cdot \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\right)\right) \cdot \left(-0.125 \cdot {\pi}^{3} + {\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right)}} \]
    Proof

    [Start]8.2

    \[ \pi \cdot -0.5 - -2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right) \]

    flip3-- [=>]8.2

    \[ \color{blue}{\frac{{\left(\pi \cdot -0.5\right)}^{3} - {\left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right)}^{3}}{\left(\pi \cdot -0.5\right) \cdot \left(\pi \cdot -0.5\right) + \left(\left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right) \cdot \left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right) + \left(\pi \cdot -0.5\right) \cdot \left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right)\right)}} \]

    flip-- [=>]8.2

    \[ \frac{\color{blue}{\frac{{\left(\pi \cdot -0.5\right)}^{3} \cdot {\left(\pi \cdot -0.5\right)}^{3} - {\left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right)}^{3} \cdot {\left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right)}^{3}}{{\left(\pi \cdot -0.5\right)}^{3} + {\left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right)}^{3}}}}{\left(\pi \cdot -0.5\right) \cdot \left(\pi \cdot -0.5\right) + \left(\left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right) \cdot \left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right) + \left(\pi \cdot -0.5\right) \cdot \left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right)\right)} \]

    associate-/l/ [=>]8.2

    \[ \color{blue}{\frac{{\left(\pi \cdot -0.5\right)}^{3} \cdot {\left(\pi \cdot -0.5\right)}^{3} - {\left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right)}^{3} \cdot {\left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right)}^{3}}{\left(\left(\pi \cdot -0.5\right) \cdot \left(\pi \cdot -0.5\right) + \left(\left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right) \cdot \left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right) + \left(\pi \cdot -0.5\right) \cdot \left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right)\right)\right) \cdot \left({\left(\pi \cdot -0.5\right)}^{3} + {\left(-2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)\right)}^{3}\right)}} \]
  6. Applied egg-rr8.2%

    \[\leadsto \frac{\color{blue}{{\left(-0.125 \cdot {\pi}^{3}\right)}^{2}} - \left({\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right) \cdot \left({\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right)}{\left(0.25 \cdot {\pi}^{2} + \left(-2 \cdot \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\right) \cdot \mathsf{fma}\left(\pi, -0.5, -2 \cdot \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\right)\right) \cdot \left(-0.125 \cdot {\pi}^{3} + {\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right)} \]
    Proof

    [Start]8.2

    \[ \frac{\left(-0.125 \cdot {\pi}^{3}\right) \cdot \left(-0.125 \cdot {\pi}^{3}\right) - \left({\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right) \cdot \left({\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right)}{\left(0.25 \cdot {\pi}^{2} + \left(-2 \cdot \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\right) \cdot \mathsf{fma}\left(\pi, -0.5, -2 \cdot \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\right)\right) \cdot \left(-0.125 \cdot {\pi}^{3} + {\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right)} \]

    pow2 [=>]8.2

    \[ \frac{\color{blue}{{\left(-0.125 \cdot {\pi}^{3}\right)}^{2}} - \left({\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right) \cdot \left({\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right)}{\left(0.25 \cdot {\pi}^{2} + \left(-2 \cdot \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\right) \cdot \mathsf{fma}\left(\pi, -0.5, -2 \cdot \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\right)\right) \cdot \left(-0.125 \cdot {\pi}^{3} + {\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right)} \]
  7. Final simplification8.2%

    \[\leadsto \frac{{\left(-0.125 \cdot {\pi}^{3}\right)}^{2} - \left({\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right) \cdot \left({\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right)}{\left(0.25 \cdot {\pi}^{2} + \left(\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right) \cdot -2\right) \cdot \mathsf{fma}\left(\pi, -0.5, \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right) \cdot -2\right)\right) \cdot \left(-0.125 \cdot {\pi}^{3} + {\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{3} \cdot -8\right)} \]

Alternatives

Alternative 1
Accuracy8.2%
Cost149696
\[\begin{array}{l} t_0 := 0.25 \cdot {\pi}^{2}\\ t_1 := \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\\ t_2 := {t_1}^{2} \cdot 4\\ \frac{t_0 \cdot t_0 - t_2 \cdot t_2}{\mathsf{fma}\left(\pi, -0.5, t_1 \cdot -2\right) \cdot \left(t_0 + t_2\right)} \end{array} \]
Alternative 2
Accuracy8.2%
Cost19840
\[\pi \cdot -0.5 + 2 \cdot \cos^{-1} \left(\sqrt{0.5 + -0.5 \cdot x}\right) \]
Alternative 3
Accuracy5.4%
Cost19584
\[\pi \cdot -0.5 + 2 \cdot \cos^{-1} \left(\sqrt{0.5}\right) \]

Error

Reproduce?

herbie shell --seed 2023133 
(FPCore (x)
  :name "Ian Simplification"
  :precision binary64

  :herbie-target
  (asin x)

  (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))