## Includes Taylor Series

- Example: a function of one variable. Here

f(x) = x3 - 4x2 + cos x

> f := x -> x^3 - 4*x^2 + cos(x) ;

defines f as a function of x (rather than as an expression)

> fp1 := unapply( diff( f(x), x ), x ) ;

gives f '(x) and stores it as a **function** named fp1.

> fp2 := unapply( diff( f(x), x$2 ), x ) ;

gives f ''(x) and stores it as a **function** named fp2.

> fp5 := unapply( diff( f(x), x$5 ), x ) ;

gives f (5)(x) and stores it as a **function** named fp5.

> g := unapply( 4*f(x) + fp1(x)^2, x ) ;

combines functions f and fp1 and stores it as a **function** named g.

> int( f(x), x ) ;

gives the integral of f with respect to x

> int( f(x), x = -1..3 ) ;

gives the definite integral of f(x) from x = -1 to 3

- Example: a function of more than one variable. Partial derivatives and partial integration. Here

f(x,z) = x3 sin z - 4 x z2 + e4z cos x

> f := (x,z) -> x^3*sin(z) - 4*x*z^2 + exp(4*z)*cos(x) ;

defines f as a function of x and z (rather than as an expression)

> diff( f(x,z), x ) ; differentiates f with respect to variable x only

> diff( f(x,z), z ) ; differentiates f with respect to variable z only

> int( f(x,z), z ) ; integrates f with respect to variable z only

> int( f(x,z), x = -1..3 ) ; integrates f(x) from x = -1 to 3

- Example: An improper integral. Here f(x) = 1/x3

> f := x -> 1/x^3; defines f as a function of x (rather than as an expression)

> int( f(x), x ) ;

> int( f(x), x = 1..infinity ) ; result: 1/2

**NOTE:** In maple, the number infinity is represented by infinity.

- Example: f(x) = e-x2

> f := exp(-x^2); defines f as an expression (rather than as a function)

> int( f, x = -infinity..infinity ) ; result: Pi1/2

> int( f, x ) ; gives what?

**Taylor Series:**To expand an expression as a Taylor series about*x=a*, usetaylor:

> f := cos(x); f is defined as an expression

> ftaylor := taylor( f, x = 0, 7 );

constructs the Taylor series of *f* about *x* = 0 up to *x*7 and stores it in ftaylor

> f7 := convert( ftaylor, polynom );

stores the 7th degreeTaylor polynomial in f7

> plot( { f, f7 }, x = -5 .. 5 );

plots function f and the 7th degreeTaylor polynomial f7 on a common graph

> ftaylor := taylor( f, x = Pi/2, 5 );

Taylor series of *f* about *x* = Pi/2 up to *x*5 and stores it in ftaylor

> convert( ftaylor, polynom );

returns the 5th degreeTaylor polynomial