Average Error: 61.2 → 59.3
Time: 9.2s
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(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)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\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(\sqrt[3]{\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)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}\right)}^{3}}}{\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\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(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)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\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(\sqrt[3]{\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)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}\right)}^{3}}}{\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}\right)}^{3}}}{e^{\log \left(\log \left(1 + x\right)\right)}}\\

\end{array}
double f(double x) {
        double r92182 = 1.0;
        double r92183 = x;
        double r92184 = r92182 - r92183;
        double r92185 = log(r92184);
        double r92186 = r92182 + r92183;
        double r92187 = log(r92186);
        double r92188 = r92185 / r92187;
        return r92188;
}

double f(double x) {
        double r92189 = x;
        double r92190 = -5.5247076957621224e-17;
        bool r92191 = r92189 <= r92190;
        double r92192 = 1.0;
        double r92193 = 3.0;
        double r92194 = pow(r92192, r92193);
        double r92195 = pow(r92189, r92193);
        double r92196 = r92194 - r92195;
        double r92197 = log(r92196);
        double r92198 = r92192 * r92192;
        double r92199 = r92189 * r92189;
        double r92200 = r92192 * r92189;
        double r92201 = r92199 + r92200;
        double r92202 = r92198 + r92201;
        double r92203 = log(r92202);
        double r92204 = r92203 * r92203;
        double r92205 = cbrt(r92204);
        double r92206 = cbrt(r92203);
        double r92207 = r92205 * r92206;
        double r92208 = pow(r92207, r92193);
        double r92209 = cbrt(r92208);
        double r92210 = r92197 - r92209;
        double r92211 = r92192 + r92189;
        double r92212 = log(r92211);
        double r92213 = r92210 / r92212;
        double r92214 = 1.1340365921574058e-16;
        bool r92215 = r92189 <= r92214;
        double r92216 = log(r92192);
        double r92217 = 0.5;
        double r92218 = 2.0;
        double r92219 = pow(r92189, r92218);
        double r92220 = pow(r92192, r92218);
        double r92221 = r92219 / r92220;
        double r92222 = r92217 * r92221;
        double r92223 = r92216 - r92222;
        double r92224 = fma(r92189, r92192, r92223);
        double r92225 = r92210 / r92224;
        double r92226 = log(r92212);
        double r92227 = exp(r92226);
        double r92228 = r92210 / r92227;
        double r92229 = r92215 ? r92225 : r92228;
        double r92230 = r92191 ? r92213 : r92229;
        return r92230;
}

Error

Bits error versus x

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(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\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(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}\right) \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\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(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)}} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\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(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)\right)}^{3}}}}{\log \left(1 + x\right)}\]
    8. Using strategy rm
    9. Applied add-cube-cbrt64.0

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

      \[\leadsto \frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\color{blue}{\sqrt[3]{\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)}} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}\right)}^{3}}}{\log \left(1 + x\right)}\]
    11. Taylor expanded around 0 62.0

      \[\leadsto \frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}\right)}^{3}}}{\color{blue}{\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}}\]
    12. Simplified62.0

      \[\leadsto \frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}\right)}^{3}}}{\color{blue}{\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}\]

    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(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\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(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}\right) \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\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(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)}} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\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(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)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\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(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)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\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(\sqrt[3]{\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)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}\right)}^{3}}}{\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right) - \sqrt[3]{{\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}\right)}^{3}}}{e^{\log \left(\log \left(1 + x\right)\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019346 +o rules:numerics
(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))))