Average Error: 6.1 → 0.5
Time: 6.2s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \le -1.92027268901345497 \cdot 10^{235}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \mathbf{elif}\;y \cdot \left(z - t\right) \le 3.07867140745968214 \cdot 10^{206}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z - t}{a}\\ \end{array}\]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;y \cdot \left(z - t\right) \le -1.92027268901345497 \cdot 10^{235}:\\
\;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r367838 = x;
        double r367839 = y;
        double r367840 = z;
        double r367841 = t;
        double r367842 = r367840 - r367841;
        double r367843 = r367839 * r367842;
        double r367844 = a;
        double r367845 = r367843 / r367844;
        double r367846 = r367838 - r367845;
        return r367846;
}

double f(double x, double y, double z, double t, double a) {
        double r367847 = y;
        double r367848 = z;
        double r367849 = t;
        double r367850 = r367848 - r367849;
        double r367851 = r367847 * r367850;
        double r367852 = -1.920272689013455e+235;
        bool r367853 = r367851 <= r367852;
        double r367854 = x;
        double r367855 = a;
        double r367856 = r367855 / r367850;
        double r367857 = r367847 / r367856;
        double r367858 = r367854 - r367857;
        double r367859 = 3.078671407459682e+206;
        bool r367860 = r367851 <= r367859;
        double r367861 = r367851 / r367855;
        double r367862 = r367854 - r367861;
        double r367863 = r367850 / r367855;
        double r367864 = r367847 * r367863;
        double r367865 = r367854 - r367864;
        double r367866 = r367860 ? r367862 : r367865;
        double r367867 = r367853 ? r367858 : r367866;
        return r367867;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.1
Target0.7
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;y \lt -1.07612662163899753 \cdot 10^{-10}:\\ \;\;\;\;x - \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y \lt 2.8944268627920891 \cdot 10^{-49}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array}\]

Derivation

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

    1. Initial program 34.7

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

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

    if -1.920272689013455e+235 < (* y (- z t)) < 3.078671407459682e+206

    1. Initial program 0.5

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

    if 3.078671407459682e+206 < (* y (- z t))

    1. Initial program 27.8

      \[x - \frac{y \cdot \left(z - t\right)}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity27.8

      \[\leadsto x - \frac{y \cdot \left(z - t\right)}{\color{blue}{1 \cdot a}}\]
    4. Applied times-frac0.7

      \[\leadsto x - \color{blue}{\frac{y}{1} \cdot \frac{z - t}{a}}\]
    5. Simplified0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \le -1.92027268901345497 \cdot 10^{235}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \mathbf{elif}\;y \cdot \left(z - t\right) \le 3.07867140745968214 \cdot 10^{206}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z - t}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020089 
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"
  :precision binary64

  :herbie-target
  (if (< y -1.0761266216389975e-10) (- x (/ 1 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (- x (/ (* y (- z t)) a)) (- x (/ y (/ a (- z t))))))

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