Average Error: 46.6 → 19.1
Time: 20.2s
Precision: 64
\[n \gt 0.0\]
\[1 - {\left(1 - x\right)}^{n}\]
\[\begin{array}{l} \mathbf{if}\;n \le 3.370731261075133210042545992259085494023 \cdot 10^{170}:\\ \;\;\;\;n \cdot \left(1 \cdot x - \log 1\right) + \left(n \cdot \left(n \cdot {\left(\log 1\right)}^{2}\right)\right) \cdot \frac{-1}{2}\\ \mathbf{else}:\\ \;\;\;\;1 - {\left(-x\right)}^{n}\\ \end{array}\]
1 - {\left(1 - x\right)}^{n}
\begin{array}{l}
\mathbf{if}\;n \le 3.370731261075133210042545992259085494023 \cdot 10^{170}:\\
\;\;\;\;n \cdot \left(1 \cdot x - \log 1\right) + \left(n \cdot \left(n \cdot {\left(\log 1\right)}^{2}\right)\right) \cdot \frac{-1}{2}\\

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

\end{array}
double f(double x, double n) {
        double r599993 = 1.0;
        double r599994 = x;
        double r599995 = r599993 - r599994;
        double r599996 = n;
        double r599997 = pow(r599995, r599996);
        double r599998 = r599993 - r599997;
        return r599998;
}

double f(double x, double n) {
        double r599999 = n;
        double r600000 = 3.370731261075133e+170;
        bool r600001 = r599999 <= r600000;
        double r600002 = 1.0;
        double r600003 = x;
        double r600004 = r600002 * r600003;
        double r600005 = log(r600002);
        double r600006 = r600004 - r600005;
        double r600007 = r599999 * r600006;
        double r600008 = 2.0;
        double r600009 = pow(r600005, r600008);
        double r600010 = r599999 * r600009;
        double r600011 = r599999 * r600010;
        double r600012 = -0.5;
        double r600013 = r600011 * r600012;
        double r600014 = r600007 + r600013;
        double r600015 = -r600003;
        double r600016 = pow(r600015, r599999);
        double r600017 = r600002 - r600016;
        double r600018 = r600001 ? r600014 : r600017;
        return r600018;
}

Error

Bits error versus x

Bits error versus n

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if n < 3.370731261075133e+170

    1. Initial program 44.8

      \[1 - {\left(1 - x\right)}^{n}\]
    2. Taylor expanded around 0 19.3

      \[\leadsto \color{blue}{1 \cdot \left(x \cdot n\right) - \left(\frac{1}{2} \cdot \left({n}^{2} \cdot {\left(\log 1\right)}^{2}\right) + n \cdot \log 1\right)}\]
    3. Simplified19.3

      \[\leadsto \color{blue}{n \cdot \left(1 \cdot x - \log 1\right) + \left({n}^{2} \cdot {\left(\log 1\right)}^{2}\right) \cdot \frac{-1}{2}}\]
    4. Using strategy rm
    5. Applied unpow219.3

      \[\leadsto n \cdot \left(1 \cdot x - \log 1\right) + \left(\color{blue}{\left(n \cdot n\right)} \cdot {\left(\log 1\right)}^{2}\right) \cdot \frac{-1}{2}\]
    6. Applied associate-*l*18.5

      \[\leadsto n \cdot \left(1 \cdot x - \log 1\right) + \color{blue}{\left(n \cdot \left(n \cdot {\left(\log 1\right)}^{2}\right)\right)} \cdot \frac{-1}{2}\]

    if 3.370731261075133e+170 < n

    1. Initial program 59.4

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

      \[\leadsto 1 - \color{blue}{e^{\left(\log -1 - \log \left(\frac{1}{x}\right)\right) \cdot n}}\]
    3. Simplified23.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \le 3.370731261075133210042545992259085494023 \cdot 10^{170}:\\ \;\;\;\;n \cdot \left(1 \cdot x - \log 1\right) + \left(n \cdot \left(n \cdot {\left(\log 1\right)}^{2}\right)\right) \cdot \frac{-1}{2}\\ \mathbf{else}:\\ \;\;\;\;1 - {\left(-x\right)}^{n}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (x n)
  :name "1 - pow(1 - x, n)"
  :precision binary64
  :pre (> n 0.0)
  (- 1 (pow (- 1 x) n)))