Average Error: 5.6 → 3.6
Time: 26.7s
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 1066442948.7059948:\\ \;\;\;\;\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)))))) < 1066442948.7059948

    1. Initial program 0.9

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

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

    if 1066442948.7059948 < (* (sqrt (- (+ (* n x) 1) (* 1/2 (* n (pow x 2))))) (sqrt (- (+ (* n x) 1) (* 1/2 (* n (pow x 2))))))

    1. Initial program 12.2

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

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

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

Runtime

Time bar (total: 26.7s)Debug log

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