Average Error: 7.7 → 3.9
Time: 7.5s
Precision: 64
$\frac{k - m}{1 + m \cdot k}$
$\begin{array}{l} \mathbf{if}\;k \le -3.57455057360882846222919865784540227846 \cdot 10^{142}:\\ \;\;\;\;\left(\frac{1}{m} - \frac{1}{k}\right) + \frac{\frac{1}{m}}{k \cdot k}\\ \mathbf{elif}\;k \le 9.936990673805698605857462902481927441496 \cdot 10^{151}:\\ \;\;\;\;\frac{k}{k \cdot m + 1} - \frac{m}{k \cdot m + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{m} - \frac{1}{k}\right) + \frac{\frac{1}{m}}{k \cdot k}\\ \end{array}$
\frac{k - m}{1 + m \cdot k}
\begin{array}{l}
\mathbf{if}\;k \le -3.57455057360882846222919865784540227846 \cdot 10^{142}:\\
\;\;\;\;\left(\frac{1}{m} - \frac{1}{k}\right) + \frac{\frac{1}{m}}{k \cdot k}\\

\mathbf{elif}\;k \le 9.936990673805698605857462902481927441496 \cdot 10^{151}:\\
\;\;\;\;\frac{k}{k \cdot m + 1} - \frac{m}{k \cdot m + 1}\\

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

\end{array}
double f(double k, double m) {
double r6109749 = k;
double r6109750 = m;
double r6109751 = r6109749 - r6109750;
double r6109752 = 1.0;
double r6109753 = r6109750 * r6109749;
double r6109754 = r6109752 + r6109753;
double r6109755 = r6109751 / r6109754;
return r6109755;
}


double f(double k, double m) {
double r6109756 = k;
double r6109757 = -3.5745505736088285e+142;
bool r6109758 = r6109756 <= r6109757;
double r6109759 = 1.0;
double r6109760 = m;
double r6109761 = r6109759 / r6109760;
double r6109762 = r6109759 / r6109756;
double r6109763 = r6109761 - r6109762;
double r6109764 = 1.0;
double r6109765 = r6109764 / r6109760;
double r6109766 = r6109756 * r6109756;
double r6109767 = r6109765 / r6109766;
double r6109768 = r6109763 + r6109767;
double r6109769 = 9.936990673805699e+151;
bool r6109770 = r6109756 <= r6109769;
double r6109771 = r6109756 * r6109760;
double r6109772 = r6109771 + r6109764;
double r6109773 = r6109756 / r6109772;
double r6109774 = r6109760 / r6109772;
double r6109775 = r6109773 - r6109774;
double r6109776 = r6109770 ? r6109775 : r6109768;
double r6109777 = r6109758 ? r6109768 : r6109776;
return r6109777;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if k < -3.5745505736088285e+142 or 9.936990673805699e+151 < k

1. Initial program 23.1

$\frac{k - m}{1 + m \cdot k}$
2. Taylor expanded around inf 8.5

$\leadsto \color{blue}{\left(1 \cdot \frac{1}{m \cdot {k}^{2}} + \frac{1}{m}\right) - \frac{1}{k}}$
3. Simplified8.5

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

## if -3.5745505736088285e+142 < k < 9.936990673805699e+151

1. Initial program 2.3

$\frac{k - m}{1 + m \cdot k}$
2. Using strategy rm
3. Applied div-sub2.3

$\leadsto \color{blue}{\frac{k}{1 + m \cdot k} - \frac{m}{1 + m \cdot k}}$
3. Recombined 2 regimes into one program.
4. Final simplification3.9

$\leadsto \begin{array}{l} \mathbf{if}\;k \le -3.57455057360882846222919865784540227846 \cdot 10^{142}:\\ \;\;\;\;\left(\frac{1}{m} - \frac{1}{k}\right) + \frac{\frac{1}{m}}{k \cdot k}\\ \mathbf{elif}\;k \le 9.936990673805698605857462902481927441496 \cdot 10^{151}:\\ \;\;\;\;\frac{k}{k \cdot m + 1} - \frac{m}{k \cdot m + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{m} - \frac{1}{k}\right) + \frac{\frac{1}{m}}{k \cdot k}\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (k m)
:name "(k-m)/(1+m*k)"
(/ (- k m) (+ 1.0 (* m k))))