I'm trying to upgrade my class library to my current mathematical skill set and am having trouble with multi-term polynomials, especially those I where I don't know how many terms the user will be putting in. I know that the formula for the first derivative of a polynomial is ax^n = n * ax^n-1; and the second derivative is the derivative of the first derivative. So for example:

Find the derivative of 4x^2:

4x^2 = 2 * 4x^2 - 1 = 8x^2-1 = 8x

Find the second derivative of 4x^3:

4x^3 = 3 * 4x^3-1 = 12x^3-1 = 12x^2

12x^2 = 2 * 12x^2-1 = 24x^2-1 = 24x

Right now I just have an algorithm for the first derivative of a single term polynomial:

```
// Pseudocode (C# Syntax):
public string DerivativeOfPolynomial(int Base, string Variable, int Exponent) {
Base = Exponent * Base;
Exponent = Exponent > 1 ? Exponent - 1 : 0;
Variable = Exponent == 0 ? "" : Variable;
return Base.ToString() + Variable + (Exponent == 0 ? "" : Exponent).ToString();
}
```

Chose to not work on the second derivatives until I figure out the whole parameter problem. I'm sure I have to use arrays or lists to accomplish this, but I'm not sure how the algorithm would work for a polynomial with 3 terms:

3x^2 + 13x + 4

Also the derivative of a constant (basically any number without a variable and exponent of 2 or higher) is equal to 0 for those who don't know.

*Edited 4 Years Ago by lxXTaCoXxl*: Added side note.