Average Error: 3.5 → 1.7
Time: 4.2s
Precision: 64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
\[\left(x - \frac{1}{z} \cdot \frac{y}{3}\right) + \frac{0.333333333333333315 \cdot \frac{t}{z}}{y}\]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\left(x - \frac{1}{z} \cdot \frac{y}{3}\right) + \frac{0.333333333333333315 \cdot \frac{t}{z}}{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) {
	return ((x - ((1.0 / z) * (y / 3.0))) + ((0.3333333333333333 * (t / z)) / y));
}

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

Derivation

  1. Initial program 3.5

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

    \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{\frac{t}{z \cdot 3}}{y}}\]
  4. Using strategy rm
  5. Applied *-un-lft-identity1.7

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

    \[\leadsto \left(x - \color{blue}{\frac{1}{z} \cdot \frac{y}{3}}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]
  7. Taylor expanded around 0 1.7

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

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

Reproduce

herbie shell --seed 2020078 +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))))