Average Error: 12.5 → 0.8
Time: 2.2s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le -4.40375298531076147 \cdot 10^{90}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 1.52299297723786964 \cdot 10^{132}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 2.57446106865930061 \cdot 10^{293}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, x\right)\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le -4.40375298531076147 \cdot 10^{90}:\\
\;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 1.52299297723786964 \cdot 10^{132}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 2.57446106865930061 \cdot 10^{293}:\\
\;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, x\right)\\

\end{array}
double code(double x, double y, double z) {
	return ((x * (y + z)) / z);
}
double code(double x, double y, double z) {
	double temp;
	if ((((x * (y + z)) / z) <= -inf.0)) {
		temp = fma((y / z), x, x);
	} else {
		double temp_1;
		if ((((x * (y + z)) / z) <= -4.4037529853107615e+90)) {
			temp_1 = ((x * (y + z)) / z);
		} else {
			double temp_2;
			if ((((x * (y + z)) / z) <= 1.5229929772378696e+132)) {
				temp_2 = fma((y / z), x, x);
			} else {
				double temp_3;
				if ((((x * (y + z)) / z) <= 2.5744610686593006e+293)) {
					temp_3 = ((x * (y + z)) / z);
				} else {
					temp_3 = fma((x / z), y, x);
				}
				temp_2 = temp_3;
			}
			temp_1 = temp_2;
		}
		temp = temp_1;
	}
	return temp;
}

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.5
Target3.0
Herbie0.8
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (* x (+ y z)) z) < -inf.0 or -4.4037529853107615e+90 < (/ (* x (+ y z)) z) < 1.5229929772378696e+132

    1. Initial program 11.3

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Simplified0.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, x, x\right)}\]

    if -inf.0 < (/ (* x (+ y z)) z) < -4.4037529853107615e+90 or 1.5229929772378696e+132 < (/ (* x (+ y z)) z) < 2.5744610686593006e+293

    1. Initial program 0.2

      \[\frac{x \cdot \left(y + z\right)}{z}\]

    if 2.5744610686593006e+293 < (/ (* x (+ y z)) z)

    1. Initial program 57.6

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{z}, y, x\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le -4.40375298531076147 \cdot 10^{90}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 1.52299297723786964 \cdot 10^{132}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 2.57446106865930061 \cdot 10^{293}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020049 +o rules:numerics
(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))