Average Error: 7.9 → 4.8
Time: 10.4s
Precision: 64
\[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -1.84154847940333438 \cdot 10^{268}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le 5.0132949514285239 \cdot 10^{-62}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{x \cdot y - \left(z \cdot 9\right) \cdot t}}\\ \mathbf{elif}\;x \cdot y \le 6.0823832327035818 \cdot 10^{165}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array}\]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -1.84154847940333438 \cdot 10^{268}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\

\mathbf{elif}\;x \cdot y \le 5.0132949514285239 \cdot 10^{-62}:\\
\;\;\;\;\frac{1}{\frac{a \cdot 2}{x \cdot y - \left(z \cdot 9\right) \cdot t}}\\

\mathbf{elif}\;x \cdot y \le 6.0823832327035818 \cdot 10^{165}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r1668 = x;
        double r1669 = y;
        double r1670 = r1668 * r1669;
        double r1671 = z;
        double r1672 = 9.0;
        double r1673 = r1671 * r1672;
        double r1674 = t;
        double r1675 = r1673 * r1674;
        double r1676 = r1670 - r1675;
        double r1677 = a;
        double r1678 = 2.0;
        double r1679 = r1677 * r1678;
        double r1680 = r1676 / r1679;
        return r1680;
}

double f(double x, double y, double z, double t, double a) {
        double r1681 = x;
        double r1682 = y;
        double r1683 = r1681 * r1682;
        double r1684 = -1.8415484794033344e+268;
        bool r1685 = r1683 <= r1684;
        double r1686 = 0.5;
        double r1687 = a;
        double r1688 = r1682 / r1687;
        double r1689 = r1681 * r1688;
        double r1690 = r1686 * r1689;
        double r1691 = 4.5;
        double r1692 = t;
        double r1693 = z;
        double r1694 = r1692 * r1693;
        double r1695 = r1694 / r1687;
        double r1696 = r1691 * r1695;
        double r1697 = r1690 - r1696;
        double r1698 = 5.013294951428524e-62;
        bool r1699 = r1683 <= r1698;
        double r1700 = 1.0;
        double r1701 = 2.0;
        double r1702 = r1687 * r1701;
        double r1703 = 9.0;
        double r1704 = r1693 * r1703;
        double r1705 = r1704 * r1692;
        double r1706 = r1683 - r1705;
        double r1707 = r1702 / r1706;
        double r1708 = r1700 / r1707;
        double r1709 = 6.082383232703582e+165;
        bool r1710 = r1683 <= r1709;
        double r1711 = r1683 / r1687;
        double r1712 = r1686 * r1711;
        double r1713 = cbrt(r1687);
        double r1714 = r1713 * r1713;
        double r1715 = r1692 / r1714;
        double r1716 = r1691 * r1715;
        double r1717 = r1693 / r1713;
        double r1718 = r1716 * r1717;
        double r1719 = r1712 - r1718;
        double r1720 = r1710 ? r1719 : r1697;
        double r1721 = r1699 ? r1708 : r1720;
        double r1722 = r1685 ? r1697 : r1721;
        return r1722;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.9
Target5.5
Herbie4.8
\[\begin{array}{l} \mathbf{if}\;a \lt -2.090464557976709 \cdot 10^{86}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \lt 2.14403070783397609 \cdot 10^{99}:\\ \;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot \left(x \cdot 0.5\right) - \frac{t}{a} \cdot \left(z \cdot 4.5\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (* x y) < -1.8415484794033344e+268 or 6.082383232703582e+165 < (* x y)

    1. Initial program 32.1

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Taylor expanded around 0 32.1

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{a}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity32.1

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{\color{blue}{1 \cdot a}} - 4.5 \cdot \frac{t \cdot z}{a}\]
    5. Applied times-frac7.1

      \[\leadsto 0.5 \cdot \color{blue}{\left(\frac{x}{1} \cdot \frac{y}{a}\right)} - 4.5 \cdot \frac{t \cdot z}{a}\]
    6. Simplified7.1

      \[\leadsto 0.5 \cdot \left(\color{blue}{x} \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\]

    if -1.8415484794033344e+268 < (* x y) < 5.013294951428524e-62

    1. Initial program 4.6

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Using strategy rm
    3. Applied clear-num5.0

      \[\leadsto \color{blue}{\frac{1}{\frac{a \cdot 2}{x \cdot y - \left(z \cdot 9\right) \cdot t}}}\]

    if 5.013294951428524e-62 < (* x y) < 6.082383232703582e+165

    1. Initial program 3.5

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Taylor expanded around 0 3.4

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{a}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt3.7

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}}\]
    5. Applied times-frac2.6

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \color{blue}{\left(\frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\right)}\]
    6. Applied associate-*r*2.6

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - \color{blue}{\left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification4.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -1.84154847940333438 \cdot 10^{268}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le 5.0132949514285239 \cdot 10^{-62}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{x \cdot y - \left(z \cdot 9\right) \cdot t}}\\ \mathbf{elif}\;x \cdot y \le 6.0823832327035818 \cdot 10^{165}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot y}{a} - \left(4.5 \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \cdot \frac{z}{\sqrt[3]{a}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020025 
(FPCore (x y z t a)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, I"
  :precision binary64

  :herbie-target
  (if (< a -2.090464557976709e+86) (- (* 0.5 (/ (* y x) a)) (* 4.5 (/ t (/ a z)))) (if (< a 2.144030707833976e+99) (/ (- (* x y) (* z (* 9 t))) (* a 2)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

  (/ (- (* x y) (* (* z 9) t)) (* a 2)))