Average Error: 3.8 → 0.4
Time: 13.5s
Precision: 64
\[\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 \le -3.2330998000871282 \cdot 10^{-19} \lor \neg \left(z \cdot 3 \le 1.3575263015916868 \cdot 10^{-10}\right):\\ \;\;\;\;\left(x - \frac{\frac{y}{3}}{z}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{\frac{y}{3}}{z}\right) + \frac{1}{z} \cdot \frac{t}{3 \cdot y}\\ \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 \le -3.2330998000871282 \cdot 10^{-19} \lor \neg \left(z \cdot 3 \le 1.3575263015916868 \cdot 10^{-10}\right):\\
\;\;\;\;\left(x - \frac{\frac{y}{3}}{z}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\

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

\end{array}
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 temp;
	if ((((z * 3.0) <= -3.233099800087128e-19) || !((z * 3.0) <= 1.3575263015916868e-10))) {
		temp = ((x - ((y / 3.0) / z)) + (t / ((z * 3.0) * y)));
	} else {
		temp = ((x - ((y / 3.0) / z)) + ((1.0 / z) * (t / (3.0 * y))));
	}
	return temp;
}

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.8
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 (* z 3.0) < -3.233099800087128e-19 or 1.3575263015916868e-10 < (* z 3.0)

    1. Initial program 0.4

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

      \[\leadsto \left(x - \frac{y}{\color{blue}{3 \cdot z}}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    4. Applied associate-/r*0.4

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

    if -3.233099800087128e-19 < (* z 3.0) < 1.3575263015916868e-10

    1. Initial program 11.2

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Using strategy rm
    3. Applied *-commutative11.2

      \[\leadsto \left(x - \frac{y}{\color{blue}{3 \cdot z}}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    4. Applied associate-/r*11.2

      \[\leadsto \left(x - \color{blue}{\frac{\frac{y}{3}}{z}}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    5. Using strategy rm
    6. Applied associate-*l*11.2

      \[\leadsto \left(x - \frac{\frac{y}{3}}{z}\right) + \frac{t}{\color{blue}{z \cdot \left(3 \cdot y\right)}}\]
    7. Applied *-un-lft-identity11.2

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

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

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

Reproduce

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

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

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