Average Error: 38.4 → 0.6
Time: 10.4s
Precision: 64
\[\log \left(1 + x\right)\]
\[\begin{array}{l} \mathbf{if}\;1 + x \le 1.000000000000006439293542825907934457064:\\ \;\;\;\;\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\log \left(1 + x\right)\\ \end{array}\]
\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.000000000000006439293542825907934457064:\\
\;\;\;\;\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\\

\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\

\end{array}
double f(double x) {
        double r787776 = 1.0;
        double r787777 = x;
        double r787778 = r787776 + r787777;
        double r787779 = log(r787778);
        return r787779;
}

double f(double x) {
        double r787780 = 1.0;
        double r787781 = x;
        double r787782 = r787780 + r787781;
        double r787783 = 1.0000000000000064;
        bool r787784 = r787782 <= r787783;
        double r787785 = r787780 * r787781;
        double r787786 = log(r787780);
        double r787787 = r787785 + r787786;
        double r787788 = 0.5;
        double r787789 = 2.0;
        double r787790 = pow(r787781, r787789);
        double r787791 = pow(r787780, r787789);
        double r787792 = r787790 / r787791;
        double r787793 = r787788 * r787792;
        double r787794 = r787787 - r787793;
        double r787795 = log(r787782);
        double r787796 = r787784 ? r787794 : r787795;
        return r787796;
}

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 (+ 1.0 x) < 1.0000000000000064

    1. Initial program 59.4

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

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

    if 1.0000000000000064 < (+ 1.0 x)

    1. Initial program 0.9

      \[\log \left(1 + x\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.6

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

Reproduce

herbie shell --seed 1 
(FPCore (x)
  :name "log(1+x)"
  :precision binary64
  (log (+ 1 x)))