From: Julian Geiger on
I want to do something simple, but I cannot do it right in Matlab and need help:

Multiply out: (x-a)(x-a^2)(x-a^3)...(x-a^10)

How can I do this? I tried so many things, including entering the equation. However, Matlab does not give me the resulting polynomial, it gives me a factorization (which is not what I look for).

Thanks in advance for every tip!!
From: Walter Roberson on
Julian Geiger wrote:
> I want to do something simple, but I cannot do it right in Matlab and
> need help:
>
> Multiply out: (x-a)(x-a^2)(x-a^3)...(x-a^10)
>
> How can I do this? I tried so many things, including entering the
> equation. However, Matlab does not give me the resulting polynomial, it
> gives me a factorization (which is not what I look for).

I gather you are doing this symbolically? If so then use expand()

http://www.mathworks.com/access/helpdesk/help/toolbox/symbolic/expand.html
From: Julian Geiger on
Great, thx. Is there a way to order the result according to coefficients of x^k?
(example: x*(-a^3 - a^5) + x^2*(a^5 + a^6) ...)

Walter Roberson <roberson(a)hushmail.com> wrote in message <hpvqoc$44k$1(a)canopus.cc.umanitoba.ca>...
> Julian Geiger wrote:
> > I want to do something simple, but I cannot do it right in Matlab and
> > need help:
> >
> > Multiply out: (x-a)(x-a^2)(x-a^3)...(x-a^10)
> >
> > How can I do this? I tried so many things, including entering the
> > equation. However, Matlab does not give me the resulting polynomial, it
> > gives me a factorization (which is not what I look for).
>
> I gather you are doing this symbolically? If so then use expand()
>
> http://www.mathworks.com/access/helpdesk/help/toolbox/symbolic/expand.html
From: Bruno Luong on
Here is a numerical trick that does not require symbolic toolbox

a=0.9;
u=a.^(1:10);

% Engine
v=vander(u);
c=inv(v)*diag(u)*v;
% Polynomial coefficients of the product
P=[1; -c(:,1)];

This code is based on a property of companion matrix. Otherwise, you can call multiple times CONV to perform brute force product.

Bruno
From: Bruno Luong on
> c=inv(v)*diag(u)*v;

Or rather this to be politically correct (before someone get nervous about calling INV)

> c = v\(diag(u)*v)

Bruno