Two months ago I asked a way to truncate a polynomial to a given degree. @Stitch answered my question by writing a program which contained the following function:
truncate[polynomial_, variable_, maxPower_] :=
Module[{rules},
rules = CoefficientRules[polynomial, {variable}];
Plus @@ (Times[Power[variable, #[[1, 1]]], #[[2]]] & /@
Select[rules, (#[[1, 1]] <= maxPower) &])]
It's good but it works only when the power of the polynomial is positive and/or is a integer number. When the power is not positive and integer, the function CoefficientRules
does not manage to select the coefficient in front of the variable and the output is completly wrong.
Is there a way to generalize this script for any kind of power? In particular I would like to find a way to order polynomial whose variables has generic power alpha
, in such a way that there are expressions like
1+ t^alpha + t^(1 + alpha) + x t^(2 alpha)
So my idea is to tell Mathematica that alpha
is between 0 and 1, and then to truncate the polynomial to a given power I choose. Is this possible in someway?
Basically, the first script is also sufficient because I can just choose a particular value of alpha
and then reverse-engineer to find what was the corresponding power of the polynomial for a generic alpha
. But, if there is also the way to make the script very general, it would be great. I do not know any function in Mathematica which works with real powers, so I do not know how it is possible to generalize CoefficientRules
.
alpha
such asEulerGamma
? $\endgroup$