PowerSeriesInversion

From TORI
Jump to navigation Jump to search

PowerSeriesInversion may refer to the case of two quantities, say, \(x\) and \(y\) related through

\( y=a_1x+a_2x^2+a_3x^3+... \)

It is supposed that

\( x=A_1y+A_2y^2+A_3y^3+.... \)

The PowerSeriesInversion may refer also the set of formulas that express the coefficients \(A\) through the coefficients \(a\).

Some of these formulas are collected below.

Explicit formula by Wolfram MathWorld

The Wolfram MathWorld [1] suggests the following relations:

\( A_1 = a_1^{-1} \\ A_2 = -a_1^{-3}a_2 \\ A_3 = a_1^{-5}(2a_2^2-a_1a_3) \\ A_4 = a_1^{-7}(5a_1a_2a_3-a_1^2a_4-5a_2^3) \\ A_5 = a_1^{-9}(6a_1^2a_2a_4+3a_1^2a_3^2+14a_2^4-a_1^3a_5-21a_1a_2^2a_3) \\ A_6 = a_1^{-11}(7a_1^3a_2a_5+7a_1^3a_3a_4+84a_1a_2^3a_3-a_1^4a_6-28a_1^2a_2a_3^2-42a_2^5-28a_1^2a_2^2a_4) \\ A_7 = a_1^{-13}(8a_1^4a_2a_6+8a_1^4a_3a_5+4a_1^4a_4^2+120a_1^2a_2^3a_4+180a_1^2a_2^2a_3^2+132a_2^6-a_1^5a_7-36a_1^3a_2^2a_5-72a_1^3a_2a_3a_4-12a_1^3a_3^3-330a_1a_2^4a_3) \)

Case of a_1=1

\( A_1 = a_1 =1 \\ A_2 = - a_2 \\ A_3 = 2a_2^2-a_3 \\ A_4 = 5a_2a_3-a_4-5a_2^3 \\ A_5 = 6a_2a_4+3a_3^2+14a_2^4-a_5-21a_2^2a_3 \\ A_6 = 7a_2a_5+7a_3a_4+84a_2^3a_3-a_6-28a_2a_3^2-42a_2^5-28a_2^2a_4 \\ A_7 = 8a_2a_6+8a_3a_5+4a_4^2+120a_2^3a_4+180a_2^2a_3^2+132a_2^6-a_7-36a_2^2a_5-72a_2a_3a_4-12a_3^3-330a_2^4a_3 \)

ChatGPT

//ChatGPT suggests the C++ implementation below; it is supposed to be saved as «PowerSeriesInversion.cin»

//
void PowerSeriesInversion(double *a, double *b, int N)
{
    // b[1..N] given
    // compute a[1..N]

    a[1] = 1.0 / b[1];

    for(int n=2; n<=N; n++)
    {
        double sum = 0.0;

        // compute sum_{k=2}^n b_k * C_{n,k}
        for(int k=2; k<=n; k++)
        {
            // compute coefficient of y^n in (A(y))^k
            // by convolution

            // temporary polynomial for A(y)
            double power[N+1] = {0};
            double next[N+1] = {0};

            // initialize power = A(y)
            for(int i=1; i<=n; i++)
                power[i] = a[i];

            // raise to k-th power
            for(int p=2; p<=k; p++)
            {
                for(int i=0;i<=n;i++) next[i]=0.0;

                for(int i=1;i<=n;i++)
                    for(int j=1;j<=n;j++)
                        if(i+j<=n)
                            next[i+j] += power[i]*a[j];

                for(int i=0;i<=n;i++)
                    power[i] = next[i];
            }

            sum += b[k] * power[n];
        }

        a[n] = - sum / b[1];
    }
}
//

Example 1

//
#include <math.h>
#include  <stdio.h>
#include  "PowerSeriesInversion.cin"

int main(){ int n,k; int N=4; int N1=N+1;
double a[N1]; double b[N1];
double f=1; for(n=1;n<N1;n++) {f/=n; b[n]=f;}
printf("before:\n");
for(n=0;n<N1;n++)  printf("%20.16lf",a[n]);
printf("\n");
for(n=0;n<N1;n++)  printf("%20.16lf",b[n]);
printf("\nPowerSeriesInversion(a,b,N):\n");
PowerSeriesInversion(a,b,N);
for(n=0;n<N1;n++)  printf("%20.16lf",a[n]);
printf("\n");
}
//

output:

before:
  0.0000000000000000  0.0000000000000000  0.0000000000000000  0.0000000000000000  0.0000000000000000
  0.0000000000000000  1.0000000000000000  0.5000000000000000  0.1666666666666667  0.0416666666666667
PowerSeriesInversion(a,b,N):
  0.0000000000000000  1.0000000000000000 -0.5000000000000000  0.3333333333333334 -0.2500000000000001

Example 2

// file Arbogast.cin should be also loaded


#include <cmath>
//#include <cstring>  // for memset
#include <stdio.h>
#include "Arbogast.cin"
#include "PowerSeriesInversion.cin"
double B=sqrt(2.); // 1.4142135623730951 
double Q=4.;
double S=log(B);
int main() { int n;
int N=20; int N1=N+1;
double t[N1], a[N1], b[N1],c[N1];
t[0]=4.;
for(n=1;n<N1;n++) t[n]=t[n-1]*S/n;

a[0]=0.;
a[1]=1.;;
for(n=2;n<N1;n++) a[n] = - Arbogast(t, a, n)/( pow(t[1],n)-t[1] );

PowerSeriesInversion(b,a,N);

PowerSeriesInversion(c,b,N);

for(n=0;n<N1;n++) printf("%02d %19.16lf %19.16lf %19.16lf\n",n,b[n],a[n],c[n]);
}
//

does:

00  0.0000000000000000  0.0000000000000000  0.0000000000000000
01  1.0000000000000000  1.0000000000000000  1.0000000000000000
02  0.4485874311952611 -0.4485874311952611 -0.4485874311952611
03  0.1903722467978066  0.2120891200549195  0.2120891200549195
04  0.0778295765369682 -0.1021843675069716 -0.1021843675069716
05  0.0309358603057080  0.0496986830373718  0.0496986830373717
06  0.0120221257690659 -0.0243075903261195 -0.0243075903261195
07  0.0045849888965618  0.0119330883965108  0.0119330883965108
08  0.0017207423310578 -0.0058736976420089 -0.0058736976420089
09  0.0006368109038799  0.0028968672871058  0.0028968672871058
10  0.0002327696003031 -0.0014309081060793 -0.0014309081060793
11  0.0000841455118381  0.0007076637148566  0.0007076637148567
12  0.0000301156464937 -0.0003503296158730 -0.0003503296158732
13  0.0000106807458130  0.0001735756004664  0.0001735756004668
14  0.0000037565713616 -0.0000860610119292 -0.0000860610119299
15  0.0000013111367785  0.0000426959089013  0.0000426959089023
16  0.0000004543791625 -0.0000211930290684 -0.0000211930290696
17  0.0000001564298463  0.0000105244225997  0.0000105244226009
18  0.0000000535232764 -0.0000052285174362 -0.0000052285174370
19  0.0000000182077863  0.0000025984499950  0.0000025984499946
20  0.0000000061604765 -0.0000012917821009 -0.0000012917820980

This output shows good agreement with table 9.1 from page 107 of book «Superfunctions»[2]. The 0th column just numerates the lines. The 2d column shows the coefficients of the expansion of the Koenigs function‎‎ and the Abel function for the exponential to base sqrt(2) at its fixed point 4. The 1st column is calculated from the 2d column with the PowerSeriesInversion routine; these are coefficients of the expansion of the growing SuperExponential and those of the corresponding Schroeder function. The last, 3d column is absent in the book; it is calculated from the 1st column with the same routine PowerSeriesInversion; it is supposed to reproduce the previous (second) column with small rounding errors, and, indeed, it does. Only in the last rows in the last digits the deviation takes place.

Remarks by ChatGPT about Example 2

The routine PowerSeriesInversion is consistent with the coefficients obtained from Arbogast.cin

The double inversion test confirms numerically that the inversion routine behaves as an involution in the algebra of truncated power series.

References

  1. https://mathworld.wolfram.com/SeriesReversion.html Series reversion is the computation of the coefficients of the inverse function given those of the forward function.
  2. https://mizugadro.mydns.jp/BOOK/468.pdf D.Kouznetsov. Superfunctions. Lambert Academic Publishing, 2020.