Average Error: 1.4 → 0.8
Time: 3.6s
Precision: binary64
\[x + y \cdot \frac{z - t}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{z - t}{a - t} \leq 4.104134791311347 \cdot 10^{+142}:\\ \;\;\;\;x + y \cdot \left(\frac{z}{a - t} - \frac{t}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a - t}\\ \end{array}\]
x + y \cdot \frac{z - t}{a - t}
\begin{array}{l}
\mathbf{if}\;\frac{z - t}{a - t} \leq 4.104134791311347 \cdot 10^{+142}:\\
\;\;\;\;x + y \cdot \left(\frac{z}{a - t} - \frac{t}{a - t}\right)\\

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

\end{array}
double code(double x, double y, double z, double t, double a) {
	return ((double) (x + ((double) (y * (((double) (z - t)) / ((double) (a - t)))))));
}
double code(double x, double y, double z, double t, double a) {
	double VAR;
	if (((((double) (z - t)) / ((double) (a - t))) <= 4.104134791311347e+142)) {
		VAR = ((double) (x + ((double) (y * ((double) ((z / ((double) (a - t))) - (t / ((double) (a - t)))))))));
	} else {
		VAR = ((double) (x + ((double) (((double) (z - t)) * (y / ((double) (a - t)))))));
	}
	return VAR;
}

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.4
Target0.5
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;y < -8.508084860551241 \cdot 10^{-17}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\ \;\;\;\;x + \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (- z t) (- a t)) < 4.104134791311347e142

    1. Initial program 0.8

      \[x + y \cdot \frac{z - t}{a - t}\]
    2. Using strategy rm
    3. Applied div-sub0.8

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

    if 4.104134791311347e142 < (/ (- z t) (- a t))

    1. Initial program 13.6

      \[x + y \cdot \frac{z - t}{a - t}\]
    2. Using strategy rm
    3. Applied div-sub13.6

      \[\leadsto x + y \cdot \color{blue}{\left(\frac{z}{a - t} - \frac{t}{a - t}\right)}\]
    4. Using strategy rm
    5. Applied div-inv13.6

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

      \[\leadsto x + y \cdot \left(\color{blue}{z \cdot \frac{1}{a - t}} - t \cdot \frac{1}{a - t}\right)\]
    7. Applied distribute-rgt-out--13.7

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

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

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

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

Reproduce

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

  :herbie-target
  (if (< y -8.508084860551241e-17) (+ x (* y (/ (- z t) (- a t)))) (if (< y 2.894426862792089e-49) (+ x (* (* y (- z t)) (/ 1.0 (- a t)))) (+ x (* y (/ (- z t) (- a t))))))

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