Counting integral solutions Suppose $a + b + c = 15$
Using stars and bars method, number of non-negative integral solutions for the above equation can be found out as $15+3-1\choose15$ $ =$ $17\choose15$
How to extend this principle for finding number of positive integral solutions of
$a + b + 3c = 15$?
I tried to do it by substituting $3c$ with another variable $d$. But could not succeed.
 A: A simple way to get this is to split into cases according to the value of $c$, and add up all contributions. If $c$ is given ($0 \le c \le 5$) then $a + b = 15 - 3 c$, and by the stars-and-bars argument you know that there are $15 - 3 c + 1$ ways to get that value as sum of $a$ and $b$, thus what you want is:
$$
\sum_{0 \le c \le 5} (16 - 3 c)
  = 6 \cdot 16 - 3 \frac{5 (5 + 1)}{2}
  = 51
$$
A: You could use a generating function. Observe that the generating function for $3c$ is:
$$f_{c}(x) = \sum_{i=0}^{\infty} x^{3i} = \dfrac{1}{1-x^{3}}$$
We have for $a$ and $b$:
$$f_{a}(x) = f_{b}(x) = \sum_{i=0}^{\infty} x^{i} = \dfrac{1}{1-x}$$
We multiply the generating functions for each term together to get:
$$f(x) = \dfrac{1}{(1-x)^{2} \cdot (1-x^{3})}$$
Now we let a computer expand out $f(x)$ as a polynomial, taking the coefficient of $15$.
A: The generating function for the number of non-negative integral solutions to $a+b+3c=n$ is
$$
f(x)=\frac1{1-x}\frac1{1-x}\frac1{1-x^3}
$$
Since
$$
\begin{align}
(1-x)^{-2}
&=\sum_{k=0}^\infty\binom{-2}{k}(-x)^k\\
&=\sum_{k=0}^\infty\binom{k+1}{k}x^k\\
&=\sum_{k=0}^\infty(k+1)x^k
\end{align}
$$
and
$$
\begin{align}
\left(1-x^3\right)^{-1}
=\sum_{k=0}^\infty x^{3k}
\end{align}
$$
the coefficient of $x^n$ in $f(x)$ is
$$
\begin{align}
\sum_{k=0}^{\lfloor n/3\rfloor}(n-3k+1)
&=(n+1)\left(\lfloor n/3\rfloor+1\right)-\frac32\left(\lfloor n/3\rfloor+1\right)\lfloor n/3\rfloor\\
&=\left(n+1-\frac32\lfloor n/3\rfloor\right)\left(\lfloor n/3\rfloor+1\right)
\end{align}
$$
For $n=15$, we get $51$ ways.
A: One way to solve this is using generating functions. If you multiply $A(z) = \sum_{n \ge 0} a_n z^n$ by $B(z) = \sum_{n \ge 0} b_n z^n$, you get:
$$
A(z) \cdot B(z) 
  = \sum_{n \ge 0} \left(\sum_{0 \le k \le n} a_k b_{n - k}\right) z^n
$$
If $a_n$ is the number of ways of picking $a$ to have value $n$, and similarly for $b$, the coefficient of $z^n$ is the number of combining a value of $a$ and one of $b$ to make up $n$.
For your original example, there is $1$ way to get $a$ (and $b$, $c$) of any particular value, so that:
$$
A(z) = B(z) = C(z)
  = \sum_{n \ge 0} z^n
  = \frac{1}{1 - z}
$$
so that the number of ways to get $n$ is ($[z^n]$ is just shorthand for "get the coefficient of $z^n$"):
$$
[z^n] A(z) \cdot B(z) \cdot C(z)
   = [z^n] \frac{1}{(1 - z)^3}
   = (-1)^n \binom{-3}{n}
   = \binom{n + 3 - 1}{3 - 1}
   = \binom{n + 2}{2}
$$
For the second case you have:
$$
C(z) = 1 + z^3 + z^6 + \dotsb
     = \sum_{n \ge 0} z^{3 n}
     = \frac{1}{1 - z^3}
$$
so here you need:
$\begin{align}
A(z) \cdot B(z) \cdot C(z)
  &= \frac{1}{(1 - z)^2 (1 - z^3)} \\
  &= \frac{1 + 2 z}{9 (1 + z + z^2)}
       + \frac{2}{9 (1 - z)}
       + \frac{1}{3 (1 - z)^2}
       + \frac{1}{3 (1 - z)^3}
\end{align}$
This is just the partial fractions mostly used when integrating.
The first term is troublesome as written. Using complex numbers you can write it as:
$$
\frac{1 + 2 z}{1 + z + z^2}
  = - \frac{\omega}{1 - \omega z}
        - \frac{\omega^2}{1 - \omega^2 z}
$$
Here $\omega = - 1/2 + \mathrm{i} \sqrt{3} /2$ is a cube root of $1$, and $\omega^2 = \overline{\omega}$ is just it's conjugate. As the sum of a complex number and it's conjugate is just twice their real part, this term contributes:
$$
- \omega \cdot \omega^n - \overline{\omega} \cdot \overline{\omega}^n
  = - \omega^{n + 1} - \overline{\omega}^{n + 1}
  = - 2 \Re \left( \omega^{n + 1} \right)
$$
We can write:
$$
\omega = \exp \left( \frac{2 \pi \mathrm{i}}{3} \right)
$$
so that:
$$
\omega^{n + 1}
  = \exp \left( \frac{2 \pi (n + 1) \mathrm{i}}{3} \right)
  = \cos \left( \frac{2 \pi (n + 1)}{3} \right)
      + \mathrm{i} \sin \left( \frac{2 \pi (n + 1)}{3} \right)
$$
and finally the contribution is:
$$
- 2 \Re \left( \omega^{n + 1} \right)
  = - 2 \cos \left( \frac{2 \pi (n + 1)}{3} \right)
$$
Adding the contributions of the other terms gives:
$$
\frac{2}{9} 
  + \frac{1}{3} \binom{n + 2 - 1}{2 - 1} 
  + \frac{1}{3} \binom{n + 3 - 1}{3 - 1}
  - \frac{2}{9} \cos \left( \frac{2 \pi (n + 1)}{3} \right)
  = \\
    \frac{3 n^2  + 15 n + 16}{18} 
      - \frac{2}{9} \cos \left( \frac{2 \pi (n + 1)}{3} \right)
$$
The last expression looks quite weird, but you'll notice that it repeats with period $3$, so you could write this out as three cases depending on the remainder when $n$ is divided by $3$.
OK, back to your specific case now. You asked for a sum of $15$. The number of ways of getting that one is:
$$
\frac{3 \cdot 15^2  + 15 \cdot 15 + 16}{18} 
      - \frac{2}{9} \cos \left( \frac{2 \pi (15 + 1)}{3} \right)
  = 51
$$
