Here is the mathematic derivation of this question.