@smichr , as we discussed some time back, I have tried implementing this function with series.
However at line 40, I would like to do return temp + Order(variable ** 6).
But it gives an error of 'Maximum recursion depth reached', so does doing 
temp = series((xin + yin) ** expr.exp, xin).expand().subs(xin, variable).subs(yin, variable2) at line 38! Any idea how I can add O(x ** 6) to temp to get the output right?