Well that Mr Ed was one savvy horse & so was that pig on Petticoat Junction.
Seriously, some animals have been taught to count, but I think quadratic equations let alone calculus might be a stretch for them.
A useful thing to teach a smart young dog is to recognise money and retrieve it, I had one friend who got one of those Japanese fighting dogs, but registered it with the local Council as a husky to avoid the complications of them knowing he had one of the breeds they get fussy about.. Like they get fussy about pitbulls. It used to be fun watching local thugs with vicious pitbulls dragging their dogs away from his dog before it munched their pitbulls. He taught, at my suggestion, all his commands for his Japanese dog in Japanese..so for example he used "Yami" as the command for "down".. So any intruder to his property who might try to use " sit", "down" or "go away" on his dog would get nowhere with that crittur.
He also trained an Australian Kelpie to recognise money, coins and notes, and retrieve money and bring it to him. That dog got so well trained with money that Michael could lay out a variety of coins on the floor and tell the Kelpie which coin to bring him..eg the dog learnt which coin was a five cent coin, a ten cent coin, a twenty cent coin, fifty cent coin, one dollar coin and two dollar coin..all Australian coins..an excellent party trick to win bets with. And the dog would literally turn up with money it had found in its wanderings several times each week.