# Revision history [back]

### substitution not simplifying

I have the following code where everything works fine until eq4 expression where all higher powers of B were simplified, unfortunately with eq5 I can still see higher powers of a like a^48 etc that were not simplified.

B,a,x,y = var('B a x y')
R= (81*x^16 + 40662*x^15 + 14353281*x^14 - 460241028*x^13 - 644722959186*x^12 + 39379675354740*x^11 + 5212980804862026*x^10 - 415546630058854656*x^9 - 8202010485984353739*x^8 + 1396767997483732402758*x^7 - 27550698906220673513787*x^6 - 1044392234943529703379852*x^5 + 60770398462922893831446348*x^4 - 1284453663719469166478575296*x^3 + 14183844641879715988450074288*x^2 - 81800517874945025246941522368*x + 196162341839727571433321441856)- (3240*x^14 + 456840*x^13 + 188268624*x^12 - 45834271200*x^11 - 2435651997264*x^10 + 682353767281968*x^9 - 7053953405575680*x^8 - 2553415737499629216*x^7 + 98906717445152189544*x^6 + 1348117411901578667784*x^5 - 162666175355778441465360*x^4 + 4276857451171442758058304*x^3 - 54456600108308451946891776*x^2 + 350065581968511893813480064*x - 918312303919436410092339456)*y;R
eq1=R.subs({x:((-1274059098685440*a^3+7047835174305792*a+44113368579047424)*B-169384920219648*a^3-9345548188385280*a+19574897567072256)/(358406430916608*B-1094855883227136)});eq1
eq2=eq1.subs({y:((12426511*a^3+80357865*a-284253452)*B-35622605*a^3+277525113*a-163747112)/(775798*B+834670)});eq2
eq3=eq2.simplify_full();eq3
eq4=eq3.subs({B: sqrt(-2)}).subs({sqrt(-2):B});eq4
eq5= eq4.subs({a^4: 5*a^2+32});eq5


Is there a way I can fix this so that the only higher powers of a remaining aren't higher than 3 because of the a^4 substitution.

### substitution not simplifying

I have the following code where everything works fine until eq4 expression where all higher powers of B were simplified, unfortunately with eq5 I can still see higher powers of a like a^48a^6 etc that were not simplified.

B,a,x,y = var('B a x y')
R= (81*x^16 + 40662*x^15 + 14353281*x^14 - 460241028*x^13 - 644722959186*x^12 + 39379675354740*x^11 + 5212980804862026*x^10 - 415546630058854656*x^9 - 8202010485984353739*x^8 + 1396767997483732402758*x^7 - 27550698906220673513787*x^6 - 1044392234943529703379852*x^5 + 60770398462922893831446348*x^4 - 1284453663719469166478575296*x^3 + 14183844641879715988450074288*x^2 - 81800517874945025246941522368*x + 196162341839727571433321441856)- (3240*x^14 + 456840*x^13 + 188268624*x^12 - 45834271200*x^11 - 2435651997264*x^10 + 682353767281968*x^9 - 7053953405575680*x^8 - 2553415737499629216*x^7 + 98906717445152189544*x^6 + 1348117411901578667784*x^5 - 162666175355778441465360*x^4 + 4276857451171442758058304*x^3 - 54456600108308451946891776*x^2 + 350065581968511893813480064*x - 918312303919436410092339456)*y;R
eq1=R.subs({x:((-1274059098685440*a^3+7047835174305792*a+44113368579047424)*B-169384920219648*a^3-9345548188385280*a+19574897567072256)/(358406430916608*B-1094855883227136)});eq1
eq2=eq1.subs({y:((12426511*a^3+80357865*a-284253452)*B-35622605*a^3+277525113*a-163747112)/(775798*B+834670)});eq2
R=x^2+y^2;R
eq1=R.subs({x:((-12*a^3+92*a+24)*B-48*a^3-80*a+6)/(8*B-6)});eq1
eq2=eq1.subs({y:((11*a^3+65*a-52)*B-605*a^3+13*a-12)/(8*B+70)});eq2
eq3=eq2.simplify_full();eq3
eq4=eq3.subs({B: sqrt(-2)}).subs({sqrt(-2):B});eq4
eq5= eq4.subs({a^4: 5*a^2+32});eq5


which gives

 1/4*(7291921*a^6 - 4678952*a^3 + 2*(3424035*a^6 + 1472328*a^3 + 24725813*a^2 + 1819560*a + 106127568)*B - 16*(19639*a^6 - 103688*a^3 + 1003105*a^2 - 163544*a + 8052784)*B - 70791609*a^2 + 10593256*a - 477643380)/(35072*B + 13999)


Is there a way I can fix this so that the only higher powers of a remaining aren't higher than 3 because of the a^4 substitution.