Average Error: 12.6 → 2.3
Time: 4.4s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;y \leq -1.0766423981689913 \cdot 10^{-63}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \mathbf{elif}\;y \leq 1.2558456771868084 \cdot 10^{-292}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{elif}\;y \leq 9.067204618713828 \cdot 10^{-232}:\\ \;\;\;\;\frac{x}{\sqrt{y}} \cdot \frac{y - z}{\sqrt{y}}\\ \mathbf{elif}\;y \leq 9.608731286136189 \cdot 10^{-45}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;y \leq -1.0766423981689913 \cdot 10^{-63}:\\
\;\;\;\;x - x \cdot \frac{z}{y}\\

\mathbf{elif}\;y \leq 1.2558456771868084 \cdot 10^{-292}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\

\mathbf{elif}\;y \leq 9.067204618713828 \cdot 10^{-232}:\\
\;\;\;\;\frac{x}{\sqrt{y}} \cdot \frac{y - z}{\sqrt{y}}\\

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

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.0766423981689913e-63)
   (- x (* x (/ z y)))
   (if (<= y 1.2558456771868084e-292)
     (- x (/ (* x z) y))
     (if (<= y 9.067204618713828e-232)
       (* (/ x (sqrt y)) (/ (- y z) (sqrt y)))
       (if (<= y 9.608731286136189e-45)
         (* (- y z) (/ x y))
         (- x (* x (/ 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 (y <= -1.0766423981689913e-63) {
		tmp = x - (x * (z / y));
	} else if (y <= 1.2558456771868084e-292) {
		tmp = x - ((x * z) / y);
	} else if (y <= 9.067204618713828e-232) {
		tmp = (x / sqrt(y)) * ((y - z) / sqrt(y));
	} else if (y <= 9.608731286136189e-45) {
		tmp = (y - z) * (x / y);
	} else {
		tmp = x - (x * (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.6
Target3.1
Herbie2.3
\[\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 y < -1.07664239816899128e-63 or 9.6087312861361891e-45 < y

    1. Initial program 14.8

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

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

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

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

      \[\leadsto x \cdot \color{blue}{\left(1 - \frac{z}{y}\right)}\]
    7. Using strategy rm
    8. Applied sub-neg_binary64_198490.3

      \[\leadsto x \cdot \color{blue}{\left(1 + \left(-\frac{z}{y}\right)\right)}\]
    9. Applied distribute-rgt-in_binary64_198060.3

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

    if -1.07664239816899128e-63 < y < 1.2558456771868084e-292

    1. Initial program 9.1

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

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

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

    if 1.2558456771868084e-292 < y < 9.067204618713828e-232

    1. Initial program 12.0

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt_binary64_1987812.2

      \[\leadsto \frac{x \cdot \left(y - z\right)}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}\]
    4. Applied times-frac_binary64_198627.8

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

    if 9.067204618713828e-232 < y < 9.6087312861361891e-45

    1. Initial program 6.3

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Using strategy rm
    5. Applied associate-/r/_binary64_198026.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.0766423981689913 \cdot 10^{-63}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \mathbf{elif}\;y \leq 1.2558456771868084 \cdot 10^{-292}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{elif}\;y \leq 9.067204618713828 \cdot 10^{-232}:\\ \;\;\;\;\frac{x}{\sqrt{y}} \cdot \frac{y - z}{\sqrt{y}}\\ \mathbf{elif}\;y \leq 9.608731286136189 \cdot 10^{-45}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \end{array}\]

Reproduce

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