Average Error: 12.3 → 2.0
Time: 3.6s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{y - z}{\frac{y}{x}}\\ \mathbf{elif}\;t_0 \leq -1.3640159599362197 \cdot 10^{+114}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{elif}\;t_0 \leq 3.93483722634 \cdot 10^{+95}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{y - z}{\sqrt[3]{y}}\\ \end{array} \]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{y - z}{\frac{y}{x}}\\

\mathbf{elif}\;t_0 \leq -1.3640159599362197 \cdot 10^{+114}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\

\mathbf{elif}\;t_0 \leq 3.93483722634 \cdot 10^{+95}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{y - z}{\sqrt[3]{y}}\\


\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x (- y z)) y)))
   (if (<= t_0 (- INFINITY))
     (/ (- y z) (/ y x))
     (if (<= t_0 -1.3640159599362197e+114)
       (- x (/ (* x z) y))
       (if (<= t_0 3.93483722634e+95)
         (* x (- 1.0 (/ z y)))
         (* (/ x (* (cbrt y) (cbrt y))) (/ (- y z) (cbrt y))))))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double t_0 = (x * (y - z)) / y;
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (y - z) / (y / x);
	} else if (t_0 <= -1.3640159599362197e+114) {
		tmp = x - ((x * z) / y);
	} else if (t_0 <= 3.93483722634e+95) {
		tmp = x * (1.0 - (z / y));
	} else {
		tmp = (x / (cbrt(y) * cbrt(y))) * ((y - z) / cbrt(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.3
Target3.4
Herbie2.0
\[\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) < -inf.0

    1. Initial program 64.0

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Using strategy rm
    3. Applied clear-num_binary6464.0

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

      \[\leadsto \frac{1}{\color{blue}{\frac{y}{\left(y - z\right) \cdot x}}} \]
    5. Using strategy rm
    6. Applied associate-/r/_binary6464.0

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(\left(y - z\right) \cdot x\right)} \]
    7. Applied associate-*r*_binary640.2

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

      \[\leadsto \color{blue}{\frac{y - z}{y}} \cdot x \]
    9. Using strategy rm
    10. Applied associate-*l/_binary6464.0

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

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

    if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -1.36401595993621966e114

    1. Initial program 0.2

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{y}{\left(y - z\right) \cdot x}}} \]
    5. Using strategy rm
    6. Applied associate-/r/_binary640.3

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(\left(y - z\right) \cdot x\right)} \]
    7. Applied associate-*r*_binary6412.6

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

      \[\leadsto \color{blue}{\frac{y - z}{y}} \cdot x \]
    9. Using strategy rm
    10. Applied pow1_binary6412.6

      \[\leadsto \frac{y - z}{y} \cdot \color{blue}{{x}^{1}} \]
    11. Applied pow1_binary6412.6

      \[\leadsto \color{blue}{{\left(\frac{y - z}{y}\right)}^{1}} \cdot {x}^{1} \]
    12. Applied pow-prod-down_binary6412.6

      \[\leadsto \color{blue}{{\left(\frac{y - z}{y} \cdot x\right)}^{1}} \]
    13. Simplified0.2

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

    if -1.36401595993621966e114 < (/.f64 (*.f64 x (-.f64 y z)) y) < 3.9348372263399999e95

    1. Initial program 4.9

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Using strategy rm
    3. Applied clear-num_binary645.0

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

      \[\leadsto \frac{1}{\color{blue}{\frac{y}{\left(y - z\right) \cdot x}}} \]
    5. Using strategy rm
    6. Applied associate-/r/_binary645.0

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(\left(y - z\right) \cdot x\right)} \]
    7. Applied associate-*r*_binary641.1

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

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

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

    if 3.9348372263399999e95 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 22.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -\infty:\\ \;\;\;\;\frac{y - z}{\frac{y}{x}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq -1.3640159599362197 \cdot 10^{+114}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 3.93483722634 \cdot 10^{+95}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{y - z}{\sqrt[3]{y}}\\ \end{array} \]

Reproduce

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