Average Error: 32.1 → 13.5
Time: 2.5s
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 -4.00847790071649149 \cdot 10^{147}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -4.16780906636482433 \cdot 10^{-5}:\\ \;\;\;\;\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}}\\ \mathbf{elif}\;x \le 4.3335505177201293 \cdot 10^{-137}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 4.23767844119500403 \cdot 10^{65}:\\ \;\;\;\;\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}}\\ \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 -4.00847790071649149 \cdot 10^{147}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \le -4.16780906636482433 \cdot 10^{-5}:\\
\;\;\;\;\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}}\\

\mathbf{elif}\;x \le 4.3335505177201293 \cdot 10^{-137}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \le 4.23767844119500403 \cdot 10^{65}:\\
\;\;\;\;\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}}\\

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

\end{array}
double f(double x, double y) {
        double r953820 = x;
        double r953821 = r953820 * r953820;
        double r953822 = y;
        double r953823 = 4.0;
        double r953824 = r953822 * r953823;
        double r953825 = r953824 * r953822;
        double r953826 = r953821 - r953825;
        double r953827 = r953821 + r953825;
        double r953828 = r953826 / r953827;
        return r953828;
}

double f(double x, double y) {
        double r953829 = x;
        double r953830 = -4.0084779007164915e+147;
        bool r953831 = r953829 <= r953830;
        double r953832 = 1.0;
        double r953833 = -4.167809066364824e-05;
        bool r953834 = r953829 <= r953833;
        double r953835 = r953829 * r953829;
        double r953836 = y;
        double r953837 = 4.0;
        double r953838 = r953836 * r953837;
        double r953839 = r953838 * r953836;
        double r953840 = r953835 - r953839;
        double r953841 = r953835 + r953839;
        double r953842 = r953840 / r953841;
        double r953843 = cbrt(r953842);
        double r953844 = r953843 * r953843;
        double r953845 = r953844 * r953843;
        double r953846 = 4.333550517720129e-137;
        bool r953847 = r953829 <= r953846;
        double r953848 = -1.0;
        double r953849 = 4.237678441195004e+65;
        bool r953850 = r953829 <= r953849;
        double r953851 = r953850 ? r953845 : r953832;
        double r953852 = r953847 ? r953848 : r953851;
        double r953853 = r953834 ? r953845 : r953852;
        double r953854 = r953831 ? r953832 : r953853;
        return r953854;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original32.1
Target31.7
Herbie13.5
\[\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 3 regimes
  2. if x < -4.0084779007164915e+147 or 4.237678441195004e+65 < x

    1. Initial program 53.3

      \[\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 11.2

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

    if -4.0084779007164915e+147 < x < -4.167809066364824e-05 or 4.333550517720129e-137 < x < 4.237678441195004e+65

    1. Initial program 16.7

      \[\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-cbrt16.8

      \[\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}}}\]

    if -4.167809066364824e-05 < x < 4.333550517720129e-137

    1. Initial program 25.5

      \[\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 0 13.0

      \[\leadsto \color{blue}{-1}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification13.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.00847790071649149 \cdot 10^{147}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -4.16780906636482433 \cdot 10^{-5}:\\ \;\;\;\;\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}}\\ \mathbf{elif}\;x \le 4.3335505177201293 \cdot 10^{-137}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 4.23767844119500403 \cdot 10^{65}:\\ \;\;\;\;\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}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

herbie shell --seed 2020034 +o rules:numerics
(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))))