Stat/Math
Software Support
Software Consulting
Software Availability
Software Price
Contact

User Support
Documentation
Knowledge Base
Education
Consulting
Podcasts

Systems & Services
Cyberinfrastructure
Supercomputers
Grid Computing
Storage
Visualization
Digital Libraries & Data

Results & Impact
Publications
Grants & Grant Info
Events & Outreach
Economic Impact
Survey Results

Vision & Planning
News & Features

## Creating your own Mathematical Functions

We have been working with expressions so far. Maple also supports the mathematical notion of a function.  To define a function, you must specify a rule for going from one number to another. Consider the following commands:

 f := x^2; f := x2 This defines f to be an abbreviation for the expression x2. f := x -> x^2; f := x -> x2 This defines f to be a function, such that f(x) = x2. f(3);f(t); 9t2 The function works as standard notation.
 A common mistake is to write f(x) := x^2;. This does not define a function. Instead, it makes the four characters on the left an abbreviation for the three characters on the right.

Functions are often more useful than expressions. However, many Maple commands (for example, diff) expect an expression as input. If f := x -> x^2, then diff(f,x); doesn't work. However, diff(f(x),x); will work, since f(x) produces the expression x2.

To convert an expression into a function, use the unapply command.

p := x^3 + 1;
p := x3 + 1
f := unapply(p, x); f(3);
f := x -> x3 + 1
28