Average Error: 9.3 → 0.6
Time: 12.8s
Precision: binary64
\[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
\[\begin{array}{l} t_1 := \frac{y \cdot \left(z - t\right)}{a - t}\\ \mathbf{if}\;t_1 \leq -2.7868805564807467 \cdot 10^{+284}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\ \mathbf{elif}\;t_1 \leq 1.5653093214390899 \cdot 10^{+184}:\\ \;\;\;\;\left(x + \frac{y \cdot z}{a - t}\right) - \frac{y \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a - t}\\ \end{array} \]
x + \frac{y \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_1 \leq -2.7868805564807467 \cdot 10^{+284}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\

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

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


\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- a t))))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ (* y (- z t)) (- a t))))
   (if (<= t_1 -2.7868805564807467e+284)
     (fma y (/ (- z t) (- a t)) x)
     (if (<= t_1 1.5653093214390899e+184)
       (- (+ x (/ (* y z) (- a t))) (/ (* y t) (- a t)))
       (+ x (* (- z t) (/ y (- a t))))))))
double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = (y * (z - t)) / (a - t);
	double tmp;
	if (t_1 <= -2.7868805564807467e+284) {
		tmp = fma(y, ((z - t) / (a - t)), x);
	} else if (t_1 <= 1.5653093214390899e+184) {
		tmp = (x + ((y * z) / (a - t))) - ((y * t) / (a - t));
	} else {
		tmp = x + ((z - t) * (y / (a - t)));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original9.3
Target1.1
Herbie0.6
\[x + \frac{y}{\frac{a - t}{z - t}} \]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < -2.786880556480747e284

    1. Initial program 36.2

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

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

    if -2.786880556480747e284 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < 1.5653093214390899e184

    1. Initial program 0.3

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

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

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

    if 1.5653093214390899e184 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t))

    1. Initial program 32.0

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

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

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

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

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

Reproduce

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

  :herbie-target
  (+ x (/ y (/ (- a t) (- z t))))

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