  In this paper, we design and analyze a novel spectral method for the
subdiffusion equation. As it has been known, the solutions of this equation are
usually singular near the initial time. Consequently, direct application of the
traditional high-order numerical methods is inefficient. We try to overcome
this difficulty in a novel approach by combining variable transformation
techniques with spectral methods. The idea is to first use suitable variable
transformation to re-scale the underlying equation, then construct spectral
methods for the re-scaled equation. We establish a new variational framework
based on the $\psi$-fractional Sobolev spaces. This allows us to prove the
well-posedness of the associated variational problem. The proposed spectral
method is based on the variational problem and generalized Jacobi polynomials
to approximate the re-scaled fractional differential equation. Our theoretical
and numerical investigation show that the proposed method is exponentially
convergent for general right hand side functions, even though the exact
solution has very limited regularity. Implementation details are also provided,
along with a series of numerical examples to show the efficiency of the
proposed method.
