Average Error: 1.3 → 0.4
Time: 11.2s
Precision: binary64
\[x + y \cdot \frac{z - t}{z - a} \]
\[\begin{array}{l} t_1 := x + y \cdot \frac{z - t}{z - a}\\ \mathbf{if}\;y \leq -7.515725844238207 \cdot 10^{-85}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.717196829604943 \cdot 10^{-16}:\\ \;\;\;\;\left(x + \frac{y \cdot z}{z - a}\right) - \frac{y \cdot t}{z - a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
x + y \cdot \frac{z - t}{z - a}
\begin{array}{l}
t_1 := x + y \cdot \frac{z - t}{z - a}\\
\mathbf{if}\;y \leq -7.515725844238207 \cdot 10^{-85}:\\
\;\;\;\;t_1\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- z a)))))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (+ x (* y (/ (- z t) (- z a))))))
   (if (<= y -7.515725844238207e-85)
     t_1
     (if (<= y 2.717196829604943e-16)
       (- (+ x (/ (* y z) (- z a))) (/ (* y t) (- z a)))
       t_1))))
double code(double x, double y, double z, double t, double a) {
	return x + (y * ((z - t) / (z - a)));
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = x + (y * ((z - t) / (z - a)));
	double tmp;
	if (y <= -7.515725844238207e-85) {
		tmp = t_1;
	} else if (y <= 2.717196829604943e-16) {
		tmp = (x + ((y * z) / (z - a))) - ((y * t) / (z - a));
	} else {
		tmp = t_1;
	}
	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

Original1.3
Target1.3
Herbie0.4
\[x + \frac{y}{\frac{z - a}{z - t}} \]

Derivation

  1. Split input into 2 regimes
  2. if y < -7.51572584423820702e-85 or 2.71719682960494313e-16 < y

    1. Initial program 0.6

      \[x + y \cdot \frac{z - t}{z - a} \]

    if -7.51572584423820702e-85 < y < 2.71719682960494313e-16

    1. Initial program 2.3

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

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

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

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

Reproduce

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

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

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