Average Error: 9.8 → 0.3
Time: 9.4s
Precision: 64
$logx - \log \left(x + 1\right)$
$\begin{array}{l} \mathbf{if}\;x + 1 \le 1.0:\\ \;\;\;\;\left(logx - x\right) - \left(x \cdot x\right) \cdot \frac{-1}{2}\\ \mathbf{else}:\\ \;\;\;\;\left(logx - \frac{1}{2} \cdot \log \left(x + 1\right)\right) - \log \left(\sqrt{x + 1}\right)\\ \end{array}$
logx - \log \left(x + 1\right)
\begin{array}{l}
\mathbf{if}\;x + 1 \le 1.0:\\
\;\;\;\;\left(logx - x\right) - \left(x \cdot x\right) \cdot \frac{-1}{2}\\

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

\end{array}
double f(double logx, double x) {
double r58990740 = logx;
double r58990741 = x;
double r58990742 = 1.0;
double r58990743 = r58990741 + r58990742;
double r58990744 = log(r58990743);
double r58990745 = r58990740 - r58990744;
return r58990745;
}


double f(double logx, double x) {
double r58990746 = x;
double r58990747 = 1.0;
double r58990748 = r58990746 + r58990747;
double r58990749 = 1.0;
bool r58990750 = r58990748 <= r58990749;
double r58990751 = logx;
double r58990752 = r58990751 - r58990746;
double r58990753 = r58990746 * r58990746;
double r58990754 = -0.5;
double r58990755 = r58990753 * r58990754;
double r58990756 = r58990752 - r58990755;
double r58990757 = 0.5;
double r58990758 = log(r58990748);
double r58990759 = r58990757 * r58990758;
double r58990760 = r58990751 - r58990759;
double r58990761 = sqrt(r58990748);
double r58990762 = log(r58990761);
double r58990763 = r58990760 - r58990762;
double r58990764 = r58990750 ? r58990756 : r58990763;
return r58990764;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if (+ x 1) < 1.0

1. Initial program 14.8

$logx - \log \left(x + 1\right)$
2. Taylor expanded around 0 0.2

$\leadsto \color{blue}{\left(\frac{1}{2} \cdot {x}^{2} + logx\right) - x}$
3. Simplified0.2

$\leadsto \color{blue}{\left(logx - x\right) - \left(x \cdot x\right) \cdot \frac{-1}{2}}$

## if 1.0 < (+ x 1)

1. Initial program 0.5

$logx - \log \left(x + 1\right)$
2. Using strategy rm

$\leadsto logx - \log \color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right)}$
4. Applied log-prod0.5

$\leadsto logx - \color{blue}{\left(\log \left(\sqrt{x + 1}\right) + \log \left(\sqrt{x + 1}\right)\right)}$
5. Applied associate--r+0.5

$\leadsto \color{blue}{\left(logx - \log \left(\sqrt{x + 1}\right)\right) - \log \left(\sqrt{x + 1}\right)}$
6. Using strategy rm
7. Applied pow1/20.5

$\leadsto \left(logx - \log \color{blue}{\left({\left(x + 1\right)}^{\frac{1}{2}}\right)}\right) - \log \left(\sqrt{x + 1}\right)$
8. Applied log-pow0.5

$\leadsto \left(logx - \color{blue}{\frac{1}{2} \cdot \log \left(x + 1\right)}\right) - \log \left(\sqrt{x + 1}\right)$
3. Recombined 2 regimes into one program.
4. Final simplification0.3

$\leadsto \begin{array}{l} \mathbf{if}\;x + 1 \le 1.0:\\ \;\;\;\;\left(logx - x\right) - \left(x \cdot x\right) \cdot \frac{-1}{2}\\ \mathbf{else}:\\ \;\;\;\;\left(logx - \frac{1}{2} \cdot \log \left(x + 1\right)\right) - \log \left(\sqrt{x + 1}\right)\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (logx x)
:name "logx-log(x+1)"
(- logx (log (+ x 1))))