Numeric.SpecFunctions:invErfc from math-functions-0.1.5.2, A

?

Percentage Accurate: 95.3% → 99.9%
Time: 8.5s
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)}

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.

Herbie found 11 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

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.

Bogosity?

Bogosity

Target

Original95.3%
Target99.9%
Herbie99.9%
\[x + \frac{1}{\frac{1.1283791670955126}{y} \cdot e^{z} - x} \]

Derivation?

  1. Initial program 94.9%

    \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
  2. Simplified100.0%

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

    [Start]94.9%

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

    *-lft-identity [<=]94.9%

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

    metadata-eval [<=]94.9%

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

    times-frac [<=]94.9%

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

    neg-mul-1 [<=]94.9%

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

    sub0-neg [<=]94.8%

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

    associate-+l- [<=]94.8%

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

    neg-sub0 [<=]94.9%

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

    +-commutative [<=]94.9%

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

    sub-neg [<=]94.9%

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

    associate-/l* [=>]95.0%

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

    div-sub [=>]94.9%

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

    associate-*r/ [<=]100.0%

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

    *-inverses [=>]100.0%

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

    *-rgt-identity [=>]100.0%

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

    associate-*l/ [<=]100.0%

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

    cancel-sign-sub-inv [=>]100.0%

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

    distribute-lft-neg-in [<=]100.0%

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

    distribute-rgt-neg-in [=>]100.0%

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

    associate-*l/ [=>]100.0%

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

    distribute-rgt-neg-in [<=]100.0%

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

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

Alternatives

Alternative 1
Accuracy99.9%
Cost13376
\[x + \frac{-1}{\mathsf{fma}\left(e^{z}, \frac{-1.1283791670955126}{y}, x\right)} \]
Alternative 2
Accuracy99.5%
Cost19912
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 0:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{elif}\;e^{z} \leq 1.002:\\ \;\;\;\;x + \frac{-1}{\left(x + -1.1283791670955126 \cdot \frac{z}{y}\right) - \frac{1.1283791670955126}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{e^{z} \cdot 1.1283791670955126}\\ \end{array} \]
Alternative 3
Accuracy97.9%
Cost14276
\[\begin{array}{l} t_0 := x + \frac{y}{e^{z} \cdot 1.1283791670955126 - x \cdot y}\\ \mathbf{if}\;t_0 \leq 10^{+199}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x + \frac{-1}{x}\\ \end{array} \]
Alternative 4
Accuracy98.8%
Cost1224
\[\begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{+26}:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{elif}\;z \leq 245:\\ \;\;\;\;x + \frac{-1}{\left(x + -1.1283791670955126 \cdot \frac{z}{y}\right) - \frac{1.1283791670955126}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Accuracy82.6%
Cost1104
\[\begin{array}{l} t_0 := x + \frac{-1}{x}\\ \mathbf{if}\;z \leq -4.6 \cdot 10^{-35}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.6 \cdot 10^{-144}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-129}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.018:\\ \;\;\;\;x + \left(y \cdot -0.8862269254527579\right) \cdot \left(-1 + z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Accuracy98.8%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{+26}:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{elif}\;z \leq 118:\\ \;\;\;\;x + \frac{y}{\left(1.1283791670955126 + z \cdot 1.1283791670955126\right) - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Accuracy82.5%
Cost980
\[\begin{array}{l} t_0 := x + \frac{-1}{x}\\ \mathbf{if}\;z \leq -6.4 \cdot 10^{-35}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-144}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{-128}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{-33}:\\ \;\;\;\;x + \frac{y}{1.1283791670955126}\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-32}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Accuracy82.6%
Cost980
\[\begin{array}{l} t_0 := x + \frac{-1}{x}\\ \mathbf{if}\;z \leq -1.9 \cdot 10^{-34}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-141}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{-132}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{-33}:\\ \;\;\;\;x + \frac{-1}{\frac{-1.1283791670955126}{y}}\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-32}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Accuracy98.7%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{+26}:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{elif}\;z \leq 145:\\ \;\;\;\;x + \frac{-1}{x + \frac{-1.1283791670955126}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy81.8%
Cost717
\[\begin{array}{l} \mathbf{if}\;z \leq -2.05 \cdot 10^{-34} \lor \neg \left(z \leq -3.3 \cdot 10^{-141}\right) \land z \leq 1.42 \cdot 10^{-245}:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Accuracy69.3%
Cost64
\[x \]

Reproduce?

herbie shell --seed 2023167 
(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)))))