substitution not working properly
I have the following code and I want to substitute all B^2=17.
B,x,y= var('B x y')
eq=81*x^16*B^6 + 40662*x^15*B^3 + 14353281*x^14*B^2;eq
eq1=eq.subs({B^2: (17)});eq1
and I get
81*B^6*x^16 + 40662*B^3*x^15 + 244005777*x^14
I am not sure why the substitution didn't bother to simplify B^6=17^3
and B^3=17*B
I also tried using this code which was suggested earlier :
B,x,y= var('B x y')
eq=81*x^16*B^6 + 40662*x^15*B^3 + 14353281*x^14*B^2;eq
eq1=eq.subs({B: sqrt(17)});eq1
which yields
397953*x^16 + 691254*sqrt(17)*x^15 + 244005777*x^14
and I have this sqrt(17)
terms which is not written as B. I need it to be written as B because later on I need to collect the coefficient of B. Perhaps I should use something like while{B^2 : 17} but no idea how to do that.