Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Calculate the coefficient of series P(x)/Q(x) in front of x^n, where P(x) and Q(x) are polynomials in x
ResourceFunction["PolynomialRatioSeriesCoefficient"][p,q,x,n] Calculates the coefficient of series |
The coefficient in front of x5 of series expansion of is 8:
In[1]:= | ![]() |
Out[1]= | ![]() |
Get the same result with PolynomialRatioSeriesCoefficient:
In[2]:= | ![]() |
Out[2]= | ![]() |
PolynomialRatioSeriesCoefficient supports symbolic computation:
In[3]:= | ![]() |
Out[3]= | ![]() |
Attempting to find a faraway coefficient of a recursive function, is time consuming with RecurrenceTable:
In[4]:= | ![]() |
Out[4]= | ![]() |
For a faster solution, first find the generating function:
In[5]:= | ![]() |
Out[5]= | ![]() |
In[6]:= | ![]() |
Out[6]= | ![]() |
Then use PolynomialRatioSeriesCoefficient to find a very faraway coefficient:
In[7]:= | ![]() |
Out[7]= | ![]() |
PolynomialRatioSeriesCoefficient returns the same value as SeriesCoefficient
In[8]:= | ![]() |
Out[8]= | ![]() |
In[9]:= | ![]() |
Out[9]= | ![]() |
However PolynomialRatioSeriesCoefficient is much faster for large orders:
In[10]:= | ![]() |
Out[10]= | ![]() |
In[11]:= | ![]() |
Out[11]= | ![]() |
Find out how many ways exist to represent 4000 as different sums of numbers {2,3,5}:
In[12]:= | ![]() |
Out[12]= | ![]() |
Same result can be obtained much faster using generating function method and PolynomialRatioSeriesCoefficient:
In[13]:= | ![]() |
Out[13]= | ![]() |
PolynomialRatioSeriesCoefficient can calculate for large numbers quickly:
In[14]:= | ![]() |
Out[14]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License