Average Error: 3.6 → 0.3
Time: 5.3s
Precision: 64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;t \le -3097409.71754964394:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{z \cdot \left(3 \cdot y\right)}\\ \mathbf{elif}\;t \le 2.78038066636221327 \cdot 10^{-9}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(0.333333333333333315 \cdot \frac{t}{z \cdot y} + x\right) - 0.333333333333333315 \cdot \frac{y}{z}\\ \end{array}\]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;t \le -3097409.71754964394:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{z \cdot \left(3 \cdot y\right)}\\

\mathbf{elif}\;t \le 2.78038066636221327 \cdot 10^{-9}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{y}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r676788 = x;
        double r676789 = y;
        double r676790 = z;
        double r676791 = 3.0;
        double r676792 = r676790 * r676791;
        double r676793 = r676789 / r676792;
        double r676794 = r676788 - r676793;
        double r676795 = t;
        double r676796 = r676792 * r676789;
        double r676797 = r676795 / r676796;
        double r676798 = r676794 + r676797;
        return r676798;
}

double f(double x, double y, double z, double t) {
        double r676799 = t;
        double r676800 = -3097409.717549644;
        bool r676801 = r676799 <= r676800;
        double r676802 = x;
        double r676803 = y;
        double r676804 = z;
        double r676805 = 3.0;
        double r676806 = r676804 * r676805;
        double r676807 = r676803 / r676806;
        double r676808 = r676802 - r676807;
        double r676809 = r676805 * r676803;
        double r676810 = r676804 * r676809;
        double r676811 = r676799 / r676810;
        double r676812 = r676808 + r676811;
        double r676813 = 2.7803806663622133e-09;
        bool r676814 = r676799 <= r676813;
        double r676815 = 1.0;
        double r676816 = r676815 / r676806;
        double r676817 = r676799 / r676803;
        double r676818 = r676816 * r676817;
        double r676819 = r676808 + r676818;
        double r676820 = 0.3333333333333333;
        double r676821 = r676804 * r676803;
        double r676822 = r676799 / r676821;
        double r676823 = r676820 * r676822;
        double r676824 = r676823 + r676802;
        double r676825 = r676803 / r676804;
        double r676826 = r676820 * r676825;
        double r676827 = r676824 - r676826;
        double r676828 = r676814 ? r676819 : r676827;
        double r676829 = r676801 ? r676812 : r676828;
        return r676829;
}

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

Derivation

  1. Split input into 3 regimes
  2. if t < -3097409.717549644

    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-*l*0.3

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

    if -3097409.717549644 < t < 2.7803806663622133e-09

    1. Initial program 6.0

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

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

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

    if 2.7803806663622133e-09 < t

    1. Initial program 0.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -3097409.71754964394:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{z \cdot \left(3 \cdot y\right)}\\ \mathbf{elif}\;t \le 2.78038066636221327 \cdot 10^{-9}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(0.333333333333333315 \cdot \frac{t}{z \cdot y} + x\right) - 0.333333333333333315 \cdot \frac{y}{z}\\ \end{array}\]

Reproduce

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