# How would one minimize with respect to an unknown number of variables?

Say I had a function like the following:

f[n_] := Sum[a + Subscript[b, k], {k, 0, n}]


Such that f[5] == 6 a + Subscript[b, 0] + Subscript[b, 1] + Subscript[b, 2] + Subscript[b, 3] + Subscript[b, 4] + Subscript[b, 5]

How would I go about minimizing f with respect to both a and all of the subscripted bs? How would I go about minimizing f[5] without manually supplying {a, Subscript[b, 0], Subscript[b, 1], Subscript[b, 2], Subscript[b, 3], Subscript[b, 4], Subscript[b, 5]} as the vars param?

I'm asking about a specific simplified case here, but hopefully answers will be applicable in the general case and to other functions that take a vars param other than Minimize[]

• did you look at this, this or any of the other similar questions around this site? – acl Jul 18 '14 at 16:55

varnum = 10;