Describe the mathematical formulation of self-attention and explain how its computational complexity scales with sequence length.