In this question, you will write a function that calculates the coefficients of
ID: 3810919 • Letter: I
Question
In this question, you will write a function that calculates the coefficients of the derivatives of real polynomials. Consider a real polynomial P of degree n or lower. This polynomial can be written asP(x) = b_nx^n + b_n - 1x^n - 1 + ... + b_1x + b_0 where the b'_i, s, i = {0, 1, ...n} are real coefficients. The derivative of this polynomial is the polynomial P such that: P(x) = nb_nx^n - 1 + (n - 1)b_n - 1x^n - 2 + ... + 2b_zx + b_1 This polynomial can be written in the form: P'(x) = c_nx^n + c_n - 1x^n - 1 + ... + c_1x + c_0 where the c'_1 s, i = {0, 1, ..., n} are real coefficients that can be calculated from the b'_is (note that c_n = 0). By applying this reasoning multiple times, we can show that the polynomial P, and any of its derivatives (first, second, and higher derivatives) can be written in the form: a_nx^n + a_n - 1x^n - 1 + ...a_1x + a_0 In this question, you will write a function calculates the coefficients of the k^th derivative of a polynomial, given the coefficient pf this polynomial. More precisely, write a function with the following header: function [coefficients_d] = ay_d_polynomial (coefficients. k) where: coefficients is a 1 times (n + 1) array of class double that represents the coefficients a_n, a_n - 1, ..., a_0 (in this order) of a real polynomial P of degree n or lower, as given by Equation 9. You can assume that n greaterthanorequalto 0 and that all the elements of coefficients are from NaN, Inf, and -Inf. k is a scalar of class double that represents an integer that is greater than or equal to a. coefficients_d is a 1 times (n + 1) array of class double that represents the coefficients a_n + a_n - 1... a_0 (in this order) of the polynomial P^(k), as given by Equation 9. P^(k) is the k^th derivative of P. Note that Peon P^(0) = P(i.e. the 0^th derivative of P is P itself).Explanation / Answer
function [coefficients_d] = my_d_polynomial(coefficients, k)
coefficients_d = coefficients;
for i=1:k
coefficients_d = polyder(coefficients_d);
end
original_size = length(coefficients);
reduced_size = length(coefficients_d);
if (reduced_size < original_size)
offset = original_size - reduced_size;
for i = 1:offset
coefficients_d = [0 coefficients_d];
end
end
end
x = [6 3 2 1];
coefficients = my_d_polynomial(x, 2);
disp(coefficients);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.