# Revision history [back]

### Decompose polynomial by other irreducible polynomial

Suppose I have irreducible polynomial $v(x)$ over $\mathbb Q$ (or arbitrary field). I want to decompose any other $f(x) \in \mathbb Q[x]$ by powers of $v$. Like this $$f(x)=a_n(v(x))^n + \dots + a_1v(x) + a_0$$

Is there some fast(?) way to do it in Sage except by hand writing your own function?

### Decompose polynomial by other irreducible polynomial

Suppose I have irreducible polynomial $v(x)$ over $\mathbb Q$ (or arbitrary field). I want to decompose any other $f(x) \in \mathbb Q[x]$ by powers of $v$. Like this $$f(x)=a_n(v(x))^n$$f(x)=a_n(x)(v(x))^n + \dots + a_1v(x) a_1(x)v(x) + a_0$$a_0(x)$$

Is there some fast(?) way to do it in Sage except by hand writing your own function?

UPD. I forget to add that $\deg a_i < \deg v$.

### Decompose polynomial by other irreducible polynomial

Suppose I have irreducible polynomial $v(x)$ over $\mathbb Q$ (or arbitrary field). I want to decompose any other $f(x) \in \mathbb Q[x]$ by powers of $v$. Like this $$f(x)=a_n(x)(v(x))^n + \dots + a_1(x)v(x) + a_0(x)$$

Is there some fast(?) way to do it in Sage except by hand writing your own function?

UPD. I forget to add that $\deg a_i < \deg v$.v$. UPD2. Naive solution:  degree = f.degree()//v.degree() decomposition = [None] * (degree + 1) for i in range(degree+1): decomposition[i] = f%v f //= v return decomposition  But may be there is some native solution ### Decompose polynomial by other irreducible polynomial Suppose I have irreducible polynomial$v(x)$over$\mathbb Q$(or arbitrary field). I want to decompose any other$f(x) \in \mathbb Q[x]$by powers of$v$. Like this $$f(x)=a_n(x)(v(x))^n + \dots + a_1(x)v(x) + a_0(x)$$ Is there some fast(?) way to do it in Sage except by hand writing your own function? UPD. I forget to add that$\deg a_i < \deg v$. v$.

UPD2. Naive solution:

  degree = f.degree()//v.degree()
decomposition = [None] * (degree + 1)
for i in range(degree+1):
decomposition[i] = f%v
f //= v
return decomposition


But may be there is some native solution