Hardware/software codesign for mathematical function acceleration