Have you ever done research mathematics? To me, the only difference between code and math is that the code can do things, make stuff happens in the world; outside of that, mathematics has a lot more opportunities to be beautiful (not to say that there isn't beautiful code, but the beauty is not central in the way it often is in mathematics).