Average Error: 1.9 → 1.9
Time: 14.1s
Precision: binary64
\[\frac{x}{y} \cdot \left(z - t\right) + t\]
\[\begin{array}{l} \mathbf{if}\;y \leq -7.425383854185525 \cdot 10^{+49}:\\ \;\;\;\;t + \frac{x}{y} \cdot \left(z - t\right)\\ \mathbf{elif}\;y \leq 1.1094884952310407 \cdot 10^{+150}:\\ \;\;\;\;t + \frac{x \cdot \left(z - t\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;t + \frac{z - t}{\frac{y}{x}}\\ \end{array}\]
\frac{x}{y} \cdot \left(z - t\right) + t
\begin{array}{l}
\mathbf{if}\;y \leq -7.425383854185525 \cdot 10^{+49}:\\
\;\;\;\;t + \frac{x}{y} \cdot \left(z - t\right)\\

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

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

\end{array}
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
(FPCore (x y z t)
 :precision binary64
 (if (<= y -7.425383854185525e+49)
   (+ t (* (/ x y) (- z t)))
   (if (<= y 1.1094884952310407e+150)
     (+ t (/ (* x (- z t)) y))
     (+ t (/ (- z t) (/ y x))))))
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 (y <= -7.425383854185525e+49) {
		tmp = t + ((x / y) * (z - t));
	} else if (y <= 1.1094884952310407e+150) {
		tmp = t + ((x * (z - t)) / y);
	} else {
		tmp = t + ((z - t) / (y / x));
	}
	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.2
Herbie1.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 y < -7.425383854185525e49

    1. Initial program 1.2

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

    if -7.425383854185525e49 < y < 1.10948849523104069e150

    1. Initial program 2.5

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

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

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

    if 1.10948849523104069e150 < y

    1. Initial program 0.9

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

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

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

      \[\leadsto \left(\sqrt[3]{\frac{x}{y}} \cdot \sqrt[3]{\frac{x}{y}}\right) \cdot \color{blue}{\left(\left(z - t\right) \cdot \sqrt[3]{\frac{x}{y}}\right)} + t\]
    6. Taylor expanded around 0 11.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.425383854185525 \cdot 10^{+49}:\\ \;\;\;\;t + \frac{x}{y} \cdot \left(z - t\right)\\ \mathbf{elif}\;y \leq 1.1094884952310407 \cdot 10^{+150}:\\ \;\;\;\;t + \frac{x \cdot \left(z - t\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;t + \frac{z - t}{\frac{y}{x}}\\ \end{array}\]

Reproduce

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