1 | initial version |
What you want to do is not always possible (for instance, if $f$ has lower degree than $v$). But when there exists an answer, what you want is just an inverse image of the polynomial $f$ by the map that sends $x$ to $v(x)$.
this can be done using elimination techniques:
sage: R.<x,t> = QQ[]
sage: v = x^2 + x + 1
sage: f = x^4 + 2*x^3 + 6*x^2 + 5*x + 2
sage: I = R.ideal([t - v, f])
sage: L = I.elimination_ideal(x)
sage: L
Ideal (t^2 + 3*t - 2) of Multivariate Polynomial Ring in x, t over Rational Field
sage: L.gen(0)(t=v) == f
True
In this case there was a solution. When there is not, you will get some polynomial whose image is a multiple of what you wanted.