Documentation

## Integrate and Differentiate Polynomials

This example shows how to use the `polyint` and `polyder` functions to analytically integrate or differentiate any polynomial represented by a vector of coefficients.

Use `polyder` to obtain the derivative of the polynomial $p\left(x\right)={x}^{3}-2x-5$. The resulting polynomial is $q\left(x\right)=\frac{d}{dx}p\left(x\right)=3{x}^{2}-2$.

```p = [1 0 -2 -5]; q = polyder(p)```
```q = 1×3 3 0 -2 ```

Similarly, use `polyint` to integrate the polynomial $p\left(x\right)=4{x}^{3}-3{x}^{2}+1$. The resulting polynomial is $q\left(x\right)=\int p\left(x\right)dx={x}^{4}-{x}^{3}+x$.

```p = [4 -3 0 1]; q = polyint(p)```
```q = 1×5 1 -1 0 1 0 ```

`polyder` also computes the derivative of the product or quotient of two polynomials. For example, create two vectors to represent the polynomials $a\left(x\right)={x}^{2}+3x+5$ and $b\left(x\right)=2{x}^{2}+4x+6$.

```a = [1 3 5]; b = [2 4 6];```

Calculate the derivative $\frac{d}{dx}\left[a\left(x\right)b\left(x\right)\right]$ by calling `polyder` with a single output argument.

`c = polyder(a,b)`
```c = 1×4 8 30 56 38 ```

Calculate the derivative $\frac{d}{dx}\left[\frac{a\left(x\right)}{b\left(x\right)}\right]$ by calling `polyder` with two output arguments. The resulting polynomial is

`$\frac{d}{dx}\left[\frac{a\left(x\right)}{b\left(x\right)}\right]=\frac{-2{x}^{2}-8x-2}{4{x}^{4}+16{x}^{3}+40{x}^{2}+48x+36}=\frac{q\left(x\right)}{d\left(x\right)}.$`

`[q,d] = polyder(a,b)`
```q = 1×3 -2 -8 -2 ```
```d = 1×5 4 16 40 48 36 ```