Average Error: 10.7 → 0.7
Time: 17.6s
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}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{z - a}\\ \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}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{z - a}\\

\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 r387512 = x;
        double r387513 = y;
        double r387514 = z;
        double r387515 = t;
        double r387516 = r387514 - r387515;
        double r387517 = r387513 * r387516;
        double r387518 = a;
        double r387519 = r387514 - r387518;
        double r387520 = r387517 / r387519;
        double r387521 = r387512 + r387520;
        return r387521;
}

double f(double x, double y, double z, double t, double a) {
        double r387522 = y;
        double r387523 = z;
        double r387524 = t;
        double r387525 = r387523 - r387524;
        double r387526 = r387522 * r387525;
        double r387527 = a;
        double r387528 = r387523 - r387527;
        double r387529 = r387526 / r387528;
        double r387530 = -4.663883987632394e+166;
        bool r387531 = r387529 <= r387530;
        double r387532 = r387525 / r387528;
        double r387533 = x;
        double r387534 = fma(r387522, r387532, r387533);
        double r387535 = 8.323175891964665e+277;
        bool r387536 = r387529 <= r387535;
        double r387537 = r387533 + r387529;
        double r387538 = 1.0;
        double r387539 = r387528 / r387522;
        double r387540 = r387538 / r387539;
        double r387541 = r387540 * r387525;
        double r387542 = r387541 + r387533;
        double r387543 = r387536 ? r387537 : r387542;
        double r387544 = r387531 ? r387534 : r387543;
        return r387544;
}

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}\]

    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}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{z - a}\\ \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))))