Average Error: 12.2 → 0.4
Time: 3.6s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -2.1473147582397338 \cdot 10^{+293}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq -8.814136530602186 \cdot 10^{+28}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 0:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 5.508883096360809 \cdot 10^{+302}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -2.1473147582397338 \cdot 10^{+293}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\

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

\mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 0:\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

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

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (if (<= (/ (* x (- y z)) y) -2.1473147582397338e+293)
   (/ x (/ y (- y z)))
   (if (<= (/ (* x (- y z)) y) -8.814136530602186e+28)
     (- x (/ (* x z) y))
     (if (<= (/ (* x (- y z)) y) 0.0)
       (* x (/ (- y z) y))
       (if (<= (/ (* x (- y z)) y) 5.508883096360809e+302)
         (- x (/ (* x z) y))
         (* x (- 1.0 (/ z y))))))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double tmp;
	if (((x * (y - z)) / y) <= -2.1473147582397338e+293) {
		tmp = x / (y / (y - z));
	} else if (((x * (y - z)) / y) <= -8.814136530602186e+28) {
		tmp = x - ((x * z) / y);
	} else if (((x * (y - z)) / y) <= 0.0) {
		tmp = x * ((y - z) / y);
	} else if (((x * (y - z)) / y) <= 5.508883096360809e+302) {
		tmp = x - ((x * z) / y);
	} else {
		tmp = x * (1.0 - (z / y));
	}
	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.2
Target2.9
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;z < -2.060202331921739 \cdot 10^{+104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z < 1.6939766013828526 \cdot 10^{+213}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array}\]

Derivation

  1. Split input into 4 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) y) < -2.1473147582397338e293

    1. Initial program 58.2

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

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

    if -2.1473147582397338e293 < (/.f64 (*.f64 x (-.f64 y z)) y) < -8.8141365306021856e28 or -0.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < 5.50888309636080925e302

    1. Initial program 0.4

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

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

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

    if -8.8141365306021856e28 < (/.f64 (*.f64 x (-.f64 y z)) y) < -0.0

    1. Initial program 10.9

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

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

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

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

    if 5.50888309636080925e302 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 62.1

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Using strategy rm
    5. Applied div-inv_binary64_188300.6

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

      \[\leadsto x \cdot \color{blue}{\left(1 - \frac{z}{y}\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -2.1473147582397338 \cdot 10^{+293}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq -8.814136530602186 \cdot 10^{+28}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 0:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 5.508883096360809 \cdot 10^{+302}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2021019 
(FPCore (x y z)
  :name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

  (/ (* x (- y z)) y))