Average Error: 3.2 → 0.0
Time: 9.4s
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.2
Target0.0
Herbie0.0
\[x + \frac{1}{\frac{1.1283791670955126}{y} \cdot e^{z} - x} \]

Derivation

  1. Initial program 3.2

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

    \[\leadsto \color{blue}{x + \frac{-1}{\mathsf{fma}\left(e^{z}, \frac{-1.1283791670955126}{y}, x\right)}} \]
    Proof
    (+.f64 x (/.f64 -1 (fma.f64 (exp.f64 z) (/.f64 -5641895835477563/5000000000000000 y) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (fma.f64 (exp.f64 z) (/.f64 (Rewrite<= metadata-eval (neg.f64 5641895835477563/5000000000000000)) y) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (fma.f64 (exp.f64 z) (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 5641895835477563/5000000000000000 y))) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (exp.f64 z) (neg.f64 (/.f64 5641895835477563/5000000000000000 y))) x)))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (+.f64 (*.f64 (exp.f64 z) (Rewrite=> distribute-neg-frac_binary64 (/.f64 (neg.f64 5641895835477563/5000000000000000) y))) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (+.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (exp.f64 z) (neg.f64 5641895835477563/5000000000000000)) y)) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (+.f64 (/.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (exp.f64 z) 5641895835477563/5000000000000000))) y) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (+.f64 (/.f64 (neg.f64 (Rewrite<= *-commutative_binary64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z)))) y) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (Rewrite<= +-commutative_binary64 (+.f64 x (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) y))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (+.f64 (Rewrite<= *-rgt-identity_binary64 (*.f64 x 1)) (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) y)))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (+.f64 (*.f64 x (Rewrite<= metadata-eval (neg.f64 -1))) (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) y)))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (Rewrite<= fma-udef_binary64 (fma.f64 x (neg.f64 -1) (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) y))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (fma.f64 (Rewrite<= /-rgt-identity_binary64 (/.f64 x 1)) (neg.f64 -1) (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) y)))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (fma.f64 (/.f64 x (Rewrite<= metadata-eval (neg.f64 -1))) (neg.f64 -1) (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) y)))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (fma.f64 (/.f64 x (neg.f64 -1)) (Rewrite=> metadata-eval 1) (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) y)))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (fma.f64 (/.f64 x (neg.f64 -1)) (Rewrite<= *-inverses_binary64 (/.f64 y y)) (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) y)))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (fma.f64 (/.f64 x (neg.f64 -1)) (/.f64 y y) (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) y)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (fma.f64 (/.f64 x (neg.f64 -1)) (/.f64 y y) (*.f64 (Rewrite<= metadata-eval (/.f64 -1 -1)) (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) y))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (fma.f64 (/.f64 x (neg.f64 -1)) (/.f64 y y) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 -1 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z)))) (*.f64 -1 y)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (fma.f64 (/.f64 x (neg.f64 -1)) (/.f64 y y) (/.f64 (*.f64 -1 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z)))) (Rewrite<= neg-mul-1_binary64 (neg.f64 y)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (fma.f64 (/.f64 x (neg.f64 -1)) (/.f64 y y) (Rewrite<= associate-*r/_binary64 (*.f64 -1 (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) (neg.f64 y))))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (fma.f64 (/.f64 x (neg.f64 -1)) (/.f64 y y) (Rewrite<= neg-mul-1_binary64 (neg.f64 (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) (neg.f64 y))))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 (/.f64 x (neg.f64 -1)) (/.f64 y y)) (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) (neg.f64 y)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (-.f64 (*.f64 (/.f64 x (Rewrite=> metadata-eval 1)) (/.f64 y y)) (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) (neg.f64 y))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (-.f64 (*.f64 (Rewrite=> /-rgt-identity_binary64 x) (/.f64 y y)) (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) (neg.f64 y))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (-.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 x y) y)) (/.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) (neg.f64 y))))): 17 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (-.f64 (/.f64 (*.f64 x y) y) (/.f64 (Rewrite=> distribute-lft-neg-in_binary64 (*.f64 (neg.f64 5641895835477563/5000000000000000) (exp.f64 z))) (neg.f64 y))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (-.f64 (/.f64 (*.f64 x y) y) (/.f64 (*.f64 (neg.f64 5641895835477563/5000000000000000) (exp.f64 z)) (Rewrite=> neg-mul-1_binary64 (*.f64 -1 y)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (-.f64 (/.f64 (*.f64 x y) y) (Rewrite=> times-frac_binary64 (*.f64 (/.f64 (neg.f64 5641895835477563/5000000000000000) -1) (/.f64 (exp.f64 z) y)))))): 3 points increase in error, 1 points decrease in error
    (+.f64 x (/.f64 -1 (-.f64 (/.f64 (*.f64 x y) y) (*.f64 (/.f64 (Rewrite=> metadata-eval -5641895835477563/5000000000000000) -1) (/.f64 (exp.f64 z) y))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (-.f64 (/.f64 (*.f64 x y) y) (*.f64 (Rewrite=> metadata-eval 5641895835477563/5000000000000000) (/.f64 (exp.f64 z) y))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 -1 (-.f64 (/.f64 (*.f64 x y) y) (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z)) y))))): 1 points increase in error, 3 points decrease in error
    (+.f64 x (/.f64 -1 (Rewrite<= div-sub_binary64 (/.f64 (-.f64 (*.f64 x y) (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) y)))): 1 points increase in error, 0 points decrease in error
    (+.f64 x (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 -1 y) (-.f64 (*.f64 x y) (*.f64 5641895835477563/5000000000000000 (exp.f64 z)))))): 13 points increase in error, 7 points decrease in error
    (+.f64 x (/.f64 (*.f64 -1 y) (Rewrite=> sub-neg_binary64 (+.f64 (*.f64 x y) (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 (*.f64 -1 y) (Rewrite=> +-commutative_binary64 (+.f64 (neg.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z))) (*.f64 x y))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 (*.f64 -1 y) (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 (*.f64 5641895835477563/5000000000000000 (exp.f64 z)))) (*.f64 x y)))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 (*.f64 -1 y) (Rewrite=> associate-+l-_binary64 (-.f64 0 (-.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z)) (*.f64 x y)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 (*.f64 -1 y) (Rewrite=> sub0-neg_binary64 (neg.f64 (-.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z)) (*.f64 x y)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (/.f64 (*.f64 -1 y) (Rewrite=> neg-mul-1_binary64 (*.f64 -1 (-.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z)) (*.f64 x y)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (Rewrite=> times-frac_binary64 (*.f64 (/.f64 -1 -1) (/.f64 y (-.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z)) (*.f64 x y)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (*.f64 (Rewrite=> metadata-eval 1) (/.f64 y (-.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z)) (*.f64 x y))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (Rewrite=> *-lft-identity_binary64 (/.f64 y (-.f64 (*.f64 5641895835477563/5000000000000000 (exp.f64 z)) (*.f64 x y))))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.0

    \[\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 20:\\ \;\;\;\;x + \frac{y}{e^{z} \cdot 1.1283791670955126 - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error0.3
Cost19912
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 0:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{elif}\;e^{z} \leq 2:\\ \;\;\;\;x + \frac{-1}{x + \frac{-1.1283791670955126}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{0.8862269254527579}{e^{z}}\\ \end{array} \]
Alternative 3
Error0.7
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -12594826812897352000:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{elif}\;z \leq 2.583350004974967:\\ \;\;\;\;x + \frac{y}{1.1283791670955126 - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error0.7
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -12594826812897352000:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{elif}\;z \leq 2.583350004974967:\\ \;\;\;\;x + \frac{-1}{x + \frac{-1.1283791670955126}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error8.9
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -4.1379343507615794 \cdot 10^{-20}:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{elif}\;z \leq 4.359648435613651 \cdot 10^{-84}:\\ \;\;\;\;x + \frac{y}{1.1283791670955126}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error19.2
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -3.019556662705295 \cdot 10^{-283}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.7647163224515423 \cdot 10^{-186}:\\ \;\;\;\;y \cdot 0.8862269254527579\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error18.8
Cost452
\[\begin{array}{l} \mathbf{if}\;z \leq 4.359648435613651 \cdot 10^{-84}:\\ \;\;\;\;x + \frac{y}{1.1283791670955126}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error20.2
Cost64
\[x \]

Error

Reproduce

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