Average Error: 11.8 → 2.8
Time: 3.9s
Precision: binary64
Cost: 776
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -8.17163490039745 \cdot 10^{-193} \lor \neg \left(z \leq 7.722781478682705 \cdot 10^{-34}\right):\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \mathbf{else}:\\ \;\;\;\;\left(z + y\right) \cdot \frac{x}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \leq -8.17163490039745 \cdot 10^{-193} \lor \neg \left(z \leq 7.722781478682705 \cdot 10^{-34}\right):\\
\;\;\;\;\frac{x}{\frac{z}{z + y}}\\

\mathbf{else}:\\
\;\;\;\;\left(z + y\right) \cdot \frac{x}{z}\\

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -8.17163490039745e-193) (not (<= z 7.722781478682705e-34)))
   (/ x (/ z (+ z y)))
   (* (+ z y) (/ x z))))
double code(double x, double y, double z) {
	return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -8.17163490039745e-193) || !(z <= 7.722781478682705e-34)) {
		tmp = x / (z / (z + y));
	} else {
		tmp = (z + y) * (x / z);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.8
Target2.8
Herbie2.8
\[\frac{x}{\frac{z}{y + z}}\]

Alternatives

Alternative 1
Error2.9
Cost776
\[\begin{array}{l} \mathbf{if}\;z \leq -4.515560721214784 \cdot 10^{-192} \lor \neg \left(z \leq 4.477470373920615 \cdot 10^{-13}\right):\\ \;\;\;\;x \cdot \frac{z + y}{z}\\ \mathbf{else}:\\ \;\;\;\;\left(z + y\right) \cdot \frac{x}{z}\\ \end{array}\]
Alternative 2
Error7.3
Cost1090
\[\begin{array}{l} \mathbf{if}\;z \leq -1.0284964039503734 \cdot 10^{+162}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 5.468732810188744 \cdot 10^{+113}:\\ \;\;\;\;\left(z + y\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
Alternative 3
Error18.5
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -7.609603959076575 \cdot 10^{+82} \lor \neg \left(y \leq 84293394894.90135\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
Alternative 4
Error19.7
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.4205284429259029 \cdot 10^{+87} \lor \neg \left(y \leq 492612863705699.2\right):\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
Alternative 5
Error25.5
Cost64
\[x\]
Alternative 6
Error61.8
Cost64
\[0\]
Alternative 7
Error61.8
Cost64
\[1\]

Error

Derivation

  1. Split input into 2 regimes
  2. if z < -8.17163490039744971e-193 or 7.7227814786827051e-34 < z

    1. Initial program 13.1

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied associate-/l*_binary64_78660.9

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Simplified0.9

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{z + y}}}\]

    if -8.17163490039744971e-193 < z < 7.7227814786827051e-34

    1. Initial program 7.6

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied associate-/l*_binary64_78668.9

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Using strategy rm
    5. Applied associate-/r/_binary64_78678.8

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)}\]
    6. Simplified8.8

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(z + y\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.17163490039745 \cdot 10^{-193} \lor \neg \left(z \leq 7.722781478682705 \cdot 10^{-34}\right):\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \mathbf{else}:\\ \;\;\;\;\left(z + y\right) \cdot \frac{x}{z}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (/ x (/ z (+ y z)))

  (/ (* x (+ y z)) z))