Created
October 1, 2013 15:24
-
-
Save tueda/6780199 to your computer and use it in GitHub Desktop.
Series expansions of denominators.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CF den; | |
S x; | |
S a,j,n,x1,x2; | |
S a,b,c; | |
L F1 = den(1-x); | |
L F2 = den(1-x)^2 / x; | |
L F3 = den(a+b*x ); | |
L F4 = den( +b*x+c*x^2); | |
L F5 = den(a+ +c*x^2); | |
L F6 = den(a+b*x+c*x^2); | |
* Expand denominators with respect to x up to O(x^5). | |
#define N "5" | |
label retry; | |
* The next two lines are for simplifying trivial den(x). | |
id den(x?!{0,}) = 1/x; | |
denominators den; | |
* Note that "splitarg ((x)),den" doesn't change den(x). | |
splitarg ((x)),den; | |
* For long arguments, workspace may overflow. | |
*repeat id den(a?,<x1?>,...,<x16?>,?xx) = den(a,<x1>+...+<x16>,?xx); | |
repeat id den(a?,x1?,x2?,?xx) = den(a,x1+x2,?xx); | |
id ifmatch->retry, den(0,x1?) = den(x1/x)/x; * Factor out 1/x. | |
repeat; | |
* ONCE is needed. Otherwise x^-1 * den(1,-x)^2 matches x^-1 * den(1,-x) and x^0 * den(1,-x). | |
id once, x^n? * den(a?,x1?) = x^n * sum_(j,0,`N'-n,sign_(j)*x1^j*(1/a)^(j+1)); | |
if (count(x,1) > `N') discard; | |
endrepeat; | |
B x; | |
P; | |
.end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment