Polynomials:
Simple curves are polynomials of various degrees, or orders. The degree is the integer of the highest exponent in the expression. The illustrations are as follows:
- A straight line is the first order or degree 1 polynomial of the form ax + b, or more clearly ax1+ b.
- A quadratic is a second order (or degree 2) polynomial of the form ax2 + bx + c.
- A cubic (degree 3) is of the form ax3 + bx2 + cx + d.
A MATLAB represents a polynomial as a row vector of coefficients. For illustration, the polynomial x3 + 2x2 - 4x + 3 would be represented by the vector [1 2 -4 3].
The polynomial 2x4 - x2 + 5 would be represented by [2 0 -1 0 5]; note that the zero terms for x3 and x1.
There are built-in functions sym2poly and poly2sym which convert symbolic expressions to polynomial vectors and vice versa, the illustration is as shown below:
>> myp = [1,2,-4,3];
>> poly2sym(myp)
ans =
x^3+2*x^2-4*x+3
>> mypoly = [2 0 -1 0 5];
>> poly2sym(mypoly)
ans =
2*x^4-x^2+5
>> sym2poly(ans)
ans =
2 0 -1 0 5