Average Error: 31.0 → 14.7
Time: 8.6s
Precision: 64
\[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -9.850726757232304656097215039461175225007 \cdot 10^{116}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -213283511644709824:\\ \;\;\;\;\sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}} \cdot \left(\sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}} \cdot \sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}}\right)\\ \mathbf{elif}\;x \le -3.478057257589816580751045492937248447757 \cdot 10^{-17}:\\ \;\;\;\;\frac{1}{-1}\\ \mathbf{elif}\;x \le -5.393824270148449076708054055498132792438 \cdot 10^{-74}:\\ \;\;\;\;\sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}} \cdot \left(\sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}} \cdot \sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}}\right)\\ \mathbf{elif}\;x \le -8.64767432764635258433792673669348312331 \cdot 10^{-129}:\\ \;\;\;\;\frac{1}{-1}\\ \mathbf{elif}\;x \le -1.23992860779612800616268155128852493615 \cdot 10^{-180}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le 6.823576610928471937518681293595906800826 \cdot 10^{-152}:\\ \;\;\;\;\frac{1}{-1}\\ \mathbf{elif}\;x \le 6.357559912396233893317957556288536407725 \cdot 10^{53}:\\ \;\;\;\;\frac{1}{\frac{y \cdot \left(4 \cdot y\right) + x \cdot x}{x \cdot x - y \cdot \left(4 \cdot y\right)}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]
\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;x \le -9.850726757232304656097215039461175225007 \cdot 10^{116}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \le -213283511644709824:\\
\;\;\;\;\sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}} \cdot \left(\sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}} \cdot \sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}}\right)\\

\mathbf{elif}\;x \le -3.478057257589816580751045492937248447757 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{-1}\\

\mathbf{elif}\;x \le -5.393824270148449076708054055498132792438 \cdot 10^{-74}:\\
\;\;\;\;\sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}} \cdot \left(\sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}} \cdot \sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}}\right)\\

\mathbf{elif}\;x \le -8.64767432764635258433792673669348312331 \cdot 10^{-129}:\\
\;\;\;\;\frac{1}{-1}\\

\mathbf{elif}\;x \le -1.23992860779612800616268155128852493615 \cdot 10^{-180}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \le 6.823576610928471937518681293595906800826 \cdot 10^{-152}:\\
\;\;\;\;\frac{1}{-1}\\

\mathbf{elif}\;x \le 6.357559912396233893317957556288536407725 \cdot 10^{53}:\\
\;\;\;\;\frac{1}{\frac{y \cdot \left(4 \cdot y\right) + x \cdot x}{x \cdot x - y \cdot \left(4 \cdot y\right)}}\\

\mathbf{else}:\\
\;\;\;\;1\\

\end{array}
double f(double x, double y) {
        double r570849 = x;
        double r570850 = r570849 * r570849;
        double r570851 = y;
        double r570852 = 4.0;
        double r570853 = r570851 * r570852;
        double r570854 = r570853 * r570851;
        double r570855 = r570850 - r570854;
        double r570856 = r570850 + r570854;
        double r570857 = r570855 / r570856;
        return r570857;
}

double f(double x, double y) {
        double r570858 = x;
        double r570859 = -9.850726757232305e+116;
        bool r570860 = r570858 <= r570859;
        double r570861 = 1.0;
        double r570862 = -2.1328351164470982e+17;
        bool r570863 = r570858 <= r570862;
        double r570864 = r570858 * r570858;
        double r570865 = y;
        double r570866 = 4.0;
        double r570867 = r570866 * r570865;
        double r570868 = r570865 * r570867;
        double r570869 = r570864 - r570868;
        double r570870 = r570868 + r570864;
        double r570871 = r570869 / r570870;
        double r570872 = cbrt(r570871);
        double r570873 = r570872 * r570872;
        double r570874 = r570872 * r570873;
        double r570875 = -3.4780572575898166e-17;
        bool r570876 = r570858 <= r570875;
        double r570877 = -1.0;
        double r570878 = r570861 / r570877;
        double r570879 = -5.393824270148449e-74;
        bool r570880 = r570858 <= r570879;
        double r570881 = -8.647674327646353e-129;
        bool r570882 = r570858 <= r570881;
        double r570883 = -1.239928607796128e-180;
        bool r570884 = r570858 <= r570883;
        double r570885 = 6.823576610928472e-152;
        bool r570886 = r570858 <= r570885;
        double r570887 = 6.357559912396234e+53;
        bool r570888 = r570858 <= r570887;
        double r570889 = r570870 / r570869;
        double r570890 = r570861 / r570889;
        double r570891 = r570888 ? r570890 : r570861;
        double r570892 = r570886 ? r570878 : r570891;
        double r570893 = r570884 ? r570861 : r570892;
        double r570894 = r570882 ? r570878 : r570893;
        double r570895 = r570880 ? r570874 : r570894;
        double r570896 = r570876 ? r570878 : r570895;
        double r570897 = r570863 ? r570874 : r570896;
        double r570898 = r570860 ? r570861 : r570897;
        return r570898;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original31.0
Target30.7
Herbie14.7
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \lt 0.9743233849626781184483093056769575923681:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot y\right) \cdot 4} - \frac{\left(y \cdot y\right) \cdot 4}{x \cdot x + \left(y \cdot y\right) \cdot 4}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{x}{\sqrt{x \cdot x + \left(y \cdot y\right) \cdot 4}}\right)}^{2} - \frac{\left(y \cdot y\right) \cdot 4}{x \cdot x + \left(y \cdot y\right) \cdot 4}\\ \end{array}\]

Derivation

  1. Split input into 4 regimes
  2. if x < -9.850726757232305e+116 or -8.647674327646353e-129 < x < -1.239928607796128e-180 or 6.357559912396234e+53 < x

    1. Initial program 45.8

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    2. Using strategy rm
    3. Applied clear-num45.8

      \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}}\]
    4. Simplified45.8

      \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x + y \cdot \left(y \cdot 4\right)}{x \cdot x - y \cdot \left(y \cdot 4\right)}}}\]
    5. Taylor expanded around inf 15.8

      \[\leadsto \frac{1}{\color{blue}{1}}\]

    if -9.850726757232305e+116 < x < -2.1328351164470982e+17 or -3.4780572575898166e-17 < x < -5.393824270148449e-74

    1. Initial program 15.0

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

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\]
    4. Simplified15.0

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}} \cdot \sqrt[3]{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}}\right)} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\]
    5. Simplified15.0

      \[\leadsto \left(\sqrt[3]{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}} \cdot \sqrt[3]{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}}\right) \cdot \color{blue}{\sqrt[3]{\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}}}\]

    if -2.1328351164470982e+17 < x < -3.4780572575898166e-17 or -5.393824270148449e-74 < x < -8.647674327646353e-129 or -1.239928607796128e-180 < x < 6.823576610928472e-152

    1. Initial program 26.0

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    2. Using strategy rm
    3. Applied clear-num26.0

      \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}}\]
    4. Simplified26.0

      \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x + y \cdot \left(y \cdot 4\right)}{x \cdot x - y \cdot \left(y \cdot 4\right)}}}\]
    5. Taylor expanded around 0 12.2

      \[\leadsto \frac{1}{\color{blue}{-1}}\]

    if 6.823576610928472e-152 < x < 6.357559912396234e+53

    1. Initial program 16.3

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    2. Using strategy rm
    3. Applied clear-num16.3

      \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}}\]
    4. Simplified16.3

      \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot x + y \cdot \left(y \cdot 4\right)}{x \cdot x - y \cdot \left(y \cdot 4\right)}}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification14.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -9.850726757232304656097215039461175225007 \cdot 10^{116}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -213283511644709824:\\ \;\;\;\;\sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}} \cdot \left(\sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}} \cdot \sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}}\right)\\ \mathbf{elif}\;x \le -3.478057257589816580751045492937248447757 \cdot 10^{-17}:\\ \;\;\;\;\frac{1}{-1}\\ \mathbf{elif}\;x \le -5.393824270148449076708054055498132792438 \cdot 10^{-74}:\\ \;\;\;\;\sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}} \cdot \left(\sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}} \cdot \sqrt[3]{\frac{x \cdot x - y \cdot \left(4 \cdot y\right)}{y \cdot \left(4 \cdot y\right) + x \cdot x}}\right)\\ \mathbf{elif}\;x \le -8.64767432764635258433792673669348312331 \cdot 10^{-129}:\\ \;\;\;\;\frac{1}{-1}\\ \mathbf{elif}\;x \le -1.23992860779612800616268155128852493615 \cdot 10^{-180}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le 6.823576610928471937518681293595906800826 \cdot 10^{-152}:\\ \;\;\;\;\frac{1}{-1}\\ \mathbf{elif}\;x \le 6.357559912396233893317957556288536407725 \cdot 10^{53}:\\ \;\;\;\;\frac{1}{\frac{y \cdot \left(4 \cdot y\right) + x \cdot x}{x \cdot x - y \cdot \left(4 \cdot y\right)}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

herbie shell --seed 2019194 
(FPCore (x y)
  :name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"

  :herbie-target
  (if (< (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4.0))) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4.0)))) 2.0) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))))

  (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))