Average Error: 24.7 → 10.0
Time: 28.5s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -4.046536476058793676946234371999781019952 \cdot 10^{-154} \lor \neg \left(a \le 7.692781660197598904440558192035913736358 \cdot 10^{-150}\right):\\ \;\;\;\;\frac{t - x}{\left(a - z\right) \cdot \frac{1}{y - z}} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, t - \frac{t \cdot y}{z}\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;a \le -4.046536476058793676946234371999781019952 \cdot 10^{-154} \lor \neg \left(a \le 7.692781660197598904440558192035913736358 \cdot 10^{-150}\right):\\
\;\;\;\;\frac{t - x}{\left(a - z\right) \cdot \frac{1}{y - z}} + x\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r426788 = x;
        double r426789 = y;
        double r426790 = z;
        double r426791 = r426789 - r426790;
        double r426792 = t;
        double r426793 = r426792 - r426788;
        double r426794 = r426791 * r426793;
        double r426795 = a;
        double r426796 = r426795 - r426790;
        double r426797 = r426794 / r426796;
        double r426798 = r426788 + r426797;
        return r426798;
}

double f(double x, double y, double z, double t, double a) {
        double r426799 = a;
        double r426800 = -4.046536476058794e-154;
        bool r426801 = r426799 <= r426800;
        double r426802 = 7.692781660197599e-150;
        bool r426803 = r426799 <= r426802;
        double r426804 = !r426803;
        bool r426805 = r426801 || r426804;
        double r426806 = t;
        double r426807 = x;
        double r426808 = r426806 - r426807;
        double r426809 = z;
        double r426810 = r426799 - r426809;
        double r426811 = 1.0;
        double r426812 = y;
        double r426813 = r426812 - r426809;
        double r426814 = r426811 / r426813;
        double r426815 = r426810 * r426814;
        double r426816 = r426808 / r426815;
        double r426817 = r426816 + r426807;
        double r426818 = r426807 / r426809;
        double r426819 = r426806 * r426812;
        double r426820 = r426819 / r426809;
        double r426821 = r426806 - r426820;
        double r426822 = fma(r426818, r426812, r426821);
        double r426823 = r426805 ? r426817 : r426822;
        return r426823;
}

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.9
Herbie10.0
\[\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 a < -4.046536476058794e-154 or 7.692781660197599e-150 < a

    1. Initial program 23.1

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a - z}{y - z}} \cdot \left(t - x\right) + x}\]
    7. Simplified9.2

      \[\leadsto \color{blue}{\frac{t - x}{\frac{a - z}{y - z}}} + x\]
    8. Using strategy rm
    9. Applied div-inv9.2

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

    if -4.046536476058794e-154 < a < 7.692781660197599e-150

    1. Initial program 30.2

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019303 +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.25361310560950359e188) (- t (* (/ y z) (- t x))) (if (< z 4.44670236911381103e64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))

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