In: Mechanical Engineering
Two polynomials in the variable x are represented by the coefficient vectors p1 = [6,2,7,-3] and p2 = [10,-5,8].
a. Use MuPAD to find the product of these two polynomials; express the product in its simplest form.
b. Use MuPAD to find the numeric value of the product if x = 2.
a)
For defining the polynomial in the variable x, we will first define a symbolic variable x. To define the polynomial with given coefficient vectors, we will use poly2sym function which will convert the polynomial expression to symbolic expression.
Input:
syms x %defining the symbolic variable x
p1=poly2sym([6,2,7,-3],x); %defining polynomial 1
p2=poly2sym([10,-5,8]) ; %defining polynomial 2
product=p1*p2; %finding the product
disp('product of two polynomial is: ')
disp(product) %displaying the product
disp('product of two polynomial in simplest form is: ')
disp(expand(product)) %using expand we can simplify the product
Output:
b)
For finding the value of product at x=2, we can use subs function which will substitute the variable x with 2 and compute the expression as follows,
Input:
syms x %defining the symbolic variable x
p1=poly2sym([6,2,7,-3],x); %defining polynomial 1
p2=poly2sym([10,-5,8]) ; %defining polynomial 2
product=p1*p2; %finding the product
val=subs(product,2); %substituting x=2 to the product
disp('The value of the product at x=2 is:')
disp(val)
Output:
a) For defining the polynomial in the variable x, we will first define a symbolic variable x.
b)
For finding the value of product at x=2, we can use subs function which will substitute the variable x with 2 and compute the expression as follows,