Average Error: 9.9 → 9.4
Time: 29.5s
Precision: 64
$w \cdot t + \left(S \cdot T\right) \cdot \left(H + r \cdot \left(r \cdot H + R\right)\right)$
$\begin{array}{l} \mathbf{if}\;\left(R + r \cdot H\right) \cdot r + H \le 3.6456067042094846 \cdot 10^{+294}:\\ \;\;\;\;\left(T \cdot S\right) \cdot \left(\left(R + r \cdot H\right) \cdot r + H\right) + t \cdot w\\ \mathbf{else}:\\ \;\;\;\;t \cdot w + H \cdot \left(T \cdot S\right)\\ \end{array}$
w \cdot t + \left(S \cdot T\right) \cdot \left(H + r \cdot \left(r \cdot H + R\right)\right)
\begin{array}{l}
\mathbf{if}\;\left(R + r \cdot H\right) \cdot r + H \le 3.6456067042094846 \cdot 10^{+294}:\\
\;\;\;\;\left(T \cdot S\right) \cdot \left(\left(R + r \cdot H\right) \cdot r + H\right) + t \cdot w\\

\mathbf{else}:\\
\;\;\;\;t \cdot w + H \cdot \left(T \cdot S\right)\\

\end{array}
double f(double w, double t, double S, double T, double H, double r, double R) {
double r18950183 = w;
double r18950184 = t;
double r18950185 = r18950183 * r18950184;
double r18950186 = S;
double r18950187 = T;
double r18950188 = r18950186 * r18950187;
double r18950189 = H;
double r18950190 = r;
double r18950191 = r18950190 * r18950189;
double r18950192 = R;
double r18950193 = r18950191 + r18950192;
double r18950194 = r18950190 * r18950193;
double r18950195 = r18950189 + r18950194;
double r18950196 = r18950188 * r18950195;
double r18950197 = r18950185 + r18950196;
return r18950197;
}

double f(double w, double t, double S, double T, double H, double r, double R) {
double r18950198 = R;
double r18950199 = r;
double r18950200 = H;
double r18950201 = r18950199 * r18950200;
double r18950202 = r18950198 + r18950201;
double r18950203 = r18950202 * r18950199;
double r18950204 = r18950203 + r18950200;
double r18950205 = 3.6456067042094846e+294;
bool r18950206 = r18950204 <= r18950205;
double r18950207 = T;
double r18950208 = S;
double r18950209 = r18950207 * r18950208;
double r18950210 = r18950209 * r18950204;
double r18950211 = t;
double r18950212 = w;
double r18950213 = r18950211 * r18950212;
double r18950214 = r18950210 + r18950213;
double r18950215 = r18950200 * r18950209;
double r18950216 = r18950213 + r18950215;
double r18950217 = r18950206 ? r18950214 : r18950216;
return r18950217;
}

# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if (+ H (* r (+ (* r H) R))) < 3.6456067042094846e+294

1. Initial program 6.6

$w \cdot t + \left(S \cdot T\right) \cdot \left(H + r \cdot \left(r \cdot H + R\right)\right)$
2. Taylor expanded around -inf 8.9

$\leadsto w \cdot t + \left(S \cdot T\right) \cdot \left(H + \color{blue}{\left(r \cdot R + {r}^{2} \cdot H\right)}\right)$
3. Simplified6.6

$\leadsto w \cdot t + \left(S \cdot T\right) \cdot \left(H + \color{blue}{\left(H \cdot r + R\right) \cdot r}\right)$

## if 3.6456067042094846e+294 < (+ H (* r (+ (* r H) R)))

1. Initial program 52.8

$w \cdot t + \left(S \cdot T\right) \cdot \left(H + r \cdot \left(r \cdot H + R\right)\right)$
2. Taylor expanded around 0 45.7

$\leadsto w \cdot t + \left(S \cdot T\right) \cdot \left(H + \color{blue}{0}\right)$
3. Recombined 2 regimes into one program.
4. Final simplification9.4

$\leadsto \begin{array}{l} \mathbf{if}\;\left(R + r \cdot H\right) \cdot r + H \le 3.6456067042094846 \cdot 10^{+294}:\\ \;\;\;\;\left(T \cdot S\right) \cdot \left(\left(R + r \cdot H\right) \cdot r + H\right) + t \cdot w\\ \mathbf{else}:\\ \;\;\;\;t \cdot w + H \cdot \left(T \cdot S\right)\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (w t S T H r R)
:name "(w * t + S * T * ( H + r * ( r * H + R) ) ) "
(+ (* w t) (* (* S T) (+ H (* r (+ (* r H) R))))))