PowerSeriesInversion
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_1^3a_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 following C++ implementation:
//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
References
- ↑ https://mathworld.wolfram.com/SeriesReversion.html Series reversion is the computation of the coefficients of the inverse function given those of the forward function.
Keywords
«Asymptotic», «ChatGPT», «Power series», «PowerSeriesInversion», «Wolfram MathWorld»,