Average Error: 38.8 → 20.6
Time: 14.1s
Precision: 64
$\log \left(\left(1 + x \cdot x\right) + y \cdot y\right)$
$\begin{array}{l} \mathbf{if}\;\left(1 + x \cdot x\right) + y \cdot y \le 1.000000005256993729219061606272589415312:\\ \;\;\;\;1 \cdot \left(y \cdot y + x \cdot x\right) + \log 1\\ \mathbf{elif}\;\left(1 + x \cdot x\right) + y \cdot y \le 2.679207215020532824792218219842848827505 \cdot 10^{303}:\\ \;\;\;\;\log \left(\left(1 + x \cdot x\right) + y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \log \left(\frac{-1}{x}\right) + \frac{1}{x \cdot x}\\ \end{array}$
\log \left(\left(1 + x \cdot x\right) + y \cdot y\right)
\begin{array}{l}
\mathbf{if}\;\left(1 + x \cdot x\right) + y \cdot y \le 1.000000005256993729219061606272589415312:\\
\;\;\;\;1 \cdot \left(y \cdot y + x \cdot x\right) + \log 1\\

\mathbf{elif}\;\left(1 + x \cdot x\right) + y \cdot y \le 2.679207215020532824792218219842848827505 \cdot 10^{303}:\\
\;\;\;\;\log \left(\left(1 + x \cdot x\right) + y \cdot y\right)\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \log \left(\frac{-1}{x}\right) + \frac{1}{x \cdot x}\\

\end{array}
double f(double x, double y) {
double r55685770 = 1.0;
double r55685771 = x;
double r55685772 = r55685771 * r55685771;
double r55685773 = r55685770 + r55685772;
double r55685774 = y;
double r55685775 = r55685774 * r55685774;
double r55685776 = r55685773 + r55685775;
double r55685777 = log(r55685776);
return r55685777;
}


double f(double x, double y) {
double r55685778 = 1.0;
double r55685779 = x;
double r55685780 = r55685779 * r55685779;
double r55685781 = r55685778 + r55685780;
double r55685782 = y;
double r55685783 = r55685782 * r55685782;
double r55685784 = r55685781 + r55685783;
double r55685785 = 1.0000000052569937;
bool r55685786 = r55685784 <= r55685785;
double r55685787 = r55685783 + r55685780;
double r55685788 = r55685778 * r55685787;
double r55685789 = log(r55685778);
double r55685790 = r55685788 + r55685789;
double r55685791 = 2.6792072150205328e+303;
bool r55685792 = r55685784 <= r55685791;
double r55685793 = log(r55685784);
double r55685794 = -2.0;
double r55685795 = -1.0;
double r55685796 = r55685795 / r55685779;
double r55685797 = log(r55685796);
double r55685798 = r55685794 * r55685797;
double r55685799 = r55685778 / r55685780;
double r55685800 = r55685798 + r55685799;
double r55685801 = r55685792 ? r55685793 : r55685800;
double r55685802 = r55685786 ? r55685790 : r55685801;
return r55685802;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if (+ (+ 1.0 (* x x)) (* y y)) < 1.0000000052569937

1. Initial program 45.1

$\log \left(\left(1 + x \cdot x\right) + y \cdot y\right)$
2. Taylor expanded around 0 0.4

$\leadsto \color{blue}{1 \cdot {x}^{2} + \left(\log 1 + 1 \cdot {y}^{2}\right)}$
3. Simplified0.4

$\leadsto \color{blue}{1 \cdot \left(x \cdot x + y \cdot y\right) + \log 1}$

## if 1.0000000052569937 < (+ (+ 1.0 (* x x)) (* y y)) < 2.6792072150205328e+303

1. Initial program 0.2

$\log \left(\left(1 + x \cdot x\right) + y \cdot y\right)$

## if 2.6792072150205328e+303 < (+ (+ 1.0 (* x x)) (* y y))

1. Initial program 63.1

$\log \left(\left(1 + x \cdot x\right) + y \cdot y\right)$
2. Taylor expanded around -inf 46.2

$\leadsto \color{blue}{1 \cdot \frac{1}{{x}^{2}} - 2 \cdot \log \left(\frac{-1}{x}\right)}$
3. Simplified46.2

$\leadsto \color{blue}{\frac{1}{x \cdot x} + -2 \cdot \log \left(\frac{-1}{x}\right)}$
3. Recombined 3 regimes into one program.
4. Final simplification20.6

$\leadsto \begin{array}{l} \mathbf{if}\;\left(1 + x \cdot x\right) + y \cdot y \le 1.000000005256993729219061606272589415312:\\ \;\;\;\;1 \cdot \left(y \cdot y + x \cdot x\right) + \log 1\\ \mathbf{elif}\;\left(1 + x \cdot x\right) + y \cdot y \le 2.679207215020532824792218219842848827505 \cdot 10^{303}:\\ \;\;\;\;\log \left(\left(1 + x \cdot x\right) + y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \log \left(\frac{-1}{x}\right) + \frac{1}{x \cdot x}\\ \end{array}$

# Reproduce

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