Average Error: 16.0 → 7.0
Time: 5.9s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -6.6367866399476112 \cdot 10^{-99} \lor \neg \left(a \le 1.5391631179144392 \cdot 10^{-246}\right):\\ \;\;\;\;x + y \cdot \left(1 - \frac{z - t}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot y}{t} + x\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;a \le -6.6367866399476112 \cdot 10^{-99} \lor \neg \left(a \le 1.5391631179144392 \cdot 10^{-246}\right):\\
\;\;\;\;x + y \cdot \left(1 - \frac{z - t}{a - t}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{z \cdot y}{t} + x\\

\end{array}
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 temp;
	if (((a <= -6.636786639947611e-99) || !(a <= 1.5391631179144392e-246))) {
		temp = (x + (y * (1.0 - ((z - t) / (a - t)))));
	} else {
		temp = (((z * y) / t) + x);
	}
	return temp;
}

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

Original16.0
Target8.6
Herbie7.0
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt -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} \lt 1.47542934445772333 \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 2 regimes
  2. if a < -6.636786639947611e-99 or 1.5391631179144392e-246 < a

    1. Initial program 15.2

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
    2. Using strategy rm
    3. Applied associate-/l*9.9

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

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

      \[\leadsto \left(x + y\right) - \color{blue}{\frac{\frac{z - t}{a - t}}{\frac{1}{y}}}\]
    7. Using strategy rm
    8. Applied associate--l+6.8

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

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

    if -6.636786639947611e-99 < a < 1.5391631179144392e-246

    1. Initial program 19.4

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
    2. Taylor expanded around inf 9.6

      \[\leadsto \color{blue}{\frac{z \cdot y}{t} + x}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification7.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -6.6367866399476112 \cdot 10^{-99} \lor \neg \left(a \le 1.5391631179144392 \cdot 10^{-246}\right):\\ \;\;\;\;x + y \cdot \left(1 - \frac{z - t}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot y}{t} + x\\ \end{array}\]

Reproduce

herbie shell --seed 2020057 
(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-07) (- (+ y x) (* (* (- z t) (/ 1 (- 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 (- a t))) y))))

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