Average Error: 6.6 → 0.4
Time: 29.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -1.499660044018064044527197665530558205483 \cdot 10^{301}:\\ \;\;\;\;\frac{\sqrt{2}}{\frac{z}{x}} \cdot \frac{\sqrt{2}}{y - t}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le -4.297858752653802496522471117454735409474 \cdot 10^{-202} \lor \neg \left(y \cdot z - t \cdot z \le 2.549751116559639162585228515298650368374 \cdot 10^{-275}\right) \land y \cdot z - t \cdot z \le 3.004747414097608463834971406098546614814 \cdot 10^{239}:\\ \;\;\;\;\frac{2 \cdot x}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{z \cdot \frac{y - t}{x}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z \le -1.499660044018064044527197665530558205483 \cdot 10^{301}:\\
\;\;\;\;\frac{\sqrt{2}}{\frac{z}{x}} \cdot \frac{\sqrt{2}}{y - t}\\

\mathbf{elif}\;y \cdot z - t \cdot z \le -4.297858752653802496522471117454735409474 \cdot 10^{-202} \lor \neg \left(y \cdot z - t \cdot z \le 2.549751116559639162585228515298650368374 \cdot 10^{-275}\right) \land y \cdot z - t \cdot z \le 3.004747414097608463834971406098546614814 \cdot 10^{239}:\\
\;\;\;\;\frac{2 \cdot x}{y \cdot z - t \cdot z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r526743 = x;
        double r526744 = 2.0;
        double r526745 = r526743 * r526744;
        double r526746 = y;
        double r526747 = z;
        double r526748 = r526746 * r526747;
        double r526749 = t;
        double r526750 = r526749 * r526747;
        double r526751 = r526748 - r526750;
        double r526752 = r526745 / r526751;
        return r526752;
}

double f(double x, double y, double z, double t) {
        double r526753 = y;
        double r526754 = z;
        double r526755 = r526753 * r526754;
        double r526756 = t;
        double r526757 = r526756 * r526754;
        double r526758 = r526755 - r526757;
        double r526759 = -1.499660044018064e+301;
        bool r526760 = r526758 <= r526759;
        double r526761 = 2.0;
        double r526762 = sqrt(r526761);
        double r526763 = x;
        double r526764 = r526754 / r526763;
        double r526765 = r526762 / r526764;
        double r526766 = r526753 - r526756;
        double r526767 = r526762 / r526766;
        double r526768 = r526765 * r526767;
        double r526769 = -4.2978587526538025e-202;
        bool r526770 = r526758 <= r526769;
        double r526771 = 2.5497511165596392e-275;
        bool r526772 = r526758 <= r526771;
        double r526773 = !r526772;
        double r526774 = 3.0047474140976085e+239;
        bool r526775 = r526758 <= r526774;
        bool r526776 = r526773 && r526775;
        bool r526777 = r526770 || r526776;
        double r526778 = r526761 * r526763;
        double r526779 = r526778 / r526758;
        double r526780 = r526766 / r526763;
        double r526781 = r526754 * r526780;
        double r526782 = r526761 / r526781;
        double r526783 = r526777 ? r526779 : r526782;
        double r526784 = r526760 ? r526768 : r526783;
        return r526784;
}

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

Original6.6
Target1.9
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061113708240820439530037456 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt 1.045027827330126029709547581125571222799 \cdot 10^{-269}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (- (* y z) (* t z)) < -1.499660044018064e+301

    1. Initial program 20.5

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

      \[\leadsto \color{blue}{\frac{2}{\frac{z}{x} \cdot \left(y - t\right)}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt1.5

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

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

    if -1.499660044018064e+301 < (- (* y z) (* t z)) < -4.2978587526538025e-202 or 2.5497511165596392e-275 < (- (* y z) (* t z)) < 3.0047474140976085e+239

    1. Initial program 0.2

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

    if -4.2978587526538025e-202 < (- (* y z) (* t z)) < 2.5497511165596392e-275 or 3.0047474140976085e+239 < (- (* y z) (* t z))

    1. Initial program 20.4

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Simplified0.9

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -1.499660044018064044527197665530558205483 \cdot 10^{301}:\\ \;\;\;\;\frac{\sqrt{2}}{\frac{z}{x}} \cdot \frac{\sqrt{2}}{y - t}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le -4.297858752653802496522471117454735409474 \cdot 10^{-202} \lor \neg \left(y \cdot z - t \cdot z \le 2.549751116559639162585228515298650368374 \cdot 10^{-275}\right) \land y \cdot z - t \cdot z \le 3.004747414097608463834971406098546614814 \cdot 10^{239}:\\ \;\;\;\;\frac{2 \cdot x}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{z \cdot \frac{y - t}{x}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019194 +o rules:numerics
(FPCore (x y z t)
  :name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"

  :herbie-target
  (if (< (/ (* x 2.0) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2.0) (if (< (/ (* x 2.0) (- (* y z) (* t z))) 1.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))

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