Average Error: 31.6 → 16.9
Time: 4.9s
Precision: 64
\[\log \left(x \cdot x + y \cdot y\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.303209947657204342880384766533788360025 \cdot 10^{84}:\\ \;\;\;\;-2 \cdot \log \left(\frac{-1}{x}\right)\\ \mathbf{elif}\;x \le 1.00238853550205355149758148628321723902 \cdot 10^{127}:\\ \;\;\;\;\log \left(y \cdot y + x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \log x\\ \end{array}\]
\log \left(x \cdot x + y \cdot y\right)
\begin{array}{l}
\mathbf{if}\;x \le -3.303209947657204342880384766533788360025 \cdot 10^{84}:\\
\;\;\;\;-2 \cdot \log \left(\frac{-1}{x}\right)\\

\mathbf{elif}\;x \le 1.00238853550205355149758148628321723902 \cdot 10^{127}:\\
\;\;\;\;\log \left(y \cdot y + x \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \log x\\

\end{array}
double f(double x, double y) {
        double r55281218 = x;
        double r55281219 = r55281218 * r55281218;
        double r55281220 = y;
        double r55281221 = r55281220 * r55281220;
        double r55281222 = r55281219 + r55281221;
        double r55281223 = log(r55281222);
        return r55281223;
}

double f(double x, double y) {
        double r55281224 = x;
        double r55281225 = -3.3032099476572043e+84;
        bool r55281226 = r55281224 <= r55281225;
        double r55281227 = -2.0;
        double r55281228 = -1.0;
        double r55281229 = r55281228 / r55281224;
        double r55281230 = log(r55281229);
        double r55281231 = r55281227 * r55281230;
        double r55281232 = 1.0023885355020536e+127;
        bool r55281233 = r55281224 <= r55281232;
        double r55281234 = y;
        double r55281235 = r55281234 * r55281234;
        double r55281236 = r55281224 * r55281224;
        double r55281237 = r55281235 + r55281236;
        double r55281238 = log(r55281237);
        double r55281239 = 2.0;
        double r55281240 = log(r55281224);
        double r55281241 = r55281239 * r55281240;
        double r55281242 = r55281233 ? r55281238 : r55281241;
        double r55281243 = r55281226 ? r55281231 : r55281242;
        return r55281243;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if x < -3.3032099476572043e+84

    1. Initial program 48.4

      \[\log \left(x \cdot x + y \cdot y\right)\]
    2. Taylor expanded around -inf 8.7

      \[\leadsto \color{blue}{-2 \cdot \log \left(\frac{-1}{x}\right)}\]
    3. Simplified8.7

      \[\leadsto \color{blue}{-2 \cdot \log \left(\frac{-1}{x}\right)}\]

    if -3.3032099476572043e+84 < x < 1.0023885355020536e+127

    1. Initial program 21.4

      \[\log \left(x \cdot x + y \cdot y\right)\]

    if 1.0023885355020536e+127 < x

    1. Initial program 56.7

      \[\log \left(x \cdot x + y \cdot y\right)\]
    2. Taylor expanded around inf 7.0

      \[\leadsto \color{blue}{-2 \cdot \log \left(\frac{1}{x}\right)}\]
    3. Simplified7.0

      \[\leadsto \color{blue}{\log x \cdot 2}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification16.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.303209947657204342880384766533788360025 \cdot 10^{84}:\\ \;\;\;\;-2 \cdot \log \left(\frac{-1}{x}\right)\\ \mathbf{elif}\;x \le 1.00238853550205355149758148628321723902 \cdot 10^{127}:\\ \;\;\;\;\log \left(y \cdot y + x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \log x\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (x y)
  :name "log((x*x) + (y*y))"
  (log (+ (* x x) (* y y))))