Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

First try using the polymer function. Try polymer ([4 -2 3 7 -5]) which should g

ID: 3028585 • Letter: F

Question

First try using the polymer function. Try polymer ([4 -2 3 7 -5]) which should give a result of [16 -6 6 7]. Remembering how Matlab represents polynomials, this is its way of telling us that d/dx {4x^4 - 2x^3 + 3x^2 + 7x - 5} = 16x^3 - 6x^2 + 6x + 7 which Ls undeniably true, polymer will correctly give us the coefficients of the derivative of a polynomial of any order. However, with what you know about Matlab arrays (and calculus), you should be able to write a simple, single line statement without using polymer! which will also calculate an array with the coefficients of the derivative of an arbitrary polynomial. To be explicit, suppose that p is an arbitrary array (of any length) defined in the Matlab workspace. If we then write dp=; determine what should be so that, dp will be an array with the coefficients of the derivative of the polynomial represented by p. For example if p=[4 -2 3 7 -5] your calculation should give dp=[16 -6 6 7], as above. You can (and should!) generate additional examples, with different length p arrays: use polymer for comparison if you really have to. We'll check your work with a different array p when you are ready, but you cannot change the statement you use to calculate dp when we check: your code must work unchanged with an entirely different, completely unknown array p. Use up-arrow to recall your previous statement after entering the new p.

Explanation / Answer

clc;
clear all;
close all;

n=input('Enter the number of coefficient u want to enter=');
for k=1:n
p(k)=input('Enter the coefficient');
end

for k=1:length(p)-1
dp(k)=p(k)*(length(p)-k);
end
p
dp

Enter the number of coefficient u want to enter=4
Enter the coefficient1
Enter the coefficient2
Enter the coefficient5
Enter the coefficient7

p =

1 2 5 7


dp =

3 4 5

Enter the number of coefficient u want to enter=6
Enter the coefficient3
Enter the coefficient5
Enter the coefficient7
Enter the coefficient-3
Enter the coefficient-8
Enter the coefficient2

p =

3 5 7 -3 -8 2


dp =

15 20 21 -6 -8