From: kp pk on 27 Jun 2010 11:35 "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <i07qcp$5do$1(a)fred.mathworks.com>... > "kp pk" <krishna123321(a)gmail.com> wrote in message <i07lr1$fpg$1(a)fred.mathworks.com>... > > "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <i07kms$3ns$1(a)fred.mathworks.com>... > > > "kp pk" <krishna123321(a)gmail.com> wrote in message <i07jpf$53d$1(a)fred.mathworks.com>... > > > > I am trying to generate orthonormal polynomials of the form > > > > 1 - P(1) > > > > a+bx - P(2) > > > > c+dx+ex^2 - P(3) > > > > > > > > and so on.. > > > > > > > > the way in which i am generating above polynomials is that > > > > integral(P(i)*P(j)) x varying from 0 to 1 = 0 if i is not equal to j > > > > = 1 if i is equal to j > > > > the code i am using to do this is > > > > > > Why write it yourself like this? > > > > > > Why not just recognize that these are Legendre > > > polynomials, shifted to be orthogonal over the > > > interval [0,1] instead of [-1,1]. > > > > > > Given that, there are simple methods to generate > > > Legendre polynomials. > > > > > > Why expend all of this effort to do something that > > > is trivially done with other methods? > > > > > > John > > > > > > the only shifted legendres over [0,1] i could find were lists of polynomials,i couldnt find any code to generate them.i would be grateful if you could give me a good link though. > > thanks. > > Download my sympoly tools from the FEX. > > http://www.mathworks.com/matlabcentral/fileexchange/9577 > > In there, you will find orthpoly. For example, > > for i = 0:5 > % standard legendre polynomials > P(i + 1) = orthpoly(i,'leg'); > end > > P = > Sympoly array has size = [1 11] > Sympoly array element [1 1] > 1 > Sympoly array element [1 2] > x > Sympoly array element [1 3] > -0.5 + 1.5*x^2 > Sympoly array element [1 4] > -1.5*x + 2.5*x^3 > Sympoly array element [1 5] > 0.375 - 3.75*x^2 + 4.375*x^4 > Sympoly array element [1 6] > 1.875*x - 8.75*x^3 + 7.875*x^5 > > These are orthogonal over the interval [-1,1], although > they are not orthonormal. First, change the interval. > > sympoly y > Q = subs(Q,'x',2*y - 1) > Q = > Sympoly array has size = [1 6] > > Sympoly array element [1 1] > 1 > Sympoly array element [1 2] > -1 + 2*y > Sympoly array element [1 3] > 1 - 6*y + 6*y^2 > Sympoly array element [1 4] > -1 + 12*y - 30*y^2 + 20*y^3 > Sympoly array element [1 5] > 1 - 20*y + 90*y^2 - 140*y^3 + 70*y^4 > Sympoly array element [1 6] > -1 + 30*y - 210*y^2 + 560*y^3 - 630*y^4 + 252*y^5 > > > These polynomials are orthogonal over [0,1]. It is > easy to convince yourself of that. For example... > > defint(Q(2)*Q(6),'y',[0 1]) > ans = > 0 > > But they are not orthonormal. > > defint(Q(6)*Q(6),'y',[0 1]) > ans = > 0.090909 > > So make them so. > > for i = 0:5 > Q(i+1) = Q(i+1)/sqrt(defint(Q(i+1)*Q(i+1),'y',[0 1])); > end > > Are the polynomials now orthonormal? Yes. > > defint(Q(6)*Q(6),'y',[0 1]) > ans = > 1 > > HTH, > John thanks.im gonna try doing what you said. but if you have the inclination to do so,could you look over what i did and see if i can actually finsh the job using my method.once again,thanks .
From: kp pk on 27 Jun 2010 11:52 im getting a error message when i run what you did. >> for i = 0:5 % standard legendre polynomials P(i + 1) = orthpoly(i,'leg'); end >> P P = Sympoly array has size = [1 6] Sympoly array element [1 1] ??? Illegal right hand side in assignment. Too many elements. Error in ==> sympoly.disp at 29 cformat = useformat{ind}; Error in ==> sympoly.display at 29 disp(sp(j)) sorry if im making a really obvious noobish mistake somewhere.
From: kp pk on 28 Jun 2010 02:19
im getting a error message when i run what you did. >> for i = 0:5 % standard legendre polynomials P(i + 1) = orthpoly(i,'leg'); end >> P P = Sympoly array has size = [1 6] Sympoly array element [1 1] ??? Illegal right hand side in assignment. Too many elements. Error in ==> sympoly.disp at 29 cformat = useformat{ind}; Error in ==> sympoly.display at 29 disp(sp(j)) >> sorry if im making a really obvious noobish mistake somewhere. |