Average Error: 3.7 → 0.6
Time: 4.1s
Precision: binary64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;t \leq -2.0973797362735423 \cdot 10^{+82}:\\ \;\;\;\;x + \frac{\frac{t}{y \cdot z} - \frac{y}{z}}{3}\\ \mathbf{elif}\;t \leq 1.9460236543815705 \cdot 10^{-10}:\\ \;\;\;\;x + \frac{\frac{\frac{t}{y} - y}{z}}{3}\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{t}{z \cdot \left(y \cdot 3\right)} - \frac{y}{z \cdot 3}\right)\\ \end{array}\]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;t \leq -2.0973797362735423 \cdot 10^{+82}:\\
\;\;\;\;x + \frac{\frac{t}{y \cdot z} - \frac{y}{z}}{3}\\

\mathbf{elif}\;t \leq 1.9460236543815705 \cdot 10^{-10}:\\
\;\;\;\;x + \frac{\frac{\frac{t}{y} - y}{z}}{3}\\

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

\end{array}
(FPCore (x y z t)
 :precision binary64
 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
(FPCore (x y z t)
 :precision binary64
 (if (<= t -2.0973797362735423e+82)
   (+ x (/ (- (/ t (* y z)) (/ y z)) 3.0))
   (if (<= t 1.9460236543815705e-10)
     (+ x (/ (/ (- (/ t y) y) z) 3.0))
     (+ x (- (/ t (* z (* y 3.0))) (/ y (* z 3.0)))))))
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 ((t <= -2.0973797362735423e+82)) {
		VAR = ((double) (x + (((double) ((t / ((double) (y * z))) - (y / z))) / 3.0)));
	} else {
		double VAR_1;
		if ((t <= 1.9460236543815705e-10)) {
			VAR_1 = ((double) (x + ((((double) ((t / y) - y)) / z) / 3.0)));
		} else {
			VAR_1 = ((double) (x + ((double) ((t / ((double) (z * ((double) (y * 3.0))))) - (y / ((double) (z * 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.7
Target1.8
Herbie0.6
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -2.0973797362735423e82

    1. Initial program 0.9

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

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

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

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

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

    if -2.0973797362735423e82 < t < 1.94602365438157047e-10

    1. Initial program 5.3

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

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

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

    if 1.94602365438157047e-10 < t

    1. Initial program 0.5

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

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

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

      \[\leadsto x + \frac{\color{blue}{\frac{\frac{t}{y}}{z} - \frac{y}{z}}}{3}\]
    7. Applied div-sub8.6

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

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

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

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

Reproduce

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