Math Expression Component - Maple Help

Math Expression Component

Insert a math expression region in a Standard Maple worksheet or document.

Description

 • The mathematical expression component displays 2-D math expressions passed from another embedded component. It also provides editing functionality for entering math expressions.
 • The math expression component returns the value of its contents as a string of MathML elements. To convert this into a Maple expression, use the MathML[ImportModified] command.
 • The mathematical expression component is customized by setting options in the Mathematical Expression context panel. To display the options in the context panel, select the embedded component. Actions are associated with components using routines in the DocumentTools package. For more information, see the Math Expression Component Example on this page.
 • The Name property is used to reference the math expression component when using the routines from the DocumentTools package.
 Component Palette Image

Mathematical Expression Properties

 • The following table describes the control and use of the mathematical expression component options.
 An x in the Get column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.
 An x in the Set column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.

 Option Get Set Option Type autoFit x x true or false editable x x true or false expression x x expression fillcolor x x color minimumpixelheight x x positive integer minimumpixelwidth x x positive integer pixelHeight x x positive integer pixelWidth x x positive integer scrolldown x x true or false showBorders x x true or false type x string value x x MathML visible x x true or false

 autoFit
 Specifies whether to automatically resize the Math Expression component to fit its contents.  By default, the value is false.
 editable
 Specifies whether the mathematical expression component is editable. By default, the value is true.
 expression
 The contents of the Math Expression component (MathContainer) as a Maple expression. The usual simplification rules are applied to the expression. For example, retrieving the expression from a MathContainer into which 3*4 has been entered will return 12. To obtain the contents exactly as they were entered, use InertForm[FromMathContainer] or the value property.
 fillcolor
 Specifies the background color of the component. The color can be given by RGB values (a list of three integers between 0 and 255) or a string representing a color name, for example, [255,0,0] or “Red”. The default value is [255,255,255] which corresponds to white.
 minimumpixelheight
 The minimum height of the mathematical expression region in pixels. Used with autoFit=true. By default, the value is 200.
 minimumpixelwidth
 The minimum width of the mathematical expression region in pixels. Used with autoFit=true. By default, the value is 300.
 pixelHeight
 The height of the mathematical expression region in pixels. By default, the value is 200.
 pixelWidth
 The width of the mathematical expression region in pixels. By default, the value is 300.
 scrolldown
 Specifies whether to allow automatic scrolling to the bottom of the Math Expression window to make new results visible, when the window size is restricted and the scroll bar is visible.
 showBorders
 Specifies if the border of the component is visible. By default, the value is true.
 type
 The type of the component. This returns "MathContainer".
 value
 The contents in the component in MathML. Note that since the content is in MathML, use of DocumentTools[Do] should either retrieve the value unparsed (i.e. %%ComponentName(value)) or use the expression property.
 visible
 Specifies if the component is visible. By default, the value is true.

 • These properties can be accessed programmatically. You can access the contents of the MathContainer, for example, using expr:= DocumentTools:-GetProperty(ComponentName,expression); as demonstrated in the example.

To make the mathematical expression component read-only:

 1 Click the component.
 2 In the Mathematical Expression context panel, clear the check box Editable.

The expression is no longer editable.

Math Expression Component Example

Note: To interact with the example provided below, open this help page as a worksheet, and then execute the worksheet.

This example uses a List Box component to display some expressions. Selecting an expression from the List Box displays the integrated expression in the Math Expression component.

To insert the label, list box, and mathematical expression components, and then configure the label component:

 1 Insert a Label, ListBox and MathExpression component using the Components palette. For information on displaying the Maple palettes, see the Show Palettes help page.
 2 Click the Label component to display the context panel.
 3 In the Caption field, enter Select a function to integrate.

To add the expressions to the list box:

 1 Click the List Box component to display the context panel.
 2 Click the Edit button of the Item List field.
 3 Double-click the first row and replace ListBox with sin(x)*2.
 4 Click Add, double-click the new field, and then replace the default entry with exp(x)^2.
 5 Repeat step 4 and add the following items to the list: cos(x)/2 and sin(x)^2-cos(2*x).
 6 Click OK to close the List Editor.

To display the integral of the expression selected from the list box:

 1 Click the List Box component, and then select Edit Select Code.

This launches the Code Editor dialog.

 2 Before the end use; statement in the dialog, enter the following command:

SetProperty("MathContainer0", value, (Int(parse(GetProperty("ListBox0", value)), x) = int(parse(GetProperty("ListBox0", value)), x)));

Note: Ensure the names of the components are correct (that is, that they match the Name fields for their components).

 3 Click  or from the File menu, select Save Code to accept all changes.
 4 From the File menu, select Close Code Editor.

When you select an item from the list box, the math expression component displays the integral for the expression.

 > with(DocumentTools):

You can verify the syntax of the embedded component action by executing the command in the worksheet.

 > SetProperty("MathContainer0", value, (Int(parse(GetProperty("ListBox0", value)), x) = int(parse(GetProperty("ListBox0", value)), x)));

To display the contents of the Math Expression component, access the expression property or use the MathML[ImportModified]  command on the value.

 > GetProperty("MathContainer0",expression);
 ${∫}\frac{{1}}{{2}}{}{\mathrm{cos}}{}\left({x}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}{=}\frac{{1}}{{2}}{}{\mathrm{sin}}{}\left({x}\right)$ (5.1)
 > MathML[ImportModified](GetProperty("MathContainer0",value));
 ${∫}\left({{\mathrm{sin}}{}\left({x}\right)}^{{2}}{-}{\mathrm{cos}}{}\left({2}{}{x}\right)\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}{=}{-}\frac{{1}}{{2}}{}{\mathrm{sin}}{}\left({x}\right){}{\mathrm{cos}}{}\left({x}\right){+}\frac{{1}}{{2}}{}{x}{-}\frac{{1}}{{2}}{}{\mathrm{sin}}{}\left({2}{}{x}\right)$ (5.2)
 >