?

Average Accuracy: 75.9% → 99.7%
Time: 12.5s
Precision: binary64
Cost: 26112

?

\[x \cdot \log \left(\frac{x}{y}\right) - z \]
\[\mathsf{fma}\left(x \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right), 3, -z\right) \]
(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
(FPCore (x y z)
 :precision binary64
 (fma (* x (log (/ (cbrt x) (cbrt y)))) 3.0 (- z)))
double code(double x, double y, double z) {
	return (x * log((x / y))) - z;
}
double code(double x, double y, double z) {
	return fma((x * log((cbrt(x) / cbrt(y)))), 3.0, -z);
}
function code(x, y, z)
	return Float64(Float64(x * log(Float64(x / y))) - z)
end
function code(x, y, z)
	return fma(Float64(x * log(Float64(cbrt(x) / cbrt(y)))), 3.0, Float64(-z))
end
code[x_, y_, z_] := N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
code[x_, y_, z_] := N[(N[(x * N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 3.0 + (-z)), $MachinePrecision]
x \cdot \log \left(\frac{x}{y}\right) - z
\mathsf{fma}\left(x \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right), 3, -z\right)

Error?

Target

Original75.9%
Target87.7%
Herbie99.7%
\[\begin{array}{l} \mathbf{if}\;y < 7.595077799083773 \cdot 10^{-308}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array} \]

Derivation?

  1. Initial program 75.9%

    \[x \cdot \log \left(\frac{x}{y}\right) - z \]
  2. Applied egg-rr75.8%

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

    [Start]75.9

    \[ x \cdot \log \left(\frac{x}{y}\right) - z \]

    add-cube-cbrt [=>]75.9

    \[ x \cdot \log \color{blue}{\left(\left(\sqrt[3]{\frac{x}{y}} \cdot \sqrt[3]{\frac{x}{y}}\right) \cdot \sqrt[3]{\frac{x}{y}}\right)} - z \]

    log-prod [=>]75.8

    \[ x \cdot \color{blue}{\left(\log \left(\sqrt[3]{\frac{x}{y}} \cdot \sqrt[3]{\frac{x}{y}}\right) + \log \left(\sqrt[3]{\frac{x}{y}}\right)\right)} - z \]

    pow2 [=>]75.8

    \[ x \cdot \left(\log \color{blue}{\left({\left(\sqrt[3]{\frac{x}{y}}\right)}^{2}\right)} + \log \left(\sqrt[3]{\frac{x}{y}}\right)\right) - z \]
  3. Simplified75.8%

    \[\leadsto x \cdot \color{blue}{\left(\log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot 3\right)} - z \]
    Proof

    [Start]75.8

    \[ x \cdot \left(\log \left({\left(\sqrt[3]{\frac{x}{y}}\right)}^{2}\right) + \log \left(\sqrt[3]{\frac{x}{y}}\right)\right) - z \]

    log-pow [=>]75.8

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

    *-lft-identity [<=]75.8

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

    distribute-rgt-out [=>]75.8

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

    metadata-eval [=>]75.8

    \[ x \cdot \left(\log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot \color{blue}{3}\right) - z \]
  4. Applied egg-rr75.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right), 3, -z\right)} \]
    Proof

    [Start]75.8

    \[ x \cdot \left(\log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot 3\right) - z \]

    associate-*r* [=>]75.8

    \[ \color{blue}{\left(x \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right)\right) \cdot 3} - z \]

    fma-neg [=>]75.8

    \[ \color{blue}{\mathsf{fma}\left(x \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right), 3, -z\right)} \]
  5. Applied egg-rr99.7%

    \[\leadsto \mathsf{fma}\left(x \cdot \log \color{blue}{\left(\sqrt[3]{x} \cdot \frac{1}{\sqrt[3]{y}}\right)}, 3, -z\right) \]
    Proof

    [Start]75.8

    \[ \mathsf{fma}\left(x \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right), 3, -z\right) \]

    cbrt-div [=>]99.7

    \[ \mathsf{fma}\left(x \cdot \log \color{blue}{\left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)}, 3, -z\right) \]

    div-inv [=>]99.7

    \[ \mathsf{fma}\left(x \cdot \log \color{blue}{\left(\sqrt[3]{x} \cdot \frac{1}{\sqrt[3]{y}}\right)}, 3, -z\right) \]
  6. Simplified99.7%

    \[\leadsto \mathsf{fma}\left(x \cdot \log \color{blue}{\left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)}, 3, -z\right) \]
    Proof

    [Start]99.7

    \[ \mathsf{fma}\left(x \cdot \log \left(\sqrt[3]{x} \cdot \frac{1}{\sqrt[3]{y}}\right), 3, -z\right) \]

    associate-*r/ [=>]99.7

    \[ \mathsf{fma}\left(x \cdot \log \color{blue}{\left(\frac{\sqrt[3]{x} \cdot 1}{\sqrt[3]{y}}\right)}, 3, -z\right) \]

    *-rgt-identity [=>]99.7

    \[ \mathsf{fma}\left(x \cdot \log \left(\frac{\color{blue}{\sqrt[3]{x}}}{\sqrt[3]{y}}\right), 3, -z\right) \]
  7. Final simplification99.7%

    \[\leadsto \mathsf{fma}\left(x \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right), 3, -z\right) \]

Alternatives

Alternative 1
Accuracy88.0%
Cost20425
\[\begin{array}{l} t_0 := x \cdot \log \left(\frac{x}{y}\right)\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 4 \cdot 10^{+305}\right):\\ \;\;\;\;x \cdot \log \left(x \cdot y\right) - z\\ \mathbf{else}:\\ \;\;\;\;t_0 - z\\ \end{array} \]
Alternative 2
Accuracy87.3%
Cost20424
\[\begin{array}{l} t_0 := x \cdot \log \left(\frac{x}{y}\right)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;-z\\ \mathbf{elif}\;t_0 \leq 4 \cdot 10^{+305}:\\ \;\;\;\;t_0 - z\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
Alternative 3
Accuracy99.7%
Cost19776
\[x \cdot \left(\log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot 3\right) - z \]
Alternative 4
Accuracy93.3%
Cost13644
\[\begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{+128}:\\ \;\;\;\;x \cdot \left(\log \left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{-171}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-308}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array} \]
Alternative 5
Accuracy90.7%
Cost13512
\[\begin{array}{l} \mathbf{if}\;x \leq -2.2 \cdot 10^{-171}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-308}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array} \]
Alternative 6
Accuracy99.5%
Cost13508
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-310}:\\ \;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array} \]
Alternative 7
Accuracy66.9%
Cost7048
\[\begin{array}{l} \mathbf{if}\;z \leq -500000:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 7 \cdot 10^{-7}:\\ \;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
Alternative 8
Accuracy66.6%
Cost6984
\[\begin{array}{l} \mathbf{if}\;z \leq -2100:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{-9}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
Alternative 9
Accuracy50.3%
Cost128
\[-z \]
Alternative 10
Accuracy2.2%
Cost64
\[z \]

Error

Reproduce?

herbie shell --seed 2023133 
(FPCore (x y z)
  :name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z))

  (- (* x (log (/ x y))) z))