
- MATLAB - Home
- MATLAB - Overview
- MATLAB - Features
- MATLAB - Environment Setup
- MATLAB - Editors
- MATLAB - Online
- MATLAB - Workspace
- MATLAB - Syntax
- MATLAB - Variables
- MATLAB - Commands
- MATLAB - Data Types
- MATLAB - Operators
- MATLAB - Dates and Time
- MATLAB - Numbers
- MATLAB - Random Numbers
- MATLAB - Strings and Characters
- MATLAB - Text Formatting
- MATLAB - Timetables
- MATLAB - M-Files
- MATLAB - Colon Notation
- MATLAB - Data Import
- MATLAB - Data Output
- MATLAB - Normalize Data
- MATLAB - Predefined Variables
- MATLAB - Decision Making
- MATLAB - Decisions
- MATLAB - If End Statement
- MATLAB - If Else Statement
- MATLAB - If…Elseif Else Statement
- MATLAB - Nest If Statememt
- MATLAB - Switch Statement
- MATLAB - Nested Switch
- MATLAB - Loops
- MATLAB - Loops
- MATLAB - For Loop
- MATLAB - While Loop
- MATLAB - Nested Loops
- MATLAB - Break Statement
- MATLAB - Continue Statement
- MATLAB - End Statement
- MATLAB - Arrays
- MATLAB - Arrays
- MATLAB - Vectors
- MATLAB - Transpose Operator
- MATLAB - Array Indexing
- MATLAB - Multi-Dimensional Array
- MATLAB - Compatible Arrays
- MATLAB - Categorical Arrays
- MATLAB - Cell Arrays
- MATLAB - Matrix
- MATLAB - Sparse Matrix
- MATLAB - Tables
- MATLAB - Structures
- MATLAB - Array Multiplication
- MATLAB - Array Division
- MATLAB - Array Functions
- MATLAB - Functions
- MATLAB - Functions
- MATLAB - Function Arguments
- MATLAB - Anonymous Functions
- MATLAB - Nested Functions
- MATLAB - Return Statement
- MATLAB - Void Function
- MATLAB - Local Functions
- MATLAB - Global Variables
- MATLAB - Function Handles
- MATLAB - Filter Function
- MATLAB - Factorial
- MATLAB - Private Functions
- MATLAB - Sub-functions
- MATLAB - Recursive Functions
- MATLAB - Function Precedence Order
- MATLAB - Map Function
- MATLAB - Mean Function
- MATLAB - End Function
- MATLAB - Error Handling
- MATLAB - Error Handling
- MATLAB - Try...Catch statement
- MATLAB - Debugging
- MATLAB - Plotting
- MATLAB - Plotting
- MATLAB - Plot Arrays
- MATLAB - Plot Vectors
- MATLAB - Bar Graph
- MATLAB - Histograms
- MATLAB - Graphics
- MATLAB - 2D Line Plot
- MATLAB - 3D Plots
- MATLAB - Formatting a Plot
- MATLAB - Logarithmic Axes Plots
- MATLAB - Plotting Error Bars
- MATLAB - Plot a 3D Contour
- MATLAB - Polar Plots
- MATLAB - Scatter Plots
- MATLAB - Plot Expression or Function
- MATLAB - Draw Rectangle
- MATLAB - Plot Spectrogram
- MATLAB - Plot Mesh Surface
- MATLAB - Plot Sine Wave
- MATLAB - Interpolation
- MATLAB - Interpolation
- MATLAB - Linear Interpolation
- MATLAB - 2D Array Interpolation
- MATLAB - 3D Array Interpolation
- MATLAB - Polynomials
- MATLAB - Polynomials
- MATLAB - Polynomial Addition
- MATLAB - Polynomial Multiplication
- MATLAB - Polynomial Division
- MATLAB - Derivatives of Polynomials
- MATLAB - Transformation
- MATLAB - Transforms
- MATLAB - Laplace Transform
- MATLAB - Laplacian Filter
- MATLAB - Laplacian of Gaussian Filter
- MATLAB - Inverse Fourier transform
- MATLAB - Fourier Transform
- MATLAB - Fast Fourier Transform
- MATLAB - 2-D Inverse Cosine Transform
- MATLAB - Add Legend to Axes
- MATLAB - Object Oriented
- MATLAB - Object Oriented Programming
- MATLAB - Classes and Object
- MATLAB - Functions Overloading
- MATLAB - Operator Overloading
- MATLAB - User-Defined Classes
- MATLAB - Copy Objects
- MATLAB - Algebra
- MATLAB - Linear Algebra
- MATLAB - Gauss Elimination
- MATLAB - Gauss-Jordan Elimination
- MATLAB - Reduced Row Echelon Form
- MATLAB - Eigenvalues and Eigenvectors
- MATLAB - Integration
- MATLAB - Integration
- MATLAB - Double Integral
- MATLAB - Trapezoidal Rule
- MATLAB - Simpson's Rule
- MATLAB - Miscellenous
- MATLAB - Calculus
- MATLAB - Differential
- MATLAB - Inverse of Matrix
- MATLAB - GNU Octave
- MATLAB - Simulink
MATLAB - Derivatives of Polynomials
In mathematics, a derivative represents the rate of change of a function with respect to a variable. In simple terms, it tells us how a function is changing at any given point. Derivatives are fundamental in calculus and are widely used in fields like physics, engineering, and economics to model change and motion.
For example, if you have a function that describes the position of a car over time, the derivative of that function would give you the car's velocity (rate of change of position).
Derivatives of Polynomials
A polynomial is a mathematical expression consisting of variables raised to different powers, combined with coefficients. For example, the polynomial P(x) = 3x2 + 2x + 5 is a second degree polynomial.
The derivative of a polynomial function is found by applying a simple rule: For each term, multiply the coefficient by the exponent, and then reduce the exponent by 1. This process is repeated for each term in the polynomial.
For example, consider the polynomial:
P(x) = 3x3 + 4x2 + 2x + 1
The derivative , P(x), is calculated as −
- For the term 3x3: Multiply 3 by 3 (the exponent), resulting in 9x2.
- For the term 4x2: Multiply 4 by 2, resulting in 8x.
- For the term 2x: Multiply 2 by 1, resulting in 2.
- The constant term (1) has a derivative of 0.
So, the derivative is −
P(x) = 9x2 + 8x + 2
Derivatives in MATLAB
MATLAB makes it easy to compute derivatives of polynomials using built-in functions. A polynomial in MATLAB is represented by a vector containing its coefficients, ordered by descending powers of the variable.
To find the derivative of a polynomial, MATLAB provides the polyder function.
Syntax
k = polyder(p) k = polyder(a,b) [q,d] = polyder(a,b)
Syntax Explanation
k = polyder(p) calculates the derivative of a polynomial given by the coefficients in p, resulting in a new polynomial k(x) that represents the derivative d/dx p(x).
k = polyder(a,b) computes the derivative of the product of two polynomials a and b, resulting in a new polynomial k(x) that represents.
$$\mathrm{\frac{d}{dx}[a(x) \: \cdot \: b(x)]}$$
[q, d] = polyder(a, b) computes the derivative of the quotient of two polynomials a and b, returning two polynomials: q(x) (the numerator) and d(x) (the denominator), representing the derivative of a(x)/b(x).
Example 1: Calculating derivative using polyder(p)
Consider we have a polynomial
P(x) = 4x3 + 3x2 + 2x + 1
This polynomial can be represented by the vector of its coefficients in MATLAB −
p = [4 3 2 1];
To compute the derivative of this polynomial, we use the polyder function in MATLAB −
k = polyder(p);
On execution of the code in matlab command window the output is.
>> p = [4 3 2 1]; k = polyder(p) k = 12 6 2 >>
For the term 4x3, the derivative is 12x2 (multiply the coefficient 4 by the exponent 3 and reduce the exponent by 1).
For the term 3x2, the derivative is 6x.
For the term 2x, the derivative is 2.
For the constant term 1 has a derivative of 0.
Thus, the derivative polynomial is :
k(x) = 12x2 + 6x + 2
In Matlab the result of k wil be : [12 6 2]
Example 2: Another example to find derivatives of a polynomial
Consider following polynomial
p(x) = 5x4 + 2x3 + 7x2 - 3x + 8
This polynomial can be represented by the vector of its coefficients in MATLAB −
p = [5 -2 7 -3 8]
To find the derivative of this polynomial will make use of the polyder function in matlab.
k = polyder(p)
This command will return the coefficients of the derivative of polynomial p.
When you execute the code in matlab command window the output is :
>> p = [5 -2 7 -3 8]; k = polyder(p) k = 20 -6 14 -3 >>
The vector k = [20 -6 14 -3] represents the polynomial
k(x) = 20x3 - 6x2 + 14x - 3
Example 3: Derivative of the Product of Two Polynomials Using polyder(a, b)
Let's consider two polynomials
a(x) = 2x2 + 3x + 1 b(x) = 4x + 5
These polynomials can be represented by vectors of their coefficients in MATLAB:
a = [2 3 1] b = [4 5]
To compute the derivative of the product of these two polynomials, we use the polyder function with two input arguments.
k = polyder(a, b);
This will return the coefficients of the derivative of the product of a(x) and b(x).
When you execute the code in matlab command window the output we get is :
>> a = [2 3 1]; b = [4 5]; k = polyder(a, b) k = 24 44 19 >>
So, the derivative polynomial is: k(x) = 24x2 + 44x + 19
Example 4: Derivative of two given polynomials
Consider two different polynomials.
a(x) = 3x3 + 2x2 + x + 4 b(x) = x2 - 5x + 6
These polynomials can be represented by the following coefficient vectors in MATLAB.
a = [3 2 1 4]; b = [1 -5 6];
To compute the derivative of the product of these two polynomials, we use the polyder function with the vectors a and b as inputs
k = polyder(a, b);
This command will return the coefficients of the derivative of the product of a(x) and b(x).
When the code is executed in matlab command window the output is :
>> a = [3 2 1 4]; b = [1 -5 6]; k = polyder(a, b) k = 15 -52 27 22 -14 >>
So, the derivative polynomial is −
k(x) = 15x4 - 52x3 + 27x2 + 22x - 14
Example 5: Derivative of the Quotient of Two Polynomials Using [q, d] = polyder(a, b)
Let's consider two polynomials −
a(x) = 4x2 + 3x + 2 b(x) = x2 - 2x + 1
These polynomials can be represented by vectors of their coefficients in Matlab.
a = [4 3 2]; b = [1 -2 1];
To compute the derivative of the quotient a(x) / b(x), we use the polyder function with two output arguments q and d.
[q,d] = polyder(a,b)
This will return two polynomials: q(x) (the numerator) and d(x) (the denominator) of the derivative of a(x) / b(x).
When the code is executed in matlab command window the output is :
>> a = [4 3 2]; b = [1 -2 1]; [q,d] = polyder(a,b) q = -11 4 7 d = 1 -4 6 -4 1 >>