Average Error: 24.1 → 8.4
Time: 6.0s
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 -3.4192536638792013 \cdot 10^{-292} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a - z} + \left(-\frac{z}{a - z}\right), t - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\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 -3.4192536638792013 \cdot 10^{-292} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a - z} + \left(-\frac{z}{a - z}\right), t - x, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r567661 = x;
        double r567662 = y;
        double r567663 = z;
        double r567664 = r567662 - r567663;
        double r567665 = t;
        double r567666 = r567665 - r567661;
        double r567667 = r567664 * r567666;
        double r567668 = a;
        double r567669 = r567668 - r567663;
        double r567670 = r567667 / r567669;
        double r567671 = r567661 + r567670;
        return r567671;
}

double f(double x, double y, double z, double t, double a) {
        double r567672 = x;
        double r567673 = y;
        double r567674 = z;
        double r567675 = r567673 - r567674;
        double r567676 = t;
        double r567677 = r567676 - r567672;
        double r567678 = r567675 * r567677;
        double r567679 = a;
        double r567680 = r567679 - r567674;
        double r567681 = r567678 / r567680;
        double r567682 = r567672 + r567681;
        double r567683 = -3.4192536638792013e-292;
        bool r567684 = r567682 <= r567683;
        double r567685 = 0.0;
        bool r567686 = r567682 <= r567685;
        double r567687 = !r567686;
        bool r567688 = r567684 || r567687;
        double r567689 = r567673 / r567680;
        double r567690 = r567674 / r567680;
        double r567691 = -r567690;
        double r567692 = r567689 + r567691;
        double r567693 = fma(r567692, r567677, r567672);
        double r567694 = r567672 / r567674;
        double r567695 = r567676 / r567674;
        double r567696 = r567694 - r567695;
        double r567697 = fma(r567673, r567696, r567676);
        double r567698 = r567688 ? r567693 : r567697;
        return r567698;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.1
Target12.1
Herbie8.4
\[\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 (+ x (/ (* (- y z) (- t x)) (- a z))) < -3.4192536638792013e-292 or 0.0 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 21.0

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{y \cdot \frac{1}{a - z}} - z \cdot \frac{1}{a - z}, t - x, x\right)\]
    8. Applied distribute-rgt-out--7.5

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{a - z} \cdot \left(y - z\right)}, t - x, x\right)\]
    9. Using strategy rm
    10. Applied sub-neg7.5

      \[\leadsto \mathsf{fma}\left(\frac{1}{a - z} \cdot \color{blue}{\left(y + \left(-z\right)\right)}, t - x, x\right)\]
    11. Applied distribute-lft-in7.4

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

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

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

    if -3.4192536638792013e-292 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 0.0

    1. Initial program 59.8

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -3.4192536638792013 \cdot 10^{-292} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a - z} + \left(-\frac{z}{a - z}\right), t - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \end{array}\]

Reproduce

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