Define custom function in Mathematica