Average Error: 2.3 → 1.9
Time: 4.1s
Precision: 64
\[\frac{x - y}{z - y} \cdot t\]
\[\begin{array}{l} \mathbf{if}\;\frac{x - y}{z - y} \cdot t \le -3.65173919326576738 \cdot 10^{-273}:\\ \;\;\;\;\frac{x - y}{z - y} \cdot t\\ \mathbf{elif}\;\frac{x - y}{z - y} \cdot t \le 5.8569725718410323 \cdot 10^{-10}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z - y}\\ \end{array}\]
\frac{x - y}{z - y} \cdot t
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{z - y} \cdot t \le -3.65173919326576738 \cdot 10^{-273}:\\
\;\;\;\;\frac{x - y}{z - y} \cdot t\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r542315 = x;
        double r542316 = y;
        double r542317 = r542315 - r542316;
        double r542318 = z;
        double r542319 = r542318 - r542316;
        double r542320 = r542317 / r542319;
        double r542321 = t;
        double r542322 = r542320 * r542321;
        return r542322;
}

double f(double x, double y, double z, double t) {
        double r542323 = x;
        double r542324 = y;
        double r542325 = r542323 - r542324;
        double r542326 = z;
        double r542327 = r542326 - r542324;
        double r542328 = r542325 / r542327;
        double r542329 = t;
        double r542330 = r542328 * r542329;
        double r542331 = -3.6517391932657674e-273;
        bool r542332 = r542330 <= r542331;
        double r542333 = 5.856972571841032e-10;
        bool r542334 = r542330 <= r542333;
        double r542335 = r542325 * r542329;
        double r542336 = r542335 / r542327;
        double r542337 = r542329 / r542327;
        double r542338 = r542325 * r542337;
        double r542339 = r542334 ? r542336 : r542338;
        double r542340 = r542332 ? r542330 : r542339;
        return r542340;
}

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.3
Target2.2
Herbie1.9
\[\frac{t}{\frac{z - y}{x - y}}\]

Derivation

  1. Split input into 3 regimes
  2. if (* (/ (- x y) (- z y)) t) < -3.6517391932657674e-273

    1. Initial program 1.5

      \[\frac{x - y}{z - y} \cdot t\]

    if -3.6517391932657674e-273 < (* (/ (- x y) (- z y)) t) < 5.856972571841032e-10

    1. Initial program 2.9

      \[\frac{x - y}{z - y} \cdot t\]
    2. Using strategy rm
    3. Applied associate-*l/1.9

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

    if 5.856972571841032e-10 < (* (/ (- x y) (- z y)) t)

    1. Initial program 3.1

      \[\frac{x - y}{z - y} \cdot t\]
    2. Using strategy rm
    3. Applied div-inv3.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y}{z - y} \cdot t \le -3.65173919326576738 \cdot 10^{-273}:\\ \;\;\;\;\frac{x - y}{z - y} \cdot t\\ \mathbf{elif}\;\frac{x - y}{z - y} \cdot t \le 5.8569725718410323 \cdot 10^{-10}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z - y}\\ \end{array}\]

Reproduce

herbie shell --seed 2020035 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cput from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (/ t (/ (- z y) (- x y)))

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