Average Error: 15.1 → 9.6
Time: 28.2s
Precision: 64
Internal Precision: 320
$\frac{l_count \cdot l_mean + r_count \cdot r_mean}{l_count + r_count}$
$\begin{array}{l} \mathbf{if}\;\frac{l_count \cdot l_mean + r_count \cdot r_mean}{l_count + r_count} \le -1.7400200975636977 \cdot 10^{+308}:\\ \;\;\;\;l_mean\\ \mathbf{if}\;\frac{l_count \cdot l_mean + r_count \cdot r_mean}{l_count + r_count} \le 4.256578409619606 \cdot 10^{+292}:\\ \;\;\;\;\left(l_count \cdot l_mean + r_count \cdot r_mean\right) \cdot \frac{1}{l_count + r_count}\\ \mathbf{else}:\\ \;\;\;\;r_mean\\ \end{array}$

# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if (/ (+ (* l_count l_mean) (* r_count r_mean)) (+ l_count r_count)) < -1.7400200975636977e+308

1. Initial program 60.0

$\frac{l_count \cdot l_mean + r_count \cdot r_mean}{l_count + r_count}$
2. Taylor expanded around inf 35.8

$\leadsto \color{blue}{l_mean}$

## if -1.7400200975636977e+308 < (/ (+ (* l_count l_mean) (* r_count r_mean)) (+ l_count r_count)) < 4.256578409619606e+292

1. Initial program 1.3

$\frac{l_count \cdot l_mean + r_count \cdot r_mean}{l_count + r_count}$
2. Using strategy rm
3. Applied div-inv1.4

$\leadsto \color{blue}{\left(l_count \cdot l_mean + r_count \cdot r_mean\right) \cdot \frac{1}{l_count + r_count}}$

## if 4.256578409619606e+292 < (/ (+ (* l_count l_mean) (* r_count r_mean)) (+ l_count r_count))

1. Initial program 58.0

$\frac{l_count \cdot l_mean + r_count \cdot r_mean}{l_count + r_count}$
2. Taylor expanded around 0 35.1

$\leadsto \color{blue}{r_mean}$
3. Recombined 3 regimes into one program.

# Runtime

Time bar (total: 28.2s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)'
(FPCore (l_count l_mean r_count r_mean)
:name "(l_count * l_mean + r_count * r_mean) / (l_count + r_count)"
(/ (+ (* l_count l_mean) (* r_count r_mean)) (+ l_count r_count)))