Average Error: 13.0 → 1.7
Time: 2.3s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;y \leq -5.495148928653015 \cdot 10^{+56} \lor \neg \left(y \leq 1.0694809551932351 \cdot 10^{+101}\right):\\ \;\;\;\;x + y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;y \leq -5.495148928653015 \cdot 10^{+56} \lor \neg \left(y \leq 1.0694809551932351 \cdot 10^{+101}\right):\\
\;\;\;\;x + y \cdot \frac{x}{z}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -5.495148928653015e+56) (not (<= y 1.0694809551932351e+101)))
   (+ x (* y (/ x z)))
   (* x (/ (+ y z) 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 ((y <= -5.495148928653015e+56) || !(y <= 1.0694809551932351e+101)) {
		tmp = x + (y * (x / z));
	} else {
		tmp = x * ((y + z) / 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

Original13.0
Target3.0
Herbie1.7
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -5.4951489286530154e56 or 1.0694809551932351e101 < y

    1. Initial program 13.3

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Taylor expanded around 0 10.8

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

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

    if -5.4951489286530154e56 < y < 1.0694809551932351e101

    1. Initial program 12.9

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{y + z}{z}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.495148928653015 \cdot 10^{+56} \lor \neg \left(y \leq 1.0694809551932351 \cdot 10^{+101}\right):\\ \;\;\;\;x + y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]

Reproduce

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