Average Error: 12.4 → 0.2
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 -4.317300523670314 \cdot 10^{+292}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq -8066392121713.778 \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \leq 70307706833107.55\right) \land \frac{x \cdot \left(y - z\right)}{y} \leq 2.2205050860855823 \cdot 10^{+306}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -4.317300523670314 \cdot 10^{+292}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\

\mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq -8066392121713.778 \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \leq 70307706833107.55\right) \land \frac{x \cdot \left(y - z\right)}{y} \leq 2.2205050860855823 \cdot 10^{+306}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (if (<= (/ (* x (- y z)) y) -4.317300523670314e+292)
   (* x (- 1.0 (/ z y)))
   (if (or (<= (/ (* x (- y z)) y) -8066392121713.778)
           (and (not (<= (/ (* x (- y z)) y) 70307706833107.55))
                (<= (/ (* x (- y z)) y) 2.2205050860855823e+306)))
     (- x (/ (* x z) y))
     (/ x (/ y (- y z))))))
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) <= -4.317300523670314e+292) {
		tmp = x * (1.0 - (z / y));
	} else if ((((x * (y - z)) / y) <= -8066392121713.778) || (!(((x * (y - z)) / y) <= 70307706833107.55) && (((x * (y - z)) / y) <= 2.2205050860855823e+306))) {
		tmp = x - ((x * z) / y);
	} else {
		tmp = x / (y / (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.4
Target3.1
Herbie0.2
\[\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 3 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) y) < -4.31730052367031402e292

    1. Initial program 57.5

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{y - z}{y}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity_binary641.5

      \[\leadsto x \cdot \frac{y - z}{\color{blue}{1 \cdot y}}\]
    8. Applied *-un-lft-identity_binary641.5

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{1}{1} \cdot \frac{y - z}{y}\right)}\]
    10. Simplified1.5

      \[\leadsto x \cdot \left(\color{blue}{1} \cdot \frac{y - z}{y}\right)\]
    11. Simplified1.5

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

    if -4.31730052367031402e292 < (/.f64 (*.f64 x (-.f64 y z)) y) < -8066392121713.77832 or 70307706833107.547 < (/.f64 (*.f64 x (-.f64 y z)) y) < 2.22050508608558229e306

    1. Initial program 0.2

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

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

    if -8066392121713.77832 < (/.f64 (*.f64 x (-.f64 y z)) y) < 70307706833107.547 or 2.22050508608558229e306 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 14.8

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied sub-neg_binary6414.8

      \[\leadsto \frac{x \cdot \color{blue}{\left(y + \left(-z\right)\right)}}{y}\]
    4. Applied distribute-rgt-in_binary6414.8

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

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

      \[\leadsto \frac{x \cdot y + \color{blue}{\left(-x \cdot z\right)}}{y}\]
    7. Using strategy rm
    8. Applied distribute-rgt-neg-in_binary6414.8

      \[\leadsto \frac{x \cdot y + \color{blue}{x \cdot \left(-z\right)}}{y}\]
    9. Applied distribute-lft-out_binary6414.8

      \[\leadsto \frac{\color{blue}{x \cdot \left(y + \left(-z\right)\right)}}{y}\]
    10. Applied associate-/l*_binary640.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -4.317300523670314 \cdot 10^{+292}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq -8066392121713.778 \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \leq 70307706833107.55\right) \land \frac{x \cdot \left(y - z\right)}{y} \leq 2.2205050860855823 \cdot 10^{+306}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array}\]

Alternatives

Reproduce

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