Average Error: 10.5 → 0.7
Time: 7.4s
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 -\infty:\\ \;\;\;\;\begin{array}{l} t_2 := \frac{y}{a - t}\\ x + \left(z \cdot t_2 - t \cdot t_2\right) \end{array}\\ \mathbf{elif}\;t_1 \leq 1.636389978005464 \cdot 10^{-106}:\\ \;\;\;\;t_1 + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a - t}{z - 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 -\infty:\\
\;\;\;\;\begin{array}{l}
t_2 := \frac{y}{a - t}\\
x + \left(z \cdot t_2 - t \cdot t_2\right)
\end{array}\\

\mathbf{elif}\;t_1 \leq 1.636389978005464 \cdot 10^{-106}:\\
\;\;\;\;t_1 + x\\

\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{a - t}{z - 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 (- INFINITY))
     (let* ((t_2 (/ y (- a t)))) (+ x (- (* z t_2) (* t t_2))))
     (if (<= t_1 1.636389978005464e-106)
       (+ t_1 x)
       (+ x (/ y (/ (- a t) (- z 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 <= -((double) INFINITY)) {
		double t_2_1 = y / (a - t);
		tmp = x + ((z * t_2_1) - (t * t_2_1));
	} else if (t_1 <= 1.636389978005464e-106) {
		tmp = t_1 + x;
	} else {
		tmp = x + (y / ((a - t) / (z - t)));
	}
	return tmp;
}

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.5
Target1.2
Herbie0.7
\[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)) < -inf.0

    1. Initial program 64.0

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

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

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

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

      \[\leadsto x + \frac{y}{a - t} \cdot \color{blue}{\left(z + \left(-t\right)\right)} \]
    6. Applied distribute-rgt-in_binary640.2

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

    if -inf.0 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < 1.6363899780054641e-106

    1. Initial program 0.3

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

    if 1.6363899780054641e-106 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t))

    1. Initial program 17.3

      \[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
    2. Applied associate-/l*_binary641.6

      \[\leadsto x + \color{blue}{\frac{y}{\frac{a - t}{z - t}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y \cdot \left(z - t\right)}{a - t} \leq -\infty:\\ \;\;\;\;x + \left(z \cdot \frac{y}{a - t} - t \cdot \frac{y}{a - t}\right)\\ \mathbf{elif}\;\frac{y \cdot \left(z - t\right)}{a - t} \leq 1.636389978005464 \cdot 10^{-106}:\\ \;\;\;\;\frac{y \cdot \left(z - t\right)}{a - t} + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a - t}{z - t}}\\ \end{array} \]

Reproduce

herbie shell --seed 2021340 
(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))))