Math Expression Component - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Document Tools : Embedded Components : MathExpressionComponent

Math Expression Component

• 

The mathematical expression component defines a math expression region in a Standard Maple worksheet or document. This 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 MathContainer Properties. To display component properties, right-click (Control-click for Macintosh) the embedded component, select Component, and then select Component Properties. 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 G column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.

  

An x in the S column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.

Option       G  S  Option Type     
                                   
autoFit      x  x  true or false   
expression   x  x  expression      
pixelHeight  x  x  positive integer
pixelWidth   x  x  positive integer
showBorders  x  x  true or false   
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.

  

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.

  

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.

  

showBorders

  

Specifies if the border of the component is visible. By default, the value is true.

  

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.

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. 

Right-click (Control-click for Macintosh) the Label component, and then select Component Properties.

3. 

In the Caption field, enter Select a function to integrate, and then click OK.

To add the expressions to the list box:

1. 

Right-click (Control-click for Macintosh) the List Box component, and then select Component Properties.

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.

7. 

Click OK to close the ListBox Properties dialog.

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

1. 

Right-click (Control-click for Macintosh) the List Box component, and then select Edit Select Action.

This launches a dialog with preset statements and additional information on how to program actions between embedded components.

2. 

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

Do(%MathContainer0 = (Int(%ListBox0,x) = int(%ListBox0,x)));

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

3. 

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.

 

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

DocumentTools[Do](%MathContainer0 = (Int(%ListBox0, x) = int(%ListBox0, x)));

∫sinx2cos2xⅆx=12sinxcosx+12x12sin2x

(3.1)

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

DocumentTools[GetProperty]('MathContainer0','expression');

∫sinx2cos2xⅆx=12sinxcosx+12x12sin2x

(3.2)

MathML[ImportModified](DocumentTools[GetProperty]('MathContainer0','value'));

∫sinx2cos2xⅆx=12sinxcosx+12x12sin2x

(3.3)

See Also

ButtonComponent, CheckBoxComponent, ComboBoxComponent, DataTableComponent, DialComponent, DocumentTools, DocumentTools[Do], DocumentTools[GetProperty], DocumentTools[SetProperty], EmbeddedComponents, InertForm[FromMathContainer], LabelComponent, ListBoxComponent, MathML[ImportModified], MeterComponent, PlotComponent, RadioButtonComponent, RotaryGaugeComponent, ShortcutComponent, SliderComponent, TextAreaComponent, ToggleButtonComponent, VideoPlayerComponent, VolumeGaugeComponent


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam