Average Error: 3.5 → 0.9
Time: 9.2s
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 -5.73103805581826556 \cdot 10^{-44} \lor \neg \left(z \cdot 3 \le 5.17756227009494755 \cdot 10^{59}\right):\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{1}{z \cdot 3}}{\frac{y}{t}}\\ \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 -5.73103805581826556 \cdot 10^{-44} \lor \neg \left(z \cdot 3 \le 5.17756227009494755 \cdot 10^{59}\right):\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r4472 = x;
        double r4473 = y;
        double r4474 = z;
        double r4475 = 3.0;
        double r4476 = r4474 * r4475;
        double r4477 = r4473 / r4476;
        double r4478 = r4472 - r4477;
        double r4479 = t;
        double r4480 = r4476 * r4473;
        double r4481 = r4479 / r4480;
        double r4482 = r4478 + r4481;
        return r4482;
}

double f(double x, double y, double z, double t) {
        double r4483 = z;
        double r4484 = 3.0;
        double r4485 = r4483 * r4484;
        double r4486 = -5.731038055818266e-44;
        bool r4487 = r4485 <= r4486;
        double r4488 = 5.1775622700949476e+59;
        bool r4489 = r4485 <= r4488;
        double r4490 = !r4489;
        bool r4491 = r4487 || r4490;
        double r4492 = x;
        double r4493 = y;
        double r4494 = r4493 / r4485;
        double r4495 = r4492 - r4494;
        double r4496 = t;
        double r4497 = r4496 / r4485;
        double r4498 = r4497 / r4493;
        double r4499 = r4495 + r4498;
        double r4500 = 1.0;
        double r4501 = r4500 / r4485;
        double r4502 = r4493 / r4496;
        double r4503 = r4501 / r4502;
        double r4504 = r4495 + r4503;
        double r4505 = r4491 ? r4499 : r4504;
        return r4505;
}

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.9
Herbie0.9
\[\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) < -5.731038055818266e-44 or 5.1775622700949476e+59 < (* 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 associate-/r*1.1

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

    if -5.731038055818266e-44 < (* z 3.0) < 5.1775622700949476e+59

    1. Initial program 9.6

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Taylor expanded around 0 9.6

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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