# Reasoning about Degree of Polynomial

Apologies if this is outside of the realm of Mathematica -- I'm still trying to figure out the limits of how expressive Mathematica is (and how much of my work can be automated).

Suppose I define the following:

f[1] = x
f[n_] = x * f[n-1]


for integral k>1, what is the degree of f[k] ?


so for example, I want to write a function:

degreeOf[f, k] = k


Now, I know that in this above example, given that we know how f is defined, it's trivial that degreeOf[f, k] = k. However, is it possible to write generic degreeOf ?

In a sense, I'm curious if the "computational" part of mathematica -- it's ability to handle symbols and do substitutions + simplifications -- or if it can reason about them at a deeper level.

Thanks!

-

Since you have defined your function recursively, you will first need to solve the recurrence equation using RSolve to get the general form.

For example:

F = f /. First @ RSolve[{f[n] == x f[n - 1], f[1] == x}, f, n]
(*  Function[{n}, x^n]  *)

Exponent[F[k], x]
(*  k  *)

-
This is amazing. – user1602 Jul 11 '12 at 22:53

Does Exponent do what you expect from degreeOf[]?

 f = (x^3 + 1)^3 + 1;
Exponent[f, x]
(* ==> 9 *)

-
I did not explain my question well. The point is that I want to get Exponent[f[n], x] WITHOUT knowing n, i.e. I want a symbolic response back of "n". – user1602 Jul 11 '12 at 7:41
@term-rewritica You mean as in Exponent[x^(n - 1) + x^a, x] (=> Max[a,n-1])? Seems Exponent works fine in that case as well. – jVincent Jul 11 '12 at 7:44
term-rewritica, similar to the example in @jVincent's comment, f = (x^n + 1)^3 + 1; Exponent[f, x] gives Max[0, n, 2 n, 3 n]. – kglr Jul 11 '12 at 8:33