Average Error: 59.4 → 0.7
Time: 50.8s
Precision: 64
Internal Precision: 2880
${2}^{n} \cdot \sqrt{2 \cdot \left(1 - \sqrt{1 - {\left(\frac{n}{{2}^{n}}\right)}^{2}}\right)}$
$\begin{array}{l} \mathbf{if}\;n \le -3.65775609935114 \cdot 10^{-310}:\\ \;\;\;\;\frac{\sqrt{2} \cdot \left(-n\right)}{\sqrt{\sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}} + 1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{2} \cdot n}{\sqrt{\sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}} + 1}}\\ \end{array}$

# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if n < -3.65775609935114e-310

1. Initial program 59.4

${2}^{n} \cdot \sqrt{2 \cdot \left(1 - \sqrt{1 - {\left(\frac{n}{{2}^{n}}\right)}^{2}}\right)}$
2. Initial simplification59.4

$\leadsto \sqrt{2 \cdot \left(1 - \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}\right)} \cdot {2}^{n}$
3. Using strategy rm
4. Applied flip--59.4

$\leadsto \sqrt{2 \cdot \color{blue}{\frac{1 \cdot 1 - \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}} \cdot \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}} \cdot {2}^{n}$
5. Applied associate-*r/59.4

$\leadsto \sqrt{\color{blue}{\frac{2 \cdot \left(1 \cdot 1 - \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}} \cdot \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}\right)}{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}} \cdot {2}^{n}$
6. Applied sqrt-div59.4

$\leadsto \color{blue}{\frac{\sqrt{2 \cdot \left(1 \cdot 1 - \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}} \cdot \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}\right)}}{\sqrt{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}} \cdot {2}^{n}$
7. Applied associate-*l/59.4

$\leadsto \color{blue}{\frac{\sqrt{2 \cdot \left(1 \cdot 1 - \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}} \cdot \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}\right)} \cdot {2}^{n}}{\sqrt{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}}$
8. Simplified28.7

$\leadsto \frac{\color{blue}{\sqrt{\frac{\frac{n \cdot 2}{{2}^{n}}}{\frac{{2}^{n}}{n}}} \cdot {2}^{n}}}{\sqrt{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}$
9. Taylor expanded around -inf 0.2

$\leadsto \frac{\color{blue}{-1 \cdot \left(n \cdot \sqrt{2}\right)}}{\sqrt{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}$
10. Simplified0.2

$\leadsto \frac{\color{blue}{\left(-n\right) \cdot \sqrt{2}}}{\sqrt{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}$

## if -3.65775609935114e-310 < n

1. Initial program 59.4

${2}^{n} \cdot \sqrt{2 \cdot \left(1 - \sqrt{1 - {\left(\frac{n}{{2}^{n}}\right)}^{2}}\right)}$
2. Initial simplification59.4

$\leadsto \sqrt{2 \cdot \left(1 - \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}\right)} \cdot {2}^{n}$
3. Using strategy rm
4. Applied flip--59.4

$\leadsto \sqrt{2 \cdot \color{blue}{\frac{1 \cdot 1 - \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}} \cdot \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}} \cdot {2}^{n}$
5. Applied associate-*r/59.4

$\leadsto \sqrt{\color{blue}{\frac{2 \cdot \left(1 \cdot 1 - \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}} \cdot \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}\right)}{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}} \cdot {2}^{n}$
6. Applied sqrt-div59.4

$\leadsto \color{blue}{\frac{\sqrt{2 \cdot \left(1 \cdot 1 - \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}} \cdot \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}\right)}}{\sqrt{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}} \cdot {2}^{n}$
7. Applied associate-*l/59.4

$\leadsto \color{blue}{\frac{\sqrt{2 \cdot \left(1 \cdot 1 - \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}} \cdot \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}\right)} \cdot {2}^{n}}{\sqrt{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}}$
8. Simplified30.1

$\leadsto \frac{\color{blue}{\sqrt{\frac{\frac{n \cdot 2}{{2}^{n}}}{\frac{{2}^{n}}{n}}} \cdot {2}^{n}}}{\sqrt{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}$
9. Taylor expanded around inf 1.2

$\leadsto \frac{\color{blue}{n \cdot \sqrt{2}}}{\sqrt{1 + \sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}}}}$
3. Recombined 2 regimes into one program.
4. Final simplification0.7

$\leadsto \begin{array}{l} \mathbf{if}\;n \le -3.65775609935114 \cdot 10^{-310}:\\ \;\;\;\;\frac{\sqrt{2} \cdot \left(-n\right)}{\sqrt{\sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}} + 1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{2} \cdot n}{\sqrt{\sqrt{1 - \frac{n}{{2}^{n}} \cdot \frac{n}{{2}^{n}}} + 1}}\\ \end{array}$

# Runtime

Time bar (total: 50.8s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)'
(FPCore (n)
:name "2^n*sqrt(2(1-sqrt(1-(n/2^n)^2)))"
(* (pow 2 n) (sqrt (* 2 (- 1 (sqrt (- 1 (pow (/ n (pow 2 n)) 2))))))))