http://www.mathworks.com/matlabcentral/newsreader/view_thread/316925
MATLAB Central Newsreader  Polynomials and Linear Change of Variable
Feed for thread: Polynomials and Linear Change of Variable
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Tue, 14 Feb 2012 22:29:31 +0000
Polynomials and Linear Change of Variable
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316925#866706
Bill Woessner
I have a polynomial, represented as a vector. So px = [3 2 1]<br>
corresponds to p(x) = 3x^2 + 2x + 1. I would like to apply a linear<br>
change of variable, say, y = 4x + 5. Is there an easy way to get<br>
Matlab to apply the change of variable for me and compute the new<br>
coefficients? In this case, I would expected to get back p(y) = 48x^2<br>
+ 128x + 86 or py = [48 128 86]. I can think of a couple brute force<br>
ways to do this involving conv() or pascal(). But I'm hoping there's<br>
a fast and easy way to accomplish this.<br>
<br>
Thanks in advance,<br>
Bill

Wed, 15 Feb 2012 00:21:17 +0000
Re: Polynomials and Linear Change of Variable
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316925#866711
John D'Errico
Bill Woessner <woessner@gmail.com> wrote in message <54339d1a198a44dc86082ebd8818c386@dq9g2000vbb.googlegroups.com>...<br>
> I have a polynomial, represented as a vector. So px = [3 2 1]<br>
> corresponds to p(x) = 3x^2 + 2x + 1. I would like to apply a linear<br>
> change of variable, say, y = 4x + 5. Is there an easy way to get<br>
> Matlab to apply the change of variable for me and compute the new<br>
> coefficients? In this case, I would expected to get back p(y) = 48x^2<br>
> + 128x + 86 or py = [48 128 86]. I can think of a couple brute force<br>
> ways to do this involving conv() or pascal(). But I'm hoping there's<br>
> a fast and easy way to accomplish this.<br>
<br>
Of course, its trivial to do symbolically. So with my<br>
sympoly toolbox...<br>
<br>
sympoly x y<br>
px = 3*x^2 + 2*x + 1;<br>
subs(px,'x',4*x + 5)<br>
ans =<br>
86 + 128*x + 48*x^2<br>
<br>
But if you want to do so the hard way, you could do<br>
this:<br>
<br>
y = [4 5];<br>
py = 3*conv(y,y) + 2*conv([0 1],y) + 1*conv([0 1],[0 1])<br>
py =<br>
48 128 86<br>
<br>
John

Wed, 15 Feb 2012 01:26:50 +0000
Re: Polynomials and Linear Change of Variable
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316925#866713
Nasser M. Abbasi
On 2/14/2012 4:29 PM, Bill Woessner wrote:<br>
> I have a polynomial, represented as a vector. So px = [3 2 1]<br>
> corresponds to p(x) = 3x^2 + 2x + 1. I would like to apply a linear<br>
> change of variable, say, y = 4x + 5. Is there an easy way to get<br>
> Matlab to apply the change of variable for me and compute the new<br>
> coefficients? In this case, I would expected to get back p(y) = 48x^2<br>
> + 128x + 86 or py = [48 128 86]. I can think of a couple brute force<br>
> ways to do this involving conv() or pascal(). But I'm hoping there's<br>
> a fast and easy way to accomplish this.<br>
><br>
> Thanks in advance,<br>
> Bill<br>
<br>
for these things, might be easier to use symbolic tools<br>
<br>
<br>
EDU>> syms x y<br>
p=3*x^2+2*x+1;<br>
p=expand(subs(p,x,4*x + 5))<br>
coeff=sym2poly(p)<br>
<br>
p =<br>
<br>
48*x^2 + 128*x + 86<br>
<br>
<br>
coeff =<br>
<br>
48 128 86<br>
<br>
<br>
Nasser

Wed, 15 Feb 2012 01:29:18 +0000
Re: Polynomials and Linear Change of Variable
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316925#866714
Roger Stafford
Bill Woessner <woessner@gmail.com> wrote in message <54339d1a198a44dc86082ebd8818c386@dq9g2000vbb.googlegroups.com>...<br>
> I have a polynomial, represented as a vector. So px = [3 2 1]<br>
> corresponds to p(x) = 3x^2 + 2x + 1. I would like to apply a linear<br>
> change of variable, say, y = 4x + 5. Is there an easy way to get<br>
> Matlab to apply the change of variable for me and compute the new<br>
> coefficients?<br>
       <br>
The following is valid for any degree polynomial. Let p be the set of original coefficients, in this case p = [3,2,1]. Let n be the length of p. Let the transformation be y = a*x+b.<br>
<br>
t = flipud(fliplr(pascal(n)).*toeplitz([p(1),zeros(1,n1)],p));<br>
q = a.^(n1:1:0).*(b.^(n1:1:0)*t);<br>
<br>
The vector q will be the new set of coefficients for powers of x.<br>
<br>
Roger Stafford

Wed, 15 Feb 2012 01:30:25 +0000
Re: Polynomials and Linear Change of Variable
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316925#866715
Nasser M. Abbasi
On 2/14/2012 7:26 PM, Nasser M. Abbasi wrote:<br>
<br>
> for these things, might be easier to use symbolic tools<br>
><br>
> <br>
> EDU>> syms x y<br>
> p=3*x^2+2*x+1;<br>
> p=expand(subs(p,x,4*x + 5))<br>
> coeff=sym2poly(p)<br>
> <br>
> p =<br>
><br>
> 48*x^2 + 128*x + 86<br>
><br>
><br>
> coeff =<br>
><br>
> 48 128 86<br>
<br>
to OP, you do not need the expand() in there, I just<br>
added it to show you that you get the same expression<br>
as you showed.<br>
<br>
If you adopt this, you should remove the expand()<br>
call to make it more efficient as not needed.<br>
<br>
Nasser

Wed, 15 Feb 2012 19:36:18 +0000
Re: Polynomials and Linear Change of Variable
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316925#866825
Bill Woessner
On Feb 14, 8:29 pm, "Roger Stafford"<br>
<ellieandrogerxy...@mindspring.com.invalid> wrote:<br>
> t = flipud(fliplr(pascal(n)).*toeplitz([p(1),zeros(1,n1)],p));<br>
> q = a.^(n1:1:0).*(b.^(n1:1:0)*t);<br>
<br>
Wow... that is simply incredible. Thank you so much. How on Earth<br>
did you come up with that? This is along the lines of what I was<br>
thinking, but I wasn't even close to coming up with toeplitz().<br>
<br>
Again, thank you very much.<br>
<br>
Bill

Wed, 15 Feb 2012 20:39:12 +0000
Re: Polynomials and Linear Change of Variable
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316925#866834
Bruno Luong
Another way:<br>
<br>
x = 0:length(px)<br>
polyfit((x5)/4,polyval(px,x),length(px)1)<br>
<br>
% Bruno

Wed, 15 Feb 2012 21:38:10 +0000
Re: Polynomials and Linear Change of Variable
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316925#866843
Roger Stafford
Bill Woessner <woessner@gmail.com> wrote in message <aac4275e0e6742b7b66218cd9536516f@hs8g2000vbb.googlegroups.com>...<br>
> On Feb 14, 8:29 pm, "Roger Stafford"<br>
> <ellieandrogerxy...@mindspring.com.invalid> wrote:<br>
> > t = flipud(fliplr(pascal(n)).*toeplitz([p(1),zeros(1,n1)],p));<br>
> > q = a.^(n1:1:0).*(b.^(n1:1:0)*t);<br>
> <br>
> Wow... that is simply incredible. Thank you so much. How on Earth<br>
> did you come up with that? This is along the lines of what I was<br>
> thinking, but I wasn't even close to coming up with toeplitz().<br>
> <br>
> Again, thank you very much.<br>
> <br>
> Bill<br>
        <br>
You may prefer to use the following. Instead of twice flipping the entire n by n matrix output of 'pascal', it flips only the smaller p and q vectors. Consequently it uses 'hankel' instead of 'toeplitz'.<br>
<br>
t = b.^(0:n1)*(pascal(n).*hankel(fliplr(p),[p(1),zeros(1,n1)]));<br>
q = fliplr(a.^(0:n1).*t);<br>
<br>
Roger Stafford

Wed, 15 Feb 2012 23:34:11 +0000
Re: Polynomials and Linear Change of Variable
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316925#866858
Bruno Luong
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <br>
<br>
> x = 0:length(px)<br>
> polyfit((x5)/4,polyval(px,x),length(px)1)<br>
<br>
May be this modified command is clearer:<br>
<br>
x = 0:length(px)<br>
polyfit(x,polyval(px,4*x+5),length(px)1)<br>
<br>
% Bruno