| Alternative 1 | |
|---|---|
| Accuracy | 8.6% |
| Cost | 32640 |
\[\frac{1}{\frac{1}{\mathsf{fma}\left(\pi, -0.5, 2 \cdot \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\right)}}
\]
(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)))))
(/
(+ (* 0.25 (pow PI 2.0)) (* (pow t_0 2.0) -4.0))
(+ (* PI -0.5) (* t_0 -2.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 ((0.25 * pow(((double) M_PI), 2.0)) + (pow(t_0, 2.0) * -4.0)) / ((((double) M_PI) * -0.5) + (t_0 * -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 code(x) t_0 = acos(sqrt(fma(-0.5, x, 0.5))) return Float64(Float64(Float64(0.25 * (pi ^ 2.0)) + Float64((t_0 ^ 2.0) * -4.0)) / Float64(Float64(pi * -0.5) + Float64(t_0 * -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]
code[x_] := Block[{t$95$0 = N[ArcCos[N[Sqrt[N[(-0.5 * x + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(0.25 * N[Power[Pi, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[t$95$0, 2.0], $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] / N[(N[(Pi * -0.5), $MachinePrecision] + N[(t$95$0 * -2.0), $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{0.25 \cdot {\pi}^{2} + {t_0}^{2} \cdot -4}{\pi \cdot -0.5 + t_0 \cdot -2}
\end{array}
| Original | 7.1% |
|---|---|
| Target | 100.0% |
| Herbie | 8.6% |
Initial program 7.1%
Applied egg-rr8.6%
[Start]7.1 | \[ \frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)
\] |
|---|---|
asin-acos [=>]8.6 | \[ \frac{\pi}{2} - 2 \cdot \color{blue}{\left(\frac{\pi}{2} - \cos^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)\right)}
\] |
div-inv [=>]8.6 | \[ \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.6 | \[ \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.6 | \[ \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.6 | \[ \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.6 | \[ \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.6 | \[ \frac{\pi}{2} - 2 \cdot \left(\pi \cdot 0.5 - \cos^{-1} \left(\sqrt{0.5 - x \cdot \color{blue}{0.5}}\right)\right)
\] |
Taylor expanded in x around 0 8.6%
Simplified8.6%
[Start]8.6 | \[ 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.6 | \[ \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.6 | \[ \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.6 | \[ \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.6 | \[ \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.6 | \[ \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.6 | \[ \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.6 | \[ \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.6 | \[ \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.6 | \[ \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.6 | \[ \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.6 | \[ \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)
\] |
Applied egg-rr8.6%
[Start]8.6 | \[ \pi \cdot -0.5 - -2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)
\] |
|---|---|
flip-- [=>]8.6 | \[ \color{blue}{\frac{\left(\pi \cdot -0.5\right) \cdot \left(\pi \cdot -0.5\right) - \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)}{\pi \cdot -0.5 + -2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)}}
\] |
div-inv [=>]8.6 | \[ \color{blue}{\left(\left(\pi \cdot -0.5\right) \cdot \left(\pi \cdot -0.5\right) - \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)\right) \cdot \frac{1}{\pi \cdot -0.5 + -2 \cdot \cos^{-1} \left(\sqrt{0.5 + x \cdot -0.5}\right)}}
\] |
Simplified8.6%
[Start]8.6 | \[ \left(0.25 \cdot {\pi}^{2} - {\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{2} \cdot 4\right) \cdot \frac{1}{\mathsf{fma}\left(\pi, -0.5, -2 \cdot \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\right)}
\] |
|---|---|
associate-*r/ [=>]8.6 | \[ \color{blue}{\frac{\left(0.25 \cdot {\pi}^{2} - {\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{2} \cdot 4\right) \cdot 1}{\mathsf{fma}\left(\pi, -0.5, -2 \cdot \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\right)}}
\] |
*-rgt-identity [=>]8.6 | \[ \frac{\color{blue}{0.25 \cdot {\pi}^{2} - {\cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)}^{2} \cdot 4}}{\mathsf{fma}\left(\pi, -0.5, -2 \cdot \cos^{-1} \left(\sqrt{\mathsf{fma}\left(-0.5, x, 0.5\right)}\right)\right)}
\] |
Taylor expanded in x around 0 8.6%
Final simplification8.6%
| Alternative 1 | |
|---|---|
| Accuracy | 8.6% |
| Cost | 32640 |
| Alternative 2 | |
|---|---|
| Accuracy | 8.6% |
| Cost | 19840 |
| Alternative 3 | |
|---|---|
| Accuracy | 5.4% |
| Cost | 19584 |
herbie shell --seed 2023135
(FPCore (x)
:name "Ian Simplification"
:precision binary64
:herbie-target
(asin x)
(- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))