Average Error: 12.8 → 0.9
Time: 2.1s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \leq -\infty:\\ \;\;\;\;x \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq -9.265470348424293 \cdot 10^{-272}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 1.3380029843894863 \cdot 10^{+106}:\\ \;\;\;\;x \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 3.7319691449889546 \cdot 10^{+292}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{\frac{z}{y + z}}} \cdot \frac{x}{\sqrt{\frac{z}{y + z}}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \leq -\infty:\\
\;\;\;\;x \cdot \left(1 + \frac{y}{z}\right)\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq -9.265470348424293 \cdot 10^{-272}:\\
\;\;\;\;x + \frac{x \cdot y}{z}\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 1.3380029843894863 \cdot 10^{+106}:\\
\;\;\;\;x \cdot \left(1 + \frac{y}{z}\right)\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 3.7319691449889546 \cdot 10^{+292}:\\
\;\;\;\;x + \frac{x \cdot y}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{z}{y + z}}} \cdot \frac{x}{\sqrt{\frac{z}{y + z}}}\\

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= (/ (* x (+ y z)) z) (- INFINITY))
   (* x (+ 1.0 (/ y z)))
   (if (<= (/ (* x (+ y z)) z) -9.265470348424293e-272)
     (+ x (/ (* x y) z))
     (if (<= (/ (* x (+ y z)) z) 1.3380029843894863e+106)
       (* x (+ 1.0 (/ y z)))
       (if (<= (/ (* x (+ y z)) z) 3.7319691449889546e+292)
         (+ x (/ (* x y) z))
         (* (/ 1.0 (sqrt (/ z (+ y z)))) (/ x (sqrt (/ z (+ y 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 (((x * (y + z)) / z) <= -((double) INFINITY)) {
		tmp = x * (1.0 + (y / z));
	} else if (((x * (y + z)) / z) <= -9.265470348424293e-272) {
		tmp = x + ((x * y) / z);
	} else if (((x * (y + z)) / z) <= 1.3380029843894863e+106) {
		tmp = x * (1.0 + (y / z));
	} else if (((x * (y + z)) / z) <= 3.7319691449889546e+292) {
		tmp = x + ((x * y) / z);
	} else {
		tmp = (1.0 / sqrt(z / (y + z))) * (x / sqrt(z / (y + 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

Original12.8
Target3.2
Herbie0.9
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 x (+.f64 y z)) z) < -inf.0 or -9.26547034842429255e-272 < (/.f64 (*.f64 x (+.f64 y z)) z) < 1.33800298438948625e106

    1. Initial program 19.3

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity_binary6419.3

      \[\leadsto \frac{x \cdot \left(y + z\right)}{\color{blue}{1 \cdot z}}\]
    4. Applied times-frac_binary640.6

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y + z}{z}}\]
    5. Simplified0.6

      \[\leadsto \color{blue}{x} \cdot \frac{y + z}{z}\]
    6. Taylor expanded around 0 0.6

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

      \[\leadsto x \cdot \color{blue}{\left(1 + \frac{y}{z}\right)}\]

    if -inf.0 < (/.f64 (*.f64 x (+.f64 y z)) z) < -9.26547034842429255e-272 or 1.33800298438948625e106 < (/.f64 (*.f64 x (+.f64 y z)) z) < 3.7319691449889546e292

    1. Initial program 0.3

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Taylor expanded around 0 0.2

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

    if 3.7319691449889546e292 < (/.f64 (*.f64 x (+.f64 y z)) z)

    1. Initial program 58.6

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt_binary647.4

      \[\leadsto \frac{x}{\color{blue}{\sqrt{\frac{z}{y + z}} \cdot \sqrt{\frac{z}{y + z}}}}\]
    6. Applied *-un-lft-identity_binary647.4

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\sqrt{\frac{z}{y + z}} \cdot \sqrt{\frac{z}{y + z}}}\]
    7. Applied times-frac_binary647.4

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\frac{z}{y + z}}} \cdot \frac{x}{\sqrt{\frac{z}{y + z}}}}\]
    8. Simplified7.4

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\frac{z}{z + y}}}} \cdot \frac{x}{\sqrt{\frac{z}{y + z}}}\]
    9. Simplified7.4

      \[\leadsto \frac{1}{\sqrt{\frac{z}{z + y}}} \cdot \color{blue}{\frac{x}{\sqrt{\frac{z}{z + y}}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \leq -\infty:\\ \;\;\;\;x \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq -9.265470348424293 \cdot 10^{-272}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 1.3380029843894863 \cdot 10^{+106}:\\ \;\;\;\;x \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 3.7319691449889546 \cdot 10^{+292}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{\frac{z}{y + z}}} \cdot \frac{x}{\sqrt{\frac{z}{y + z}}}\\ \end{array}\]

Reproduce

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