Jmat.Real.lambertw, estimator

Percentage Accurate: 99.6% → 100.0%
Time: 8.1s
Alternatives: 3
Speedup: 1.4×

Specification

?
\[\begin{array}{l} \\ \log x - \log \log x \end{array} \]
(FPCore (x) :precision binary64 (- (log x) (log (log x))))
double code(double x) {
	return log(x) - log(log(x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = log(x) - log(log(x))
end function
public static double code(double x) {
	return Math.log(x) - Math.log(Math.log(x));
}
def code(x):
	return math.log(x) - math.log(math.log(x))
function code(x)
	return Float64(log(x) - log(log(x)))
end
function tmp = code(x)
	tmp = log(x) - log(log(x));
end
code[x_] := N[(N[Log[x], $MachinePrecision] - N[Log[N[Log[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\log x - \log \log x
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 3 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \log x - \log \log x \end{array} \]
(FPCore (x) :precision binary64 (- (log x) (log (log x))))
double code(double x) {
	return log(x) - log(log(x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = log(x) - log(log(x))
end function
public static double code(double x) {
	return Math.log(x) - Math.log(Math.log(x));
}
def code(x):
	return math.log(x) - math.log(math.log(x))
function code(x)
	return Float64(log(x) - log(log(x)))
end
function tmp = code(x)
	tmp = log(x) - log(log(x));
end
code[x_] := N[(N[Log[x], $MachinePrecision] - N[Log[N[Log[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\log x - \log \log x
\end{array}

Alternative 1: 100.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ -\log \left(\frac{\log x}{x}\right) \end{array} \]
(FPCore (x) :precision binary64 (- (log (/ (log x) x))))
double code(double x) {
	return -log((log(x) / x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = -log((log(x) / x))
end function
public static double code(double x) {
	return -Math.log((Math.log(x) / x));
}
def code(x):
	return -math.log((math.log(x) / x))
function code(x)
	return Float64(-log(Float64(log(x) / x)))
end
function tmp = code(x)
	tmp = -log((log(x) / x));
end
code[x_] := (-N[Log[N[(N[Log[x], $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}

\\
-\log \left(\frac{\log x}{x}\right)
\end{array}
Derivation
  1. Initial program 99.6%

    \[\log x - \log \log x \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-log.f64N/A

      \[\leadsto \log x - \log \color{blue}{\log x} \]
    2. lift-log.f6499.6

      \[\leadsto \log x - \color{blue}{\log \log x} \]
    3. remove-double-negN/A

      \[\leadsto \log x - \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log \log x\right)\right)\right)\right)} \]
    4. neg-sub0N/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\color{blue}{\left(0 - \log \log x\right)}\right)\right) \]
    5. flip3--N/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\color{blue}{\frac{{0}^{3} - {\log \log x}^{3}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}}\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{0} - {\log \log x}^{3}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    7. neg-sub0N/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{\mathsf{neg}\left({\log \log x}^{3}\right)}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    8. cube-negN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{{\left(\mathsf{neg}\left(\log \log x\right)\right)}^{3}}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    9. sqr-powN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{{\left(\mathsf{neg}\left(\log \log x\right)\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\mathsf{neg}\left(\log \log x\right)\right)}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    10. unpow-prod-downN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{{\left(\left(\mathsf{neg}\left(\log \log x\right)\right) \cdot \left(\mathsf{neg}\left(\log \log x\right)\right)\right)}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    11. sqr-negN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{{\color{blue}{\left(\log \log x \cdot \log \log x\right)}}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    12. pow-prod-downN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{{\log \log x}^{\left(\frac{3}{2}\right)} \cdot {\log \log x}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    13. sqr-powN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{{\log \log x}^{3}}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    14. distribute-frac-negN/A

      \[\leadsto \log x - \color{blue}{\frac{\mathsf{neg}\left({\log \log x}^{3}\right)}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}} \]
  4. Applied rewrites99.6%

    \[\leadsto \log x - \color{blue}{{\log \log x}^{2} \cdot \frac{1}{\log \log x}} \]
  5. Step-by-step derivation
    1. lift-log.f64N/A

      \[\leadsto \log x - {\log \color{blue}{\log x}}^{2} \cdot \frac{1}{\log \log x} \]
    2. lift-log.f64N/A

      \[\leadsto \log x - {\color{blue}{\log \log x}}^{2} \cdot \frac{1}{\log \log x} \]
    3. metadata-evalN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\color{blue}{\mathsf{neg}\left(-1\right)}}{\log \log x} \]
    4. lift-log.f64N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \color{blue}{\log x}} \]
    5. unpow1N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \color{blue}{\left({\log x}^{1}\right)}} \]
    6. metadata-evalN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \left({\log x}^{\color{blue}{\left(2 - 1\right)}}\right)} \]
    7. pow-divN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \color{blue}{\left(\frac{{\log x}^{2}}{{\log x}^{1}}\right)}} \]
    8. lift-pow.f64N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \left(\frac{\color{blue}{{\log x}^{2}}}{{\log x}^{1}}\right)} \]
    9. unpow1N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \left(\frac{{\log x}^{2}}{\color{blue}{\log x}}\right)} \]
    10. clear-numN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \color{blue}{\left(\frac{1}{\frac{\log x}{{\log x}^{2}}}\right)}} \]
    11. --rgt-identityN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \left(\frac{1}{\frac{\log x}{\color{blue}{{\log x}^{2} - 0}}}\right)} \]
    12. lift--.f64N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \left(\frac{1}{\frac{\log x}{\color{blue}{{\log x}^{2} - 0}}}\right)} \]
    13. log-recN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\color{blue}{\mathsf{neg}\left(\log \left(\frac{\log x}{{\log x}^{2} - 0}\right)\right)}} \]
    14. unpow1N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \left(\frac{\color{blue}{{\log x}^{1}}}{{\log x}^{2} - 0}\right)\right)} \]
    15. lift--.f64N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \left(\frac{{\log x}^{1}}{\color{blue}{{\log x}^{2} - 0}}\right)\right)} \]
    16. --rgt-identityN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \left(\frac{{\log x}^{1}}{\color{blue}{{\log x}^{2}}}\right)\right)} \]
    17. lift-pow.f64N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \left(\frac{{\log x}^{1}}{\color{blue}{{\log x}^{2}}}\right)\right)} \]
    18. pow-divN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \color{blue}{\left({\log x}^{\left(1 - 2\right)}\right)}\right)} \]
    19. metadata-evalN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \left({\log x}^{\color{blue}{-1}}\right)\right)} \]
    20. inv-powN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \color{blue}{\left(\frac{1}{\log x}\right)}\right)} \]
  6. Applied rewrites100.0%

    \[\leadsto \color{blue}{\log \left(\frac{x}{\log x}\right)} \]
  7. Applied rewrites30.9%

    \[\leadsto \log \color{blue}{\left(\frac{x \cdot \left(x \cdot x\right)}{\left(x \cdot x\right) \cdot \log x}\right)} \]
  8. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \log \left(\frac{x \cdot \color{blue}{\left(x \cdot x\right)}}{\left(x \cdot x\right) \cdot \log x}\right) \]
    2. lift-*.f64N/A

      \[\leadsto \log \left(\frac{\color{blue}{x \cdot \left(x \cdot x\right)}}{\left(x \cdot x\right) \cdot \log x}\right) \]
    3. lift-*.f64N/A

      \[\leadsto \log \left(\frac{x \cdot \left(x \cdot x\right)}{\color{blue}{\left(x \cdot x\right)} \cdot \log x}\right) \]
    4. lift-log.f64N/A

      \[\leadsto \log \left(\frac{x \cdot \left(x \cdot x\right)}{\left(x \cdot x\right) \cdot \color{blue}{\log x}}\right) \]
    5. lift-*.f64N/A

      \[\leadsto \log \left(\frac{x \cdot \left(x \cdot x\right)}{\color{blue}{\left(x \cdot x\right) \cdot \log x}}\right) \]
    6. frac-2negN/A

      \[\leadsto \log \color{blue}{\left(\frac{\mathsf{neg}\left(x \cdot \left(x \cdot x\right)\right)}{\mathsf{neg}\left(\left(x \cdot x\right) \cdot \log x\right)}\right)} \]
    7. *-rgt-identityN/A

      \[\leadsto \log \left(\frac{\color{blue}{\left(\mathsf{neg}\left(x \cdot \left(x \cdot x\right)\right)\right) \cdot 1}}{\mathsf{neg}\left(\left(x \cdot x\right) \cdot \log x\right)}\right) \]
    8. log-divN/A

      \[\leadsto \color{blue}{\log \left(\left(\mathsf{neg}\left(x \cdot \left(x \cdot x\right)\right)\right) \cdot 1\right) - \log \left(\mathsf{neg}\left(\left(x \cdot x\right) \cdot \log x\right)\right)} \]
    9. *-rgt-identityN/A

      \[\leadsto \log \color{blue}{\left(\mathsf{neg}\left(x \cdot \left(x \cdot x\right)\right)\right)} - \log \left(\mathsf{neg}\left(\left(x \cdot x\right) \cdot \log x\right)\right) \]
    10. log-divN/A

      \[\leadsto \color{blue}{\log \left(\frac{\mathsf{neg}\left(x \cdot \left(x \cdot x\right)\right)}{\mathsf{neg}\left(\left(x \cdot x\right) \cdot \log x\right)}\right)} \]
    11. frac-2negN/A

      \[\leadsto \log \color{blue}{\left(\frac{x \cdot \left(x \cdot x\right)}{\left(x \cdot x\right) \cdot \log x}\right)} \]
    12. clear-numN/A

      \[\leadsto \log \color{blue}{\left(\frac{1}{\frac{\left(x \cdot x\right) \cdot \log x}{x \cdot \left(x \cdot x\right)}}\right)} \]
    13. log-recN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\log \left(\frac{\left(x \cdot x\right) \cdot \log x}{x \cdot \left(x \cdot x\right)}\right)\right)} \]
    14. lower-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\log \left(\frac{\left(x \cdot x\right) \cdot \log x}{x \cdot \left(x \cdot x\right)}\right)\right)} \]
  9. Applied rewrites100.0%

    \[\leadsto \color{blue}{-\log \left(\frac{\log x}{x}\right)} \]
  10. Add Preprocessing

Alternative 2: 100.0% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \log \left(\frac{x}{\log x}\right) \end{array} \]
(FPCore (x) :precision binary64 (log (/ x (log x))))
double code(double x) {
	return log((x / log(x)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = log((x / log(x)))
end function
public static double code(double x) {
	return Math.log((x / Math.log(x)));
}
def code(x):
	return math.log((x / math.log(x)))
function code(x)
	return log(Float64(x / log(x)))
end
function tmp = code(x)
	tmp = log((x / log(x)));
end
code[x_] := N[Log[N[(x / N[Log[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\log \left(\frac{x}{\log x}\right)
\end{array}
Derivation
  1. Initial program 99.6%

    \[\log x - \log \log x \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-log.f64N/A

      \[\leadsto \log x - \log \color{blue}{\log x} \]
    2. lift-log.f6499.6

      \[\leadsto \log x - \color{blue}{\log \log x} \]
    3. remove-double-negN/A

      \[\leadsto \log x - \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log \log x\right)\right)\right)\right)} \]
    4. neg-sub0N/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\color{blue}{\left(0 - \log \log x\right)}\right)\right) \]
    5. flip3--N/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\color{blue}{\frac{{0}^{3} - {\log \log x}^{3}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}}\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{0} - {\log \log x}^{3}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    7. neg-sub0N/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{\mathsf{neg}\left({\log \log x}^{3}\right)}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    8. cube-negN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{{\left(\mathsf{neg}\left(\log \log x\right)\right)}^{3}}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    9. sqr-powN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{{\left(\mathsf{neg}\left(\log \log x\right)\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\mathsf{neg}\left(\log \log x\right)\right)}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    10. unpow-prod-downN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{{\left(\left(\mathsf{neg}\left(\log \log x\right)\right) \cdot \left(\mathsf{neg}\left(\log \log x\right)\right)\right)}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    11. sqr-negN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{{\color{blue}{\left(\log \log x \cdot \log \log x\right)}}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    12. pow-prod-downN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{{\log \log x}^{\left(\frac{3}{2}\right)} \cdot {\log \log x}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    13. sqr-powN/A

      \[\leadsto \log x - \left(\mathsf{neg}\left(\frac{\color{blue}{{\log \log x}^{3}}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)\right) \]
    14. distribute-frac-negN/A

      \[\leadsto \log x - \color{blue}{\frac{\mathsf{neg}\left({\log \log x}^{3}\right)}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}} \]
  4. Applied rewrites99.6%

    \[\leadsto \log x - \color{blue}{{\log \log x}^{2} \cdot \frac{1}{\log \log x}} \]
  5. Step-by-step derivation
    1. lift-log.f64N/A

      \[\leadsto \log x - {\log \color{blue}{\log x}}^{2} \cdot \frac{1}{\log \log x} \]
    2. lift-log.f64N/A

      \[\leadsto \log x - {\color{blue}{\log \log x}}^{2} \cdot \frac{1}{\log \log x} \]
    3. metadata-evalN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\color{blue}{\mathsf{neg}\left(-1\right)}}{\log \log x} \]
    4. lift-log.f64N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \color{blue}{\log x}} \]
    5. unpow1N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \color{blue}{\left({\log x}^{1}\right)}} \]
    6. metadata-evalN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \left({\log x}^{\color{blue}{\left(2 - 1\right)}}\right)} \]
    7. pow-divN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \color{blue}{\left(\frac{{\log x}^{2}}{{\log x}^{1}}\right)}} \]
    8. lift-pow.f64N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \left(\frac{\color{blue}{{\log x}^{2}}}{{\log x}^{1}}\right)} \]
    9. unpow1N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \left(\frac{{\log x}^{2}}{\color{blue}{\log x}}\right)} \]
    10. clear-numN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \color{blue}{\left(\frac{1}{\frac{\log x}{{\log x}^{2}}}\right)}} \]
    11. --rgt-identityN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \left(\frac{1}{\frac{\log x}{\color{blue}{{\log x}^{2} - 0}}}\right)} \]
    12. lift--.f64N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\log \left(\frac{1}{\frac{\log x}{\color{blue}{{\log x}^{2} - 0}}}\right)} \]
    13. log-recN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\color{blue}{\mathsf{neg}\left(\log \left(\frac{\log x}{{\log x}^{2} - 0}\right)\right)}} \]
    14. unpow1N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \left(\frac{\color{blue}{{\log x}^{1}}}{{\log x}^{2} - 0}\right)\right)} \]
    15. lift--.f64N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \left(\frac{{\log x}^{1}}{\color{blue}{{\log x}^{2} - 0}}\right)\right)} \]
    16. --rgt-identityN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \left(\frac{{\log x}^{1}}{\color{blue}{{\log x}^{2}}}\right)\right)} \]
    17. lift-pow.f64N/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \left(\frac{{\log x}^{1}}{\color{blue}{{\log x}^{2}}}\right)\right)} \]
    18. pow-divN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \color{blue}{\left({\log x}^{\left(1 - 2\right)}\right)}\right)} \]
    19. metadata-evalN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \left({\log x}^{\color{blue}{-1}}\right)\right)} \]
    20. inv-powN/A

      \[\leadsto \log x - {\log \log x}^{2} \cdot \frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(\log \color{blue}{\left(\frac{1}{\log x}\right)}\right)} \]
  6. Applied rewrites100.0%

    \[\leadsto \color{blue}{\log \left(\frac{x}{\log x}\right)} \]
  7. Add Preprocessing

Alternative 3: 24.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \log \left(x \cdot \log x\right) \end{array} \]
(FPCore (x) :precision binary64 (log (* x (log x))))
double code(double x) {
	return log((x * log(x)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = log((x * log(x)))
end function
public static double code(double x) {
	return Math.log((x * Math.log(x)));
}
def code(x):
	return math.log((x * math.log(x)))
function code(x)
	return log(Float64(x * log(x)))
end
function tmp = code(x)
	tmp = log((x * log(x)));
end
code[x_] := N[Log[N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\log \left(x \cdot \log x\right)
\end{array}
Derivation
  1. Initial program 99.6%

    \[\log x - \log \log x \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-log.f64N/A

      \[\leadsto \log x - \log \color{blue}{\log x} \]
    2. diff-logN/A

      \[\leadsto \color{blue}{\log \left(\frac{x}{\log x}\right)} \]
    3. lower-log.f64N/A

      \[\leadsto \color{blue}{\log \left(\frac{x}{\log x}\right)} \]
    4. div-invN/A

      \[\leadsto \log \color{blue}{\left(x \cdot \frac{1}{\log x}\right)} \]
    5. inv-powN/A

      \[\leadsto \log \left(x \cdot \color{blue}{{\log x}^{-1}}\right) \]
    6. pow-to-expN/A

      \[\leadsto \log \left(x \cdot \color{blue}{e^{\log \log x \cdot -1}}\right) \]
    7. lift-log.f64N/A

      \[\leadsto \log \left(x \cdot e^{\color{blue}{\log \log x} \cdot -1}\right) \]
    8. *-commutativeN/A

      \[\leadsto \log \left(x \cdot e^{\color{blue}{-1 \cdot \log \log x}}\right) \]
    9. neg-mul-1N/A

      \[\leadsto \log \left(x \cdot e^{\color{blue}{\mathsf{neg}\left(\log \log x\right)}}\right) \]
    10. neg-sub0N/A

      \[\leadsto \log \left(x \cdot e^{\color{blue}{0 - \log \log x}}\right) \]
    11. flip3--N/A

      \[\leadsto \log \left(x \cdot e^{\color{blue}{\frac{{0}^{3} - {\log \log x}^{3}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}}}\right) \]
    12. metadata-evalN/A

      \[\leadsto \log \left(x \cdot e^{\frac{\color{blue}{0} - {\log \log x}^{3}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}}\right) \]
    13. neg-sub0N/A

      \[\leadsto \log \left(x \cdot e^{\frac{\color{blue}{\mathsf{neg}\left({\log \log x}^{3}\right)}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}}\right) \]
    14. distribute-frac-negN/A

      \[\leadsto \log \left(x \cdot e^{\color{blue}{\mathsf{neg}\left(\frac{{\log \log x}^{3}}{0 \cdot 0 + \left(\log \log x \cdot \log \log x + 0 \cdot \log \log x\right)}\right)}}\right) \]
  4. Applied rewrites25.0%

    \[\leadsto \color{blue}{\log \left(x \cdot \log x\right)} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2024216 
(FPCore (x)
  :name "Jmat.Real.lambertw, estimator"
  :precision binary64
  (- (log x) (log (log x))))