Average Error: 2.1 → 0.9
Time: 4.5s
Precision: binary64
\[\frac{x}{y} \cdot \left(z - t\right) + t \]
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -\infty:\\ \;\;\;\;t + \frac{1}{\frac{y}{x \cdot \left(z - t\right)}}\\ \mathbf{elif}\;\frac{x}{y} \leq 2.6912293875757195 \cdot 10^{+131}:\\ \;\;\;\;t + \frac{x}{y} \cdot \left(z - t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{z}{y} - \frac{t}{y}\right)\\ \end{array} \]
\frac{x}{y} \cdot \left(z - t\right) + t
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -\infty:\\
\;\;\;\;t + \frac{1}{\frac{y}{x \cdot \left(z - t\right)}}\\

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

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


\end{array}
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
(FPCore (x y z t)
 :precision binary64
 (if (<= (/ x y) (- INFINITY))
   (+ t (/ 1.0 (/ y (* x (- z t)))))
   (if (<= (/ x y) 2.6912293875757195e+131)
     (+ t (* (/ x y) (- z t)))
     (* x (- (/ z y) (/ t y))))))
double code(double x, double y, double z, double t) {
	return ((x / y) * (z - t)) + t;
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x / y) <= -((double) INFINITY)) {
		tmp = t + (1.0 / (y / (x * (z - t))));
	} else if ((x / y) <= 2.6912293875757195e+131) {
		tmp = t + ((x / y) * (z - t));
	} else {
		tmp = x * ((z / y) - (t / y));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.1
Target2.1
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;z < 2.759456554562692 \cdot 10^{-282}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \mathbf{elif}\;z < 2.326994450874436 \cdot 10^{-110}:\\ \;\;\;\;x \cdot \frac{z - t}{y} + t\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 x y) < -inf.0

    1. Initial program 64.0

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

      \[\leadsto \color{blue}{\frac{\left(z - t\right) \cdot x}{y}} + t \]
    3. Applied clear-num_binary640.3

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

    if -inf.0 < (/.f64 x y) < 2.6912293875757195e131

    1. Initial program 0.7

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

    if 2.6912293875757195e131 < (/.f64 x y)

    1. Initial program 11.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -\infty:\\ \;\;\;\;t + \frac{1}{\frac{y}{x \cdot \left(z - t\right)}}\\ \mathbf{elif}\;\frac{x}{y} \leq 2.6912293875757195 \cdot 10^{+131}:\\ \;\;\;\;t + \frac{x}{y} \cdot \left(z - t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{z}{y} - \frac{t}{y}\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022076 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (if (< z 2.759456554562692e-282) (+ (* (/ x y) (- z t)) t) (if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t)))

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