Which collection is best to do mathematical operation on it?

I want to make a program to take derivatives of a given function. I want to take the function from the command-line, analyze the function and separate the terms, take the derivative of each one, and display it. My question is what would be the best collection to use for this? I will give each term a slot in some collection, and run methods like hasACoefficent(), hasAnExponent(), etc to analyze the term after separating them. Then use a differentiate method on each term. Then probably go through the collection and set the answer. What do you guys think would be the best collect to do so with? ArrayList? Array(I would prefer something dynamic though)? HashMap? Can anyone give me an opinion please? Thanks.