?

Average Error: 3.0 → 0.1
Time: 13.6s
Precision: binary64
Cost: 13376

?

\[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
\[x + \frac{-1}{\mathsf{fma}\left(e^{z}, \frac{-1.1283791670955126}{y}, x\right)} \]
(FPCore (x y z)
 :precision binary64
 (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))
(FPCore (x y z)
 :precision binary64
 (+ x (/ -1.0 (fma (exp z) (/ -1.1283791670955126 y) x))))
double code(double x, double y, double z) {
	return x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
}
double code(double x, double y, double z) {
	return x + (-1.0 / fma(exp(z), (-1.1283791670955126 / y), x));
}
function code(x, y, z)
	return Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y))))
end
function code(x, y, z)
	return Float64(x + Float64(-1.0 / fma(exp(z), Float64(-1.1283791670955126 / y), x)))
end
code[x_, y_, z_] := N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x + N[(-1.0 / N[(N[Exp[z], $MachinePrecision] * N[(-1.1283791670955126 / y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
x + \frac{-1}{\mathsf{fma}\left(e^{z}, \frac{-1.1283791670955126}{y}, x\right)}

Error?

Target

Original3.0
Target0.1
Herbie0.1
\[x + \frac{1}{\frac{1.1283791670955126}{y} \cdot e^{z} - x} \]

Derivation?

  1. Initial program 3.0

    \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
  2. Simplified0.1

    \[\leadsto \color{blue}{x + \frac{-1}{\mathsf{fma}\left(e^{z}, \frac{-1.1283791670955126}{y}, x\right)}} \]
    Proof

    [Start]3.0

    \[ x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]

    --rgt-identity [<=]3.0

    \[ \color{blue}{\left(x - 0\right)} + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]

    associate-+l- [=>]3.0

    \[ \color{blue}{x - \left(0 - \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\right)} \]

    sub-neg [=>]3.0

    \[ \color{blue}{x + \left(-\left(0 - \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\right)\right)} \]

    +-lft-identity [<=]3.0

    \[ x + \left(-\left(0 - \color{blue}{\left(0 + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\right)}\right)\right) \]

    sub0-neg [=>]3.0

    \[ x + \left(-\color{blue}{\left(-\left(0 + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\right)\right)}\right) \]

    neg-mul-1 [=>]3.0

    \[ x + \left(-\color{blue}{-1 \cdot \left(0 + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\right)}\right) \]

    distribute-lft-neg-in [=>]3.0

    \[ x + \color{blue}{\left(--1\right) \cdot \left(0 + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\right)} \]

    +-lft-identity [=>]3.0

    \[ x + \left(--1\right) \cdot \color{blue}{\frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}} \]

    associate-*r/ [=>]3.0

    \[ x + \color{blue}{\frac{\left(--1\right) \cdot y}{1.1283791670955126 \cdot e^{z} - x \cdot y}} \]

    sub-neg [=>]3.0

    \[ x + \frac{\left(--1\right) \cdot y}{\color{blue}{1.1283791670955126 \cdot e^{z} + \left(-x \cdot y\right)}} \]

    +-commutative [=>]3.0

    \[ x + \frac{\left(--1\right) \cdot y}{\color{blue}{\left(-x \cdot y\right) + 1.1283791670955126 \cdot e^{z}}} \]

    neg-sub0 [=>]3.0

    \[ x + \frac{\left(--1\right) \cdot y}{\color{blue}{\left(0 - x \cdot y\right)} + 1.1283791670955126 \cdot e^{z}} \]

    associate-+l- [=>]3.0

    \[ x + \frac{\left(--1\right) \cdot y}{\color{blue}{0 - \left(x \cdot y - 1.1283791670955126 \cdot e^{z}\right)}} \]

    sub0-neg [=>]3.0

    \[ x + \frac{\left(--1\right) \cdot y}{\color{blue}{-\left(x \cdot y - 1.1283791670955126 \cdot e^{z}\right)}} \]

    neg-mul-1 [=>]3.0

    \[ x + \frac{\left(--1\right) \cdot y}{\color{blue}{-1 \cdot \left(x \cdot y - 1.1283791670955126 \cdot e^{z}\right)}} \]

    times-frac [=>]3.0

    \[ x + \color{blue}{\frac{--1}{-1} \cdot \frac{y}{x \cdot y - 1.1283791670955126 \cdot e^{z}}} \]
  3. Final simplification0.1

    \[\leadsto x + \frac{-1}{\mathsf{fma}\left(e^{z}, \frac{-1.1283791670955126}{y}, x\right)} \]

Alternatives

Alternative 1
Error0.1
Cost20168
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 0:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;e^{z} \leq 1.001:\\ \;\;\;\;x + \frac{y}{e^{z} \cdot 1.1283791670955126 - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error0.2
Cost14152
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 0:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;e^{z} \leq 1.001:\\ \;\;\;\;x + \frac{-1}{\left(x + -1.1283791670955126 \cdot \frac{z}{y}\right) + -1.1283791670955126 \cdot \frac{1}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error18.0
Cost1244
\[\begin{array}{l} t_0 := x + \frac{y}{1.1283791670955126}\\ \mathbf{if}\;x \leq -4 \cdot 10^{-22}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.3 \cdot 10^{-85}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;x \leq -2.65 \cdot 10^{-244}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.45 \cdot 10^{-260}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-252}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-163}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-67}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error18.1
Cost1244
\[\begin{array}{l} t_0 := x + \frac{y}{1.1283791670955126}\\ \mathbf{if}\;x \leq -1.6 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-76}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-242}:\\ \;\;\;\;x + y \cdot 0.8862269254527579\\ \mathbf{elif}\;x \leq -2.45 \cdot 10^{-260}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-252}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-164}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-67}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error8.7
Cost1244
\[\begin{array}{l} t_0 := x - \frac{1}{x}\\ t_1 := x + y \cdot 0.8862269254527579\\ \mathbf{if}\;z \leq -4.4 \cdot 10^{-13}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.4 \cdot 10^{-210}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.9 \cdot 10^{-119}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.45 \cdot 10^{-11}:\\ \;\;\;\;x + \frac{y}{1.1283791670955126}\\ \mathbf{elif}\;z \leq 0.00062:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error8.7
Cost1244
\[\begin{array}{l} t_0 := x - \frac{1}{x}\\ \mathbf{if}\;z \leq -1.45 \cdot 10^{-9}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{-187}:\\ \;\;\;\;x + y \cdot \left(0.8862269254527579 + z \cdot -0.8862269254527579\right)\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{-208}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{-160}:\\ \;\;\;\;x + y \cdot 0.8862269254527579\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{-121}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.52 \cdot 10^{-9}:\\ \;\;\;\;x + \frac{y}{1.1283791670955126}\\ \mathbf{elif}\;z \leq 0.000245:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error0.2
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -145:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;z \leq 0.00155:\\ \;\;\;\;x - \frac{y}{-1.1283791670955126 + \left(x \cdot y + z \cdot -1.1283791670955126\right)}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error18.9
Cost984
\[\begin{array}{l} \mathbf{if}\;x \leq -6.2 \cdot 10^{-21}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-146}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;x \leq -3.6 \cdot 10^{-231}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.15 \cdot 10^{-260}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-252}:\\ \;\;\;\;y \cdot 0.8862269254527579\\ \mathbf{elif}\;x \leq 6.6 \cdot 10^{-105}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error0.3
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -135:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;z \leq 0.00155:\\ \;\;\;\;x + \frac{-1}{x + \frac{-1.1283791670955126}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error19.2
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{-259}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-95}:\\ \;\;\;\;y \cdot 0.8862269254527579\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error19.8
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023031 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:invErfc from math-functions-0.1.5.2, A"
  :precision binary64

  :herbie-target
  (+ x (/ 1.0 (- (* (/ 1.1283791670955126 y) (exp z)) x)))

  (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))