Horsepower is calculated using a mathematical formula: horsepower = torque x rpm / 5252. This formula takes into account both the amount of torque an engine produces and how quickly it can rotate.