Average Error: 10.6 → 0.6
Time: 19.0s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;t \le -3.621409335508072898622395529775828545171 \cdot 10^{-15} \lor \neg \left(t \le 6.874929093463645168164571333770296454924 \cdot 10^{-172}\right):\\ \;\;\;\;\frac{t}{\frac{a - z}{y - z}} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{a - z} \cdot \left(\left(y - z\right) \cdot t\right) + x\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
\mathbf{if}\;t \le -3.621409335508072898622395529775828545171 \cdot 10^{-15} \lor \neg \left(t \le 6.874929093463645168164571333770296454924 \cdot 10^{-172}\right):\\
\;\;\;\;\frac{t}{\frac{a - z}{y - z}} + x\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r333497 = x;
        double r333498 = y;
        double r333499 = z;
        double r333500 = r333498 - r333499;
        double r333501 = t;
        double r333502 = r333500 * r333501;
        double r333503 = a;
        double r333504 = r333503 - r333499;
        double r333505 = r333502 / r333504;
        double r333506 = r333497 + r333505;
        return r333506;
}

double f(double x, double y, double z, double t, double a) {
        double r333507 = t;
        double r333508 = -3.621409335508073e-15;
        bool r333509 = r333507 <= r333508;
        double r333510 = 6.874929093463645e-172;
        bool r333511 = r333507 <= r333510;
        double r333512 = !r333511;
        bool r333513 = r333509 || r333512;
        double r333514 = a;
        double r333515 = z;
        double r333516 = r333514 - r333515;
        double r333517 = y;
        double r333518 = r333517 - r333515;
        double r333519 = r333516 / r333518;
        double r333520 = r333507 / r333519;
        double r333521 = x;
        double r333522 = r333520 + r333521;
        double r333523 = 1.0;
        double r333524 = r333523 / r333516;
        double r333525 = r333518 * r333507;
        double r333526 = r333524 * r333525;
        double r333527 = r333526 + r333521;
        double r333528 = r333513 ? r333522 : r333527;
        return r333528;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.6
Target0.5
Herbie0.6
\[\begin{array}{l} \mathbf{if}\;t \lt -1.068297449017406694366747246993994850729 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t \lt 3.911094988758637497591020599238553861375 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if t < -3.621409335508073e-15 or 6.874929093463645e-172 < t

    1. Initial program 16.9

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a - z}{y - z}} \cdot t + x}\]
    7. Simplified0.7

      \[\leadsto \color{blue}{\frac{t}{\frac{a - z}{y - z}}} + x\]

    if -3.621409335508073e-15 < t < 6.874929093463645e-172

    1. Initial program 0.3

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a - z}{y - z}} \cdot t + x}\]
    7. Simplified2.0

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

      \[\leadsto \frac{t}{\color{blue}{\left(a - z\right) \cdot \frac{1}{y - z}}} + x\]
    10. Applied *-un-lft-identity2.0

      \[\leadsto \frac{\color{blue}{1 \cdot t}}{\left(a - z\right) \cdot \frac{1}{y - z}} + x\]
    11. Applied times-frac0.3

      \[\leadsto \color{blue}{\frac{1}{a - z} \cdot \frac{t}{\frac{1}{y - z}}} + x\]
    12. Simplified0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -3.621409335508072898622395529775828545171 \cdot 10^{-15} \lor \neg \left(t \le 6.874929093463645168164571333770296454924 \cdot 10^{-172}\right):\\ \;\;\;\;\frac{t}{\frac{a - z}{y - z}} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{a - z} \cdot \left(\left(y - z\right) \cdot t\right) + x\\ \end{array}\]

Reproduce

herbie shell --seed 2019326 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, A"
  :precision binary64

  :herbie-target
  (if (< t -1.0682974490174067e-39) (+ x (* (/ (- y z) (- a z)) t)) (if (< t 3.9110949887586375e-141) (+ x (/ (* (- y z) t) (- a z))) (+ x (* (/ (- y z) (- a z)) t))))

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