The big limitation to using any sort of math functions, arbitrary or otherwise, with an AIML bot is that the AIML “language” is actually nothing more than a database schema, and trying to do math with a database is a little like using laundry hampers to make music. Sure, it’s possible, but not very practical.
In order to have a chatbot that both uses AIML categories and do math, you really need an interpreter that can do the math separately, and then inject the math results back into the input stream. If the AIML interpreter can handle custom AIML tags (such as <add>, <subtract>, <multiply> etc.), then some pretty amazing things can be accomplished. Program O is designed to handle such custom tags, but in order to use them, you need to write PHP functions to parse them. This isn’t incredibly hard, mind you, but it’s not exactly beginner’s level stuff, either.