Average Error: 7.9 → 4.3
Time: 18.3s
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.380541817508050736154941138842174306444 \cdot 10^{132}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - \left(4.5 \cdot \frac{t}{a}\right) \cdot z\\ \mathbf{elif}\;x \cdot y \le 1.164981797442287361051324591328157653864 \cdot 10^{58}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\sqrt{0.5} \cdot \frac{x \cdot y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\sqrt{0.5} \cdot \left(x \cdot \frac{y}{a}\right)\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \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.380541817508050736154941138842174306444 \cdot 10^{132}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - \left(4.5 \cdot \frac{t}{a}\right) \cdot z\\

\mathbf{elif}\;x \cdot y \le 1.164981797442287361051324591328157653864 \cdot 10^{58}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(\sqrt{0.5} \cdot \frac{x \cdot y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r514631 = x;
        double r514632 = y;
        double r514633 = r514631 * r514632;
        double r514634 = z;
        double r514635 = 9.0;
        double r514636 = r514634 * r514635;
        double r514637 = t;
        double r514638 = r514636 * r514637;
        double r514639 = r514633 - r514638;
        double r514640 = a;
        double r514641 = 2.0;
        double r514642 = r514640 * r514641;
        double r514643 = r514639 / r514642;
        return r514643;
}

double f(double x, double y, double z, double t, double a) {
        double r514644 = x;
        double r514645 = y;
        double r514646 = r514644 * r514645;
        double r514647 = -1.3805418175080507e+132;
        bool r514648 = r514646 <= r514647;
        double r514649 = 0.5;
        double r514650 = a;
        double r514651 = r514645 / r514650;
        double r514652 = r514644 * r514651;
        double r514653 = r514649 * r514652;
        double r514654 = 4.5;
        double r514655 = t;
        double r514656 = r514655 / r514650;
        double r514657 = r514654 * r514656;
        double r514658 = z;
        double r514659 = r514657 * r514658;
        double r514660 = r514653 - r514659;
        double r514661 = 1.1649817974422874e+58;
        bool r514662 = r514646 <= r514661;
        double r514663 = sqrt(r514649);
        double r514664 = r514646 / r514650;
        double r514665 = r514663 * r514664;
        double r514666 = r514663 * r514665;
        double r514667 = r514655 * r514658;
        double r514668 = r514667 / r514650;
        double r514669 = r514654 * r514668;
        double r514670 = r514666 - r514669;
        double r514671 = r514663 * r514652;
        double r514672 = r514663 * r514671;
        double r514673 = r514650 / r514658;
        double r514674 = r514655 / r514673;
        double r514675 = r514654 * r514674;
        double r514676 = r514672 - r514675;
        double r514677 = r514662 ? r514670 : r514676;
        double r514678 = r514648 ? r514660 : r514677;
        return r514678;
}

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.8
Herbie4.3
\[\begin{array}{l} \mathbf{if}\;a \lt -2.090464557976709043451944897028999329376 \cdot 10^{86}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;a \lt 2.144030707833976090627817222818061808815 \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.3805418175080507e+132

    1. Initial program 20.6

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

      \[\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 associate-/l*18.3

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

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

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

      \[\leadsto 0.5 \cdot \left(\color{blue}{x} \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\]
    9. Using strategy rm
    10. Applied associate-/r/2.4

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

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

    if -1.3805418175080507e+132 < (* x y) < 1.1649817974422874e+58

    1. Initial program 4.2

      \[\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\]
    2. Taylor expanded around 0 4.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 add-sqr-sqrt4.4

      \[\leadsto \color{blue}{\left(\sqrt{0.5} \cdot \sqrt{0.5}\right)} \cdot \frac{x \cdot y}{a} - 4.5 \cdot \frac{t \cdot z}{a}\]
    5. Applied associate-*l*4.3

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

    if 1.1649817974422874e+58 < (* x y)

    1. Initial program 17.0

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

      \[\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 associate-/l*14.0

      \[\leadsto 0.5 \cdot \frac{x \cdot y}{a} - 4.5 \cdot \color{blue}{\frac{t}{\frac{a}{z}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity14.0

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

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

      \[\leadsto 0.5 \cdot \left(\color{blue}{x} \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt5.7

      \[\leadsto \color{blue}{\left(\sqrt{0.5} \cdot \sqrt{0.5}\right)} \cdot \left(x \cdot \frac{y}{a}\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\]
    11. Applied associate-*l*5.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -1.380541817508050736154941138842174306444 \cdot 10^{132}:\\ \;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right) - \left(4.5 \cdot \frac{t}{a}\right) \cdot z\\ \mathbf{elif}\;x \cdot y \le 1.164981797442287361051324591328157653864 \cdot 10^{58}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\sqrt{0.5} \cdot \frac{x \cdot y}{a}\right) - 4.5 \cdot \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5} \cdot \left(\sqrt{0.5} \cdot \left(x \cdot \frac{y}{a}\right)\right) - 4.5 \cdot \frac{t}{\frac{a}{z}}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< a -2.090464557976709e86) (- (* 0.5 (/ (* y x) a)) (* 4.5 (/ t (/ a z)))) (if (< a 2.14403070783397609e99) (/ (- (* x y) (* z (* 9 t))) (* a 2)) (- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5)))))

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