Average Error: 3.5 → 1.4
Time: 4.0s
Precision: binary64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)} \leq -6.866700008068578 \cdot 10^{+228}:\\ \;\;\;\;x + \left(\frac{t}{y} - y\right) \cdot \frac{1}{z \cdot 3}\\ \mathbf{elif}\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)} \leq 3.5032342006610504 \cdot 10^{+298}:\\ \;\;\;\;x + \frac{\frac{t}{y \cdot z} - \frac{y}{z}}{3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{z} \cdot \frac{\frac{t}{y} - y}{3}\\ \end{array}\]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)} \leq -6.866700008068578 \cdot 10^{+228}:\\
\;\;\;\;x + \left(\frac{t}{y} - y\right) \cdot \frac{1}{z \cdot 3}\\

\mathbf{elif}\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)} \leq 3.5032342006610504 \cdot 10^{+298}:\\
\;\;\;\;x + \frac{\frac{t}{y \cdot z} - \frac{y}{z}}{3}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{1}{z} \cdot \frac{\frac{t}{y} - y}{3}\\

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) (((double) (x - (y / ((double) (z * 3.0))))) + (t / ((double) (((double) (z * 3.0)) * y)))));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if ((((double) (((double) (x - (y / ((double) (z * 3.0))))) + (t / ((double) (y * ((double) (z * 3.0))))))) <= -6.866700008068578e+228)) {
		VAR = ((double) (x + ((double) (((double) ((t / y) - y)) * (1.0 / ((double) (z * 3.0)))))));
	} else {
		double VAR_1;
		if ((((double) (((double) (x - (y / ((double) (z * 3.0))))) + (t / ((double) (y * ((double) (z * 3.0))))))) <= 3.5032342006610504e+298)) {
			VAR_1 = ((double) (x + (((double) ((t / ((double) (y * z))) - (y / z))) / 3.0)));
		} else {
			VAR_1 = ((double) (x + ((double) ((1.0 / z) * (((double) ((t / y) - y)) / 3.0)))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.5
Target1.6
Herbie1.4
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]

Derivation

  1. Split input into 3 regimes
  2. if (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))) < -6.8667000080685776e228

    1. Initial program 11.1

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Simplified5.7

      \[\leadsto \color{blue}{x + \frac{\frac{t}{y} - y}{z \cdot 3}}\]
    3. Using strategy rm
    4. Applied div-inv5.8

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

    if -6.8667000080685776e228 < (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))) < 3.5032342006610504e298

    1. Initial program 0.5

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Simplified3.5

      \[\leadsto \color{blue}{x + \frac{\frac{t}{y} - y}{z \cdot 3}}\]
    3. Using strategy rm
    4. Applied associate-/r*3.5

      \[\leadsto x + \color{blue}{\frac{\frac{\frac{t}{y} - y}{z}}{3}}\]
    5. Using strategy rm
    6. Applied div-sub3.5

      \[\leadsto x + \frac{\color{blue}{\frac{\frac{t}{y}}{z} - \frac{y}{z}}}{3}\]
    7. Simplified0.5

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

    if 3.5032342006610504e298 < (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y)))

    1. Initial program 40.2

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Simplified3.6

      \[\leadsto \color{blue}{x + \frac{\frac{t}{y} - y}{z \cdot 3}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity3.6

      \[\leadsto x + \frac{\color{blue}{1 \cdot \left(\frac{t}{y} - y\right)}}{z \cdot 3}\]
    5. Applied times-frac3.6

      \[\leadsto x + \color{blue}{\frac{1}{z} \cdot \frac{\frac{t}{y} - y}{3}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)} \leq -6.866700008068578 \cdot 10^{+228}:\\ \;\;\;\;x + \left(\frac{t}{y} - y\right) \cdot \frac{1}{z \cdot 3}\\ \mathbf{elif}\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)} \leq 3.5032342006610504 \cdot 10^{+298}:\\ \;\;\;\;x + \frac{\frac{t}{y \cdot z} - \frac{y}{z}}{3}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{z} \cdot \frac{\frac{t}{y} - y}{3}\\ \end{array}\]

Reproduce

herbie shell --seed 2020199 
(FPCore (x y z t)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, H"
  :precision binary64

  :herbie-target
  (+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y))

  (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))