Maple Professional
Maple Academic
Maple Student Edition
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professional
MapleSim Academic
Maple T.A. - Testing & Assessment
Maple T.A. MAA Placement Test Suite
Möbius - Online Courseware
Machine Design / Industrial Automation
Aerospace
Vehicle Engineering
Robotics
Power Industries
System Simulation and Analysis
Model development for HIL
Plant Modeling for Control Design
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematics Education
Engineering Education
High Schools & Two-Year Colleges
Testing & Assessment
Students
Financial Modeling
Operations Research
High Performance Computing
Physics
Live Webinars
Recorded Webinars
Upcoming Events
MaplePrimes
Maplesoft Blog
Maplesoft Membership
Maple Ambassador Program
MapleCloud
Technical Whitepapers
E-Mail Newsletters
Maple Books
Math Matters
Application Center
MapleSim Model Gallery
User Case Studies
Exploring Engineering Fundamentals
Teaching Concepts with Maple
Maplesoft Welcome Center
Teacher Resource Center
Student Help Center
Define
With the define command, evaluation and simplification properties for functions and operators can be defined. Properties are specified by both keywords and by equations that use the syntax of the pattern matcher (patmatch command). The define command then creates a procedure that implements the function and its properties. Note that properties are used in the order that they are given; therefore, if one pattern is more general than the other, it has to be specified first: for example, f(x)=x should be defined before
First Examples
In the first example, we use the keyword linear:
To define commutative and associative operations, use the keywords orderless and flat. orderless means that the arguments of a function have no order, and flat means that f(a,f(b,c)) is equal to f(a,b,c).
One can use define for functional programming:
A nice way to define the greatest common divisor of integers:
The keyword multilinear can be used to define multilinear functions:
Now we use the definemore command to add to the existing definition of H the rule of commutativity (keyword orderless), and a simplification rule for some special arguments:
Further Examples
Define an integration procedure: integration is linear, equals when a does not depend on .
We now define the integral of :
And now the integral for powers of :
An example with the keyword diff and the command diff : We define the derivative of to be :
Define properties of a function which is linear, has a derivative of , and for which .
Check the derivative of :
Given that is linear:
Now Maple can compute the following integral using the fact that is linear and has derivative :
Even nested functions with can be integrated:
Since the derivative is given, we can compute limit and series:
An Example with an Infix Operator
Using the neutral operator &m, we define:
We can add more properties:
The syntax for define is described in the help page of define, while the syntax for patterns is described in the help page of patmatch.
Return to Example Worksheets Index
Download Help Document