Average Error: 1.9 → 1.2
Time: 4.0s
Precision: binary64
\[\frac{x}{y} \cdot \left(z - t\right) + t\]
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1.8531219142654067 \cdot 10^{+153}:\\ \;\;\;\;t + \frac{x \cdot \left(z - t\right)}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 4.1493558833484096 \cdot 10^{+130}:\\ \;\;\;\;t + \frac{x}{y} \cdot \left(z - t\right)\\ \mathbf{else}:\\ \;\;\;\;t + x \cdot \frac{z - t}{y}\\ \end{array}\]
\frac{x}{y} \cdot \left(z - t\right) + t
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -1.8531219142654067 \cdot 10^{+153}:\\
\;\;\;\;t + \frac{x \cdot \left(z - t\right)}{y}\\

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

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

\end{array}
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
(FPCore (x y z t)
 :precision binary64
 (if (<= (/ x y) -1.8531219142654067e+153)
   (+ t (/ (* x (- z t)) y))
   (if (<= (/ x y) 4.1493558833484096e+130)
     (+ t (* (/ x y) (- z t)))
     (+ t (* x (/ (- z 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) <= -1.8531219142654067e+153) {
		tmp = t + ((x * (z - t)) / y);
	} else if ((x / y) <= 4.1493558833484096e+130) {
		tmp = t + ((x / y) * (z - t));
	} else {
		tmp = t + (x * ((z - 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

Original1.9
Target2.3
Herbie1.2
\[\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) < -1.85312191426540667e153

    1. Initial program 13.2

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

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

    if -1.85312191426540667e153 < (/.f64 x y) < 4.14935588334840957e130

    1. Initial program 0.8

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

    if 4.14935588334840957e130 < (/.f64 x y)

    1. Initial program 8.8

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1.8531219142654067 \cdot 10^{+153}:\\ \;\;\;\;t + \frac{x \cdot \left(z - t\right)}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 4.1493558833484096 \cdot 10^{+130}:\\ \;\;\;\;t + \frac{x}{y} \cdot \left(z - t\right)\\ \mathbf{else}:\\ \;\;\;\;t + x \cdot \frac{z - t}{y}\\ \end{array}\]

Reproduce

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