Average Error: 33.5 → 22.4
Time: 19.1s
Precision: 64
$1 - {\left(1 - x\right)}^{n}$
$\begin{array}{l} \mathbf{if}\;n \le -5.704806257884767907049421399438379710004 \cdot 10^{-269}:\\ \;\;\;\;\frac{\frac{{1}^{4} - {\left(1 - x\right)}^{\left(4 \cdot n\right)}}{1 \cdot 1 + {\left(1 - x\right)}^{\left(2 \cdot n\right)}}}{1 + {\left(1 - x\right)}^{n}}\\ \mathbf{elif}\;n \le 1.963192683363803761764622454271784231656 \cdot 10^{142}:\\ \;\;\;\;1 \cdot \left(x \cdot n\right) - \left(0.5 \cdot \left({n}^{2} \cdot {\left(\log 1\right)}^{2}\right) + 1 \cdot \left(n \cdot \log 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 - {\left(-x\right)}^{n}\\ \end{array}$
1 - {\left(1 - x\right)}^{n}
\begin{array}{l}
\mathbf{if}\;n \le -5.704806257884767907049421399438379710004 \cdot 10^{-269}:\\
\;\;\;\;\frac{\frac{{1}^{4} - {\left(1 - x\right)}^{\left(4 \cdot n\right)}}{1 \cdot 1 + {\left(1 - x\right)}^{\left(2 \cdot n\right)}}}{1 + {\left(1 - x\right)}^{n}}\\

\mathbf{elif}\;n \le 1.963192683363803761764622454271784231656 \cdot 10^{142}:\\
\;\;\;\;1 \cdot \left(x \cdot n\right) - \left(0.5 \cdot \left({n}^{2} \cdot {\left(\log 1\right)}^{2}\right) + 1 \cdot \left(n \cdot \log 1\right)\right)\\

\mathbf{else}:\\
\;\;\;\;1 - {\left(-x\right)}^{n}\\

\end{array}
double f(double x, double n) {
double r592163 = 1.0;
double r592164 = x;
double r592165 = r592163 - r592164;
double r592166 = n;
double r592167 = pow(r592165, r592166);
double r592168 = r592163 - r592167;
return r592168;
}


double f(double x, double n) {
double r592169 = n;
double r592170 = -5.704806257884768e-269;
bool r592171 = r592169 <= r592170;
double r592172 = 1.0;
double r592173 = 4.0;
double r592174 = pow(r592172, r592173);
double r592175 = x;
double r592176 = r592172 - r592175;
double r592177 = r592173 * r592169;
double r592178 = pow(r592176, r592177);
double r592179 = r592174 - r592178;
double r592180 = r592172 * r592172;
double r592181 = 2.0;
double r592182 = r592181 * r592169;
double r592183 = pow(r592176, r592182);
double r592184 = r592180 + r592183;
double r592185 = r592179 / r592184;
double r592186 = pow(r592176, r592169);
double r592187 = r592172 + r592186;
double r592188 = r592185 / r592187;
double r592189 = 1.9631926833638038e+142;
bool r592190 = r592169 <= r592189;
double r592191 = r592175 * r592169;
double r592192 = r592172 * r592191;
double r592193 = 0.5;
double r592194 = pow(r592169, r592181);
double r592195 = log(r592172);
double r592196 = pow(r592195, r592181);
double r592197 = r592194 * r592196;
double r592198 = r592193 * r592197;
double r592199 = r592169 * r592195;
double r592200 = r592172 * r592199;
double r592201 = r592198 + r592200;
double r592202 = r592192 - r592201;
double r592203 = -r592175;
double r592204 = pow(r592203, r592169);
double r592205 = r592172 - r592204;
double r592206 = r592190 ? r592202 : r592205;
double r592207 = r592171 ? r592188 : r592206;
return r592207;
}



# Try it out

Your Program's Arguments

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if n < -5.704806257884768e-269

1. Initial program 23.9

$1 - {\left(1 - x\right)}^{n}$
2. Using strategy rm
3. Applied flip--23.9

$\leadsto \color{blue}{\frac{1 \cdot 1 - {\left(1 - x\right)}^{n} \cdot {\left(1 - x\right)}^{n}}{1 + {\left(1 - x\right)}^{n}}}$
4. Simplified23.8

$\leadsto \frac{\color{blue}{1 \cdot 1 - {\left(1 - x\right)}^{\left(2 \cdot n\right)}}}{1 + {\left(1 - x\right)}^{n}}$
5. Using strategy rm
6. Applied flip--23.8

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

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

## if -5.704806257884768e-269 < n < 1.9631926833638038e+142

1. Initial program 43.1

$1 - {\left(1 - x\right)}^{n}$
2. Using strategy rm
3. Applied flip--43.1

$\leadsto \color{blue}{\frac{1 \cdot 1 - {\left(1 - x\right)}^{n} \cdot {\left(1 - x\right)}^{n}}{1 + {\left(1 - x\right)}^{n}}}$
4. Simplified43.1

$\leadsto \frac{\color{blue}{1 \cdot 1 - {\left(1 - x\right)}^{\left(2 \cdot n\right)}}}{1 + {\left(1 - x\right)}^{n}}$
5. Taylor expanded around 0 19.3

$\leadsto \color{blue}{1 \cdot \left(x \cdot n\right) - \left(0.5 \cdot \left({n}^{2} \cdot {\left(\log 1\right)}^{2}\right) + 1 \cdot \left(n \cdot \log 1\right)\right)}$

## if 1.9631926833638038e+142 < n

1. Initial program 59.3

$1 - {\left(1 - x\right)}^{n}$
2. Taylor expanded around inf 64.0

$\leadsto \color{blue}{1 - e^{\left(\log -1 - \log \left(\frac{1}{x}\right)\right) \cdot n}}$
3. Simplified28.6

$\leadsto \color{blue}{1 - {\left(-x\right)}^{n}}$
3. Recombined 3 regimes into one program.
4. Final simplification22.4

$\leadsto \begin{array}{l} \mathbf{if}\;n \le -5.704806257884767907049421399438379710004 \cdot 10^{-269}:\\ \;\;\;\;\frac{\frac{{1}^{4} - {\left(1 - x\right)}^{\left(4 \cdot n\right)}}{1 \cdot 1 + {\left(1 - x\right)}^{\left(2 \cdot n\right)}}}{1 + {\left(1 - x\right)}^{n}}\\ \mathbf{elif}\;n \le 1.963192683363803761764622454271784231656 \cdot 10^{142}:\\ \;\;\;\;1 \cdot \left(x \cdot n\right) - \left(0.5 \cdot \left({n}^{2} \cdot {\left(\log 1\right)}^{2}\right) + 1 \cdot \left(n \cdot \log 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 - {\left(-x\right)}^{n}\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (x n)
:name "1 - (1 - x)^n"
:precision binary64
(- 1 (pow (- 1 x) n)))