I'm trying to find the shortest path, getting from $x=0$ to $x=k$ in a certain problem, where I can slowly accelerate and decelerate.
It comes down to finding the smallest $n$ and set of values $\{a_1,\dots,a_n\}$ such that: $$ a_i\in\{-1,0,1\}\\ a_1+a_2+\dots+a_n=0\\ na_1+(n-1)a_2+\dots+a_n=k $$
For different $k\ge0$ I can compute the following sequence of $n$'s: $0,2,3,4,4,5,5,6,6,6,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,10,11,11,11,11,11,12,12,12,12,12,12,13,13,13,13,13,13,14,14,14,14,14,14,14\dots$, but there doesn't seem to be a visible pattern. I also tried OEIS to no luck.
I'm not well versed in these sort of integer equations. Do you know of any ways to get a closed form for $n(k)$ or possible just a lower bound?
Update: Samrat points out there is actually a pretty simple pattern for the above sequence. I wonder if I have also missed a pattern in the following sequence, where we go from $x=0$ to $x=0$ but need to change the speed: $$ a_i\in\{-1,0,1\}\\ a_1+a_2+\dots+a_n=k\\ na_1+(n-1)a_2+\dots+a_n=0 $$ Sequence: $3,6,8,11,13,16,18,20,23,25,28,30,33,35,37,40,42,45,47,49,52,54,57,59,62,64,66,69,71,74,76,78,81,83,86,88,91,93,95,98,100,103,105,107,110,112,115,117,119$ First differences: $3,3,2,3,2,3,2,2,3,2,3,2,3,2,2,3,2,3,2,2,3,2,3,2,3,2,2,3,2,3,2,2,3,2,3,2,3,2,2,3,2,3,2,2,3,2,3,2,2$
Update 2: The first sequence turns out to be $n*emphasized text*_k=\lceil2\sqrt{|k|}\rceil$, at least following the pattern. We can then use that to create, at least an upper bound for, the second sequence. We take $n_{-\binom{k+1}{2}}$ and then add $k$ extra $1$s to balance the negative value out. The final formula is then $m_k=n_{\binom{k+1}{2}}+k$.
It's still not a proof of course, but it appears to fit with the sequence.