Average Error: 13.1 → 4.6
Time: 10.2s
Precision: 64
$x \cdot \sqrt{1 + \frac{y \cdot y}{x \cdot x}}$
$\begin{array}{l} \mathbf{if}\;x \le 0.0 \lor \neg \left(x \le 0.0\right):\\ \;\;\;\;x \cdot \sqrt{1 + \left|\frac{y}{x}\right| \cdot \left|\frac{y}{x}\right|}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array}$
x \cdot \sqrt{1 + \frac{y \cdot y}{x \cdot x}}
\begin{array}{l}
\mathbf{if}\;x \le 0.0 \lor \neg \left(x \le 0.0\right):\\
\;\;\;\;x \cdot \sqrt{1 + \left|\frac{y}{x}\right| \cdot \left|\frac{y}{x}\right|}\\

\mathbf{else}:\\
\;\;\;\;y\\

\end{array}
double f(double x, double y) {
double r2259198 = x;
double r2259199 = 1.0;
double r2259200 = y;
double r2259201 = r2259200 * r2259200;
double r2259202 = r2259198 * r2259198;
double r2259203 = r2259201 / r2259202;
double r2259204 = r2259199 + r2259203;
double r2259205 = sqrt(r2259204);
double r2259206 = r2259198 * r2259205;
return r2259206;
}


double f(double x, double y) {
double r2259207 = x;
double r2259208 = 0.0;
bool r2259209 = r2259207 <= r2259208;
double r2259210 = !r2259209;
bool r2259211 = r2259209 || r2259210;
double r2259212 = 1.0;
double r2259213 = y;
double r2259214 = r2259213 / r2259207;
double r2259215 = fabs(r2259214);
double r2259216 = r2259215 * r2259215;
double r2259217 = r2259212 + r2259216;
double r2259218 = sqrt(r2259217);
double r2259219 = r2259207 * r2259218;
double r2259220 = r2259211 ? r2259219 : r2259213;
return r2259220;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if x < 0.0 or 0.0 < x

1. Initial program 13.1

$x \cdot \sqrt{1 + \frac{y \cdot y}{x \cdot x}}$
2. Using strategy rm

$\leadsto x \cdot \sqrt{1 + \color{blue}{\sqrt{\frac{y \cdot y}{x \cdot x}} \cdot \sqrt{\frac{y \cdot y}{x \cdot x}}}}$
4. Simplified13.1

$\leadsto x \cdot \sqrt{1 + \color{blue}{\left|\frac{y}{x}\right|} \cdot \sqrt{\frac{y \cdot y}{x \cdot x}}}$
5. Simplified4.6

$\leadsto x \cdot \sqrt{1 + \left|\frac{y}{x}\right| \cdot \color{blue}{\left|\frac{y}{x}\right|}}$

## if 0.0 < x < 0.0

1. Initial program 13.1

$x \cdot \sqrt{1 + \frac{y \cdot y}{x \cdot x}}$
2. Taylor expanded around 0 9.1

$\leadsto \color{blue}{y}$
3. Recombined 2 regimes into one program.
4. Final simplification4.6

$\leadsto \begin{array}{l} \mathbf{if}\;x \le 0.0 \lor \neg \left(x \le 0.0\right):\\ \;\;\;\;x \cdot \sqrt{1 + \left|\frac{y}{x}\right| \cdot \left|\frac{y}{x}\right|}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (x y)
:name "x * sqrt(1 + (y * y) / (x * x))"
:precision binary32
(* x (sqrt (+ 1 (/ (* y y) (* x x))))))