Average Error: 0.1 → 0.1
Time: 13.5s
Precision: binary64
Cost: 19648
\[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
\[\mathsf{fma}\left(\log y, x, \log t - \left(y + z\right)\right) \]
(FPCore (x y z t) :precision binary64 (+ (- (- (* x (log y)) y) z) (log t)))
(FPCore (x y z t) :precision binary64 (fma (log y) x (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
	return (((x * log(y)) - y) - z) + log(t);
}
double code(double x, double y, double z, double t) {
	return fma(log(y), x, (log(t) - (y + z)));
}
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(x * log(y)) - y) - z) + log(t))
end
function code(x, y, z, t)
	return fma(log(y), x, Float64(log(t) - Float64(y + z)))
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[Log[y], $MachinePrecision] * x + N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\mathsf{fma}\left(\log y, x, \log t - \left(y + z\right)\right)

Error

Derivation

  1. Initial program 0.1

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Simplified0.1

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

    [Start]0.1

    \[ \left(\left(x \cdot \log y - y\right) - z\right) + \log t \]

    associate-+l- [=>]0.1

    \[ \color{blue}{\left(x \cdot \log y - y\right) - \left(z - \log t\right)} \]
  3. Taylor expanded in x around 0 0.1

    \[\leadsto \color{blue}{\left(\log y \cdot x + \log t\right) - \left(y + z\right)} \]
  4. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, \log t - \left(y + z\right)\right)} \]
    Proof

    [Start]0.1

    \[ \left(\log y \cdot x + \log t\right) - \left(y + z\right) \]

    +-commutative [=>]0.1

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

    remove-double-neg [<=]0.1

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

    neg-mul-1 [=>]0.1

    \[ \left(\color{blue}{-1 \cdot \left(-\log t\right)} + \log y \cdot x\right) - \left(y + z\right) \]

    mul-1-neg [<=]0.1

    \[ \left(-1 \cdot \color{blue}{\left(-1 \cdot \log t\right)} + \log y \cdot x\right) - \left(y + z\right) \]

    associate-*r* [=>]0.1

    \[ \left(\color{blue}{\left(-1 \cdot -1\right) \cdot \log t} + \log y \cdot x\right) - \left(y + z\right) \]

    metadata-eval [=>]0.1

    \[ \left(\color{blue}{1} \cdot \log t + \log y \cdot x\right) - \left(y + z\right) \]

    *-commutative [<=]0.1

    \[ \left(\color{blue}{\log t \cdot 1} + \log y \cdot x\right) - \left(y + z\right) \]

    *-commutative [=>]0.1

    \[ \left(\log t \cdot 1 + \color{blue}{x \cdot \log y}\right) - \left(y + z\right) \]

    associate-+r- [<=]0.1

    \[ \color{blue}{\log t \cdot 1 + \left(x \cdot \log y - \left(y + z\right)\right)} \]

    *-rgt-identity [<=]0.1

    \[ \log t \cdot 1 + \color{blue}{\left(x \cdot \log y - \left(y + z\right)\right) \cdot 1} \]

    distribute-rgt-in [<=]0.1

    \[ \color{blue}{1 \cdot \left(\log t + \left(x \cdot \log y - \left(y + z\right)\right)\right)} \]

    *-lft-identity [=>]0.1

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

    +-commutative [=>]0.1

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

    associate-+l- [=>]0.1

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

    associate-+r- [<=]0.1

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

    unsub-neg [<=]0.1

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

    *-commutative [<=]0.1

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

    fma-udef [<=]0.1

    \[ \color{blue}{\mathsf{fma}\left(\log y, x, -\left(y + \left(z - \log t\right)\right)\right)} \]

    distribute-neg-in [=>]0.1

    \[ \mathsf{fma}\left(\log y, x, \color{blue}{\left(-y\right) + \left(-\left(z - \log t\right)\right)}\right) \]

    sub-neg [<=]0.1

    \[ \mathsf{fma}\left(\log y, x, \color{blue}{\left(-y\right) - \left(z - \log t\right)}\right) \]

    associate--r- [=>]0.1

    \[ \mathsf{fma}\left(\log y, x, \color{blue}{\left(\left(-y\right) - z\right) + \log t}\right) \]

    +-commutative [=>]0.1

    \[ \mathsf{fma}\left(\log y, x, \color{blue}{\log t + \left(\left(-y\right) - z\right)}\right) \]

    associate--l+ [<=]0.1

    \[ \mathsf{fma}\left(\log y, x, \color{blue}{\left(\log t + \left(-y\right)\right) - z}\right) \]

    neg-sub0 [=>]0.1

    \[ \mathsf{fma}\left(\log y, x, \left(\log t + \color{blue}{\left(0 - y\right)}\right) - z\right) \]

    associate-+r- [=>]0.1

    \[ \mathsf{fma}\left(\log y, x, \color{blue}{\left(\left(\log t + 0\right) - y\right)} - z\right) \]

    +-commutative [<=]0.1

    \[ \mathsf{fma}\left(\log y, x, \left(\color{blue}{\left(0 + \log t\right)} - y\right) - z\right) \]

    metadata-eval [<=]0.1

    \[ \mathsf{fma}\left(\log y, x, \left(\left(\color{blue}{\left(0 - 0\right)} + \log t\right) - y\right) - z\right) \]

    associate--r- [<=]0.1

    \[ \mathsf{fma}\left(\log y, x, \left(\color{blue}{\left(0 - \left(0 - \log t\right)\right)} - y\right) - z\right) \]

    neg-sub0 [<=]0.1

    \[ \mathsf{fma}\left(\log y, x, \left(\left(0 - \color{blue}{\left(-\log t\right)}\right) - y\right) - z\right) \]

    neg-sub0 [<=]0.1

    \[ \mathsf{fma}\left(\log y, x, \left(\color{blue}{\left(-\left(-\log t\right)\right)} - y\right) - z\right) \]

    remove-double-neg [=>]0.1

    \[ \mathsf{fma}\left(\log y, x, \left(\color{blue}{\log t} - y\right) - z\right) \]

    associate--r+ [<=]0.1

    \[ \mathsf{fma}\left(\log y, x, \color{blue}{\log t - \left(y + z\right)}\right) \]
  5. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(\log y, x, \log t - \left(y + z\right)\right) \]

Alternatives

Alternative 1
Error0.9
Cost20425
\[\begin{array}{l} t_1 := \log y \cdot x - y\\ \mathbf{if}\;t_1 \leq -1000000000000 \lor \neg \left(t_1 \leq 0.0001\right):\\ \;\;\;\;t_1 - z\\ \mathbf{else}:\\ \;\;\;\;\log t - z\\ \end{array} \]
Alternative 2
Error0.5
Cost13380
\[\begin{array}{l} t_1 := \log y \cdot x\\ \mathbf{if}\;y \leq 6 \cdot 10^{-10}:\\ \;\;\;\;\left(\log t + t_1\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(t_1 - y\right) - z\\ \end{array} \]
Alternative 3
Error0.1
Cost13376
\[\log t + \left(\left(\log y \cdot x - y\right) - z\right) \]
Alternative 4
Error19.3
Cost7120
\[\begin{array}{l} t_1 := \log y \cdot x\\ t_2 := \left(-z\right) - y\\ \mathbf{if}\;x \leq -4.9 \cdot 10^{+120}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{-295}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-100}:\\ \;\;\;\;\log t - z\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+156}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error10.3
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{+120} \lor \neg \left(x \leq 8 \cdot 10^{+155}\right):\\ \;\;\;\;\log y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\log t - \left(y + z\right)\\ \end{array} \]
Alternative 6
Error6.8
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -1.46 \cdot 10^{+119} \lor \neg \left(x \leq 1.8 \cdot 10^{+28}\right):\\ \;\;\;\;\log y \cdot x - y\\ \mathbf{else}:\\ \;\;\;\;\log t - \left(y + z\right)\\ \end{array} \]
Alternative 7
Error7.2
Cost6984
\[\begin{array}{l} t_1 := \log y \cdot x\\ \mathbf{if}\;x \leq -1.46 \cdot 10^{+119}:\\ \;\;\;\;t_1 - y\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{+98}:\\ \;\;\;\;\log t - \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 - z\\ \end{array} \]
Alternative 8
Error17.8
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{+120} \lor \neg \left(x \leq 8 \cdot 10^{+155}\right):\\ \;\;\;\;\log y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(-z\right) - y\\ \end{array} \]
Alternative 9
Error33.0
Cost392
\[\begin{array}{l} \mathbf{if}\;z \leq -1.2 \cdot 10^{+100}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+92}:\\ \;\;\;\;-y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
Alternative 10
Error26.6
Cost256
\[\left(-z\right) - y \]
Alternative 11
Error44.3
Cost128
\[-y \]

Error

Reproduce

herbie shell --seed 2022364 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, A"
  :precision binary64
  (+ (- (- (* x (log y)) y) z) (log t)))