?

Average Error: 59.6 → 58.7
Time: 21.5s
Precision: binary64
Cost: 161984

?

\[\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right) \]
\[\begin{array}{l} t_0 := \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\\ \frac{{t_0}^{6} \cdot -64 + 0.015625 \cdot {\pi}^{6}}{\mathsf{fma}\left(0.25, {\pi}^{2}, \mathsf{fma}\left({t_0}^{2}, 4, t_0 \cdot \pi\right)\right) \cdot \mathsf{fma}\left(-0.125, {\pi}^{3}, {t_0}^{3} \cdot -8\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 (acos (sqrt (fma -0.5 x 0.5)))))
   (/
    (+ (* (pow t_0 6.0) -64.0) (* 0.015625 (pow PI 6.0)))
    (*
     (fma 0.25 (pow PI 2.0) (fma (pow t_0 2.0) 4.0 (* t_0 PI)))
     (fma -0.125 (pow PI 3.0) (* (pow t_0 3.0) -8.0))))))
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 = acos(sqrt(fma(-0.5, x, 0.5)));
	return ((pow(t_0, 6.0) * -64.0) + (0.015625 * pow(((double) M_PI), 6.0))) / (fma(0.25, pow(((double) M_PI), 2.0), fma(pow(t_0, 2.0), 4.0, (t_0 * ((double) M_PI)))) * fma(-0.125, pow(((double) M_PI), 3.0), (pow(t_0, 3.0) * -8.0)));
}
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 = acos(sqrt(fma(-0.5, x, 0.5)))
	return Float64(Float64(Float64((t_0 ^ 6.0) * -64.0) + Float64(0.015625 * (pi ^ 6.0))) / Float64(fma(0.25, (pi ^ 2.0), fma((t_0 ^ 2.0), 4.0, Float64(t_0 * pi))) * fma(-0.125, (pi ^ 3.0), Float64((t_0 ^ 3.0) * -8.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]
code[x_] := Block[{t$95$0 = N[ArcCos[N[Sqrt[N[(-0.5 * x + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[Power[t$95$0, 6.0], $MachinePrecision] * -64.0), $MachinePrecision] + N[(0.015625 * N[Power[Pi, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(0.25 * N[Power[Pi, 2.0], $MachinePrecision] + N[(N[Power[t$95$0, 2.0], $MachinePrecision] * 4.0 + N[(t$95$0 * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.125 * N[Power[Pi, 3.0], $MachinePrecision] + N[(N[Power[t$95$0, 3.0], $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)
\begin{array}{l}
t_0 := \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\\
\frac{{t_0}^{6} \cdot -64 + 0.015625 \cdot {\pi}^{6}}{\mathsf{fma}\left(0.25, {\pi}^{2}, \mathsf{fma}\left({t_0}^{2}, 4, t_0 \cdot \pi\right)\right) \cdot \mathsf{fma}\left(-0.125, {\pi}^{3}, {t_0}^{3} \cdot -8\right)}
\end{array}

Error?

Target

Original59.6
Target0
Herbie58.7
\[\sin^{-1} x \]

Derivation?

  1. Initial program 59.6

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

    \[\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)} \]
  3. Taylor expanded in x around 0 58.7

    \[\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. Simplified58.7

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

    [Start]58.7

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

    *-commutative [<=]58.7

    \[ \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 [=>]58.7

    \[ \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 [=>]58.7

    \[ \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 [=>]58.7

    \[ \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 [=>]58.7

    \[ \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 [<=]58.7

    \[ \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 [<=]58.7

    \[ \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 [<=]58.7

    \[ \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 [=>]58.7

    \[ \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 [=>]58.7

    \[ \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 [<=]58.7

    \[ \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-rr58.7

    \[\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)}} \]
  6. Simplified58.7

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

    [Start]58.7

    \[ \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)} \]
  7. Applied egg-rr58.7

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

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

Alternatives

Alternative 1
Error58.7
Cost129600
\[\begin{array}{l} t_0 := \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\\ \frac{\sqrt[3]{0.25 \cdot {\pi}^{2} + {t_0}^{2} \cdot -4}}{\frac{\sqrt[3]{\mathsf{fma}\left(\pi, -0.5, t_0 \cdot -2\right)}}{{\left(\sqrt[3]{\mathsf{fma}\left(-0.5, \pi, t_0 \cdot 2\right)}\right)}^{2}}} \end{array} \]
Alternative 2
Error58.7
Cost45184
\[\log \left(e^{\mathsf{fma}\left(\pi, -0.5, \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right) \cdot 2\right)}\right) \]
Alternative 3
Error58.7
Cost19840
\[-0.5 \cdot \pi - -2 \cdot \cos^{-1} \left(\sqrt{0.5 + -0.5 \cdot x}\right) \]
Alternative 4
Error60.6
Cost19584
\[-0.5 \cdot \pi - -2 \cdot \cos^{-1} \left(\sqrt{0.5}\right) \]

Error

Reproduce?

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

  :herbie-target
  (asin x)

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