2
$\begingroup$

Following up my previous question which got great replies, I am now trying to do

NMinimize[{1/2 + Sqrt[2] Sqrt[n] - Ceiling[1/2 (-1 + Sqrt[1 + 8 n])],  n > 4}, n]

It gives me the answer 0.328427.

NMinimize[{1/2 + Sqrt[2] Sqrt[n] - Ceiling[1/2 (-1 + Sqrt[1 + 8 n])],  n > 5}, n]

gives me -0.0358984 and so it goes on if I change the range or add upper bounds for n as well.

Is there any way to get a minimum with any confidence?

My guess is that the true minimum for n > 4 is 2*(sqrt(3)-2).

$\endgroup$

2 Answers 2

8
$\begingroup$

Please, visualize your function before you do anything:

Plot[1/2 + Sqrt[2] Sqrt[n] - Ceiling[1/2 (-1 + Sqrt[1 + 8 n])], {n, 0, 20}, PlotStyle -> Thick]

Plot

The function is discontinuous and each time it jumps, it hits a new local infimum. Where are the jumps? Exactly where Ceiling does; that is, whenever its argument is an integer. I will confine this analysis to positive $n$ and find the values of $n$ where it is potentially discontinuous by equating the argument's value with an unknown integer $m$:

Reduce[1/2 (-1 + Sqrt[1 + 8 n]) == m  && m \[Element] Integers && n >= 0, {n}]

$m\in \text{Integers}\ \&\&\ m\geq 0\ \&\&\ n==\frac{1}{2} \left(m+m^2\right)$

We can plot the pieces of this function independently, using the integer $m$ to index the regions where it's continuous:

Show[base = Table[
  Plot[1/2 + Sqrt[2] Sqrt[n] - m, {n, 1/2 (m - 1 + (m - 1)^2),  1/2 (m + m^2)},
   PlotStyle -> {Thick, Hue[m/5]}], 
 {m, 1, 5}], PlotRange -> All]

Plot

In a similar way we can index these new local minima by m:

min[m_] := Evaluate@First@Minimize[{1/2 + Sqrt[2] Sqrt[n] - m, 
  1/2 (m - 1 + (m - 1)^2) < n <=  1/2 (m + m^2) && m >= 1}, n];
? min

$\min [\text{m$\_$}]\text{:=}\text{Piecewise}\left[\left\{\left\{-\frac{1}{2},m==1\right\},\left\{\frac{1}{2} (1-2 m)+\frac{\sqrt{-2 m+2 m^2}}{\sqrt{2}},m>1\right\}\right\},\infty \right]$

That answers the conjecture in the question by giving a formula for how these local minima depend on $m$, whence on $n$ via substitution:

min[1/2 (-1 + Sqrt[1 + 8 n])] // Simplify

$\begin{array}{ll} \{ & \begin{array}{ll} -\frac{1}{2} & \sqrt{1+8 n}==3 \\ 1-\frac{1}{2} \sqrt{1+8 n}+\sqrt{1+2 n-\sqrt{1+8 n}} & \sqrt{1+8 n}>3 \\ \infty & \text{True} \end{array} \end{array}$

A plot of this function serves to check the work, remembering that $m$ must be obtained as the ceiling of the values:

minima = Plot[min[Ceiling[1/2 (-1 + Sqrt[1 + 8 n])]], {n, 1, 15}, 
  PlotStyle -> {Thick, Dashed, Black}];
Show[base, pts, PlotRange -> All]

Plot 3

The minimum depends on the lower limit imposed on $n$ and, as that lower limit increases, appears to increase. It would be asking a lot of Mathematica to compute this limit literally, as in

Limit[min[Ceiling[1/2 (-1 + Sqrt[1 + 8 n])]], n -> Infinity]

(and sure enough, its output is uninformative), but it's not necessary: this limit must coincide with the limit obtained without restricting the argument of min to integral values:

Limit[min[1/2 (-1 + Sqrt[1 + 8 n])], n -> Infinity]

$0$

$\endgroup$
2
$\begingroup$

Try :

NMinimize[{1/2 + Sqrt[2] Sqrt[n] - Ceiling[1/2 (-1 + Sqrt[1 + 8 n])], 
  n > 4, n \[Element] Integers}, n]
(* {0.241657, {n -> 7}} *)

NMinimize[{1/2 + Sqrt[2] Sqrt[n] - Ceiling[1/2 (-1 + Sqrt[1 + 8 n])], 
  n > 5, n \[Element] Integers}, n]
(* {0.241657, {n -> 7}} *)

You can check the above with a plot :

DiscretePlot[1/2 + Sqrt[2] Sqrt[n] - Ceiling[1/2 (-1 + Sqrt[1 + 8 n])], {n,1, 10}]

plot

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.