Average Error: 38.4 → 0.6
Time: 9.5s
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 r283846 = 1.0;
        double r283847 = x;
        double r283848 = r283846 + r283847;
        double r283849 = log(r283848);
        return r283849;
}

double f(double x) {
        double r283850 = 1.0;
        double r283851 = x;
        double r283852 = r283850 + r283851;
        double r283853 = 1.0000000000000064;
        bool r283854 = r283852 <= r283853;
        double r283855 = r283850 * r283851;
        double r283856 = log(r283850);
        double r283857 = r283855 + r283856;
        double r283858 = 0.5;
        double r283859 = 2.0;
        double r283860 = pow(r283851, r283859);
        double r283861 = pow(r283850, r283859);
        double r283862 = r283860 / r283861;
        double r283863 = r283858 * r283862;
        double r283864 = r283857 - r283863;
        double r283865 = log(r283852);
        double r283866 = r283854 ? r283864 : r283865;
        return r283866;
}

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)))