Problem 42775. Raise a polynomial to a power
In Matlab, polynomials are represented by a vector of coefficients. For example, the polynomial p=a*x^2 + b*x + c is represented by the vector p=[a, b, c].
In this problem, you will be given a polynomial p and a power N. We would like you to return the vector q that represents the polynominal p^N, the Nth power of p. If p = (x + 1), for instance, you will be returning the coefficients of (x+1)^N. (N will be a positive integer greater than 0.)
Solution Stats
Problem Comments
-
2 Comments
Thought of another way to do this...
q=poly(kron(roots(p),ones(N,1)));
One-liner with size 21, but fails because of trivial roundoff error :(
This isnt a particularly difficult problem
you can call this function powerpoly
function ppower = powerpoly(p,n)
ppower = p;
i = 1
while i < n
ppower = conv(ppower,p);
i = i + 1;
end
Solution Comments
Show commentsProblem Recent Solvers94
Suggested Problems
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15773 Solvers
-
391 Solvers
-
Relative ratio of "1" in binary number
1591 Solvers
-
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
397 Solvers
-
String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values
1948 Solvers
More from this Author2
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!