Part 1: Talking to Maple - Maple Programming Help

Home : Support : Online Help : Getting Started : Tutorials : MaplePortal/Tutorial1

Part 1: Talking to Maple

 Introduction Maple Tutorials are designed to help you get started with Maple, learn about the key tools available in Maple, and lead you through a series of problems.   In Part 1: Talking to Maple, you will become fluent using the Maple environment. You will learn how to use palettes and the Context Panel to perform analysis and create interactive graphics, without needing to know any Maple commands.   To try this material on your own, start with an empty Maple document. Perform the steps described in the left column of each table below.  The results of the steps are displayed in the right column for reference.   Refer to Help>Quick Reference for basic getting started tips.   Note for non-Windows users: The keystrokes given in this document are for Windows.  There will be differences for other platforms. If you are using a different platform, see Shortcut Keys.

How to Get Started

In this section, you will learn the basics of asking Maple a question and getting the result.

Steps

Results

Using [Enter]

When you launch Maple you start with a blank document, with menus and toolbars at the top and palettes on the side. At the cursor, you can start typing math. Press [Enter] to see the result.

Example: Type "1+2 [Enter]".
Notice that the result appears on the next line.

Example: Type "x^2 +5 -2".  Notice that typing "^" automatically moves you to the exponent position. To leave the exponent, use the right arrow [→] key.  Press [Enter] to see the result.













$1+2$

 ${3}$ (2.1)



${x}^{2}+5-2$

 ${{x}}^{{2}}{+}{3}$ (2.2)



The Context Panel

You can use the context-sensitive options in the Context Panel to perform a wide variety of mathematical and other operations.

Example: Place your cursor on the last result. The Context Panel offers several operations that you can perform on the current expression.  To integrate this expression, select Integrate, then x.

Example: To plot the result of the integration, select Plots > 2-D Plot in the Context Panel.

Tip: You can modify the plot after it has been created.  Simply click on the plot and then use the Context Panel, or access the Plot menu and the plotting toolbar.













 ${{x}}^{{2}}{+}{3}$ (2.3)

$\stackrel{\text{integrate w.r.t. x}}{\to }$$\frac{{1}}{{3}}{}{{x}}^{{3}}{+}{3}{}{x}$$\to$



Changing the Problem

Mathematics in a Maple document are live. You can go back, make changes, and re-execute the problem to obtain a new result.

Example:  Go back to your original calculation "$1+2$", change the number "1" to a "3", and press [Enter]. Note the change in output.

Example:  In the Context Panel example above, change the ${x}^{2}$ to .  Highlight the entire line, including the plot, then click the execute button, , found at the top of the Maple worksheet. All selected calculations are updated.









$3+2$

 ${5}$ (2.4)



$\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}$



 ${10}{}{{x}}^{{2}}{+}{3}$ (2.5)

$\stackrel{\text{integrate w.r.t. x}}{\to }$$\frac{{10}}{{3}}{}{{x}}^{{3}}{+}{3}{}{x}$$\to$









Tip: Clicking on the Execute All button, ,  recalculates the entire document.

Entering Math

There are a number of methods to enter math into Maple.  You can enter math using a combination of palettes, keyboard shortcuts, and commands.  Most operations can be entered in more than one way, so you can pick the method you are most comfortable with.

Steps

Result

Maple calculates exact answers. That is, fractions remain as fractions and $ⅇ$ and $\mathrm{π}$ remain symbolic throughout calculations.  This reduces errors due to approximations in multi-step calculations.

Example: On a new line, enter "1/2 + 1/3".

Note that typing [/] automatically moves you to the denominator. The right arrow will take you out.  Press [Enter] to see the result.

Maple also calculates numeric approximations.

Example: From the Context Panel for the above result, select Approximate. Select accuracy of 5 digits.

If your problem uses decimals already, Maple will return the answer in the same format, with floating-point numbers.

Example: Enter , and press [Enter].

You can apply different formatting to numeric results.

Example: In the Context Panel, under Format Output, select Scientific. The selected numeric formatting is applied to the result in-place.







$\frac{1}{2}+\frac{1}{3}$

 $\frac{{5}}{{6}}$ (3.1)

$\stackrel{\text{at 5 digits}}{\to }$

 ${0.83333}$ (3.2)





$\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}$





 ${0.8333333333}{}{x}$ (3.3)

 ${0.8333333333}{}{x}$ (3.4)



Palettes

Maple has over 1000 palette symbols within more than 20 palettes.  You can use Maple's Expression or Calculus palettes to enter common mathematics expressions.  These palettes contains fill-in-the-blank templates for common operations.

Example: Using the Calculus palette, find the integral of $4\cdot {t}^{6}+\mathrm{sin}\left(t\right)\mathrm{dt}$.

Start by placing your cursor where you want to work.  Open the Calculus palette (click on Calculus on the left-hand side of your Maple document) and click the indefinite integral $\int {f}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}ⅆ{x}$.  An indefinite integral template will appear in your worksheet.  Fill in the placeholders, using [Tab] to move to the next placeholder. When done, press [Enter] to evaluate.

Example: Use the Calculus palette to find the limit of a function.

Start by placing your cursor where you want to work.  Open the expression palette (click on Calculus on the left-hand side of your Maple document) and click the limit expression $\underset{{x}\to {a}}{lim}{f}$ . Fill in the placeholders, using [Tab] to move to the next placeholder. When done, press [Enter] to evaluate.

Tip: Put frequently used palette entries on the Favorites Palette. Right-click on the palette button and select Add to Favorites Palette.

































 $\frac{{4}{}{{t}}^{{7}}}{{7}}{-}{\mathrm{cos}}{}\left({t}\right)$ (3.5)

















$\underset{x\to 0}{lim}\frac{\mathrm{sin}\left({x}^{2}\right)}{x}$

 ${0}$ (3.6)





Symbol and Command Completion

The symbol and command completion mechanism provides an alternative to palettes for entering symbols.

Type the first few characters of the symbol name, and press [Esc]. Choose the symbol you want from the list.

Example: Try entering  ${\mathrm{\pi }}^{2}+\sqrt{x}$

To enter $\mathrm{\pi },$type "pi [Esc]".  Select the symbol $\mathrm{π}.$

Use [^] to enter the exponent.  To leave the exponent, use the right arrow [→] key.

For $\sqrt{{x}}$, enter "sqrt [Esc]".Select the   option. Press [Enter].

To enter the exponential function $ⅇ$ or the imaginary number $i$, use symbol completion.

Example: Plot $y={ⅇ}^{x}$.  Use symbol completion to create the exponential $ⅇ$.  Type "e [Esc]", and select e (exponential) from the list.  Then plot the function from the Context Panel by selecting Plots > 2-D Plot of Right Side.

Note: Simply typing "e" will produce the name e.  To enter the exponential function, you must select e(exponential) from the symbol completion list.  Alternatively, you can use the ${ⅇ}^{{a}}$ template from the Expression palette.

















${\mathrm{\pi }}^{2}+\sqrt{x}$

 ${{\mathrm{\pi }}}^{{2}}{+}\sqrt{{x}}$ (3.7)













$y={ⅇ}^{x}$$\to$

Some command completion templates offer calling sequences for Maple commands, making it easy for you to get the syntax right on your first try.

Example:  Find the taylor series expansion of  about the point 2.

Type "taylor [Esc]".  From the list, choose taylor(series expansion).  The template $\mathrm{taylor}\left({\mathrm{expr}},{x}={a},{n}\right)$ is entered into your document.

Simply replace ${\mathrm{expr}}$ by $\frac{1}{1+{z}^{2}}$, ${x}$ by $z$, and ${a}$ by 2.  The last parameter, ${n}$, is the order of the expansion.  We will find the 4th order expansion.









$\mathrm{taylor}\left(\frac{1}{1+{z}^{2}},z=2,4\right)$

 $\frac{{1}}{{5}}{-}\frac{{4}}{{25}}{}\left({z}{-}{2}\right){+}\frac{{11}}{{125}}{}{\left({z}{-}{2}\right)}^{{2}}{-}\frac{{24}}{{625}}{}{\left({z}{-}{2}\right)}^{{3}}{+}{O}{}\left({\left({z}{-}{2}\right)}^{{4}}\right)$ (3.8)



Case-Sensitivity

Maple is case-sensitive.

Example: Compute $x+x$.  Compute $y+Y$.

Compare the results.









$x+x$

 ${2}{}{x}$ (3.9)

$y+Y$

 ${y}{+}{Y}$ (3.10)





Multiplication

In general, Maple understands * or a space between terms to mean multiplication.

Example: Type "3 [Space] x  [Space] y"for "3 times $x$ times $y$".

In the case of a number times a variable, the space can be omitted.

Example: Type "3x [Space] y"for "3 times $x$ times $y$".

For readability, Maple automatically formats the expression to include a space between terms.

Caution:  The space can only be omitted in the case of a number multiplied by a variable. All other cases require a space or an explicit multiplication symbol (*).

For example, "$xy$" means "$x$ times $y$", but "$\mathrm{xy}$" means the variable whose name is "$\mathrm{xy}$".

Example: Type "$x$ [Space] $y+\mathrm{xy}$ ".

If you choose to Evaluate at a Point using the Context Panel, you will see that $x$, $y$, and $\mathrm{xy}$ are treated as three separate variables due to the way they were entered.

Avoid confusion with function calls.  To us,  $f\left(x+1\right)$ looks like a function call, and $x\left(x+1\right)$ looks like implied multiplication.  Maple understands both of these as function calls. You must use a space or an explicit multiplication symbol to denote multiplication.







${}$





 ${3}{}{x}{}{y}$ (3.11)





 ${3}{}{x}{}{y}$ (3.12)























 ${x}{}{y}{+}{\mathrm{xy}}$ (3.13)













${}$















Mathematical Notation

Maple understands familiar mathematical notation.

For example, Maple understands that $y''+y'+y=0$ is a differential equation in $y\left(x\right)$.

Example: Enter the equation listed above (using the single quote ['] key for the prime notation).  To verify that it is in fact a differential equation, select Solve DE in the Context Panel.













$y''+y'+y=0$$\stackrel{\text{solve DE}}{\to }$${y}{}\left({x}\right){=}{\mathrm{_C1}}{}{{ⅇ}}^{{-}\frac{{x}}{{2}}}{}{\mathrm{sin}}{}\left(\frac{\sqrt{{3}}{}{x}}{{2}}\right){+}{\mathrm{_C2}}{}{{ⅇ}}^{{-}\frac{{x}}{{2}}}{}{\mathrm{cos}}{}\left(\frac{\sqrt{{3}}{}{x}}{{2}}\right)$



Label References

Maple uses label references.

Whenever you use [Enter] to get a response, the result is automatically given an equation label.  To refer to a previous result in a computation, use [Ctrl][L] and enter the number of the equation label.

Example: Multiply the result ${{\mathrm{π}}}^{{2}}{+}\sqrt{{x}}$ (from above) by $x$, using labels.

















$\cdot x$

 $\left({{\mathrm{\pi }}}^{{2}}{+}\sqrt{{x}}\right){}{x}$ (3.14)





Assignments

After entering an expression or performing a computation, you can assign the result to a name.

Example:

Enter the expression to the right, , and from the Context Panel options, select Expand.

From the Context Panel for the output  select Assign to a Name.  Enter "Answer1".

You can then use this name to refer to the result and to use it in further computations.  For example, we can extract the coefficients of $x\cdot {y}^{2}$.

The assignment statement := (colon equals) assigns the right-hand side to the name on the left-hand side.

Example: Assign values to "value1" and "value2" and then add them together.









$\stackrel{\text{expand}}{=}$${{x}}^{{3}}{+}{6}{}{{x}}^{{2}}{}{y}{+}{12}{}{x}{}{{y}}^{{2}}{+}{8}{}{{y}}^{{3}}$$\stackrel{\text{assign to a name}}{\to }$${\mathrm{Answer1}}$









$\mathrm{coeffs}\left(\mathrm{Answer1}\right)$

 ${1}{,}{6}{,}{12}{,}{8}$ (3.15)













$\mathrm{value1}≔5\cdot x$

 ${\mathrm{value1}}{≔}{5}{}{x}$ (3.16)

$\mathrm{value2}≔4\cdot x$

 ${\mathrm{value2}}{≔}{4}{}{x}$ (3.17)

$\mathrm{value1}+\mathrm{value2}$

 ${9}{}{x}$ (3.18)





Sometimes you do not want to see the results of the assignment statement. To suppress the result of any Maple operation, end your statement with a colon (:)

Example: Assign a value to ${a}_{1}$, but do not show the result. Then, compute ${a}_{1}^{2}$.  (To get a subscript, enter two underscores [_ _].  Use the right arrow to leave the subscript.)

To clear a variable, use the unassign command. You must enclose the name in right single quotes [''].  This prevents Maple from automatically replacing with its value before passing it to the command.

Note:  In Maple, you have to execute a command before it is processed.  Thus, you must press [Enter] (or [Ctrl][=] to display the result inline; for more information see 2-Putting Your Ideas Together) after each statement.







$\mathrm{a__1}≔1.2:$



${\mathrm{a__1}}^{2}$

 ${1.44}$ (3.19)



$\mathrm{unassign}\left('\mathrm{a__1}'\right):$



$\mathrm{a__1}$

 $\mathrm{a__1}$ (3.20)



Maple Commands

You can always enter Maple commands by typing them directly. Examples of Maple commands will be found throughout the tutorials.

Example: For instance, the definite integral of ${e}^{{x}^{2}}$ can be expressed using the integral symbol from the palettes or using the command int.

The calling sequence for definite integration is int(expression,x=a..b), where a and b are the endpoints of integration.  A range in Maple is given by a..b.

You can enter the exponential function using symbol completion or using the name of the Maple command.  The name of the Maple command for the exponential function $y={e}^{x}$ is exp.

Type "int(exp(x^2), x = 2.1..2.4)".

Example: Earlier, you solved the differential equation $y''+y'+y=0$ using the Context Panel.  Now, you will solve this using a command.  dsolve is the differential equations solver in Maple.

Solve the differential equation above using dsolve.

The terms _C1 and _C2 are constants of integration.  For more examples including how to specify initial conditions, see How Do I Solve an ODE.











${∫}_{2.1}^{2.4}{ⅇ}^{{x}^{2}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}ⅆx$

 ${51.48568229}$ (3.21)

$\mathrm{int}\left(\mathrm{exp}\left({x}^{2}\right),x=2.1..2.4\right)$

 ${51.48568229}$ (3.22)

















$\mathrm{dsolve}\left(y''+y'+y=0\right)$

 ${y}{}\left({x}\right){=}{\mathrm{_C1}}{}{{ⅇ}}^{{-}\frac{{x}}{{2}}}{}{\mathrm{sin}}{}\left(\frac{\sqrt{{3}}{}{x}}{{2}}\right){+}{\mathrm{_C2}}{}{{ⅇ}}^{{-}\frac{{x}}{{2}}}{}{\mathrm{cos}}{}\left(\frac{\sqrt{{3}}{}{x}}{{2}}\right)$ (3.23)



Tip: Find the list of keyboard shortcuts for your platform.  In the Quick Help tips in the Context Panel, click Math Editor Shortcuts or find a full list from Shortcut Keys.

Exercise: Using palettes and the Context Panel:

 • Create a polynomial in $x$ and $y$, such as ${x}^{2}+x\cdot y+{y}^{2}$. Evaluate that polynomial at $x=10.$Integrate the result with respect to $y$.