Sample Maplet Application: Integration
This worksheet demonstrates how to write Maplet applications that function similarly to the Integration Maplet application available in the Maplets[Examples] package. It is designed for experienced Maple authors.
restart;
Indefinite Integration
The user is prompted for the integrand and the variable of integration. The MathML viewer requires that its value be valid MathML, while the user expects an algebraic solution upon selecting OK. To solve this problem, the solution to the integral is stored in a hidden text field, and this value is then used in a second Evaluate statement to generate the MathML required to display the result.
with(Maplets[Elements]): maplet1 := Maplet( [ ["Integrand: ", TextField['intg']( 30 ), " Variable: ", TextField['var']( 5 )], MathMLViewer['MMLV1'](), [ Button( "Integrate", Action( Evaluate( 'integral' = 'int( intg, var )' ), Evaluate( 'MMLV1' = 'MathML[Export]( integral )' ) ) ), Button( "Clear", Action( SetOption( 'intg' = "" ), SetOption( 'var' = "" ), SetOption( 'MMLV1' = "" ), SetOption( 'integral' = "" ) ) ), Button( "OK", Shutdown( ['integral'] ) ), Button( "Cancel", Shutdown() ) ] ], TextField[integral]() ):
result := Maplets[Display]( maplet1 );
if type( result, ['string'] ) then parse( result[1] ); else NULL; end if;
Definite Integration
The major differences between definite and indefinite integration are:
1. The lower and upper limits of integration.
2. Cauchy principal value integration is an option which applies only in definite integration.
3. The int option 'continuous' speeds up the integration routine, as it assumes the integrand (and therefore the resulting integral) is continuous.
with(Maplets[Elements]): maplet2 := Maplet( [ ["Integrand: ", TextField['intg']( 30 ), " Variable: ", TextField['var']( 5 )], ["Lower limit: ", TextField['LL']( 10 ), " Upper limit: ", TextField['UL']( 10 )], ["Use Cauchy principal value integration: ", CheckBox['CB1']()], ["The function is continuous on the given range: ", CheckBox['CB2']()], MathMLViewer['MMLV1'](), [ Button( "Integrate", Action( Evaluate( 'integral' = 'int( intg, var=LL..UL, `if`( CB1, CauchyPrincipalValue, NULL ), `if`( CB2, continuous, NULL ) )' ), Evaluate( 'MMLV1' = 'MathML[Export]( integral )' ) ) ), Button( "Clear", Action( SetOption( 'intg' = "" ), SetOption( 'var' = "" ), SetOption( 'LL' = "" ), SetOption( 'UL' = "" ), SetOption( 'MMLV1' = "" ), SetOption( 'integral' = "" ) ) ), Button( "OK", Shutdown( ['integral'] ) ), Button( "Cancel", Shutdown() ) ] ], TextField['integral']() ):
Maplets[Display]( maplet2 );
Maplets[Examples][Integration]
The Maplets[Examples][Integration] function displays a similar Maplet application to that of the previous examples. The function, however, gives the user the option of selecting the integration type. Also, if the user specifies one argument, it is placed in the Integrand field. If two arguments are specified, they are placed in the Integrand and Variable fields, respectively.
For help on this Maplet application, see:
?Maplets[Examples][Integration]
To view the source code, enter:
print( Maplets[Examples][Integration] );
See Also
Maplets[Examples], int
Return to Index for Example Worksheets
Download Help Document