Average Error: 25.3 → 9.9
Time: 4.8s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.653271416695378433251533453453101546377 \cdot 10^{159} \lor \neg \left(z \le 3.6212987406493825547877762167062528524 \cdot 10^{230}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \frac{y - z}{a - z}, t - x, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -2.653271416695378433251533453453101546377 \cdot 10^{159} \lor \neg \left(z \le 3.6212987406493825547877762167062528524 \cdot 10^{230}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r561836 = x;
        double r561837 = y;
        double r561838 = z;
        double r561839 = r561837 - r561838;
        double r561840 = t;
        double r561841 = r561840 - r561836;
        double r561842 = r561839 * r561841;
        double r561843 = a;
        double r561844 = r561843 - r561838;
        double r561845 = r561842 / r561844;
        double r561846 = r561836 + r561845;
        return r561846;
}

double f(double x, double y, double z, double t, double a) {
        double r561847 = z;
        double r561848 = -2.6532714166953784e+159;
        bool r561849 = r561847 <= r561848;
        double r561850 = 3.6212987406493826e+230;
        bool r561851 = r561847 <= r561850;
        double r561852 = !r561851;
        bool r561853 = r561849 || r561852;
        double r561854 = y;
        double r561855 = x;
        double r561856 = r561855 / r561847;
        double r561857 = t;
        double r561858 = r561857 / r561847;
        double r561859 = r561856 - r561858;
        double r561860 = fma(r561854, r561859, r561857);
        double r561861 = 1.0;
        double r561862 = r561854 - r561847;
        double r561863 = a;
        double r561864 = r561863 - r561847;
        double r561865 = r561862 / r561864;
        double r561866 = r561861 * r561865;
        double r561867 = r561857 - r561855;
        double r561868 = fma(r561866, r561867, r561855);
        double r561869 = r561853 ? r561860 : r561868;
        return r561869;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original25.3
Target11.7
Herbie9.9
\[\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 2 regimes
  2. if z < -2.6532714166953784e+159 or 3.6212987406493826e+230 < z

    1. Initial program 50.1

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

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

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

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

    if -2.6532714166953784e+159 < z < 3.6212987406493826e+230

    1. Initial program 18.6

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y - z\right) \cdot \frac{1}{a - z}}, t - x, x\right)\]
    5. Using strategy rm
    6. Applied *-un-lft-identity8.7

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

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

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

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

Reproduce

herbie shell --seed 2019353 +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))))