# it converts y to sum; # tosum(y_,x_,a_,n_,x_):= Block(p:=sum(D(y_,x_,j)*xx^j/j!, j,1,n_ ,1), Replace(Replace(p,x_,a_),xx,x)); tosum(y_,x_):= if(isfunction(y),infsums(d(y,x,0,k)*x^k/(k!),k)); tosum(a_*y_,x_):= If(not(isfunction(a)), a*tosum(y,x), If(not(isfunction(y)), y*tosum(a,x) )); tosum(a_+y_,x_):= If(isfree(a,x), a+tosum(y,x), If(isfree(y,x), tosum(a,x)+y,tosum(a,x)+tosum(y,x) )); tosum(-y_,x_):= -tosum(y,x); tosum(x_,x_):=x; tosum(a_+b_):= If(not(isfunction(a)), a+tosum(b), tosum(a)+tosum(b)); tosum(a_*b_):= If(not(isfunction(a)), a*tosum(b), If(not(isfunction(b)), b*tosum(a), tosum(a)*tosum(b) )); tosum(-y_):= -tosum(y); tosum(d(y_,x_)):= d(tosum(y),x); tosum(d(y_,x_,n_)):= d(tosum(y),x,n); tosum(integrate(y_,x_)):= integrate(tosum(y),x); tosum(d(f(x_),x_,v_)):= lims(gamma(v+1)/delta*infsums((-1)^j/(gamma(j+1)*gamma(v-j+1))*f(x-delta*j),j), delta=0); tosum(Sophomore(x_)):= infsum1s((-1)^k*k^(-k),k)*GammaQ(x); tosum(Sophomore2(x_)):= infsum1s(k^(-k),k)*GammaQ(x); tosum(Cl(a_,x_)):= infsum1s(sin(k*x)/k^a,k); tosum(Ein(x_)):= -infsum1s((-1)^k*x^k/(k*k!),k); tosum(Ei(x_)):= gamma+log(x)+infsum1s(x^k/(k*k!),k); tosum(beta(x_)):= infsums((-1)^k/(2k+1)^x, k); tosum(zeta(x_)):= infsum1s(k^(-x), k); tosum(zeta(a_,x_)):= infsums((k+x)^(-a), k); tosum(zeta(a_,x_,c_)):= sums((k+x)^(-a), k,0,c-1); tosum(eta(x_)):= -infsum1s((-1)^k*k^(-x), k); tosum(eta(a_,x_)):= -infsums((-1)^k*(k+x)^(-a), k); tosum(eta(a_,x_,c_)):= -sums((-1)^k*(k+x)^(-a), k,0,c-1); tosum(mittag(a_,x_)):= infsums(x^k/((a*k)!), k); tosum(mittag(a_,b_,x_)):= infsums(x^k/gamma(a*k+b), k); tosum(polylog(a_,x_,b_)):= infsum1s(x^k/k^a*gamma(a,b*k)/gamma(a), k); tosum(polylog(a_,x_)):= infsum1s(x^k/k^a, k); tosum(L(x_,s_,a_)):= infsums(x^k/(a+k)^s, k); tosum(L(x_,s_)):= infsum1s(x^k/(k)^s, k); tosum(psi(n_,x_)):= -(-1)^n*n!*infsums(1/(k+x)^(n+1),k); tosum(psi(x_)):= gamma-infsums(1/(k+x),k); tosum(erf(x_)) := 2* infsums((-1)^k* x^(1 + 2 k)/((1 + 2 k)* k!),k)/sqrt(pi); tosum(erfi(x_)) := 2* infsums(x^(1 + 2 k)/((1 + 2 k)* k!),k)/sqrt(pi); tosum(harmonic(x_)):=sums(1/k,k,1,x); tosum(harmonic(a_,x_)):=sums(1/k^a,k,1,x); tosum(Gamma(a_,x_)):=Gamma(a)*exp(-x)*sums(x^k/(k!),k,0,a-1); tosum(Gamma(a_)):=Gamma(a,y)*exp(y)/sums(y^k/(k!),k,0,a-1); tosum(En(a_,x_)):=x^(a-1)*Gamma(1-a)*exp(-x)*sums(x^k/(k!),k,0,-a); tosum(En(1,x_)):= -gamma-log(x)-infsum1s((-1)^k*x^k/(k*k!),k); #tosum(erf(x_)):= 1-exp(-x^2)/x/sqrt(pi)*infsums((-1)^k*(2k-1)!!/(2x^2)^k,k); tosum(exp(x_)):= infsums(x^k/(k!),k); tosum(li(n_,x_)):=infsum1s(x^k/k^n,k); tosum(log(x_)):= -infsum1s((1-x)^k/k,k); #tosum(log(1+x_)):= -infsum1s((-1)^k*x^k/k,k); #tosum(log(1-x_)):= -infsum1s(x^k/k,k); tosum(sin(x_)):= infsums((-1)^k*x^(2k+1)/((2k+1)!),k); tosum(cos(x_)):= infsums((-1)^k*x^(2k)/((2k)!),k); tosum(tan(x_)):= infsums(k*x^(2k+1)/((2k+1)!!),k); tosum(sec(x_)):= infsums(x^(2 k)* Euler(2 k)/((2k)!),k); tosum(si(x_)):= infsums((-1)^k*x^(2k+1)/((2k)!),k); tosum(ci(x_)):= infsums((-1)^k*x^(2k)/((2k-1)!),k); #tosum(asin(x_)):= infsum1s(x^(1 + 2 k)*(2k-1)!!/((2k)!!*(2k+1)),k)+x; tosum(asin(x_)):= infsums((2k-1)!!/((2k)!!*(2k+1))*x^(2k+1),k); tosum(acos(x_)):= pi/2-infsums(x^(1 + 2 k)*(2k-1)!!/((2k)!!*(2k+1)),k); #tosum(acos(x_)):= pi/2-infsums(x^(1 + 2 k)*pochhammer(1/2,k)/(k! + 2 k* k!),k); tosum(atan(x_)):= infsums((-1)^k*x^(2k+1)/(2k+1),k); tosum(acot(x_)):= pi/2-infsums((-1)^k*x^(2k+1)/(2k+1),k); tosum(sinh(x_)):= infsums(x^(2k+1)/((2k+1)!),k); tosum(cosh(x_)):= infsums(x^(2k)/((2k)!),k); tosum(tanh(x_)):= -2*infsums((-1)^k*exp(2k*x),k); tosum(shi(x_)):= infsums(x^(2k+1)/((2k)!),k); tosum(chi(x_)):= infsums(x^(2k)/((2k-1)!),k); tosum(asinh(x_)):= infsums((-1)^k*(2k-1)!!/((2k)!!*(2k+1))*x^(2k+1),k); tosum(atanh(x_)):= infsums(x^(2k+1)/(2k+1),k); #tosum((1+x_)^n_):= when(abs(x)<1,infsums(binomial(n,k)*x^k), when(abs(x)>1, infsums(binomial(n,k)/x^k)*x^n )); tosum((1+x_)^n_):= infsums(binomial(n,k)*x^k,k); tosum((-1+x_)^n_):= (-1)^n*infsums(binomial(n,k)*(-x)^k,k); #tosum((1+x_)^n_):= if(n== -0.5, infsums((-1)^(2k+1)*(2k-1)!!/((2k)!!)*x^k), if(n==0.5, 1+infsum1s((-1)^(2k+1)*(2k-3)!!/((2k)!!)*x^k), infsums(binomial(n,k)*x^k,k) )); #tosum((1-x_)^n_):= if(n== -0.5, infsums((2k-1)!!/((2k)!!)*x^k), if(n==0.5, 1-infsum1s((2k-3)!!/((2k)!!)*x^k), infsums(binomial(-n,k)*x^k,k) )); tosum(1/(-1+x_)):= -infsums(x^k,k); tosum(1/(1-x_)):= infsums(x^k,k); tosum(1/(1+x_)):= infsums((-x)^k,k); tosum((-1+x_^n_)/(-1+x_)):=sums(x^k,k,0,n-1); tosum((1-x_^n_)/(1-x_)):=sums(x^k,k,0,n-1); tosum(sqrt(x_)):=tosum(x^(1/2)); tosum(cbrt(x_)):=tosum(x^(1/3)); tosum(1/(e^x_-1)):=infsums(exp(-k*x),k); tosum(e^(x_)):= infsums(x^k/(k!),k); tosum(e^(x_)*x_):= infsums(x^k/k!,k)*x; tosum(e^(x_)*x_^n_):= infsums(x^k/k!,k)*x^n; tosum(e^(a_*x_)*x_^n_):= infsums((a*x)^k/k!,k)*x^n;