Average Error: 16.5 → 6.6
Time: 5.7s
Precision: binary64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -1.533098449819548 \cdot 10^{+121}:\\ \;\;\;\;\mathsf{fma}\left(z - a, \frac{y}{t}, x\right)\\ \mathbf{elif}\;t \leq 1.5668554075406726 \cdot 10^{+154}:\\ \;\;\;\;y + \left(x + y \cdot \frac{t - z}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - a}{t}, x\right)\\ \end{array} \]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \leq -1.533098449819548 \cdot 10^{+121}:\\
\;\;\;\;\mathsf{fma}\left(z - a, \frac{y}{t}, x\right)\\

\mathbf{elif}\;t \leq 1.5668554075406726 \cdot 10^{+154}:\\
\;\;\;\;y + \left(x + y \cdot \frac{t - z}{a - t}\right)\\

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


\end{array}
(FPCore (x y z t a) :precision binary64 (- (+ x y) (/ (* (- z t) y) (- a t))))
(FPCore (x y z t a)
 :precision binary64
 (if (<= t -1.533098449819548e+121)
   (fma (- z a) (/ y t) x)
   (if (<= t 1.5668554075406726e+154)
     (+ y (+ x (* y (/ (- t z) (- a t)))))
     (fma y (/ (- z a) t) x))))
double code(double x, double y, double z, double t, double a) {
	return (x + y) - (((z - t) * y) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (t <= -1.533098449819548e+121) {
		tmp = fma((z - a), (y / t), x);
	} else if (t <= 1.5668554075406726e+154) {
		tmp = y + (x + (y * ((t - z) / (a - t))));
	} else {
		tmp = fma(y, ((z - a) / t), x);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.5
Target8.6
Herbie6.6
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < -1.3664970889390727 \cdot 10^{-7}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \mathbf{elif}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < 1.4754293444577233 \cdot 10^{-239}:\\ \;\;\;\;\frac{y \cdot \left(a - z\right) - x \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if t < -1.5330984498195481e121

    1. Initial program 31.4

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

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

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

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

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

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

    if -1.5330984498195481e121 < t < 1.56685540754067258e154

    1. Initial program 9.7

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

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

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

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

    if 1.56685540754067258e154 < t

    1. Initial program 31.5

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

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

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

      \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - a\right)} \]
    5. Applied div-inv_binary645.5

      \[\leadsto x + \color{blue}{\left(y \cdot \frac{1}{t}\right)} \cdot \left(z - a\right) \]
    6. Applied associate-*l*_binary644.8

      \[\leadsto x + \color{blue}{y \cdot \left(\frac{1}{t} \cdot \left(z - a\right)\right)} \]
    7. Taylor expanded in x around 0 13.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.533098449819548 \cdot 10^{+121}:\\ \;\;\;\;\mathsf{fma}\left(z - a, \frac{y}{t}, x\right)\\ \mathbf{elif}\;t \leq 1.5668554075406726 \cdot 10^{+154}:\\ \;\;\;\;y + \left(x + y \cdot \frac{t - z}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - a}{t}, x\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022125 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"
  :precision binary64

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-7) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y))))

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