Example 2 Find all real roots of the equation $x^{2}-2 x \sin \frac{\pi x}{2}+1=0$.
(1956, Beijing Mathematical Competition)
Text [3] P73 Consider the equation as a quadratic equation with a parameter in the linear term, and directly use the discriminant to solve it. Later, many journals published the solution method using the discriminant for this problem, and then made a "correction" to the "ingenious solution," the main reason being that the original equation is not a quadratic equation, and using the discriminant is completely wrong; the correct conclusion is only a "coincidence." In fact, any expression can be completed by the method of completing the square when needed, and the result of completing the square in Example 2 is still
$$
\text { . }\left(x-\sin \frac{\pi x}{2}\right)^{2}=\sin ^{2} \frac{\pi x}{2}-1 \text {, }
$$

which is exactly $(2 a x+b)^{2}=b^{2}-4 a c$.
Moreover, can't an equation that is not a quadratic equation be treated as a quadratic equation? Can't it be transformed into a quadratic equation? For example, let $k=\sin \frac{\pi x}{2} \in[-1,1]$, and then discuss the parameter $(|k| \leqslant 1)$, and solve the equation. Isn't this something everyone is very familiar with?
For instance, let $x=a$ be a real root of the original equation, then
$$
a^{2}-2 a \sin \frac{\pi a}{2}+1=0 \text {. }
$$

This indicates that $x=a$ is a real root of the quadratic equation
$$
x^{2}-2 x \sin \frac{\pi a}{2}+1=0
$$

At this point, using the discriminant should not be a problem.
$$
\Delta=4 \sin ^{2} \frac{\pi a}{2}-4=4\left(\sin ^{2} \frac{\pi a}{2}-1\right) \geqslant 0,
$$

which means $\sin ^{2} \frac{\pi a}{2} \geqslant 1$.
However, by the range of the sine function, we also have $\sin ^{2} \frac{\pi a}{2} \leqslant 1$.
Therefore, $\sin ^{2} \frac{\pi a}{2}=1$ (necessity).
Substituting into equation (7), we get $x^{2} \pm 2 x+1=0$.
Solving, we get $x= \pm 1$.
Verification shows that $x=a= \pm 1$ satisfies both equation (7) and equation (8) (sufficiency), hence they are all the real roots of the original equation.

This treatment differs from the standard answer only in minor notational differences (introducing $a$). If the essence is understood, this difference is actually superfluous.

For this problem, although independently using the discriminant is reasonable, linking the discriminant with the completed square is simpler.
Solution: From the given (i.e., equation (2))
$$
\left(x-\sin \frac{\pi x}{2}\right)^{2}=\sin ^{2} \frac{\pi x}{2}-1 \text {. }
$$

By the non-negativity of the square of a real number and the range of the sine function, we have $0 \leqslant\left(x-\sin \frac{\pi x}{2}\right)^{2}=\sin ^{2} \frac{\pi x}{2}-1 \leqslant 0$.
Thus, we have $\left\{\begin{array}{l}x=\sin \frac{\pi x}{2}, \\ \sin \frac{\pi x}{2}= \pm 1 .\end{array}\right.$
Therefore, $x=1,-1$ are all the real roots of the original equation.
1.4 Recognizing closure, a solution method for constructing equations for a fill-in-the-blank problem.