It is said in my lecture notes that if $f$ is a probability density function, then it must fulfill the condition:
$$\int_{-\infty}^{\infty} f(x)dx = 1$$
But then consider this function $$f(x) = \frac{12.5}{(10+x)^2}$$ when $x \in [0,40]$, and it is evaluated at 0 otherwise.
Then it can be observed when integrating over $[0,40]$, the definite integral is 1. But consider also:
$$12.5\int_{-\infty}^{\infty} f(x)dx = 0$$
Does this disqualify $f$ from being a probability density function? What am I misunderstanding here?
This is a case where good notation might be really helpful. You write
It might be easier to understand what this is saying if you precisely write it down in notation as a piecewise defined function, to wit $$ f(x) = \begin{cases} \frac{12.5}{(10+x)^2} & \text{if $x\in[0,40]$, and} \\ 0 & \text{if $x \in (-\infty,0)\cup(40,\infty)$}. \end{cases} $$ This makes it clear that if we want to do anything with this function, we have to consider what it does on two different sets: the interval $[0,40]$ on which it does something interesting, and the union of intervals $(-\infty,0)\cup(40,\infty)$ on which it is zero.
Integrating this over $\mathbb{R}$, we obtain \begin{align} \int_{-\infty}^{\infty} f(x) \,\mathrm{d}x &= \int_{-\infty}^{0} f(x) \,\mathrm{d}x + \int_{0}^{40} f(x) \,\mathrm{d}x + \int_{40}^{\infty} f(x) \,\mathrm{d}x \tag{1}\\ &= \int_{-\infty}^{0} 0 \,\mathrm{d}x + \int_{0}^{40} \frac{12.5}{(10+x)^2} \,\mathrm{d}x + \int_{40}^{\infty} 0 \,\mathrm{d}x \tag{2}\\ &= 0 + 1 + 0 \tag{3} \\ &= 1. \end{align} In step (1), we are using the additivity of the integral to break it up into an integral over several intervals–the actual function we are integrating is irrelevant. In step (2), we are applying the definition of $f$–it is defined by the rational expression on $[0,40]$, and is zero otherwise. Finally, we evaluate the integrals–here, I am assuming that your work was correct, and recalling that $\int_a^b 0 \,\mathrm{d}x= 0$ for any $a \le b$, where either could be infinite.