I have been trying to implement a recursive function, but still struggle. Here's what I have written:
Subscript[p, n_] := Subscript[p, n - 1] + (n + 1)*x^n
Subscript[p, 1] = 1
And executing
Subscript[p, 4]
I get
1 + 3 x^2 + 4 x^3 +5 x^4
Now, I tried to define:
Polynom[x_] := Subscript[p, 4]
However, when I try to evaluate
Polynom[4]
I still get the result:
1 + 3 x^2 + 4 x^3 + 5 x^4
So Mathematica didn't replace x with 2 . Can anyone explain to me why or how I can define the function I want so it evaluates for Polynom[4]?
Polynom[x_] = Subscript[p, 4];but it is very important that you understand why this works and its limitations. After reading those Q&A's please let me know if it remains unclear. – Mr.Wizard Jan 08 '15 at 05:08