In reply to Ke Tang.

The computer code shows the formulas. It is easier if you work with the standard beta distribution on [0,1], then linearly scale it to get the beta distribution on [a,b]. For the beta distribution on [0,1], the mode is at (Alpha-1)/(Alpha+Beta-2). Unfortunately, I don't have time to show you how to derive the formulas. Good luck.