Average Error: 61.2 → 59.2
Time: 17.4s
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.488092594349469926360726931400109592164 \cdot 10^{-17}:\\ \;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right)}{\log \left(1 + x\right)} - \frac{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}{\log \left(1 + x\right)}\\ \mathbf{elif}\;x \le 1.107680636981443042090808211242423464562 \cdot 10^{-16}:\\ \;\;\;\;\frac{\log \left(1 - x\right)}{\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\sqrt{1 - x}\right) + \log \left(\sqrt{1 - x}\right)}{\log \left(1 + x\right)}\\ \end{array}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\begin{array}{l}
\mathbf{if}\;x \le -5.488092594349469926360726931400109592164 \cdot 10^{-17}:\\
\;\;\;\;\frac{\log \left({1}^{3} - {x}^{3}\right)}{\log \left(1 + x\right)} - \frac{\log \left(1 \cdot 1 + \left(x \cdot x + 1 \cdot x\right)\right)}{\log \left(1 + x\right)}\\

\mathbf{elif}\;x \le 1.107680636981443042090808211242423464562 \cdot 10^{-16}:\\
\;\;\;\;\frac{\log \left(1 - x\right)}{\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\\

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

\end{array}
double f(double x) {
        double r102957 = 1.0;
        double r102958 = x;
        double r102959 = r102957 - r102958;
        double r102960 = log(r102959);
        double r102961 = r102957 + r102958;
        double r102962 = log(r102961);
        double r102963 = r102960 / r102962;
        return r102963;
}

double f(double x) {
        double r102964 = x;
        double r102965 = -5.48809259434947e-17;
        bool r102966 = r102964 <= r102965;
        double r102967 = 1.0;
        double r102968 = 3.0;
        double r102969 = pow(r102967, r102968);
        double r102970 = pow(r102964, r102968);
        double r102971 = r102969 - r102970;
        double r102972 = log(r102971);
        double r102973 = r102967 + r102964;
        double r102974 = log(r102973);
        double r102975 = r102972 / r102974;
        double r102976 = r102967 * r102967;
        double r102977 = r102964 * r102964;
        double r102978 = r102967 * r102964;
        double r102979 = r102977 + r102978;
        double r102980 = r102976 + r102979;
        double r102981 = log(r102980);
        double r102982 = r102981 / r102974;
        double r102983 = r102975 - r102982;
        double r102984 = 1.107680636981443e-16;
        bool r102985 = r102964 <= r102984;
        double r102986 = r102967 - r102964;
        double r102987 = log(r102986);
        double r102988 = log(r102967);
        double r102989 = r102978 + r102988;
        double r102990 = 0.5;
        double r102991 = 2.0;
        double r102992 = pow(r102964, r102991);
        double r102993 = pow(r102967, r102991);
        double r102994 = r102992 / r102993;
        double r102995 = r102990 * r102994;
        double r102996 = r102989 - r102995;
        double r102997 = r102987 / r102996;
        double r102998 = sqrt(r102986);
        double r102999 = log(r102998);
        double r103000 = r102999 + r102999;
        double r103001 = r103000 / r102974;
        double r103002 = r102985 ? r102997 : r103001;
        double r103003 = r102966 ? r102983 : r103002;
        return r103003;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original61.2
Target0.3
Herbie59.2
\[-\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.48809259434947e-17

    1. Initial program 15.7

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

      \[\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-div11.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. Applied div-sub11.2

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

    if -5.48809259434947e-17 < x < 1.107680636981443e-16

    1. Initial program 64.0

      \[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
    2. Taylor expanded around 0 62.0

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

    if 1.107680636981443e-16 < x

    1. Initial program 15.1

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

      \[\leadsto \frac{\log \color{blue}{\left(\sqrt{1 - x} \cdot \sqrt{1 - x}\right)}}{\log \left(1 + x\right)}\]
    4. Applied log-prod16.8

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

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

Reproduce

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

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

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