#C21.txt: ExpMath(RU), April 5, 2018 ##Note: this is a reconsturced file. I stupidly forgot to save the file done in class Help:=proc(): print(`EvalCFg(A,B), MyPade(f,x,m,n) , PadeExp(f,x,m,n)`): end: #EvalCFg(A,B): evaluates the non-simple continued with numerators B and denominators A s given in Chrystal's book p. 512, Eq. (1) EvalCFg:=proc(A,B) local A1,B1,x: if not (type(A,list) and nops(A)>0) then RETURN(FAIL): fi: if not (type(B,list) and nops(B)>0) then RETURN(FAIL): fi: if nops(A)<>nops(B) then RETURN(FAIL): fi: if nops(A)=1 then RETURN(B[1]/A[1]): fi: A1:=[op(2..nops(A),A)]: B1:=[op(2..nops(B),B)]: x:=EvalCFg(A1,B1): normal(B[1]/(A[1]+x)): end: #MyPade(f,x,m,n): inputs a polynmial (or function) f of x and pos. integers m and n, output the #rational function R whose degree of numerator is m and degree of denominator is n whose Taylor expansion #is the same as f up to m+n terms MyPade:=proc(f,x,m,n) local T,B,t,b,eq,var,i,gu: T:=add(t[i]*x^i,i=0..m): B:=1+add(b[i]*x^i,i=1..n): gu:=taylor(B*f-T,x=0,m+n+1): eq:={seq(coeff(gu,x,i),i=0..m+n)}: var:={seq(t[i],i=0..n), seq(b[i],i=1..m)}: var:=solve(eq,var): if var=NULL then RETURN(FAIL): fi: subs(var,T/B): end: #PadeExp(f,x,m,n): inputs a polynmial (or function) f of x and pos. integers m and n, output the #rational function R of exp(x) , whose degree of numerator is m and degree of denominator is n whose Taylor expansion #is the same as f up to m+n terms PadeExp:=proc(f,x,m,n) local T,B,t,b,eq,var,i,gu: T:=add(t[i]*exp(x*i),i=0..m): B:=1+add(b[i]*exp(x*i),i=1..n): gu:=taylor(B*f-T,x=0,m+n+1): eq:={seq(coeff(gu,x,i),i=0..m+n)}: var:={seq(t[i],i=0..n), seq(b[i],i=1..m)}: var:=solve(eq,var): if var=NULL then RETURN(FAIL): fi: subs(var,T/B): end: