Appendix
A-8: Functions
Example A-8.2
Convert the expression x2 cos2 x to a function g, then obtain g2.7.
Solution
Interactive Solution
Control-drag (or type) the expression.
Context Panel: Assign to a Name
x2 cos2 x→assign to a nameq
Type the equation gx=…
Context Panel: Assign Function
gx=q→assign as functiong
Type the notation for the desired value.
Context Panel: Evaluate and Display Inline
g2.7 = 4.626911065
When defining the function g, the right-hand side of the equation gx=…can be the expression defining the rule, a name to which the rule has been assigned, or the equation label of the expression defining the rule of the function.
Coded Solution
The syntax for defining a function is shown to the right.
g≔x→x2 cos2 x
Alternative for an expression previously defined in Maple
Assign the given expression to q.
q≔x2 cos2 x
Use the unapply command.
g≔unapplyq,x
Type the notation for the desired value and press the Enter key.
g2.7
Except for the Context Panel's Assign Function, the unapply command must be used to define a function with a rule that is already entered into Maple. The syntax g≔x→q would not define the desired function.
<< Previous Example Section A-8 Next Example >>
© Maplesoft, a division of Waterloo Maple Inc., 2024. All rights reserved. This product is protected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation.
For more information on Maplesoft products and services, visit www.maplesoft.com
Download Help Document