Average Error: 6.3 → 2.6
Time: 36.4s
Precision: 64
\[\left(c - a \cdot b\right) \cdot \left(c - a \cdot b\right) - \left(1 - a \cdot a\right) \cdot \left(\left(d - b \cdot b\right) - R \cdot R\right)\]
\[\begin{array}{l} \mathbf{if}\;a \le -2.3641533612719124 \cdot 10^{+76}:\\ \;\;\;\;\left(\left(a \cdot \left(d \cdot a\right) - \left(2 \cdot c\right) \cdot \left(a \cdot b\right)\right) - \left(R \cdot a\right) \cdot \left(R \cdot a\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)\\ \mathbf{elif}\;a \le 2.8497698901809797 \cdot 10^{+55}:\\ \;\;\;\;\left(\left(a \cdot a\right) \cdot \left(\left(d - R \cdot R\right) - b \cdot b\right) + \left(\left(c \cdot c + \left(a \cdot b\right) \cdot \left(a \cdot b\right)\right) - \left(2 \cdot c\right) \cdot \left(a \cdot b\right)\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a \cdot \left(d \cdot a\right) - \left(2 \cdot c\right) \cdot \left(a \cdot b\right)\right) - \left(R \cdot a\right) \cdot \left(R \cdot a\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)\\ \end{array}\]
\left(c - a \cdot b\right) \cdot \left(c - a \cdot b\right) - \left(1 - a \cdot a\right) \cdot \left(\left(d - b \cdot b\right) - R \cdot R\right)
\begin{array}{l}
\mathbf{if}\;a \le -2.3641533612719124 \cdot 10^{+76}:\\
\;\;\;\;\left(\left(a \cdot \left(d \cdot a\right) - \left(2 \cdot c\right) \cdot \left(a \cdot b\right)\right) - \left(R \cdot a\right) \cdot \left(R \cdot a\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)\\

\mathbf{elif}\;a \le 2.8497698901809797 \cdot 10^{+55}:\\
\;\;\;\;\left(\left(a \cdot a\right) \cdot \left(\left(d - R \cdot R\right) - b \cdot b\right) + \left(\left(c \cdot c + \left(a \cdot b\right) \cdot \left(a \cdot b\right)\right) - \left(2 \cdot c\right) \cdot \left(a \cdot b\right)\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot \left(d \cdot a\right) - \left(2 \cdot c\right) \cdot \left(a \cdot b\right)\right) - \left(R \cdot a\right) \cdot \left(R \cdot a\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)\\

\end{array}
double f(double c, double a, double b, double d, double R) {
        double r21161671 = c;
        double r21161672 = a;
        double r21161673 = b;
        double r21161674 = r21161672 * r21161673;
        double r21161675 = r21161671 - r21161674;
        double r21161676 = r21161675 * r21161675;
        double r21161677 = 1.0;
        double r21161678 = r21161672 * r21161672;
        double r21161679 = r21161677 - r21161678;
        double r21161680 = d;
        double r21161681 = r21161673 * r21161673;
        double r21161682 = r21161680 - r21161681;
        double r21161683 = R;
        double r21161684 = r21161683 * r21161683;
        double r21161685 = r21161682 - r21161684;
        double r21161686 = r21161679 * r21161685;
        double r21161687 = r21161676 - r21161686;
        return r21161687;
}

double f(double c, double a, double b, double d, double R) {
        double r21161688 = a;
        double r21161689 = -2.3641533612719124e+76;
        bool r21161690 = r21161688 <= r21161689;
        double r21161691 = d;
        double r21161692 = r21161691 * r21161688;
        double r21161693 = r21161688 * r21161692;
        double r21161694 = 2.0;
        double r21161695 = c;
        double r21161696 = r21161694 * r21161695;
        double r21161697 = b;
        double r21161698 = r21161688 * r21161697;
        double r21161699 = r21161696 * r21161698;
        double r21161700 = r21161693 - r21161699;
        double r21161701 = R;
        double r21161702 = r21161701 * r21161688;
        double r21161703 = r21161702 * r21161702;
        double r21161704 = r21161700 - r21161703;
        double r21161705 = r21161701 * r21161701;
        double r21161706 = r21161691 - r21161705;
        double r21161707 = r21161697 * r21161697;
        double r21161708 = r21161706 - r21161707;
        double r21161709 = r21161704 - r21161708;
        double r21161710 = 2.8497698901809797e+55;
        bool r21161711 = r21161688 <= r21161710;
        double r21161712 = r21161688 * r21161688;
        double r21161713 = r21161712 * r21161708;
        double r21161714 = r21161695 * r21161695;
        double r21161715 = r21161698 * r21161698;
        double r21161716 = r21161714 + r21161715;
        double r21161717 = r21161716 - r21161699;
        double r21161718 = r21161713 + r21161717;
        double r21161719 = r21161718 - r21161708;
        double r21161720 = r21161711 ? r21161719 : r21161709;
        double r21161721 = r21161690 ? r21161709 : r21161720;
        return r21161721;
}

Error

Bits error versus c

Bits error versus a

Bits error versus b

Bits error versus d

Bits error versus R

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if a < -2.3641533612719124e+76 or 2.8497698901809797e+55 < a

    1. Initial program 32.1

      \[\left(c - a \cdot b\right) \cdot \left(c - a \cdot b\right) - \left(1 - a \cdot a\right) \cdot \left(\left(d - b \cdot b\right) - R \cdot R\right)\]
    2. Simplified31.6

      \[\leadsto \color{blue}{\left(\left(c - b \cdot a\right) \cdot \left(c - b \cdot a\right) + \left(a \cdot a\right) \cdot \left(\left(d - R \cdot R\right) - b \cdot b\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)}\]
    3. Taylor expanded around -inf 23.9

      \[\leadsto \color{blue}{\left({a}^{2} \cdot d - \left(2 \cdot \left(a \cdot \left(b \cdot c\right)\right) + {a}^{2} \cdot {R}^{2}\right)\right)} - \left(\left(d - R \cdot R\right) - b \cdot b\right)\]
    4. Simplified8.0

      \[\leadsto \color{blue}{\left(\left(\left(a \cdot d\right) \cdot a - \left(2 \cdot c\right) \cdot \left(a \cdot b\right)\right) - \left(a \cdot R\right) \cdot \left(a \cdot R\right)\right)} - \left(\left(d - R \cdot R\right) - b \cdot b\right)\]

    if -2.3641533612719124e+76 < a < 2.8497698901809797e+55

    1. Initial program 2.2

      \[\left(c - a \cdot b\right) \cdot \left(c - a \cdot b\right) - \left(1 - a \cdot a\right) \cdot \left(\left(d - b \cdot b\right) - R \cdot R\right)\]
    2. Simplified1.7

      \[\leadsto \color{blue}{\left(\left(c - b \cdot a\right) \cdot \left(c - b \cdot a\right) + \left(a \cdot a\right) \cdot \left(\left(d - R \cdot R\right) - b \cdot b\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)}\]
    3. Taylor expanded around -inf 1.2

      \[\leadsto \left(\color{blue}{\left(\left({a}^{2} \cdot {b}^{2} + {c}^{2}\right) - 2 \cdot \left(a \cdot \left(b \cdot c\right)\right)\right)} + \left(a \cdot a\right) \cdot \left(\left(d - R \cdot R\right) - b \cdot b\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)\]
    4. Simplified1.7

      \[\leadsto \left(\color{blue}{\left(\left(\left(a \cdot b\right) \cdot \left(a \cdot b\right) + c \cdot c\right) - \left(2 \cdot c\right) \cdot \left(a \cdot b\right)\right)} + \left(a \cdot a\right) \cdot \left(\left(d - R \cdot R\right) - b \cdot b\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -2.3641533612719124 \cdot 10^{+76}:\\ \;\;\;\;\left(\left(a \cdot \left(d \cdot a\right) - \left(2 \cdot c\right) \cdot \left(a \cdot b\right)\right) - \left(R \cdot a\right) \cdot \left(R \cdot a\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)\\ \mathbf{elif}\;a \le 2.8497698901809797 \cdot 10^{+55}:\\ \;\;\;\;\left(\left(a \cdot a\right) \cdot \left(\left(d - R \cdot R\right) - b \cdot b\right) + \left(\left(c \cdot c + \left(a \cdot b\right) \cdot \left(a \cdot b\right)\right) - \left(2 \cdot c\right) \cdot \left(a \cdot b\right)\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a \cdot \left(d \cdot a\right) - \left(2 \cdot c\right) \cdot \left(a \cdot b\right)\right) - \left(R \cdot a\right) \cdot \left(R \cdot a\right)\right) - \left(\left(d - R \cdot R\right) - b \cdot b\right)\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (c a b d R)
  :name "(c-a*b)*(c-a*b) - (1-a*a)*(d-b*b-R*R)"
  (- (* (- c (* a b)) (- c (* a b))) (* (- 1 (* a a)) (- (- d (* b b)) (* R R)))))