Average Error: 8.5 → 0.2
Time: 12.4s
Precision: 64
$\left(\sqrt{x} + \sqrt{y}\right) - \sqrt{\frac{x}{y}}$
$\sqrt{y} - \left(\left|\frac{1}{\frac{\sqrt{y}}{\sqrt{x}}}\right| - \sqrt{x}\right)$
\left(\sqrt{x} + \sqrt{y}\right) - \sqrt{\frac{x}{y}}
\sqrt{y} - \left(\left|\frac{1}{\frac{\sqrt{y}}{\sqrt{x}}}\right| - \sqrt{x}\right)
double f(double x, double y) {
double r2107224 = x;
double r2107225 = sqrt(r2107224);
double r2107226 = y;
double r2107227 = sqrt(r2107226);
double r2107228 = r2107225 + r2107227;
double r2107229 = r2107224 / r2107226;
double r2107230 = sqrt(r2107229);
double r2107231 = r2107228 - r2107230;
return r2107231;
}


double f(double x, double y) {
double r2107232 = y;
double r2107233 = sqrt(r2107232);
double r2107234 = 1.0;
double r2107235 = x;
double r2107236 = sqrt(r2107235);
double r2107237 = r2107233 / r2107236;
double r2107238 = r2107234 / r2107237;
double r2107239 = fabs(r2107238);
double r2107240 = r2107239 - r2107236;
double r2107241 = r2107233 - r2107240;
return r2107241;
}



Try it out

Results

 In Out
Enter valid numbers for all inputs

Derivation

1. Initial program 8.5

$\left(\sqrt{x} + \sqrt{y}\right) - \sqrt{\frac{x}{y}}$
2. Simplified8.5

$\leadsto \color{blue}{\sqrt{y} - \left(\sqrt{\frac{x}{y}} - \sqrt{x}\right)}$
3. Using strategy rm

$\leadsto \sqrt{y} - \left(\sqrt{\frac{x}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}} - \sqrt{x}\right)$

$\leadsto \sqrt{y} - \left(\sqrt{\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\sqrt{y} \cdot \sqrt{y}}} - \sqrt{x}\right)$
6. Applied times-frac8.6

$\leadsto \sqrt{y} - \left(\sqrt{\color{blue}{\frac{\sqrt{x}}{\sqrt{y}} \cdot \frac{\sqrt{x}}{\sqrt{y}}}} - \sqrt{x}\right)$
7. Applied rem-sqrt-square0.2

$\leadsto \sqrt{y} - \left(\color{blue}{\left|\frac{\sqrt{x}}{\sqrt{y}}\right|} - \sqrt{x}\right)$
8. Using strategy rm
9. Applied *-un-lft-identity0.2

$\leadsto \sqrt{y} - \left(\left|\frac{\sqrt{\color{blue}{1 \cdot x}}}{\sqrt{y}}\right| - \sqrt{x}\right)$
10. Applied sqrt-prod0.2

$\leadsto \sqrt{y} - \left(\left|\frac{\color{blue}{\sqrt{1} \cdot \sqrt{x}}}{\sqrt{y}}\right| - \sqrt{x}\right)$
11. Applied associate-/l*0.2

$\leadsto \sqrt{y} - \left(\left|\color{blue}{\frac{\sqrt{1}}{\frac{\sqrt{y}}{\sqrt{x}}}}\right| - \sqrt{x}\right)$
12. Final simplification0.2

$\leadsto \sqrt{y} - \left(\left|\frac{1}{\frac{\sqrt{y}}{\sqrt{x}}}\right| - \sqrt{x}\right)$

Reproduce

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