Finding $f$ with Möbius inversion formula How to find an arithmetic function $f$, when the summatory function $F$ of $f$ is given by
$F(n)=\begin{cases} 1 & \mathrm{if}\  n \mathrm{\ is \ a \ square \ number}  \\ 0 & \mathrm{otherwise} \end{cases}$ 
My idea was to use the Möbius inversion formula:
Let $n$ be a square number. By definiton $F(n)=\sum \limits_{d \vert n}f(d)$, so
$f(n)=\sum \limits_{d \vert n}F(d)\mu(\frac{n}{d})=\sum \limits_{d \vert n}\sum \limits_{d \vert d}f(d)\mu(\frac{n}{d})=\sum \limits_{d \vert d}\sum \limits_{d \vert n}f(d)\mu(\frac{n}{d})$
Since $\sum \limits_{d \vert n}f(d)=1$, I got
$f(n)=\mu(\frac{n}{d})$, so $f=\mu$.
But if I try $F(4)=\sum \limits_{d \vert 4}\mu(d)$, I don't get $1$ as a result. 
Where is my mistake and how to show it right?
 A: Phicar has explained what ought to be done; I’ll explain where your calculations go astray.
The second equality in the chain of equalities is wrong: you can’t use $d$ as the index of summation on the inner sum when it is already in use as the index of summation on the outer sum. You need a different index of summation, e.g., $d'$:
$$\sum_{d\mid n}F(d)\mu\left(\frac{n}d\right)=\sum_{d\mid n}\sum_{d'\mid d}f(d')\mu\left(\frac{n}d\right)\;.$$
It is possible to reverse the order of summation, but it’s a bit tricky. Each value of $d'$ is a divisor of a divisor of $n$, so the indices $d'$ range over the divisors of $n$, and the outer summation will therefore have the form $\sum_{d'\mid n}$. The double summation is over all pairs $\langle d',d\rangle$ such that $d'\mid d\mid n$, so for each $d'$ in what will now be the outer summation we must consider every $d$ such that $d'\mid d\mid n$. Thus,
$$\begin{align*}
\sum_{d\mid n}\sum_{d'\mid d}f(d')\mu\left(\frac{n}d\right)&=\sum_{d'\mid n}\sum_{d'\mid d\mid n}f(d')\mu\left(\frac{n}d\right)\\
&=\sum_{d'\mid n}f(d')\sum_{d'\mid d\mid n}\mu\left(\frac{n}d\right)\\
&=\sum_{d'\mid n}f(d')\sum_{d''\mid\frac{n}{d'}}\mu\left(\frac{n/d'}{d''}\right)\;,
\end{align*}$$
where in the last step $d''=\frac{d}{d'}$. And 
$$\sum_{d''\mid\frac{n}{d'}}\mu\left(\frac{n/d'}{d''}\right)=\begin{cases}
1,&\text{if }\frac{n}{d'}=1\\
0,&\text{otherwise,}
\end{cases}$$
so
$$\sum_{d'\mid n}f(d')\sum_{d''\mid\frac{n}{d'}}\mu\left(\frac{n/d'}{d''}\right)=f(n)\;,$$
as it should: the only non-zero term in the outer summation is the $d'=n$ term.
A: Well i do not understand why you went back to use $f.$ So $$f(n)=\sum _{d|n}F(d)\mu \left (\frac{n}{d}\right )=\sum _{d^2|n}\mu \left (\frac{n}{d^2}\right ).$$ By definition of $F.$ Notice that $\mu$ is going to be zero, unless you take out every prime that has even exponent and all the even part of odd exponents. So at the end you have to end up having $$f(n)=(-1)^{\text{# primes with odd exponent in }n}\neq \mu.$$ Notice that $\mu$ is more restrictive, i.e., the exponent has to be 1.
