# Am I right? Building matrix from polynomial and derivative

I'm just really unsure whether I'm correct about building a system of equations since there are derivatives.

What is known: $$f(x) = a_1x^3 + a_2x^2 + a_3x + a_4$$ $$f(−1) = 5, f(1) = 3, f'(−1) =−7, f'(1) = 13$$ So we have:

1. $$f(-1) = a_1(-1)^3 + a_2(-1)^2 + a_3(-1) + a_4 = -a_1 + a_2 -a_3 + a_4 = 5$$
2. $$f(1) = a_1\times1^3 + a_2\times1^2 + a_3\times1 + a_4 = a_1 + a_2 + a_3 + a_4 = 3$$

The derivative form of this function is the following (I guess): $$f'(x) = 3a_1x^2 + 2a_2x + a_3$$

As a result,

1. $$f'(-1) = 3a_1(-1)^2 + 2a_2(-1) + a_3 = 3a_1 -2a_2 + a_3 =-7$$

2. $$f'(1) = 3a*1^2 + 2b*1 + c = 3a_1 + 2a_2 + a_3 = 13$$

So we have system of equations:

1. $$-x_1 + x_2 - x_3 + x_4 = 5$$
2. $$x_1 + x_2 + x_3 + x_4 = 3$$
3. $$3x_1 - 2x_2 +x_3 + 0 \times x_4 = -7$$
4. $$3x_1 + 2x_2 +x_3 + 0 \times x_4 = 13$$

And from this system I can build matrix. Is everything correct?

Your linear system seems correct but you will need some software to solve it. Because of the nature of the problem, it would be better (in my opinion) to parameterize the cubic as $$p(x) =b_0+b_1(x+1)+b_2(x+1)^2+b_3(x+1)^3$$ It is simple to check that $$p(-1)=b_0, p'(-1)=b_1$$. So we are left with two unknowns. The polynomial and its derivative write $$p(x) =5-7(x+1)+b_2(x+1)^2+b_3(x+1)^3$$ $$p'(x) =-7+2b_2(x+1)+3b_3(x+1)^2$$ Using the remaining conditions gives you directly $$b_2=-1$$ and $$b_3=2$$.