Average Error: 3.7 → 0.4
Time: 4.9s
Precision: binary64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot 3 \leq -2.683149926532122 \cdot 10^{+31} \lor \neg \left(z \cdot 3 \leq 22839784493.296265\right):\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot -0.3333333333333333 + \frac{t}{y} \cdot 0.3333333333333333}{z}\\ \end{array}\]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;z \cdot 3 \leq -2.683149926532122 \cdot 10^{+31} \lor \neg \left(z \cdot 3 \leq 22839784493.296265\right):\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\

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

\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 (or (<= (* z 3.0) -2.683149926532122e+31)
         (not (<= (* z 3.0) 22839784493.296265)))
   (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y)))
   (+ x (/ (+ (* y -0.3333333333333333) (* (/ t y) 0.3333333333333333)) z))))
double code(double x, double y, double z, double t) {
	return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if (((z * 3.0) <= -2.683149926532122e+31) || !((z * 3.0) <= 22839784493.296265)) {
		tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
	} else {
		tmp = x + (((y * -0.3333333333333333) + ((t / y) * 0.3333333333333333)) / z);
	}
	return tmp;
}

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.7
Herbie0.4
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 z 3) < -2.683149926532122e31 or 22839784493.29626 < (*.f64 z 3)

    1. Initial program 0.4

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

    if -2.683149926532122e31 < (*.f64 z 3) < 22839784493.29626

    1. Initial program 9.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{-0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)}\]
    3. Using strategy rm
    4. Applied associate-*l/_binary64_177530.4

      \[\leadsto x + \color{blue}{\frac{-0.3333333333333333 \cdot \left(y - \frac{t}{y}\right)}{z}}\]
    5. Using strategy rm
    6. Applied sub-neg_binary64_178030.4

      \[\leadsto x + \frac{-0.3333333333333333 \cdot \color{blue}{\left(y + \left(-\frac{t}{y}\right)\right)}}{z}\]
    7. Applied distribute-rgt-in_binary64_177600.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot 3 \leq -2.683149926532122 \cdot 10^{+31} \lor \neg \left(z \cdot 3 \leq 22839784493.296265\right):\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot -0.3333333333333333 + \frac{t}{y} \cdot 0.3333333333333333}{z}\\ \end{array}\]

Reproduce

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