def convert_postfix_list(arr, i=0):
    if (i >= len(arr)):
        raise Exception('Index out of bounds')
    res = convert_postfix(arr[i])
    if (isinstance(res, sympy.Expr) or isinstance(res, sympy.Matrix) or (res is sympy.S.EmptySet)):
        if (i == (len(arr) - 1)):
            return res
        else:
            rh = convert_postfix_list(arr, (i + 1))
            if (res.is_Matrix or rh.is_Matrix):
                return mat_mul_flat(res, rh)
            else:
                return mul_flat(res, rh)
    else:
        wrt = res[0]
        if (i == (len(arr) - 1)):
            raise Exception('Expected expression for derivative')
        else:
            expr = convert_postfix_list(arr, (i + 1))
            return sympy.Derivative(expr, wrt)
def convert_postfix_list(arr, i=0):
    if (i >= len(arr)):
        raise Exception('Index out of bounds')
    res = convert_postfix(arr[i])
    if (isinstance(res, sympy.Expr) or isinstance(res, sympy.Matrix) or (res is sympy.S.EmptySet)):
        if (i == (len(arr) - 1)):
            return res
        else:
            rh = convert_postfix_list(arr, (i + 1))
            if (res.is_Matrix or rh.is_Matrix):
                return mat_mul_flat(res, rh)
            else:
                return mul_flat(res, rh)
    else:
        wrt = res[0]
        if (i == (len(arr) - 1)):
            raise Exception('Expected expression for derivative')
        else:
            expr = convert_postfix_list(arr, (i + 1))
            return sympy.Derivative(expr, wrt)