Average Error: 24.7 → 7.1
Time: 23.4s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -8.877742204906099261515182903566331701678 \cdot 10^{295}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x - \frac{y - z}{\frac{a - z}{x}}\right) + \mathsf{fma}\left(-\frac{y - z}{a - z}, x, \frac{y - z}{a - z} \cdot x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -1.539254624498238512905823682389083375771 \cdot 10^{-307}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0:\\ \;\;\;\;\frac{x \cdot y}{z} + t \cdot \frac{y - z}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x - \frac{y - z}{\frac{a - z}{x}}\right) + \mathsf{fma}\left(-\frac{y - z}{a - z}, x, \frac{y - z}{a - z} \cdot x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -8.877742204906099261515182903566331701678 \cdot 10^{295}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x - \frac{y - z}{\frac{a - z}{x}}\right) + \mathsf{fma}\left(-\frac{y - z}{a - z}, x, \frac{y - z}{a - z} \cdot x\right)\\

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

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r29726096 = x;
        double r29726097 = y;
        double r29726098 = z;
        double r29726099 = r29726097 - r29726098;
        double r29726100 = t;
        double r29726101 = r29726100 - r29726096;
        double r29726102 = r29726099 * r29726101;
        double r29726103 = a;
        double r29726104 = r29726103 - r29726098;
        double r29726105 = r29726102 / r29726104;
        double r29726106 = r29726096 + r29726105;
        return r29726106;
}

double f(double x, double y, double z, double t, double a) {
        double r29726107 = x;
        double r29726108 = y;
        double r29726109 = z;
        double r29726110 = r29726108 - r29726109;
        double r29726111 = t;
        double r29726112 = r29726111 - r29726107;
        double r29726113 = r29726110 * r29726112;
        double r29726114 = a;
        double r29726115 = r29726114 - r29726109;
        double r29726116 = r29726113 / r29726115;
        double r29726117 = r29726107 + r29726116;
        double r29726118 = -8.8777422049061e+295;
        bool r29726119 = r29726117 <= r29726118;
        double r29726120 = r29726110 / r29726115;
        double r29726121 = r29726115 / r29726107;
        double r29726122 = r29726110 / r29726121;
        double r29726123 = r29726107 - r29726122;
        double r29726124 = fma(r29726120, r29726111, r29726123);
        double r29726125 = -r29726120;
        double r29726126 = r29726120 * r29726107;
        double r29726127 = fma(r29726125, r29726107, r29726126);
        double r29726128 = r29726124 + r29726127;
        double r29726129 = -1.5392546244982385e-307;
        bool r29726130 = r29726117 <= r29726129;
        double r29726131 = 0.0;
        bool r29726132 = r29726117 <= r29726131;
        double r29726133 = r29726107 * r29726108;
        double r29726134 = r29726133 / r29726109;
        double r29726135 = r29726111 * r29726120;
        double r29726136 = r29726134 + r29726135;
        double r29726137 = r29726132 ? r29726136 : r29726128;
        double r29726138 = r29726130 ? r29726117 : r29726137;
        double r29726139 = r29726119 ? r29726128 : r29726138;
        return r29726139;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.7
Target11.5
Herbie7.1
\[\begin{array}{l} \mathbf{if}\;z \lt -1.253613105609503593846459977496550767343 \cdot 10^{188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z \lt 4.446702369113811028051510715777703865332 \cdot 10^{64}:\\ \;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\ \mathbf{else}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (+ x (/ (* (- y z) (- t x)) (- a z))) < -8.8777422049061e+295 or 0.0 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 31.7

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

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

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

      \[\leadsto \frac{y - z}{a - z} \cdot \color{blue}{\left(t + \left(-x\right)\right)} + x\]
    7. Applied distribute-lft-in9.9

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

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

      \[\leadsto \frac{y - z}{a - z} \cdot t + \color{blue}{\left(x - x \cdot \frac{y - z}{a - z}\right)}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt30.0

      \[\leadsto \frac{y - z}{a - z} \cdot t + \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} - x \cdot \frac{y - z}{a - z}\right)\]
    12. Applied prod-diff30.8

      \[\leadsto \frac{y - z}{a - z} \cdot t + \color{blue}{\left(\mathsf{fma}\left(\sqrt{x}, \sqrt{x}, -\frac{y - z}{a - z} \cdot x\right) + \mathsf{fma}\left(-\frac{y - z}{a - z}, x, \frac{y - z}{a - z} \cdot x\right)\right)}\]
    13. Applied associate-+r+30.8

      \[\leadsto \color{blue}{\left(\frac{y - z}{a - z} \cdot t + \mathsf{fma}\left(\sqrt{x}, \sqrt{x}, -\frac{y - z}{a - z} \cdot x\right)\right) + \mathsf{fma}\left(-\frac{y - z}{a - z}, x, \frac{y - z}{a - z} \cdot x\right)}\]
    14. Simplified8.2

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

    if -8.8777422049061e+295 < (+ x (/ (* (- y z) (- t x)) (- a z))) < -1.5392546244982385e-307

    1. Initial program 1.9

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

    if -1.5392546244982385e-307 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 0.0

    1. Initial program 61.3

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

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

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

      \[\leadsto \frac{y - z}{a - z} \cdot \color{blue}{\left(t + \left(-x\right)\right)} + x\]
    7. Applied distribute-lft-in61.3

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

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

      \[\leadsto \frac{y - z}{a - z} \cdot t + \color{blue}{\left(x - x \cdot \frac{y - z}{a - z}\right)}\]
    10. Taylor expanded around inf 18.9

      \[\leadsto \frac{y - z}{a - z} \cdot t + \color{blue}{\frac{x \cdot y}{z}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification7.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -8.877742204906099261515182903566331701678 \cdot 10^{295}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x - \frac{y - z}{\frac{a - z}{x}}\right) + \mathsf{fma}\left(-\frac{y - z}{a - z}, x, \frac{y - z}{a - z} \cdot x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -1.539254624498238512905823682389083375771 \cdot 10^{-307}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0:\\ \;\;\;\;\frac{x \cdot y}{z} + t \cdot \frac{y - z}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x - \frac{y - z}{\frac{a - z}{x}}\right) + \mathsf{fma}\left(-\frac{y - z}{a - z}, x, \frac{y - z}{a - z} \cdot x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019192 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"

  :herbie-target
  (if (< z -1.2536131056095036e+188) (- t (* (/ y z) (- t x))) (if (< z 4.446702369113811e+64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))

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