Average Error: 38.4 → 0.6
Time: 9.7s
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 r911190 = 1.0;
        double r911191 = x;
        double r911192 = r911190 + r911191;
        double r911193 = log(r911192);
        return r911193;
}

double f(double x) {
        double r911194 = 1.0;
        double r911195 = x;
        double r911196 = r911194 + r911195;
        double r911197 = 1.0000000000000064;
        bool r911198 = r911196 <= r911197;
        double r911199 = r911194 * r911195;
        double r911200 = log(r911194);
        double r911201 = r911199 + r911200;
        double r911202 = 0.5;
        double r911203 = 2.0;
        double r911204 = pow(r911195, r911203);
        double r911205 = pow(r911194, r911203);
        double r911206 = r911204 / r911205;
        double r911207 = r911202 * r911206;
        double r911208 = r911201 - r911207;
        double r911209 = log(r911196);
        double r911210 = r911198 ? r911208 : r911209;
        return r911210;
}

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