Average Error: 5.6 → 3.9
Time: 27.9s
Precision: 64
Internal Precision: 1344
\[{\left(1 + x\right)}^{n}\]
\[\begin{array}{l} \mathbf{if}\;\sqrt{\left(n \cdot x + 1\right) - \frac{1}{2} \cdot \left(n \cdot {x}^{2}\right)} \cdot \sqrt{\left(n \cdot x + 1\right) - \frac{1}{2} \cdot \left(n \cdot {x}^{2}\right)} \le 5.443296447853933 \cdot 10^{+44}:\\ \;\;\;\;\left(n \cdot x + 1\right) - \frac{1}{2} \cdot \left(n \cdot {x}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{n}\\ \end{array}\]

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 (* (sqrt (- (+ (* n x) 1) (* 1/2 (* n (pow x 2))))) (sqrt (- (+ (* n x) 1) (* 1/2 (* n (pow x 2)))))) < 5.443296447853933e+44

    1. Initial program 0.9

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

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

    if 5.443296447853933e+44 < (* (sqrt (- (+ (* n x) 1) (* 1/2 (* n (pow x 2))))) (sqrt (- (+ (* n x) 1) (* 1/2 (* n (pow x 2))))))

    1. Initial program 12.4

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

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

      \[\leadsto \color{blue}{{x}^{n}}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 27.9s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)' 
(FPCore (x n)
  :name "(1 + x)^ n"
  (pow (+ 1 x) n))