Average Error: 12.5 → 2.2
Time: 3.3s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -2.06095086161022338 \cdot 10^{-199}:\\ \;\;\;\;\frac{x \cdot 1}{\frac{y}{y - z}}\\ \mathbf{elif}\;y \le 6.745538666331437 \cdot 10^{-83}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 1\right) \cdot \frac{y - z}{y}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;y \le -2.06095086161022338 \cdot 10^{-199}:\\
\;\;\;\;\frac{x \cdot 1}{\frac{y}{y - z}}\\

\mathbf{elif}\;y \le 6.745538666331437 \cdot 10^{-83}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\

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

\end{array}
double code(double x, double y, double z) {
	return ((double) (((double) (x * ((double) (y - z)))) / y));
}
double code(double x, double y, double z) {
	double VAR;
	if ((y <= -2.0609508616102234e-199)) {
		VAR = ((double) (((double) (x * 1.0)) / ((double) (y / ((double) (y - z))))));
	} else {
		double VAR_1;
		if ((y <= 6.745538666331437e-83)) {
			VAR_1 = ((double) (x - ((double) (((double) (x * z)) / y))));
		} else {
			VAR_1 = ((double) (((double) (x * 1.0)) * ((double) (((double) (y - z)) / y))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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.5
Target3.4
Herbie2.2
\[\begin{array}{l} \mathbf{if}\;z \lt -2.060202331921739 \cdot 10^{104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z \lt 1.69397660138285259 \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 y < -2.0609508616102234e-199

    1. Initial program 12.2

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

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

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

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

    if -2.0609508616102234e-199 < y < 6.745538666331437e-83

    1. Initial program 10.0

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

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

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

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

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

    if 6.745538666331437e-83 < y

    1. Initial program 14.4

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot 1}{\frac{y}{y - z}}}\]
    6. Using strategy rm
    7. Applied div-inv0.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.06095086161022338 \cdot 10^{-199}:\\ \;\;\;\;\frac{x \cdot 1}{\frac{y}{y - z}}\\ \mathbf{elif}\;y \le 6.745538666331437 \cdot 10^{-83}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 1\right) \cdot \frac{y - z}{y}\\ \end{array}\]

Reproduce

herbie shell --seed 2020113 +o rules:numerics
(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))