Average Error: 10.7 → 0.7
Time: 16.2s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{z - a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y \cdot \left(z - t\right)}{z - a} \le -4.663883987632393677861891411181961763687 \cdot 10^{166}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)\\ \mathbf{elif}\;\frac{y \cdot \left(z - t\right)}{z - a} \le 8.323175891964665054213654353279421968364 \cdot 10^{277}:\\ \;\;\;\;\frac{y \cdot \left(z - t\right)}{z - a} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z - a}{y}} \cdot \left(z - t\right) + x\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{z - a}
\begin{array}{l}
\mathbf{if}\;\frac{y \cdot \left(z - t\right)}{z - a} \le -4.663883987632393677861891411181961763687 \cdot 10^{166}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r446116 = x;
        double r446117 = y;
        double r446118 = z;
        double r446119 = t;
        double r446120 = r446118 - r446119;
        double r446121 = r446117 * r446120;
        double r446122 = a;
        double r446123 = r446118 - r446122;
        double r446124 = r446121 / r446123;
        double r446125 = r446116 + r446124;
        return r446125;
}

double f(double x, double y, double z, double t, double a) {
        double r446126 = y;
        double r446127 = z;
        double r446128 = t;
        double r446129 = r446127 - r446128;
        double r446130 = r446126 * r446129;
        double r446131 = a;
        double r446132 = r446127 - r446131;
        double r446133 = r446130 / r446132;
        double r446134 = -4.663883987632394e+166;
        bool r446135 = r446133 <= r446134;
        double r446136 = r446129 / r446132;
        double r446137 = x;
        double r446138 = fma(r446126, r446136, r446137);
        double r446139 = 8.323175891964665e+277;
        bool r446140 = r446133 <= r446139;
        double r446141 = r446133 + r446137;
        double r446142 = 1.0;
        double r446143 = r446132 / r446126;
        double r446144 = r446142 / r446143;
        double r446145 = r446144 * r446129;
        double r446146 = r446145 + r446137;
        double r446147 = r446140 ? r446141 : r446146;
        double r446148 = r446135 ? r446138 : r446147;
        return r446148;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.7
Target1.3
Herbie0.7
\[x + \frac{y}{\frac{z - a}{z - t}}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (* y (- z t)) (- z a)) < -4.663883987632394e+166

    1. Initial program 41.6

      \[x + \frac{y \cdot \left(z - t\right)}{z - a}\]
    2. Simplified4.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z - a}, z - t, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef4.0

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

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

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

      \[\leadsto y \cdot \color{blue}{\frac{z - t}{z - a}} + x\]
    9. Using strategy rm
    10. Applied fma-def2.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)}\]

    if -4.663883987632394e+166 < (/ (* y (- z t)) (- z a)) < 8.323175891964665e+277

    1. Initial program 0.3

      \[x + \frac{y \cdot \left(z - t\right)}{z - a}\]
    2. Simplified3.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z - a}, z - t, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef3.0

      \[\leadsto \color{blue}{\frac{y}{z - a} \cdot \left(z - t\right) + x}\]
    5. Using strategy rm
    6. Applied div-inv3.0

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

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

      \[\leadsto y \cdot \color{blue}{\frac{z - t}{z - a}} + x\]
    9. Using strategy rm
    10. Applied associate-*r/0.3

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

    if 8.323175891964665e+277 < (/ (* y (- z t)) (- z a))

    1. Initial program 59.3

      \[x + \frac{y \cdot \left(z - t\right)}{z - a}\]
    2. Simplified1.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z - a}, z - t, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef1.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y \cdot \left(z - t\right)}{z - a} \le -4.663883987632393677861891411181961763687 \cdot 10^{166}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)\\ \mathbf{elif}\;\frac{y \cdot \left(z - t\right)}{z - a} \le 8.323175891964665054213654353279421968364 \cdot 10^{277}:\\ \;\;\;\;\frac{y \cdot \left(z - t\right)}{z - a} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z - a}{y}} \cdot \left(z - t\right) + x\\ \end{array}\]

Reproduce

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

  :herbie-target
  (+ x (/ y (/ (- z a) (- z t))))

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