[series] Fix a gruntz problem.
[series] Fix a gruntz problem.

The basic problem is that e.g. sin(x + sqrt(y)).series(y) returns
non-sensical results, because it tries to do a taylor expansion.

The gruntz algorithm uses certain generalised series expansions which are
allowed (and indeed required) to contain fractional exponents. Producing these
for more or less arbitrary functions seems hard.

Instead, we adapt the `rewrite' function to try and avoid creating fractional
powers. Since this function is free to choose the function in terms of which it
rewrites the expression, this is always possible (provided no irrational
exponents occur). This effectively resolves the problem, since the
above-mentioned problematic series expansions no longer occur.

It is necessary to adapt the function calculate_series, since in certain
pathological cases avoiding the fractional exponents can mean that expanding
to 8th order is not sufficient.

There does not seem to be a satisfactory way to test these changes. The
behaviour of `rewrite` depends on the ordering of the dummys in a dict
it is passed.

toolforger/sympy,drufat/sympy,maniteja123/sympy,iamutkarshtiwari/sympy,bukzor/sympy,shikil/sympy,dqnykamp/sympy,yashsharan/sympy,Mitchkoens/sympy,Arafatk/sympy,bukzor/sympy,yukoba/sympy,farhaanbukhsh/sympy,jbbskinny/sympy,wyom/sympy,cswiercz/sympy,pandeyadarsh/sympy,Titan-C/sympy,ahhda/sympy,hargup/sympy,kmacinnis/sympy,shikil/sympy,meghana1995/sympy,meghana1995/sympy,atreyv/sympy,shipci/sympy,kaushik94/sympy,dqnykamp/sympy,kumarkrishna/sympy,grevutiu-gabriel/sympy,ChristinaZografou/sympy,aktech/sympy,garvitr/sympy,jaimahajan1997/sympy,kaushik94/sympy,jamesblunt/sympy,Davidjohnwilson/sympy,meghana1995/sympy,postvakje/sympy,hargup/sympy,lindsayad/sympy,asm666/sympy,sahilshekhawat/sympy,liangjiaxing/sympy,sahilshekhawat/sympy,garvitr/sympy,abloomston/sympy,emon10005/sympy,toolforger/sympy,Arafatk/sympy,AunShiLord/sympy,vipulroxx/sympy,MridulS/sympy,atsao72/sympy,lidavidm/sympy,madan96/sympy,MechCoder/sympy,Sumith1896/sympy,saurabhjn76/sympy,hrashk/sympy,Davidjohnwilson/sympy,moble/sympy,oliverlee/sympy,kmacinnis/sympy,AkademieOlympia/sympy,MechCoder/sympy,oliverlee/sympy,souravsingh/sympy,moble/sympy,sahmed95/sympy,Mitchkoens/sympy,MridulS/sympy,abloomston/sympy,hrashk/sympy,pbrady/sympy,cccfran/sympy,kaichogami/sympy,kaichogami/sympy,Designist/sympy,wanglongqi/sympy,AkademieOlympia/sympy,jamesblunt/sympy,Curious72/sympy,kmacinnis/sympy,emon10005/sympy,beni55/sympy,mcdaniel67/sympy,sahmed95/sympy,yashsharan/sympy,VaibhavAgarwalVA/sympy,VaibhavAgarwalVA/sympy,mcdaniel67/sympy,lindsayad/sympy,jbbskinny/sympy,abhiii5459/sympy,emon10005/sympy,Sumith1896/sympy,diofant/diofant,debugger22/sympy,atreyv/sympy,sampadsaha5/sympy,jaimahajan1997/sympy,asm666/sympy,beni55/sympy,MechCoder/sympy,ga7g08/sympy,pbrady/sympy,cccfran/sympy,Arafatk/sympy,liangjiaxing/sympy,wyom/sympy,Shaswat27/sympy,wanglongqi/sympy,hrashk/sympy,postvakje/sympy,jbbskinny/sympy,chaffra/sympy,liangjiaxing/sympy,wyom/sympy,Vishluck/sympy,Designist/sympy,kaichogami/sympy,farhaanbukhsh/sympy,flacjacket/sympy,hargup/sympy,beni55/sympy,lidavidm/sympy,rahuldan/sympy,amitjamadagni/sympy,yukoba/sympy,jerli/sympy,vipulroxx/sympy,postvakje/sympy,abloomston/sympy,drufat/sympy,sunny94/temp,ChristinaZografou/sympy,cswiercz/sympy,MridulS/sympy,kevalds51/sympy,sunny94/temp,jaimahajan1997/sympy,AunShiLord/sympy,sampadsaha5/sympy,skidzo/sympy,aktech/sympy,skidzo/sympy,ahhda/sympy,abhiii5459/sympy,Titan-C/sympy,lindsayad/sympy,souravsingh/sympy,kumarkrishna/sympy,skidzo/sympy,srjoglekar246/sympy,oliverlee/sympy,kumarkrishna/sympy,iamutkarshtiwari/sympy,Shaswat27/sympy,jerli/sympy,madan96/sympy,abhiii5459/sympy,Davidjohnwilson/sympy,sampadsaha5/sympy,shipci/sympy,wanglongqi/sympy,Sumith1896/sympy,pandeyadarsh/sympy,bukzor/sympy,madan96/sympy,chaffra/sympy,jerli/sympy,cccfran/sympy,Titan-C/sympy,sahilshekhawat/sympy,drufat/sympy,maniteja123/sympy,toolforger/sympy,VaibhavAgarwalVA/sympy,jamesblunt/sympy,moble/sympy,mafiya69/sympy,aktech/sympy,debugger22/sympy,vipulroxx/sympy,AunShiLord/sympy,atsao72/sympy,shikil/sympy,debugger22/sympy,ga7g08/sympy,Gadal/sympy,ga7g08/sympy,chaffra/sympy,lidavidm/sympy,yukoba/sympy,Designist/sympy,dqnykamp/sympy,sunny94/temp,farhaanbukhsh/sympy,rahuldan/sympy,maniteja123/sympy,pandeyadarsh/sympy,Vishluck/sympy,kaushik94/sympy,amitjamadagni/sympy,yashsharan/sympy,Gadal/sympy,ahhda/sympy,mafiya69/sympy,Curious72/sympy,atsao72/sympy,mcdaniel67/sympy,garvitr/sympy,grevutiu-gabriel/sympy,grevutiu-gabriel/sympy,sahmed95/sympy,kevalds51/sympy,Mitchkoens/sympy,saurabhjn76/sympy,atreyv/sympy,Shaswat27/sympy,AkademieOlympia/sympy,pbrady/sympy,Curious72/sympy,Vishluck/sympy,mafiya69/sympy,asm666/sympy,iamutkarshtiwari/sympy,skirpichev/omg,rahuldan/sympy,ChristinaZografou/sympy,souravsingh/sympy,Gadal/sympy,cswiercz/sympy,shipci/sympy,kevalds51/sympy,saurabhjn76/sympy