How can I get the exact value minimum of this function?

I want to find min of the function $$\frac{1}{\sqrt{2 x^2+\left(3+\sqrt{3}\right) x+3}}+\frac{1}{\sqrt{2 x^2+\left(3-\sqrt{3}\right) x+3}}+\sqrt{\frac{1}{3} \left(2 x^2+2 x+1\right)}.$$ I know, the exact value minimum is $\sqrt{3}$ at $x = 0$. With Mathematica, I tried

A = 1/Sqrt[2 x^2 + (3 + Sqrt[3]) x + 3] +
1/Sqrt[2 x^2 + (3 - Sqrt[3]) x + 3] + Sqrt[(2 x^2 + 2 x + 1)/3]
NMinimize[A, {x}]


And I got

{1.73205, {x -> -2.57345*10^-16}}

When I tried

A = 1/Sqrt[2 x^2 + (3 + Sqrt[3]) x + 3] +
1/Sqrt[2 x^2 + (3 - Sqrt[3]) x + 3] + Sqrt[(2 x^2 + 2 x + 1)/3]
Minimize[A, {x}]


my computer ran about 20 minutes and I did not got the result. How can I get the exact value minimum of the given function?

In this case you can find minimum by comparing values at zero derivates:

TakeSmallestBy[{A /. #, #} & /@ Solve[D[A, x] == 0, x, Reals], First, 1]


{{Sqrt[3], {x -> 0}}}

TakeSmallestBy is a v10.1 function similar to MinimalBy, but performs numerical comparisons.

• Or First@MinimalBy[First][{A /. #, #} & /@ Solve[D[A, x] == 0, x, Reals]] for 10.0.x users. Commented Apr 3, 2015 at 10:03
• @Taiki The problem with MinimalBy is that it doesn't perform the comparison numerical order, but instead by using OrderedQ ordering. Of course there are correct ways to do this in pre-v10.1 versions too, but they're a bit awkward (Sorting with Less as comparison function, or such)... Commented Apr 3, 2015 at 10:09
• I can't see why it's a problem here. The canonical order of First[e_i] is by numerical magnitude anyway. Commented Apr 3, 2015 at 10:23
• @Taiki Order given by MinimalBy is correct by sheer luck in this case. Consider MinimalBy[x /. Solve[D[A, x] == 0, x, Reals], Identity, 3] // N (* {0., -2.14393, -1.20441} *) - from this its' obvious you can't trust MinimalBy to give numerically sorted ordering of symbolic expressions. Commented Apr 3, 2015 at 10:29
• Oh right... you meant that MinimalBy wouldn't evaluate Root? Yeah the result is indeed correct by luck here. Commented Apr 3, 2015 at 10:32
a[x_] := Sqrt[1 + 2 x + 2 x^2]/Sqrt[3] + 1/Sqrt[
3 + (3 - Sqrt[3]) x + 2 x^2] + 1/Sqrt[3 + (3 + Sqrt[3]) x + 2 x^2]

Plot[a[x], {x, -5, 5}]


extr = NSolve[a'[x] == 0, x, Reals]


{{x -> -2.14393}, {x -> -1.20438}, {x -> 0.}}

{a[x] /. #, #} & /@ extr


{{2.42668, {x -> -2.14393}}, {3.4091, {x -> -1.20438}}, \ {1.73205, {x -> 0.}}}

• 0. is not exact. Commented Apr 3, 2015 at 10:11

You could use FindInstance to find some of the exact stationary points, when mathematica can't solve the equation:

FindInstance[Evaluate[D[A, x]] == 0, x]
(*{{x -> 0}}*)

• Did you mean FindInstance[D[A, x] == 0, x]? But still it takes too long. Commented Apr 3, 2015 at 10:09
• @Taiki Yes, thank you Commented Apr 3, 2015 at 10:31