Average Error: 12.4 → 1.4
Time: 3.3s
Precision: binary64
\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.715631163475474 \cdot 10^{+50} \lor \neg \left(z \leq 2.1939773630248555 \cdot 10^{+116}\right):\\ \;\;\;\;\begin{array}{l} t_0 := \sqrt[3]{y - z}\\ \frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{t_0 \cdot t_0}} \cdot \frac{\sqrt[3]{x}}{\frac{\sqrt[3]{y}}{t_0}} \end{array}\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \end{array} \]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;z \leq -1.715631163475474 \cdot 10^{+50} \lor \neg \left(z \leq 2.1939773630248555 \cdot 10^{+116}\right):\\
\;\;\;\;\begin{array}{l}
t_0 := \sqrt[3]{y - z}\\
\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{t_0 \cdot t_0}} \cdot \frac{\sqrt[3]{x}}{\frac{\sqrt[3]{y}}{t_0}}
\end{array}\\

\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 (or (<= z -1.715631163475474e+50) (not (<= z 2.1939773630248555e+116)))
   (let* ((t_0 (cbrt (- y z))))
     (*
      (/ (* (cbrt x) (cbrt x)) (/ (* (cbrt y) (cbrt y)) (* t_0 t_0)))
      (/ (cbrt x) (/ (cbrt y) t_0))))
   (- 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 ((z <= -1.715631163475474e+50) || !(z <= 2.1939773630248555e+116)) {
		double t_0_1 = cbrt(y - z);
		tmp = ((cbrt(x) * cbrt(x)) / ((cbrt(y) * cbrt(y)) / (t_0_1 * t_0_1))) * (cbrt(x) / (cbrt(y) / t_0_1));
	} 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.4
Target3.1
Herbie1.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 2 regimes
  2. if z < -1.71563116347547401e50 or 2.19397736302485552e116 < z

    1. Initial program 12.2

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Applied associate-/l*_binary6410.0

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Applied add-cube-cbrt_binary6410.9

      \[\leadsto \frac{x}{\frac{y}{\color{blue}{\left(\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}\right) \cdot \sqrt[3]{y - z}}}} \]
    4. Applied add-cube-cbrt_binary6410.8

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

      \[\leadsto \frac{x}{\color{blue}{\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}} \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{y - z}}}} \]
    6. Applied add-cube-cbrt_binary6411.3

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

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

    if -1.71563116347547401e50 < z < 2.19397736302485552e116

    1. Initial program 12.4

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Applied div-inv_binary640.8

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.715631163475474 \cdot 10^{+50} \lor \neg \left(z \leq 2.1939773630248555 \cdot 10^{+116}\right):\\ \;\;\;\;\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}}} \cdot \frac{\sqrt[3]{x}}{\frac{\sqrt[3]{y}}{\sqrt[3]{y - z}}}\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \frac{z}{y}\\ \end{array} \]

Reproduce

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