Average Error: 3.6 → 1.0
Time: 7.7s
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 -2079016385846159.2 \lor \neg \left(z \cdot 3 \leq 3.985574761400528 \cdot 10^{-181}\right):\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{z \cdot -3} \cdot \left(y - \frac{t}{y}\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}\;z \cdot 3 \leq -2079016385846159.2 \lor \neg \left(z \cdot 3 \leq 3.985574761400528 \cdot 10^{-181}\right):\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{1}{z \cdot -3} \cdot \left(y - \frac{t}{y}\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 (or (<= (* z 3.0) -2079016385846159.2)
         (not (<= (* z 3.0) 3.985574761400528e-181)))
   (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y)))
   (+ x (* (/ 1.0 (* z -3.0)) (- y (/ t y))))))
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) <= -2079016385846159.2) || !((z * 3.0) <= 3.985574761400528e-181)) {
		tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
	} else {
		tmp = x + ((1.0 / (z * -3.0)) * (y - (t / y)));
	}
	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.6
Target1.6
Herbie1.0
\[\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) < -2079016385846159.25 or 3.9855747614005278e-181 < (*.f64 z 3)

    1. Initial program 1.1

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

    if -2079016385846159.25 < (*.f64 z 3) < 3.9855747614005278e-181

    1. Initial program 12.2

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

      \[\leadsto \color{blue}{x + \frac{-0.3333333333333333}{z} \cdot \left(y - \frac{t}{y}\right)}\]
    3. Using strategy rm
    4. Applied clear-num_binary64_120120.4

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

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

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

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

Reproduce

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