Average Error: 24.6 → 11.1
Time: 20.2s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -3.6771152743398664 \cdot 10^{-164} \lor \neg \left(a \le 1.40127841177239266 \cdot 10^{42}\right):\\ \;\;\;\;\mathsf{fma}\left(\left(y - z\right) \cdot \frac{1}{a - z}, t - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;a \le -3.6771152743398664 \cdot 10^{-164} \lor \neg \left(a \le 1.40127841177239266 \cdot 10^{42}\right):\\
\;\;\;\;\mathsf{fma}\left(\left(y - z\right) \cdot \frac{1}{a - z}, t - x, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r799755 = x;
        double r799756 = y;
        double r799757 = z;
        double r799758 = r799756 - r799757;
        double r799759 = t;
        double r799760 = r799759 - r799755;
        double r799761 = r799758 * r799760;
        double r799762 = a;
        double r799763 = r799762 - r799757;
        double r799764 = r799761 / r799763;
        double r799765 = r799755 + r799764;
        return r799765;
}

double f(double x, double y, double z, double t, double a) {
        double r799766 = a;
        double r799767 = -3.6771152743398664e-164;
        bool r799768 = r799766 <= r799767;
        double r799769 = 1.4012784117723927e+42;
        bool r799770 = r799766 <= r799769;
        double r799771 = !r799770;
        bool r799772 = r799768 || r799771;
        double r799773 = y;
        double r799774 = z;
        double r799775 = r799773 - r799774;
        double r799776 = 1.0;
        double r799777 = r799766 - r799774;
        double r799778 = r799776 / r799777;
        double r799779 = r799775 * r799778;
        double r799780 = t;
        double r799781 = x;
        double r799782 = r799780 - r799781;
        double r799783 = fma(r799779, r799782, r799781);
        double r799784 = r799773 / r799774;
        double r799785 = r799784 * r799782;
        double r799786 = r799780 - r799785;
        double r799787 = r799772 ? r799783 : r799786;
        return r799787;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.6
Target11.6
Herbie11.1
\[\begin{array}{l} \mathbf{if}\;z \lt -1.25361310560950359 \cdot 10^{188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z \lt 4.44670236911381103 \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 2 regimes
  2. if a < -3.6771152743398664e-164 or 1.4012784117723927e+42 < a

    1. Initial program 22.6

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

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

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

    if -3.6771152743398664e-164 < a < 1.4012784117723927e+42

    1. Initial program 28.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)}\]
    3. Taylor expanded around inf 21.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -3.6771152743398664 \cdot 10^{-164} \lor \neg \left(a \le 1.40127841177239266 \cdot 10^{42}\right):\\ \;\;\;\;\mathsf{fma}\left(\left(y - z\right) \cdot \frac{1}{a - z}, t - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \end{array}\]

Reproduce

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

  :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))))