Average Error: 2.2 → 1.1
Time: 3.8s
Precision: 64
\[\frac{x}{y} \cdot \left(z - t\right) + t\]
\[\begin{array}{l} \mathbf{if}\;y \le -1020.47037932589012:\\ \;\;\;\;x \cdot \frac{z - t}{y} + t\\ \mathbf{elif}\;y \le 2.2155056236690332 \cdot 10^{-6}:\\ \;\;\;\;\frac{x \cdot \left(z - t\right)}{y} + t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{1}{y} \cdot z\right) + \left(t - t \cdot \frac{x}{y}\right)\\ \end{array}\]
\frac{x}{y} \cdot \left(z - t\right) + t
\begin{array}{l}
\mathbf{if}\;y \le -1020.47037932589012:\\
\;\;\;\;x \cdot \frac{z - t}{y} + t\\

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

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

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) (((double) (((double) (x / y)) * ((double) (z - t)))) + t));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if ((y <= -1020.4703793258901)) {
		VAR = ((double) (((double) (x * ((double) (((double) (z - t)) / y)))) + t));
	} else {
		double VAR_1;
		if ((y <= 2.215505623669033e-06)) {
			VAR_1 = ((double) (((double) (((double) (x * ((double) (z - t)))) / y)) + t));
		} else {
			VAR_1 = ((double) (((double) (x * ((double) (((double) (1.0 / y)) * z)))) + ((double) (t - ((double) (t * ((double) (x / y))))))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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.2
Target2.5
Herbie1.1
\[\begin{array}{l} \mathbf{if}\;z \lt 2.7594565545626922 \cdot 10^{-282}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \mathbf{elif}\;z \lt 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 y < -1020.4703793258901

    1. Initial program 1.1

      \[\frac{x}{y} \cdot \left(z - t\right) + t\]
    2. Using strategy rm
    3. Applied div-inv1.2

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

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

      \[\leadsto x \cdot \color{blue}{\frac{z - t}{y}} + t\]

    if -1020.4703793258901 < y < 2.215505623669033e-06

    1. Initial program 3.9

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

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

    if 2.215505623669033e-06 < y

    1. Initial program 1.2

      \[\frac{x}{y} \cdot \left(z - t\right) + t\]
    2. Using strategy rm
    3. Applied sub-neg1.2

      \[\leadsto \frac{x}{y} \cdot \color{blue}{\left(z + \left(-t\right)\right)} + t\]
    4. Applied distribute-lft-in1.2

      \[\leadsto \color{blue}{\left(\frac{x}{y} \cdot z + \frac{x}{y} \cdot \left(-t\right)\right)} + t\]
    5. Applied associate-+l+1.2

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

      \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(t - t \cdot \frac{x}{y}\right)}\]
    7. Using strategy rm
    8. Applied div-inv1.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1020.47037932589012:\\ \;\;\;\;x \cdot \frac{z - t}{y} + t\\ \mathbf{elif}\;y \le 2.2155056236690332 \cdot 10^{-6}:\\ \;\;\;\;\frac{x \cdot \left(z - t\right)}{y} + t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{1}{y} \cdot z\right) + \left(t - t \cdot \frac{x}{y}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020121 
(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))