Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Polynomials and Linear Change of Variable
Date: Wed, 15 Feb 2012 00:21:17 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 28
Message-ID: <jhetpt$31c$1@newscl01ah.mathworks.com>
References: <54339d1a-198a-44dc-8608-2ebd8818c386@dq9g2000vbb.googlegroups.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1329265277 3116 172.30.248.37 (15 Feb 2012 00:21:17 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 15 Feb 2012 00:21:17 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:757674

Bill Woessner <woessner@gmail.com> wrote in message <54339d1a-198a-44dc-8608-2ebd8818c386@dq9g2000vbb.googlegroups.com>...
> I have a polynomial, represented as a vector.  So px = [3 2 1]
> corresponds to p(x) = 3x^2 + 2x + 1.  I would like to apply a linear
> change of variable, say, y = 4x + 5.  Is there an easy way to get
> Matlab to apply the change of variable for me and compute the new
> coefficients?  In this case, I would expected to get back p(y) = 48x^2
> + 128x + 86 or py = [48 128 86].  I can think of a couple brute force
> ways to do this involving conv() or pascal().  But I'm hoping there's
> a fast and easy way to accomplish this.
 
Of course, its trivial to do symbolically. So with my
sympoly toolbox...

sympoly x y
px = 3*x^2 + 2*x + 1;
subs(px,'x',4*x + 5)
ans =
    86 + 128*x + 48*x^2

But if you want to do so the hard way, you could do
this:

y = [4 5];
py = 3*conv(y,y) + 2*conv([0 1],y) + 1*conv([0 1],[0 1])
py =
    48   128    86

John