Let $f:[0,1]\rightarrow R$ be a function defined by
$ f(x)= 0 $ if x is irrational
$f(x)$=${1}\over {q^{2}}$ for $x$=${p}\over{ q} $ where $p$ and $q$ are relatively prime
$f(0)=0$
$f(1)=1$
Then is $f$ of bounded variation$?$
If I take partitions of the interval $[0,1]$ as $\{x_{0},x_{1},.......x_{n}\}$ such that $x_{i}$ is irrational for odd $i$ and rational for even $i$. Then $\sum_{1}^{n}|\Delta f_{k} |$=$\sum_{i=1}^{[n/2]}$ ${1}\over {q^{2}} $.Now taking limit $n\rightarrow \infty$ this series is $\sum_{i=1}^{\infty}$${1}\over {n^{2}}$ which is convergent hence bounded by some $M$$\in R$. So by definition of bounded variation this function is of bounded variation. Am I correct? But I did not use the definition of $f$ at $0$ and $1$ .
You can't bound the variation by $\sum \frac{1}{n^2}$, since $f$ attains the value $\frac{1}{n^2}$ multiple times (for $n > 2$), e.g. we have $f\bigl(\frac{1}{6}\bigr) = f\bigl(\frac{5}{6}\bigr) = \frac{1}{6^2}$. Generally, the value $\frac{1}{n^2}$ is attained at each reduced fraction with denominator $n$. A fraction $\frac{k}{n}$ is reduced if and only if $\gcd(k,n) = 1$, and the number of such $k$ not exceeding $n$ is given by Euler's totient function: $f$ attains the value $\frac{1}{n^2}$ exactly $\varphi(n)$ times.
To see that $f$ is of unbounded variation, it suffices to consider the primes. For any finite set $F$ of primes, there are partitions of $[0,1]$ such that all points $\frac{k}{p},\, 1 \leqslant k < p$ with $p\in F$ occur in the partition, and between any two successive such points there occurs an irrational partition point. Thus, for any $x\in (0,+\infty)$, there is a partition with
$$\sum \lvert \Delta f_k\rvert = 2\sum_{p \leqslant x} \frac{p-1}{p^2} \geqslant 2\sum_{p \leqslant x} \frac{1}{p} - 2\sum_{n = 1}^\infty \frac{1}{n^2}.$$
Since
$$\sum_{p \leqslant x} \frac{1}{p} \sim \log \log x$$
(Mertens' second theorem), we see that the variation of $f$ is unbounded.
The values $f(0)$ and $f(1)$ are irrelevant, except that they need to be defined so that we have a function defined on the whole interval $[0,1]$. If a function of bounded variation is changed at finitely many points, the resulting function still has bounded variation - the value of the total variation usually changes, of course.