I have a function defined by its series expansion
$$
\begin{align}
F(\vec{x}=(x_1,\dots x_l);\vec{y}=(y_1,\dots,y_l);q)=\frac{1}{\sum_{k=1}^l y_k}\sum \limits_{j=0}^{\infty} (\prod\limits_{i=1}^{l} x_i)^{j-2}q^j
\end{align}
$$
only and I want to evaluate it for a fixed but high order in $q$ and many different $\vec{x},\vec{y}$.
Therefore I want to tabulate the coefficients of the series expansion for arbitrary $\vec{x},\vec{y}$, save them in a external table and use them for specific values afterwards.
The code I've written is:
(* SETUP *)
MyFunc2Table[myfunc[xlist_,ylist_,var_],upper_]:=Module[{term,newterm},
(* xlist and ylist are lists, var is a symbol, upper an integer *)
(* define expansion term at j-th order *)
term=Apply[Times,xlist]^(j-2)/Apply[Plus,ylist] var^(j);
(* expand to O[var]^upper *)
newterm=0;
Do[newterm=newterm+term,{j,0,upper}];
(* tabulate and export series coefficients *)
Export["myExpansionTable",CoefficientList[Series[newterm,{var,0,upper}],var],"List"];
]
MyFuncFromTable[myfunc[xlist_,ylist_,var_],upper_]:=Module[
{x,y,expansion,coeff}
,
(* xlist and ylist are lists, var is a symbol, upper an integer *)
(* get general expansion coefficents *)
coeff=ToExpression[Import["myExpansionTable","List"]];
(* replace (?!) x[i] and y[i] by it's values *)
x[i_]:=xlist[[i]];
y[i_]:=ylist[[i]];
(* expand in var *)
expansion=Normal[
Series[FromDigits[Reverse[coeff],var],{var,0,upper}]
];
expansion
]
(* Test of the procedures *)
(* Step 1: Save Coefficients for ARBITRARY x[i] and y[i] by fixed length:*)
MyFunc2Table[myfunc[{x[1],x[2]},{y[1],y[2]},Q],3]
(* Step 2: Get a series expansion for SPECIFIC x[i] and y[i] *)
MyFuncFromTable[myfunc[{1,2},{3,4},Q],3]
Q^2/(y[1]+y[2])+1/(x[1]^2 x[2]^2 (y[1]+y[2]))+Q/(x[1] x[2] (y[1]+y[2]))+(Q^3 x[1] x[2])/(y[1]+y[2])
(* The replacement by specific values did not work *)
but it does not work. There seems to be a problem with the correct replacement in the function
MyFuncFromTable[myfunc[{1,2},{3,4},Q],3]
What do I miss? Many thanks in advance for helping me out!
Remark 1:
The function defined above is not my actual function. It is just for the sake of illustration and keeping it simple. my actual problem is the function defined in another question I already asked some time ago.
Get
instead ofImport
andToExpression
? $\endgroup$