# Defining family of multivariable polynomials

Brand new to Sage here and trying to define a family of polynomials indexed by natural numbers. In particular, I'd like to be able to generate then perform symbolic calculations with the family of polynomials defined for all $n\in \mathbb{N}$ and all $k=0,\dotsc, 2n$ by $$p_{n,k}=\begin{cases} 0 & \textrm{if } k=0\newline \sum_{j=1}^k x_j&\textrm{if } k\leq n\newline \sum_{j=1}^{2n-k+1}x_j&\textrm{if }k>n \end{cases}$$

So far the attempts that I've had are of the form:

```
sage: h = lambda k:sum([var('d_%d' %(i+1)) for i in range(k)])
```

but I don't seem to easily perform calculations with these. Another method I was trying is defining $\mathbb{Q}[x_0,\dotsc, x_n]$ then trying to define these polynomials using conditional statements. I seem to keep getting errors stating my variables don't exist.

Would love some help or a hint.

Your $p_k$ silently depends on $n$. So you want to fix $n$ and study the $p_k$?

As you write them, your $p_k$ are first-degrees polynomials of $n$ variables at most. Is that really what you want ?

That is correct, I'd like to fix any $n$ then study the $p_k$.

Yes, these will be degree $1$ polynomials in at most $n$ variables.

Comments:

`h = lambda k: ...`

by 4 spaces will make it display as codeThanks for taking all the comments into account and editing your question!