Average Error: 2.1 → 2.3
Time: 3.8s
Precision: 64
\[x + \left(y - x\right) \cdot \frac{z}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -6499096036328816583835987738624:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{elif}\;t \le 5.484469418718039822131826670235908244496 \cdot 10^{163}:\\ \;\;\;\;x + \left(\frac{z \cdot y}{t} - \frac{x \cdot z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{t} \cdot \left(y - x\right)\\ \end{array}\]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;t \le -6499096036328816583835987738624:\\
\;\;\;\;x + z \cdot \frac{y - x}{t}\\

\mathbf{elif}\;t \le 5.484469418718039822131826670235908244496 \cdot 10^{163}:\\
\;\;\;\;x + \left(\frac{z \cdot y}{t} - \frac{x \cdot z}{t}\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r667099 = x;
        double r667100 = y;
        double r667101 = r667100 - r667099;
        double r667102 = z;
        double r667103 = t;
        double r667104 = r667102 / r667103;
        double r667105 = r667101 * r667104;
        double r667106 = r667099 + r667105;
        return r667106;
}

double f(double x, double y, double z, double t) {
        double r667107 = t;
        double r667108 = -6.499096036328817e+30;
        bool r667109 = r667107 <= r667108;
        double r667110 = x;
        double r667111 = z;
        double r667112 = y;
        double r667113 = r667112 - r667110;
        double r667114 = r667113 / r667107;
        double r667115 = r667111 * r667114;
        double r667116 = r667110 + r667115;
        double r667117 = 5.48446941871804e+163;
        bool r667118 = r667107 <= r667117;
        double r667119 = r667111 * r667112;
        double r667120 = r667119 / r667107;
        double r667121 = r667110 * r667111;
        double r667122 = r667121 / r667107;
        double r667123 = r667120 - r667122;
        double r667124 = r667110 + r667123;
        double r667125 = r667111 / r667107;
        double r667126 = r667125 * r667113;
        double r667127 = r667110 + r667126;
        double r667128 = r667118 ? r667124 : r667127;
        double r667129 = r667109 ? r667116 : r667128;
        return r667129;
}

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

Original2.1
Target2.3
Herbie2.3
\[\begin{array}{l} \mathbf{if}\;\left(y - x\right) \cdot \frac{z}{t} \lt -1013646692435.88671875:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;\left(y - x\right) \cdot \frac{z}{t} \lt -0.0:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -6.499096036328817e+30

    1. Initial program 1.1

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

      \[\leadsto x + \color{blue}{\frac{z}{t} \cdot \left(y - x\right)}\]
    4. Using strategy rm
    5. Applied div-inv1.1

      \[\leadsto x + \color{blue}{\left(z \cdot \frac{1}{t}\right)} \cdot \left(y - x\right)\]
    6. Applied associate-*l*1.0

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

      \[\leadsto x + z \cdot \color{blue}{\frac{y - x}{t}}\]

    if -6.499096036328817e+30 < t < 5.48446941871804e+163

    1. Initial program 2.7

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

      \[\leadsto x + \color{blue}{\frac{z}{t} \cdot \left(y - x\right)}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt3.4

      \[\leadsto x + \color{blue}{\left(\left(\sqrt[3]{\frac{z}{t}} \cdot \sqrt[3]{\frac{z}{t}}\right) \cdot \sqrt[3]{\frac{z}{t}}\right)} \cdot \left(y - x\right)\]
    6. Applied associate-*l*3.4

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

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

    if 5.48446941871804e+163 < t

    1. Initial program 1.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -6499096036328816583835987738624:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{elif}\;t \le 5.484469418718039822131826670235908244496 \cdot 10^{163}:\\ \;\;\;\;x + \left(\frac{z \cdot y}{t} - \frac{x \cdot z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z}{t} \cdot \left(y - x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019354 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"
  :precision binary64

  :herbie-target
  (if (< (* (- y x) (/ z t)) -1013646692435.887) (+ x (/ (- y x) (/ t z))) (if (< (* (- y x) (/ z t)) -0.0) (+ x (/ (* (- y x) z) t)) (+ x (/ (- y x) (/ t z)))))

  (+ x (* (- y x) (/ z t))))