Average Error: 39.6 → 0.3
Time: 34.7s
Precision: 64
Internal Precision: 1344
\[\log \left(1 + x\right) - x\]
\[\begin{array}{l} \mathbf{if}\;\log \left(1 + x\right) - x \le -0.6160084834776067:\\ \;\;\;\;\left(\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)\right) - x\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \frac{1}{3} - \frac{1}{2}\right) \cdot \left(x \cdot x\right) - {x}^{4} \cdot \frac{1}{4}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (- (log (+ 1 x)) x) < -0.6160084834776067

    1. Initial program 0.0

      \[\log \left(1 + x\right) - x\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.0

      \[\leadsto \log \color{blue}{\left(\sqrt{1 + x} \cdot \sqrt{1 + x}\right)} - x\]
    4. Applied log-prod0.0

      \[\leadsto \color{blue}{\left(\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)\right)} - x\]

    if -0.6160084834776067 < (- (log (+ 1 x)) x)

    1. Initial program 59.3

      \[\log \left(1 + x\right) - x\]
    2. Taylor expanded around 0 0.5

      \[\leadsto \color{blue}{\frac{1}{3} \cdot {x}^{3} - \left(\frac{1}{2} \cdot {x}^{2} + \frac{1}{4} \cdot {x}^{4}\right)}\]
    3. Applied simplify0.5

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

Runtime

Time bar (total: 34.7s)Debug log

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