Average Error: 0.1 → 0.1
Time: 9.5s
Precision: 64
$\sqrt{1 + 2 \cdot x} + \sqrt{x}$
$\sqrt{2 \cdot x + 1} + \sqrt{x}$
\sqrt{1 + 2 \cdot x} + \sqrt{x}
\sqrt{2 \cdot x + 1} + \sqrt{x}
double f(double x) {
double r1047142 = 1.0;
double r1047143 = 2.0;
double r1047144 = x;
double r1047145 = r1047143 * r1047144;
double r1047146 = r1047142 + r1047145;
double r1047147 = sqrt(r1047146);
double r1047148 = sqrt(r1047144);
double r1047149 = r1047147 + r1047148;
return r1047149;
}


double f(double x) {
double r1047150 = 2.0;
double r1047151 = x;
double r1047152 = r1047150 * r1047151;
double r1047153 = 1.0;
double r1047154 = r1047152 + r1047153;
double r1047155 = sqrt(r1047154);
double r1047156 = sqrt(r1047151);
double r1047157 = r1047155 + r1047156;
return r1047157;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 0.1

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

$\leadsto \sqrt{\color{blue}{\sqrt{1 + 2 \cdot x} \cdot \sqrt{1 + 2 \cdot x}}} + \sqrt{x}$
4. Applied sqrt-prod0.2

$\leadsto \color{blue}{\sqrt{\sqrt{1 + 2 \cdot x}} \cdot \sqrt{\sqrt{1 + 2 \cdot x}}} + \sqrt{x}$
5. Using strategy rm
6. Applied *-un-lft-identity0.2

$\leadsto \sqrt{\color{blue}{1 \cdot \sqrt{1 + 2 \cdot x}}} \cdot \sqrt{\sqrt{1 + 2 \cdot x}} + \sqrt{x}$
7. Applied sqrt-prod0.2

$\leadsto \color{blue}{\left(\sqrt{1} \cdot \sqrt{\sqrt{1 + 2 \cdot x}}\right)} \cdot \sqrt{\sqrt{1 + 2 \cdot x}} + \sqrt{x}$
8. Applied associate-*l*0.2

$\leadsto \color{blue}{\sqrt{1} \cdot \left(\sqrt{\sqrt{1 + 2 \cdot x}} \cdot \sqrt{\sqrt{1 + 2 \cdot x}}\right)} + \sqrt{x}$
9. Simplified0.1

$\leadsto \sqrt{1} \cdot \color{blue}{\sqrt{2 \cdot x + 1}} + \sqrt{x}$
10. Final simplification0.1

$\leadsto \sqrt{2 \cdot x + 1} + \sqrt{x}$

# Reproduce

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