Why does the product of $\sin ^2(\pi x)$ and $ \sum _{i=1}^4 \cot ^2 (\frac{\pi x}{i} )$ with the singularities of the later produce a continuous function?
The function
$\sin ^2(\pi x)\,\,\,\,\,(1)$
produces zero's for some values and the function
$ \sum _{i=1}^4 \cot ^2\left(\frac{\pi x}{i}\right)\,\,\,\,\,(2)$
produces singularities for some values of $\cot ^2\left(\frac{\pi x}{i}\right)$.
How can for example $\sin ^2(\pi x) \sum _{i=1}^4 \cot ^2 (\frac{\pi x}{i} )$ give approximately at $x=2$ $y=5$, $x=3$ $y=10$, $x=4$ $y=20$ when plotted?
How is this worked out in each case?
Should not an infinity times a zero equal zero?
At $x=4$ for example $\sum _{i=1}^4 \cot ^2 (\frac{\pi x}{i} )$ give infinity + infinity + infinity + $\frac{1}{3}$, then times $\sin ^2(\pi 4)$ which somehow produces 20.
What is happening is that you have a function $f(x)$ which has singularities and another function $g(x)$ which has zeros at those singularities, in such a way that $g(x)f(x)$ has what are called removable singularities. These are points where, strictly speaking, the function is undefined, yet there is a consistent way to modify the definition of the function at the singularities such that it becomes continuous.
Infinity times zero is an indeterminate form, for the same reason that infinity divided by infinity is indeterminate. This means that it can take any value whatsoever, depending on how infinity and zero are approached.
For example, both $x$ and $x^2$ tend to $0$ as $x\to 0$, and likewise both $1/x$ and $1/x^2$ tend to $\infty$ as $x\to 0$, however by multiplying together these functions we can obtain three different behaviors: $$ x\cdot 1/x $$ tends to $1$ as $x\to 0$, $$ x^2\cdot 1/x $$ tends to $0$ as $x\to 0$, $$ x\cdot 1/x^2 $$ tends to $\infty$ as $x\to 0$.
Thus, whenever we encounter infinity times zero expressions, in order to continue we need to compare how quickly the infinity is approached and how quickly the zero is approached. It's a tug of war...
Now you asked how the value is determined, in the case of a removable singularity. It's actually the same as asking how to calculate a limit, in general - since any limit can appear in such a question. In your case, the functions are nice enough that we can calculate the limits directly: for each $i=1,\ldots,4$
$$\sin^2(\pi x)\cdot \cot^2(\pi x/i)=\cos^2(\pi x/i)\cdot \left(\frac{\sin(\pi x)}{\sin (\pi x/i)}\right)^2$$
The only places where there can be a singularity is when the denominator $\sin(\pi x/i)$ equals $0$, which occurs whenever $x=in$ for some integer $n$. Thus to answer your question, it will suffice to find $$ \lim_{x\to in}\frac{\sin(\pi x)}{\sin (\pi x/i)}. $$ Since both the numerator and denominator tend to $0$, we may apply this rule to obtain that $$ \lim_{x\to in}\frac{\sin(\pi x)}{\sin (\pi x/i)}= \lim_{x\to in}\frac{\pi\cos(\pi x)}{\tfrac{\pi}{i}\cos (\pi x/i)}=\frac{\pi (-1)^{in}}{\tfrac{\pi}{i}(-1)^n}=i(-1)^{(i-1)n}, $$ where we have taken the derivative in the first step, calculated the limit in the second step by plugging $x=in$ into the cosines, and then did some algebraic simplification in the last step.
Thus, $$ \lim_{x\to in}\sin^2(\pi x)\cot^2(\pi x/i)=\cos^2(\pi n)\cdot \bigl(i(-1)^{(i-1)m}\bigr)^2=i^2, $$ whereas when $m$ is an integer that is not a multiple of $i$, we have that $$ \lim_{x\to m}\sin^2(\pi x)\cot^2(\pi x/i)=\sin^2(\pi m)\cot^2(\pi m/i)=0 $$ since there is no singularity in the second factor (and the first factor is zero).
As a result, your function takes the following values: $$ x=2\colon y=1^2+2^2,\qquad x=3\colon y=1^2+3^2,\qquad x=4\colon y=1^2+2^2+4^2, $$ notice in each case that it is the sum of the squares of the divisors.