Browse
Login Sign Up

Factors of each term of a Polynomial Power

Share & earn cash

%By Chukwunomso Agunwamba
%In order to form the new terms in the new polynomial, it calculates the  
%powers to which one should raise the coefficients of a polynomial, when the
%the polynomial of opw number of terms is raised to a power of n.  
 
##This mathematical code is provided as is, for the end user to be able to use  
##it and to edit it for educational purposes. However, any modified version must  
##include my name as the original producer of the code.
 
##The name of the mfile code is getcoeffnthpw. It has two required input  
##arguments and an optional third input argument.  
##The first input is the power to raise the polynomial to.   
##The second input is the number of terms in the original polynomial, which is  
##the length of the vector of coefficients.  
##The optional third argument is the coefficient vector of the polynomial  
##you want to multiply n times.
 
 
##So, symbolically speaking (not strictly usage syntax),  
##P^n = P.^getcoeffnthpw(n,opw) is the desired usage. For example,  
#[3 2].^getcoeffnthpw(3,2) gives
##ans =
##
##   27    1
##    9    2
##    3    4
##    1    8
##(I was using the implied first output variable, ignoring the 2nd output.)
 
##So care must be taken to get the intended result, as the 1s that appear beside
##27 and beside 8 are a result of zero filling the empty locations of the  
##matrix, not the actual powers for 2 or for 3 respectively. That is the desired
##list of powers should be of the form:
##
##    27 empty
##    9          2
##    3          4
##    empty 8
## Here, 'empty's can be replaced with zeros.
 
##Usage syntax example:
##[h, coefficients] = getcoeffnthpw(n,opw);
##
##n = 3
##P = [3 2 5]
##opw = length(P)
##h = getcoeffnthpw(n,opw)
##G = (P.^h)
##G is the desired result that has the factors of each new coefficient
##explained out before that new coefficient is finally calculated.
##G =
##
##    27     1     1
##     9     2     1
##     9      1     5
##     3     4     1
##     3     2     5
##     3      1   25
##     1      8     1
##     1      4     5
##     1      2   25
##     1      1   125
##
##To get the final coefficient vector, one can place h into the multichoose
##function to account for how many times each term occurs after the product.
 
##Example with multichoose:
##coefficients = (prod(G.').').*multichoose(h)
 
##feel free to change or remove/disable the default inputs

License type: "Custom". Read more.
By Chukwunomnso423
Octave Matlab Polynomial Product Polynomialproducts
Reviews
Nobody has rated this offer yet.
PARTICIPATE
  • Buy
  • Offer
  • Share
LEARN
  • About
  • Blog
  • FAQ
CONNECT
  • Twitter
  • Facebook
  • Contact
LEGAL
  • Terms
  • Privacy
  • © 2025 Sellcodes
Log in to your Sellcodes account
Forgot your password?
Looking to create an account?
Sign up for Sellcodes
By creating an account you agree to our Terms Of Use and Privacy Policy
Did you mean to Login?