answered 2 years ago
slelievre's answer is general, and should be kept in mind ; in this specific case, SR has a specific suitable method :
slelievre
SR
sage: a.trig_reduce() tan(x^2 + x + 1)
HTH,