Average Error: 37.7 → 25.5
Time: 8.4s
Precision: 64
\[\sqrt{\left(a \cdot a + b \cdot b\right) + c \cdot c}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.324658437546774214300692136580246152968 \cdot 10^{50}:\\ \;\;\;\;-a\\ \mathbf{elif}\;a \le 5.318175054981041455737691344586413861204 \cdot 10^{96}:\\ \;\;\;\;\sqrt{\left(a \cdot a + b \cdot b\right) + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array}\]
\sqrt{\left(a \cdot a + b \cdot b\right) + c \cdot c}
\begin{array}{l}
\mathbf{if}\;a \le -1.324658437546774214300692136580246152968 \cdot 10^{50}:\\
\;\;\;\;-a\\

\mathbf{elif}\;a \le 5.318175054981041455737691344586413861204 \cdot 10^{96}:\\
\;\;\;\;\sqrt{\left(a \cdot a + b \cdot b\right) + c \cdot c}\\

\mathbf{else}:\\
\;\;\;\;a\\

\end{array}
double f(double a, double b, double c) {
        double r1296709 = a;
        double r1296710 = r1296709 * r1296709;
        double r1296711 = b;
        double r1296712 = r1296711 * r1296711;
        double r1296713 = r1296710 + r1296712;
        double r1296714 = c;
        double r1296715 = r1296714 * r1296714;
        double r1296716 = r1296713 + r1296715;
        double r1296717 = sqrt(r1296716);
        return r1296717;
}

double f(double a, double b, double c) {
        double r1296718 = a;
        double r1296719 = -1.3246584375467742e+50;
        bool r1296720 = r1296718 <= r1296719;
        double r1296721 = -r1296718;
        double r1296722 = 5.318175054981041e+96;
        bool r1296723 = r1296718 <= r1296722;
        double r1296724 = r1296718 * r1296718;
        double r1296725 = b;
        double r1296726 = r1296725 * r1296725;
        double r1296727 = r1296724 + r1296726;
        double r1296728 = c;
        double r1296729 = r1296728 * r1296728;
        double r1296730 = r1296727 + r1296729;
        double r1296731 = sqrt(r1296730);
        double r1296732 = r1296723 ? r1296731 : r1296718;
        double r1296733 = r1296720 ? r1296721 : r1296732;
        return r1296733;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if a < -1.3246584375467742e+50

    1. Initial program 49.4

      \[\sqrt{\left(a \cdot a + b \cdot b\right) + c \cdot c}\]
    2. Taylor expanded around -inf 21.2

      \[\leadsto \color{blue}{-1 \cdot a}\]
    3. Simplified21.2

      \[\leadsto \color{blue}{-a}\]

    if -1.3246584375467742e+50 < a < 5.318175054981041e+96

    1. Initial program 29.1

      \[\sqrt{\left(a \cdot a + b \cdot b\right) + c \cdot c}\]

    if 5.318175054981041e+96 < a

    1. Initial program 53.7

      \[\sqrt{\left(a \cdot a + b \cdot b\right) + c \cdot c}\]
    2. Taylor expanded around inf 18.4

      \[\leadsto \color{blue}{a}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification25.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.324658437546774214300692136580246152968 \cdot 10^{50}:\\ \;\;\;\;-a\\ \mathbf{elif}\;a \le 5.318175054981041455737691344586413861204 \cdot 10^{96}:\\ \;\;\;\;\sqrt{\left(a \cdot a + b \cdot b\right) + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (a b c)
  :name "sqrt(a*a+b*b+c*c)"
  :precision binary64
  (sqrt (+ (+ (* a a) (* b b)) (* c c))))