Average Error: 7.7 → 2.8
Time: 6.9s
Precision: 64
$b \cdot 4503599627370496 \le a$
$\frac{a + b}{1 - a \cdot b}$
$\begin{array}{l} \mathbf{if}\;b \le -4.716782922743729933181762281246782486786 \cdot 10^{189} \lor \neg \left(b \le 4.354857369571379975401692621934704586388 \cdot 10^{-39}\right):\\ \;\;\;\;\frac{-1}{b} - \left(\frac{1}{\left(a \cdot b\right) \cdot a} + \frac{1}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 - a \cdot b} \cdot \left(a + b\right)\\ \end{array}$
\frac{a + b}{1 - a \cdot b}
\begin{array}{l}
\mathbf{if}\;b \le -4.716782922743729933181762281246782486786 \cdot 10^{189} \lor \neg \left(b \le 4.354857369571379975401692621934704586388 \cdot 10^{-39}\right):\\
\;\;\;\;\frac{-1}{b} - \left(\frac{1}{\left(a \cdot b\right) \cdot a} + \frac{1}{a}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{1 - a \cdot b} \cdot \left(a + b\right)\\

\end{array}
double f(double a, double b) {
double r2293940 = a;
double r2293941 = b;
double r2293942 = r2293940 + r2293941;
double r2293943 = 1.0;
double r2293944 = r2293940 * r2293941;
double r2293945 = r2293943 - r2293944;
double r2293946 = r2293942 / r2293945;
return r2293946;
}


double f(double a, double b) {
double r2293947 = b;
double r2293948 = -4.71678292274373e+189;
bool r2293949 = r2293947 <= r2293948;
double r2293950 = 4.35485736957138e-39;
bool r2293951 = r2293947 <= r2293950;
double r2293952 = !r2293951;
bool r2293953 = r2293949 || r2293952;
double r2293954 = -1.0;
double r2293955 = r2293954 / r2293947;
double r2293956 = 1.0;
double r2293957 = a;
double r2293958 = r2293957 * r2293947;
double r2293959 = r2293958 * r2293957;
double r2293960 = r2293956 / r2293959;
double r2293961 = 1.0;
double r2293962 = r2293961 / r2293957;
double r2293963 = r2293960 + r2293962;
double r2293964 = r2293955 - r2293963;
double r2293965 = r2293956 - r2293958;
double r2293966 = r2293961 / r2293965;
double r2293967 = r2293957 + r2293947;
double r2293968 = r2293966 * r2293967;
double r2293969 = r2293953 ? r2293964 : r2293968;
return r2293969;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if b < -4.71678292274373e+189 or 4.35485736957138e-39 < b

1. Initial program 23.7

$\frac{a + b}{1 - a \cdot b}$
2. Using strategy rm
3. Applied clear-num23.6

$\leadsto \color{blue}{\frac{1}{\frac{1 - a \cdot b}{a + b}}}$
4. Taylor expanded around inf 11.1

$\leadsto \color{blue}{-\left(\frac{1}{b} + \left(1 \cdot \frac{1}{{a}^{2} \cdot b} + \frac{1}{a}\right)\right)}$
5. Simplified4.5

$\leadsto \color{blue}{\frac{-1}{b} - \left(\frac{1}{\left(a \cdot b\right) \cdot a} + \frac{1}{a}\right)}$

## if -4.71678292274373e+189 < b < 4.35485736957138e-39

1. Initial program 2.3

$\frac{a + b}{1 - a \cdot b}$
2. Using strategy rm
3. Applied clear-num2.3

$\leadsto \color{blue}{\frac{1}{\frac{1 - a \cdot b}{a + b}}}$
4. Using strategy rm
5. Applied div-inv2.4

$\leadsto \frac{1}{\color{blue}{\left(1 - a \cdot b\right) \cdot \frac{1}{a + b}}}$

$\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\left(1 - a \cdot b\right) \cdot \frac{1}{a + b}}$
7. Applied times-frac2.4

$\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1 - a \cdot b} \cdot \frac{\sqrt[3]{1}}{\frac{1}{a + b}}}$
8. Simplified2.4

$\leadsto \color{blue}{\frac{1}{1 - a \cdot b}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{a + b}}$
9. Simplified2.3

$\leadsto \frac{1}{1 - a \cdot b} \cdot \color{blue}{\left(a + b\right)}$
3. Recombined 2 regimes into one program.
4. Final simplification2.8

$\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.716782922743729933181762281246782486786 \cdot 10^{189} \lor \neg \left(b \le 4.354857369571379975401692621934704586388 \cdot 10^{-39}\right):\\ \;\;\;\;\frac{-1}{b} - \left(\frac{1}{\left(a \cdot b\right) \cdot a} + \frac{1}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 - a \cdot b} \cdot \left(a + b\right)\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (a b)
:name "(a+b)/(1-a*b)"
:precision binary64
:pre (<= (* b 4.5036e15) a)
(/ (+ a b) (- 1 (* a b))))