In your first example, while I'd prefer with for the preposition, they are both acceptable, and are both interchangeable. Gerunds and infinitives generally function similarly, although sometimes changes in syntax are required. The one you chose will be based on which best fits into the rhythm or voice of your writing.
The second set of examples are a bit more problematic. First of all, unless I'm misunderstanding, the verb should be processes.
The system process processes A [in order] to obtain B, containing C.
The system process processes A [in order] to obtain B, which contains C.
The problem here is that you have a restrictive clause--i.e. one that is needed to modify the word it identifies, which in this case is B--so the appropriate relative pronoun is which, not that. Always use which for restrictive clauses and that for non-restrictive clauses.
Also, in the first of these, containing C is a participial phrase in the present tense. It's also modifying B.
In both cases you need a comma after obtain B, and [result] B is being modified by each.
Sometimes the gerund and infinitive forms are interchangeable; sometimes they are not. Your examples above ("travelling", "dancing", "getting") are all examples of interchangeable usage. Here are examples where interchanging alters the meaning of the sentence:
"Travelling" vs "to travel":
- He remembered travelling to Canada. (He has traveled to Canada, and
now remembers that.)
- He remembered to travel to Canada. (He was supposed to go to Canada, and then he did.)
"Dancing" vs "to dance":
- She stopped dancing. (She never danced again.)
- She stopped to dance. (She interrupted an activity to begin dancing.)
How do you know when the gerund and infinitive are interchangeable? Generally, gerunds are best for talking about completed actions, and infinitives are best for talking about incomplete or future actions.
Gerund: I was getting up earlier last week. (The getting up already heppened.)
Infinitive: I want to get up earlier. (The getting up hasn't happened yet.)
Still, knowing which form to use requires some memorization and intuition. Here is a list of common verbs from http://www.gingersoftware.com/content/grammar-rules/verbs/gerunds-and-infinitives/:
Followed by a gerund:
admit, advise, avoid, be, used to, can’t help, can’t stand, consider, deny, discuss, dislike, end up, enjoy, feel like, finish, forget, get used to, give up, go on, have difficulty, have problems, have trouble, imagine, it’s no use, it’s worthwhile, keep, look forward to, mention, mind, miss, recommend, remember, quit, spend time, stop, suggest, understand, waste time, work at
Followed by either a gerund or an infinitive without causing a change in meaning:
begin, continue, hate, intend, like, love, prefer, start
Followed by a gerund or infinitive but with a change in meaning:
forget, remember, stop
Followed by an infinitive:
afford, agree, appear, arrange, ask, care, decide, demand, expect, fail, forget, hope, learn, manage, mean, offer, plan, prepare, pretend, promise, refuse, remember, seem, stop, volunteer, wait, want, wish
Followed by a noun or pronoun and then by an infinitive:
advise, allow, ask, cause, challenge, command, convince, expect, forbid, force, hire, instruct, invite, order, pay, permit, program, remind, teach, tell, urge, want, warn
Best Answer
In terms of grammar, either form is perfectly acceptable. The preferred usage will certainly vary by region, but in my personal experience, the gerund is definitely the more common form, whereas the infinitive can often sound dated and awkward. However, I have certainly heard the infinitive used well, especially in more formal contexts.