Rational functions Polynomial expansion.....[partfrac or cpartfrac]:
08-20-2015, 09:57 AM (This post was last modified: 08-24-2015 01:58 AM by toshk.)
Post: #1
 toshk Member Posts: 194 Joined: Feb 2015
Rational functions Polynomial expansion.....[partfrac or cpartfrac]:
coded to Solve!
Prime Solve!
Don't have Hp prime to test it......but works on virtual fine.

PHP Code:
#pragma mode( separator(.,;) integer(h32) )Residue1();Residue2();#casResidues(f)BEGINlocal n,a,ms,M1,denm, numm, m:=0;L1:={};L0:={};L3:={};L4:={};L2:={};f:=exact(f);f1:=numer(f);f2:=denom(f);numm:=coeff(numer(expand(f)));denm:=coeff(denom(expand(f)));IF degree(numm)>=degree(denm) THEN a:=quo(numm,denm); else a:=0;END;M1:=proot(denm);M1:=sort(M1);ms:=size(M1);L0:=(mat2list(M1));A:=0;B:=1;REPEAT ms:=size(L0); L2:=remove(L0(1),L0); ms2:=size(L2);A:=ms-ms2;IF A==1 OR A==0 then Residue1();else Residue2();end;UNTIL size(L0)==0;msgbox("F(x)=(r1/(x-p1))+(r2/x-p2)+.....+K[polynomial]");msgbox("if p1=p2=!p3,then F(x)=(r1/(x-p1)^2)+r2/(x-p2)+r3/(x-p3)+....+K[polynomial]");return{r=list2mat(L4,1),p=trn(M1),k=a};END;#end#casResidue1()BEGINlocal n,fa,derf,derfa; derf:=diff(f2,x);fa:=subst(f1,x=L0(1));derfa:=subst(derf,x=L0(1));n:=fa/derfa;L4(B):=n;B++;L0:=L2;END;#end#casResidue2()BEGINlocal n,ffa,c,ff1,ff2;c:=A;ff2:=subst(simplify(f*(x-L0(1))^c),x,L0(1)); L4(B):=ff2; B++;ff1:=simplify(f*(x-L0(1))^c);FOR n FROM 1 TO A-1 STEP 1 DOff1:=simplify(diff(ff1,x));ffa:=1/(A-1)!*subst(ff1,x=L0(1));L4(B):=ffa;B++;end;L0:=L2;END;#end
08-20-2015, 11:33 AM
Post: #2
 roadrunner Senior Member Posts: 417 Joined: Jun 2015
RE: Rational functions.....partfac( ):
Shouldn't it be partfrac()?

partfrac(((x^4+x^3-2*x^2+x+1)/(x^5+2*x^2+7*x+1/2))) -->
(2*x^4+2*x^3-4*x^2+2*x+2)/(2*x^5+4*x^2+14*x+1)
08-20-2015, 03:30 PM
Post: #3
 Aries Member Posts: 158 Joined: Oct 2014
RE: Rational functions.....partfac( ):
Try using partfrac() or cpartfrac() (the last for the complex field) ;-)
08-20-2015, 05:52 PM (This post was last modified: 08-20-2015 05:53 PM by Tim Wessman.)
Post: #4
 Tim Wessman Senior Member Posts: 2,281 Joined: Dec 2013
RE: Rational functions Polynomial expansion.....[partfrac or cpartfrac]:
Works here for me.

There was an issue with c/partfrac in the current release bernard fixed a while back as a result of another thread where having an approximate value wasn't happy in c/partfrac. Apparently it was not keeping the approximate values grouped nicely. Basically, for the moment keep floats out and everything is happy.

TW

Although I work for HP, the views and opinions I post here are my own.
08-21-2015, 05:35 AM (This post was last modified: 08-24-2015 01:50 AM by toshk.)
Post: #5
 toshk Member Posts: 194 Joined: Feb 2015
RE: Rational functions Polynomial expansion.....[partfrac or cpartfrac]:

08-24-2015, 01:56 AM (This post was last modified: 08-24-2015 02:38 AM by toshk.)
Post: #6
 toshk Member Posts: 194 Joined: Feb 2015
RE: Rational functions Polynomial expansion.....[partfrac or cpartfrac]: ilaplace()
Use this in conjunction with ilaplace() which Prime finds difficult to solve:
PHP Code:
#pragma mode( separator(.,;) integer(h32) )Residue1();Residue2();#casResidues(f)BEGINlocal n,a,ms,ms2,M1,denm, numm;L0:={};L4:={};L2:={};f:=exact(f);f1:=numer(f);f2:=denom(f);numm:=coeff((expand(f1)));denm:=coeff((expand(f2)));IF degree(numm)>=degree(denm) THEN a:=quo(numm,denm); else a:=0;END;M1:=proot(denm);M1:=sort(M1);ms:=size(M1);L0:=mat2list(M1);A:=0;B:=1;REPEAT ms:=size(L0); L2:=remove(L0(1),L0); ms2:=size(L2);A:=ms-ms2;IF A==1 OR A==0 then Residue1();else Residue2();end;UNTIL size(L0)==0;return(ΣLIST(L4)+poly2symb(a));END;#end#casResidue1()BEGINlocal n,fa,derf,derfa; derf:=diff(f2,x);fa:=subst(f1,x=L0(1));derfa:=subst(derf,x=L0(1));n:=fa/derfa;L4(B):=n/(x-L0(1));B++;L0:=L2;END;#end#casResidue2()BEGINlocal n,ffa,c,ff1,ff2;c:=A;ff2:=subst(simplify(f*(x-L0(1))^c),x,L0(1)); L4(B):=ff2/(x-L0(1))^c; B++;ff1:=simplify(f*(x-L0(1))^c);FOR n FROM 1 TO A-1 STEP 1 DOff1:=simplify(diff(ff1,x));ffa:=1/(A-1)!*subst(ff1,x=L0(1));L4(B):=ffa/(x-L0(1))^(c-n);B++;end;L0:=L2;END;#end

 « Next Oldest | Next Newest »

User(s) browsing this thread: