I have a vector x and a function that sums the elements of x like so:
$$f(1) = x_1$$ $$f(2) = x_1 + \sum_{i=1}^2 x_i$$ $$f(3) = x_1 + \sum_{i=1}^2 x_i + \sum_{j=1}^3 x_j$$ $$f(4) = x_1 + \sum_{i=1}^2 x_i + \sum_{j=1}^3 x_j + \sum_{k=1}^4 x_k$$
...and so on. How might I represent this function more compactly, please?
$f(n) = \sum\limits_{i=1}^{n}\sum\limits_{j=1}^{i} x_j = \sum\limits_{i=1}^{n} (n-i+1)x_i$