Average Error: 61.2 → 59.3
Time: 9.5s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.524707695762122406128297926502901213277 \cdot 10^{-17}:\\ \;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right) \cdot \log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)} \cdot \sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)}\right)}^{3}}}{\log \left(1 + x\right)}\\ \mathbf{elif}\;x \le 1.134036592157405800381078481820496753738 \cdot 10^{-16}:\\ \;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)\right)}^{3}}}{\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right) \cdot \log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)} \cdot \sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)}\right)}^{3}}}{e^{\log \left(\log \left(1 + x\right)\right)}}\\ \end{array}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\begin{array}{l}
\mathbf{if}\;x \le -5.524707695762122406128297926502901213277 \cdot 10^{-17}:\\
\;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right) \cdot \log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)} \cdot \sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)}\right)}^{3}}}{\log \left(1 + x\right)}\\

\mathbf{elif}\;x \le 1.134036592157405800381078481820496753738 \cdot 10^{-16}:\\
\;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)\right)}^{3}}}{\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right) \cdot \log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)} \cdot \sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)}\right)}^{3}}}{e^{\log \left(\log \left(1 + x\right)\right)}}\\

\end{array}
double f(double x) {
        double r97015 = 1.0;
        double r97016 = x;
        double r97017 = r97015 - r97016;
        double r97018 = log(r97017);
        double r97019 = r97015 + r97016;
        double r97020 = log(r97019);
        double r97021 = r97018 / r97020;
        return r97021;
}

double f(double x) {
        double r97022 = x;
        double r97023 = -5.5247076957621224e-17;
        bool r97024 = r97022 <= r97023;
        double r97025 = 1.0;
        double r97026 = 3.0;
        double r97027 = pow(r97025, r97026);
        double r97028 = pow(r97022, r97026);
        double r97029 = r97027 - r97028;
        double r97030 = log(r97029);
        double r97031 = r97022 + r97025;
        double r97032 = r97022 * r97031;
        double r97033 = 2.0;
        double r97034 = pow(r97025, r97033);
        double r97035 = r97032 + r97034;
        double r97036 = log(r97035);
        double r97037 = r97036 * r97036;
        double r97038 = cbrt(r97037);
        double r97039 = cbrt(r97036);
        double r97040 = r97038 * r97039;
        double r97041 = pow(r97040, r97026);
        double r97042 = cbrt(r97041);
        double r97043 = r97030 - r97042;
        double r97044 = r97025 + r97022;
        double r97045 = log(r97044);
        double r97046 = r97043 / r97045;
        double r97047 = 1.1340365921574058e-16;
        bool r97048 = r97022 <= r97047;
        double r97049 = pow(r97036, r97026);
        double r97050 = cbrt(r97049);
        double r97051 = r97030 - r97050;
        double r97052 = r97025 * r97022;
        double r97053 = log(r97025);
        double r97054 = r97052 + r97053;
        double r97055 = 0.5;
        double r97056 = pow(r97022, r97033);
        double r97057 = r97056 / r97034;
        double r97058 = r97055 * r97057;
        double r97059 = r97054 - r97058;
        double r97060 = r97051 / r97059;
        double r97061 = log(r97045);
        double r97062 = exp(r97061);
        double r97063 = r97043 / r97062;
        double r97064 = r97048 ? r97060 : r97063;
        double r97065 = r97024 ? r97046 : r97064;
        return r97065;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original61.2
Target0.2
Herbie59.3
\[-\left(\left(\left(1 + x\right) + \frac{x \cdot x}{2}\right) + 0.4166666666666666851703837437526090070605 \cdot {x}^{3}\right)\]

Derivation

  1. Split input into 3 regimes
  2. if x < -5.5247076957621224e-17

    1. Initial program 14.7

      \[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
    2. Using strategy rm
    3. Applied flip3--14.8

      \[\leadsto \frac{\log \color{blue}{\left(\frac{{1}^{3} - {x}^{3}}{1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)}\right)}}{\log \left(1 + x\right)}\]
    4. Applied log-div12.9

      \[\leadsto \frac{\color{blue}{\log \left({1}^{3} - {x}^{3}\right) - \log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}}{\log \left(1 + x\right)}\]
    5. Using strategy rm
    6. Applied add-cbrt-cube12.9

      \[\leadsto \frac{\log \left({1}^{3} - {x}^{3}\right) - \color{blue}{\sqrt[3]{\left(\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right) \cdot \log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)\right) \cdot \log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}}}{\log \left(1 + x\right)}\]
    7. Simplified12.9

      \[\leadsto \frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{\color{blue}{{\left(\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)\right)}^{3}}}}{\log \left(1 + x\right)}\]
    8. Using strategy rm
    9. Applied add-cube-cbrt12.8

      \[\leadsto \frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\color{blue}{\left(\left(\sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)} \cdot \sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)}\right) \cdot \sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)}\right)}}^{3}}}{\log \left(1 + x\right)}\]
    10. Simplified12.8

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

    if -5.5247076957621224e-17 < x < 1.1340365921574058e-16

    1. Initial program 64.0

      \[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
    2. Using strategy rm
    3. Applied flip3--64.0

      \[\leadsto \frac{\log \color{blue}{\left(\frac{{1}^{3} - {x}^{3}}{1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)}\right)}}{\log \left(1 + x\right)}\]
    4. Applied log-div64.0

      \[\leadsto \frac{\color{blue}{\log \left({1}^{3} - {x}^{3}\right) - \log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}}{\log \left(1 + x\right)}\]
    5. Using strategy rm
    6. Applied add-cbrt-cube64.0

      \[\leadsto \frac{\log \left({1}^{3} - {x}^{3}\right) - \color{blue}{\sqrt[3]{\left(\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right) \cdot \log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)\right) \cdot \log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}}}{\log \left(1 + x\right)}\]
    7. Simplified64.0

      \[\leadsto \frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{\color{blue}{{\left(\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)\right)}^{3}}}}{\log \left(1 + x\right)}\]
    8. Taylor expanded around 0 62.0

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

    if 1.1340365921574058e-16 < x

    1. Initial program 14.1

      \[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
    2. Using strategy rm
    3. Applied flip3--3.8

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

      \[\leadsto \frac{\color{blue}{\log \left({1}^{3} - {x}^{3}\right) - \log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}}{\log \left(1 + x\right)}\]
    5. Using strategy rm
    6. Applied add-cbrt-cube13.1

      \[\leadsto \frac{\log \left({1}^{3} - {x}^{3}\right) - \color{blue}{\sqrt[3]{\left(\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right) \cdot \log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)\right) \cdot \log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}}}{\log \left(1 + x\right)}\]
    7. Simplified13.1

      \[\leadsto \frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{\color{blue}{{\left(\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)\right)}^{3}}}}{\log \left(1 + x\right)}\]
    8. Using strategy rm
    9. Applied add-cube-cbrt13.2

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

      \[\leadsto \frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\color{blue}{\sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right) \cdot \log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)}} \cdot \sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)}\right)}^{3}}}{\log \left(1 + x\right)}\]
    11. Using strategy rm
    12. Applied add-exp-log13.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -5.524707695762122406128297926502901213277 \cdot 10^{-17}:\\ \;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right) \cdot \log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)} \cdot \sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)}\right)}^{3}}}{\log \left(1 + x\right)}\\ \mathbf{elif}\;x \le 1.134036592157405800381078481820496753738 \cdot 10^{-16}:\\ \;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)\right)}^{3}}}{\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right) \cdot \log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)} \cdot \sqrt[3]{\log \left(x \cdot \left(x + 1\right) + {1}^{2}\right)}\right)}^{3}}}{e^{\log \left(\log \left(1 + x\right)\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019346 
(FPCore (x)
  :name "qlog (example 3.10)"
  :precision binary64
  :pre (and (< -1 x) (< x 1))

  :herbie-target
  (- (+ (+ (+ 1 x) (/ (* x x) 2)) (* 0.4166666666666667 (pow x 3))))

  (/ (log (- 1 x)) (log (+ 1 x))))