Average Error: 31.8 → 14.1
Time: 2.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}\;y \le -3.4362841072323272 \cdot 10^{150}:\\ \;\;\;\;\frac{1}{-1}\\ \mathbf{elif}\;y \le -3.8396732637812812 \cdot 10^{-74}:\\ \;\;\;\;\frac{1}{\frac{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\\ \mathbf{elif}\;y \le 1.41284087263746274 \cdot 10^{-110}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \le 4.54642378775940041 \cdot 10^{-26}:\\ \;\;\;\;\frac{1}{\sqrt[3]{\frac{1}{\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{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}} \cdot \frac{1}{\sqrt[3]{\frac{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}}\\ \mathbf{elif}\;y \le 2.97781259123946345 \cdot 10^{57}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-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}\;y \le -3.4362841072323272 \cdot 10^{150}:\\
\;\;\;\;\frac{1}{-1}\\

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

\mathbf{elif}\;y \le 1.41284087263746274 \cdot 10^{-110}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \le 4.54642378775940041 \cdot 10^{-26}:\\
\;\;\;\;\frac{1}{\sqrt[3]{\frac{1}{\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{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}} \cdot \frac{1}{\sqrt[3]{\frac{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}}\\

\mathbf{elif}\;y \le 2.97781259123946345 \cdot 10^{57}:\\
\;\;\;\;1\\

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

\end{array}
double f(double x, double y) {
        double r783786 = x;
        double r783787 = r783786 * r783786;
        double r783788 = y;
        double r783789 = 4.0;
        double r783790 = r783788 * r783789;
        double r783791 = r783790 * r783788;
        double r783792 = r783787 - r783791;
        double r783793 = r783787 + r783791;
        double r783794 = r783792 / r783793;
        return r783794;
}

double f(double x, double y) {
        double r783795 = y;
        double r783796 = -3.436284107232327e+150;
        bool r783797 = r783795 <= r783796;
        double r783798 = 1.0;
        double r783799 = -1.0;
        double r783800 = r783798 / r783799;
        double r783801 = -3.839673263781281e-74;
        bool r783802 = r783795 <= r783801;
        double r783803 = x;
        double r783804 = r783803 * r783803;
        double r783805 = 4.0;
        double r783806 = r783795 * r783805;
        double r783807 = r783806 * r783795;
        double r783808 = r783804 - r783807;
        double r783809 = r783804 + r783807;
        double r783810 = r783808 / r783809;
        double r783811 = r783798 / r783810;
        double r783812 = r783798 / r783811;
        double r783813 = 1.4128408726374627e-110;
        bool r783814 = r783795 <= r783813;
        double r783815 = 4.5464237877594004e-26;
        bool r783816 = r783795 <= r783815;
        double r783817 = cbrt(r783811);
        double r783818 = r783817 * r783817;
        double r783819 = r783798 / r783818;
        double r783820 = r783798 / r783817;
        double r783821 = r783819 * r783820;
        double r783822 = 2.9778125912394635e+57;
        bool r783823 = r783795 <= r783822;
        double r783824 = r783823 ? r783798 : r783800;
        double r783825 = r783816 ? r783821 : r783824;
        double r783826 = r783814 ? r783798 : r783825;
        double r783827 = r783802 ? r783812 : r783826;
        double r783828 = r783797 ? r783800 : r783827;
        return r783828;
}

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.8
Target31.5
Herbie14.1
\[\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.974323384962678118:\\ \;\;\;\;\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 y < -3.436284107232327e+150 or 2.9778125912394635e+57 < y

    1. Initial program 51.9

      \[\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-num51.9

      \[\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. Taylor expanded around 0 12.1

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

    if -3.436284107232327e+150 < y < -3.839673263781281e-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 clear-num15.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. Using strategy rm
    5. Applied clear-num15.0

      \[\leadsto \frac{1}{\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}}}}\]

    if -3.839673263781281e-74 < y < 1.4128408726374627e-110 or 4.5464237877594004e-26 < y < 2.9778125912394635e+57

    1. Initial program 24.8

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    2. Taylor expanded around inf 14.9

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

    if 1.4128408726374627e-110 < y < 4.5464237877594004e-26

    1. Initial program 16.9

      \[\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.9

      \[\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. Using strategy rm
    5. Applied clear-num16.9

      \[\leadsto \frac{1}{\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}}}}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt16.9

      \[\leadsto \frac{1}{\color{blue}{\left(\sqrt[3]{\frac{1}{\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{1}{\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{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}}}\]
    8. Applied add-sqr-sqrt16.9

      \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\left(\sqrt[3]{\frac{1}{\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{1}{\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{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}}\]
    9. Applied times-frac16.9

      \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt[3]{\frac{1}{\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{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}} \cdot \frac{\sqrt{1}}{\sqrt[3]{\frac{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}}}\]
    10. Simplified16.9

      \[\leadsto \color{blue}{\frac{1}{\sqrt[3]{\frac{1}{\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{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}}} \cdot \frac{\sqrt{1}}{\sqrt[3]{\frac{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}}\]
    11. Simplified16.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -3.4362841072323272 \cdot 10^{150}:\\ \;\;\;\;\frac{1}{-1}\\ \mathbf{elif}\;y \le -3.8396732637812812 \cdot 10^{-74}:\\ \;\;\;\;\frac{1}{\frac{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\\ \mathbf{elif}\;y \le 1.41284087263746274 \cdot 10^{-110}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \le 4.54642378775940041 \cdot 10^{-26}:\\ \;\;\;\;\frac{1}{\sqrt[3]{\frac{1}{\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{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}} \cdot \frac{1}{\sqrt[3]{\frac{1}{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}}\\ \mathbf{elif}\;y \le 2.97781259123946345 \cdot 10^{57}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-1}\\ \end{array}\]

Reproduce

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

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

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