Average Error: 23.4 → 19.0
Time: 4.9s
Precision: 64
\[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.0667327550105751 \cdot 10^{75} \lor \neg \left(z \le 9.08101503372451 \cdot 10^{95}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\ \end{array}\]
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\begin{array}{l}
\mathbf{if}\;z \le -1.0667327550105751 \cdot 10^{75} \lor \neg \left(z \le 9.08101503372451 \cdot 10^{95}\right):\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

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

\end{array}
double code(double x, double y, double z, double t, double a, double b) {
	return (((x * y) + (z * (t - a))) / (y + (z * (b - y))));
}
double code(double x, double y, double z, double t, double a, double b) {
	double VAR;
	if (((z <= -1.066732755010575e+75) || !(z <= 9.081015033724511e+95))) {
		VAR = ((t / b) - (a / b));
	} else {
		VAR = (((x * y) + (z * (t - a))) / fma(z, (b - y), y));
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original23.4
Target18.1
Herbie19.0
\[\frac{z \cdot t + y \cdot x}{y + z \cdot \left(b - y\right)} - \frac{a}{\left(b - y\right) + \frac{y}{z}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -1.066732755010575e+75 or 9.081015033724511e+95 < z

    1. Initial program 45.8

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

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

      \[\leadsto \frac{x \cdot y + z \cdot \left(t - a\right)}{\color{blue}{\mathsf{fma}\left(z, b - y, y\right)}}\]
    4. Using strategy rm
    5. Applied clear-num45.8

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(z, b - y, y\right)}{x \cdot y + z \cdot \left(t - a\right)}}}\]
    6. Taylor expanded around inf 33.4

      \[\leadsto \color{blue}{\frac{t}{b} - \frac{a}{b}}\]

    if -1.066732755010575e+75 < z < 9.081015033724511e+95

    1. Initial program 11.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.0667327550105751 \cdot 10^{75} \lor \neg \left(z \le 9.08101503372451 \cdot 10^{95}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2020078 +o rules:numerics
(FPCore (x y z t a b)
  :name "Development.Shake.Progress:decay from shake-0.15.5"
  :precision binary64

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

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