Average Error: 16.0 → 8.7
Time: 5.5s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -4.4697002957629188 \cdot 10^{211}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{elif}\;t \le -4.604891947633429 \cdot 10^{-207}:\\ \;\;\;\;y \cdot \frac{t - z}{a - t} + \left(x + y\right)\\ \mathbf{elif}\;t \le 6.953532797602288 \cdot 10^{-132}:\\ \;\;\;\;\left(y \cdot \left(t - z\right)\right) \cdot \frac{1}{a - t} + \left(x + y\right)\\ \mathbf{elif}\;t \le 5.0511599837810109 \cdot 10^{195}:\\ \;\;\;\;y \cdot \frac{t - z}{a - t} + \left(x + y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \le -4.4697002957629188 \cdot 10^{211}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\

\mathbf{elif}\;t \le -4.604891947633429 \cdot 10^{-207}:\\
\;\;\;\;y \cdot \frac{t - z}{a - t} + \left(x + y\right)\\

\mathbf{elif}\;t \le 6.953532797602288 \cdot 10^{-132}:\\
\;\;\;\;\left(y \cdot \left(t - z\right)\right) \cdot \frac{1}{a - t} + \left(x + y\right)\\

\mathbf{elif}\;t \le 5.0511599837810109 \cdot 10^{195}:\\
\;\;\;\;y \cdot \frac{t - z}{a - t} + \left(x + y\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\

\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 ((t <= -4.469700295762919e+211)) {
		temp = fma((z / t), y, x);
	} else {
		double temp_1;
		if ((t <= -4.6048919476334295e-207)) {
			temp_1 = ((y * ((t - z) / (a - t))) + (x + y));
		} else {
			double temp_2;
			if ((t <= 6.953532797602288e-132)) {
				temp_2 = (((y * (t - z)) * (1.0 / (a - t))) + (x + y));
			} else {
				double temp_3;
				if ((t <= 5.051159983781011e+195)) {
					temp_3 = ((y * ((t - z) / (a - t))) + (x + y));
				} else {
					temp_3 = fma((z / t), y, x);
				}
				temp_2 = temp_3;
			}
			temp_1 = temp_2;
		}
		temp = temp_1;
	}
	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.3
Herbie8.7
\[\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 3 regimes
  2. if t < -4.469700295762919e+211 or 5.051159983781011e+195 < t

    1. Initial program 33.9

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a - t}, t - z, x + y\right)}\]
    3. Using strategy rm
    4. Applied fma-udef25.6

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

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

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

      \[\leadsto y \cdot \color{blue}{\frac{t - z}{a - t}} + \left(x + y\right)\]
    9. Taylor expanded around inf 15.5

      \[\leadsto \color{blue}{\frac{z \cdot y}{t} + x}\]
    10. Simplified9.7

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

    if -4.469700295762919e+211 < t < -4.6048919476334295e-207 or 6.953532797602288e-132 < t < 5.051159983781011e+195

    1. Initial program 14.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a - t}, t - z, x + y\right)}\]
    3. Using strategy rm
    4. Applied fma-udef10.3

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

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

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

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

    if -4.6048919476334295e-207 < t < 6.953532797602288e-132

    1. Initial program 4.7

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a - t}, t - z, x + y\right)}\]
    3. Using strategy rm
    4. Applied fma-udef3.9

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

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

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

      \[\leadsto y \cdot \color{blue}{\frac{t - z}{a - t}} + \left(x + y\right)\]
    9. Using strategy rm
    10. Applied div-inv4.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -4.4697002957629188 \cdot 10^{211}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{elif}\;t \le -4.604891947633429 \cdot 10^{-207}:\\ \;\;\;\;y \cdot \frac{t - z}{a - t} + \left(x + y\right)\\ \mathbf{elif}\;t \le 6.953532797602288 \cdot 10^{-132}:\\ \;\;\;\;\left(y \cdot \left(t - z\right)\right) \cdot \frac{1}{a - t} + \left(x + y\right)\\ \mathbf{elif}\;t \le 5.0511599837810109 \cdot 10^{195}:\\ \;\;\;\;y \cdot \frac{t - z}{a - t} + \left(x + y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020049 +o rules:numerics
(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))))