Daniel Skoog

Daniel Skoog

1766 Reputation

22 Badges

13 years, 348 days

MaplePrimes Activity


These are Posts that have been published by Daniel Skoog

The Joint Mathematics Meetings are taking place this week (January 4 – 7) in Atlanta, Georgia, U.S.A. This will be the 100th annual winter meeting of the Mathematical Association of America (MAA) and the 123nd annual meeting of the American Mathematical Society (AMS).

Maplesoft will be exhibiting at booth #118 as well as in the networking area. Please stop by our booth or the networking area to chat with me and other members of the Maplesoft team, as well as to pick up some free Maplesoft swag or win some prizes.

There are also several interesting Maple-related talks and events happening this week:

 

Teaching Cryptology to Increase Interest in Mathematics for Students Majoring in Non-Technical Disciplines and High School Students

Wednesday, January 4, 0820, L401 & L402, Lobby Level, Marriott Marquis

Neil Sigmon, Radford University

 

Enigma: A Combinatorial Analysis and Maple Simulator

Wednesday, January 4, 0900, L401 & L402, Lobby Level, Marriott Marquis

Rick Klima, Appalachian State University

 

MYMathApps Calculus - Building on Maplets for Calculus

Thursday, January 5, 0800, Courtland, Conference Level, Hyatt Regency

Philip B. Yasskin, Texas A&M University 
Douglas B. Meade, University of South Carolina 
Andrew Crenwelge, Texas A&M University

 

Maple Software Technology as a Stimulant Tool for Dynamic Interactive Calculus Teaching and Learning

Thursday, January 5, 1000, Courtland, Conference Level, Hyatt Regency

Lina Wu, Borough of Manhattan Community College-The City University of New York 

 

Collaborative Research: Maplets for Calculus

Thursday, January 5, 1400, Marquis Ballroom, Marquis Level, Marriott Marquis

Philip Yasskin, Texas A&M University 
Douglas Meade, U of South Carolina

 

Digital Graphic Calculus Art Design in Maple Software

Thursday, January 5, 1420, International 7, International Level, Marriott Marquis

Lina Wu, Borough of Manhattan Community College-The City University of New York 

 

Maplesoft will also be hosting a catered reception and brief presentation on Teaching STEM Online: Challenges and Solutions, Thursday January 5th, from 6:00pm – 7:30pm, at the Hyatt Regency, Hanover AB, on the exhibitor level. Please RSVP at www.maplesoft.com/jmm or at Maplesoft booth #118.

 

If you are attending the Joint Math meetings this week and plan on presenting anything on Maple, please feel free to let me know and I'll update this list accordingly.


See you in Atlanta!

Daniel

Maple Product Manager

Students using Maple often have different needs than non-students. Students need more than just a final answer; they are looking to gain an understanding of the mathematical concepts behind the problems they are asked to solve and to learn how to solve problems. They need an environment that allows them to explore the concepts and break problems down into smaller steps.

The Student packages in Maple offer focused learning environments in which students can explore and reinforce fundamental concepts for courses in Precalculus, Calculus, Linear Algebra, Statistics, and more. For example, Maple includes step-by-step tutors that allow students to practice integration, differentiation, the finding of limits, and more. The Integration Tutor, shown below, lets a student evaluate an integral by selecting an applicable rule at each step. Maple will also offer hints or show the next step, if asked.  The tutor doesn't only demonstrate how to obtain the result, but is designed for practicing and learning.

For this blog post, I’d like to focus in on an area of great interest to students: showing step-by-step solutions for a variety of problems in Maple.

Several commands in the Student packages can show solution steps as either output or inline in an interactive pop-up window. The first few examples return the solution steps as output.

Precalculus problems:

The Student:-Basics sub-package provides a collection of commands to help students and teachers explore fundamental mathematical concepts that are core to many disciplines. It features two commands, both of which return step-by-step solutions as output.

The ExpandSteps command accepts a product of polynomials and displays the steps required to expand the expression:

with(Student:-Basics):
ExpandSteps( (a^2-1)/(a/3+1/3) );

The LinearSolveSteps command accepts an equation in one variable and displays the steps required to solve for that variable.

with(Student:-Basics):
LinearSolveSteps( (x+1)/y = 4*y^2 + 3*x, x );

This command also accepts some nonlinear equations that can be reduced down to linear equations.

Calculus problems:

The Student:-Calculus1 sub-package is designed to cover the basic material of a standard first course in single-variable calculus. Several commands in this package provide interactive tutors where you can step through computations and step-by-step solutions can be returned as standard worksheet output.

Tools like the integration, differentiation, and limit method tutors are interactive interfaces that allow for exploration. For example, similar to the integration-methods tutor above, the differentiation-methods tutor lets a student obtain a derivative by selecting the appropriate rule that applies at each step or by requesting a complete solution all at once. When done, pressing “Close” prints out to the Maple worksheet an annotated solution containing all of the steps.

For example, try entering the following into Maple:

with(Student:-Calculus1):
x*sin(x);

Next, right click on the Matrix and choose “Student Calculus1 -> Tutors -> Differentiation Methods…

The Student:-Calculus1 sub-package is not alone in offering this kind of step-by-step solution finding. Other commands in other Student packages are also capable of returning solutions.

Linear Algebra Problems:

The Student:-LinearAlgebra sub-package is designed to cover the basic material of a standard first course in linear algebra. This sub-package features similar tutors to those found in the Calculus1 sub-package. Commands such as the Gaussian EliminationGauss-Jordan Elimination, Matrix Inverse, Eigenvalues or Eigenvectors tutors show step-by-step solutions for linear algebra problems in interactive pop-up tutor windows. Of these tutors, a personal favourite has to be the Gauss-Jordan Elimination tutor, which were I still a student, would have saved me a lot of time and effort searching for simple arithmetic errors while row-reducing matrices.

For example, try entering the following into Maple:

with(Student:-LinearAlgebra):
M:=<<77,9,31>|<-50,-80,43>|<25,94,12>|<20,-61,-48>>;

Next, right click on the Matrix and choose “Student Linear Algebra -> Tutors -> Gauss-Jordan Elimination Tutor

This tutor makes it possible to step through row-reducing a matrix by using the controls on the right side of the pop-up window. If you are unsure where to go next, the “Next Step” button can be used to move forward one-step. Pressing “All Steps” returns all of the steps required to row reduce this matrix.

When this tutor is closed, it does not return results to the Maple worksheet, however it is still possible to use the Maple interface to step through performing elementary row operations and to capture the output in the Maple worksheet. By loading the Student:-LinearAlgebra package, you can simply use the right-click context menu to apply elementary row operations to a Matrix in order to step through the operations, capturing all of your steps along the way!

An interactive application for showing steps for some problems:

While working on this blog post, it struck me that we did not have any online interactive applications that could show solution steps, so using the commands that I’ve discussed above, I authored an application that can expand, solve linear problems, integrate, differentiate, or find limits. You can interact with this application here, but note that this application is a work in progress, so feel free to email me (maplepm (at) Maplesoft.com) any strange bugs that you may encounter with it.

More detail on each of these commands can be found in Maple’s help pages.

 

Run the following command in Maple:

Explore(plot(x^k), k = 1 .. 3);

 

Once you’ve run the command, move the slider from side to side. Neat, isn’t it?

With this single line of code, you have built an interactive application that shows the graph of x to the power of various exponent powers.

 

The Explore command is an application builder. More specifically, the Explore command can programmatically generate interactive content in Maple worksheets.

Programmatically generated content is inserted into a Maple worksheet by executing Maple commands. For example, when you run the Explore command on an expression, it inserts a collection of input and output controllers, called Embedded Components, into your Maple worksheet. In the preceding example, the Explore command inserts a table containing:

  • a Slider component, which corresponds to the value for the exponent k
  • a Plot component, which shows the graph of x raised to the power for k

Together these components form an interactive application that can be used to visualize the effect of changing parameter values.

Explore can be viewed as an easy application creator that generates simple applications with input and output components. Recently added packages for programmatic content generation broaden Maple’s application authoring abilities to form a full development framework for creating customized interactive content in a Maple worksheet. The DocumentTools package contains many of these new tools. Components and Layout are two sub-packages that generate XML using function calls that represents GUI elements, such as embedded components, tables, input, or output. For example, the DocumentTools:-Components:-Plot command creates a new Plot component. These key pieces of functionality provide all of the building blocks needed to create customizable interfaces inside of the Maple worksheet. For me, this new functionality has completely altered my approach to building Maple worksheets and made it much easier to create new applications that can explore hundreds of data sets, visualize mathematical functions, and more.

I would go so far as to say that the ability to programmatically generate content is one of the most important new sources of functionality over the past few years, and is something that has the potential to significantly alter the way in which we all use Maple. Programmatic content generation allows you to create applications with hundreds of interactive components in a very short period of time when compared to building them manually using embedded components. As an illustration of this, I will show you how I easily created a table with over 180 embedded components—and the logic to control them.

 

Building an interface for exploring data sets:

In my previous blog post on working with data sets in Maple, I demonstrated a simple customized interface for exploring country data sets. That post only hinted at the much bigger story of how the Maple programming language was used to author the application. What follows is the method that I used, and a couple of lessons that I learned along the way.

When I started building an application to explore the country data sets, I began with an approach that I had used to build several MathApps in the past. I started with a blank Maple worksheet and manually added embedded components for controlling input and output. This included checkbox components for each of the world’s countries, drop down boxes for available data sets, and a couple of control buttons for retrieving data to complete my application.

This manual, piece-by-piece method seemed like the most direct approach, but building my application by hand proved time-consuming, given that I needed to create 180 checkboxes to house all available countries with data. What I really needed was a quicker, more scriptable way to build my interface.

 

So jumping right into it, you can view the code that I wrote to create the country data application here:PECCode.txt

Note that you can download a copy of the associated Maple worksheet at the bottom of this page.

 

I won’t go into too much detail on how to write this code, but the first thing to note is the length of the code; in fewer than 70 lines, this code generates an interface with all of the required underlying code to drive interaction for 180+ checkboxes, 2 buttons and a plot. In fact, if you open up the application, you’ll see that every check box has several lines of code behind it. If you tried to do this by hand, the amount of effort would be multiplied several times over.

This is really the key benefit to the world of programmatic content generation. You can easily build and rebuild any kind of interactive application that you need using the Maple programming language. The possibilities are endless.

 

Some tips and tricks:

There are a few pitfalls to be aware of when you learn to create content with Maple code. One of the first lessons I learned was that it is always important to consider embedded component name collision and name resolution.

For those that have experimented with embedded components, you may have noticed that Maple’s GUI gives unique names to components that are copied (or added) in a Maple worksheet. For example, the first TextArea component that you add to a worksheet usually has the default name TextArea0. If you next add another TextArea, this new TextArea gets the name TextArea1, so as to not collide with the first component. Similar behaviour can be observed with any other component and even within some component properties such as ‘group’ name.

Many of the options for commands in the DocumentTools sub-packages can have “action code”, or code that is run when the component is interacted with. When building action code for a generated component, the action code is specified using a long string that encapsulates all of the code. Due to this code being provided as a long string, one trick that I quickly picked up is that it is important to separate out the names for any components into sub-strings inside of a longer cat statement.

For example, here is a line that is contained within a longer cat statement in the preceding code:

cat( "DocumentTools:-SetProperty( \"", "ComboBox_0", "\", 'value', \"Internet Users\" );\n" )

It is necessary to enclose “ComboBox_0” in quotes, as well as to add in escaped quotes in order to have the resulting action code look like (also note the added new line at the end):

“DocumentTools:-SetProperty( “ComboBox_0”, ‘value’, “Internet Users” );”

Doing so ensures that when the components are created, the names are not hard-coded to always just look for a given name. This means that the GUI can scrape through the code and update any newly generated components with a new name when needed. This is important if “ComboBox_0” already exists so that the GUI can instead create “ComboBox_1”.

 

Another challenge for coding applications is adding a component state. One of the most common problems encountered with running any interactive content in Maple is that if state is not persistent, errors can occur when, for example, a play button is clicked but the required procedures have not been run. This is a very challenging problem, which often require solutions like the use of auto-executing start-up code or more involved component programming. Some features in Maple 2016 have started working to address this, but state is still something that usually needs to be considered on an application by application basis.

In my example, I needed to save the state of a table containing country names so that the interface retains the information for check box state (checked or unchecked) after restart. That is, if I saved the application with two countries selected, I wanted to ensure that when I opened the file again those same two countries would still be selected, both in the interface as well as in the table that is used to generate the plot. Now accomplishing this was a more interesting task: my hack was to insert a DataTable component, which stored my table as an entry of a 1x1 Matrix rtable. Since the rtable that underlies a DataTable is loaded into memory on Maple load, this gave me a way to ensure that the checked country table was loaded on open.

Here, for example, is the initial creation of this table:

"if not eval( :-_SelectedCountries )::Matrix then\n",
"    :-_SelectedCountries := Matrix(1,1,[table([])]):\n",
"end if;\n",

For more details, just look for the term: “:-_SelectedCountries” in the preceding code.

I could easily devote separate posts to discussing in detail each of these two quick tips. Similarly, there’s much more that can be discussed with respect to authoring an interface using programmatic tools from the DocumentTools packages, but I found the best way to learn more about a command is to try it out yourself. Once you do, you’ll find that there are an endless number of combinations for the kinds of interfaces that can be quickly built using programmatic content generation. Several commands in Maple have already started down the path of inserting customized content for their output (see DataSets:-InsertSearchBox and AudioTools:-Preview as a couple of examples) and I can only see this trend growing.

Finally, I would like to say that getting started with programmatic content generation was intimidating at first, but with a little bit of experimentation, it was a rewarding experience that has changed the way in which I work in Maple. In many cases, I now view output as something that can be customized for any command. More often than not, I turn to commands like ‘Explore’ to create an interface to see how sweeping through parameters effects my results, and any time I want to perform a more complex analysis or visualization for my data, I write code to create interfaces that can more easily be customized and re-used for other applications.

If you are interested in learning more about this topic, some good examples to get started with are the examples page for programmatic content generation as well as the help pages for the DocumentTools:-Components and DocumentTools:-Layout sub-packages.

To download a copy of the worksheet used in this post, click here (note that the code can be found in the start-up code of this worksheet): CountryDataPEC.mw To create the datasets interface, simply run the CountrySelection(); command.

Aggregate statistics are calculated by splitting the rows of a DataFrame by each factor in a given column into subsets and computing summary statistics for each of these subsets.

The following is a short example of how the Aggregate command is used to compute aggregate statistics for a DataFrame with housing data:

To begin, we construct a DataFrame with housing data: The first column has number of bedrooms, the second has the area in square feet, the third has price.
 

bedrooms := <3, 4, 2, 4, 3, 2, 2, 3, 4, 4, 2, 4, 4, 3, 3>:
area := <1130, 1123, 1049, 1527, 907, 580, 878, 1075, 
         1040, 1295, 1100, 995, 908, 853, 856>:
price := <114700, 125200, 81600, 127400, 88500, 59500, 96500, 113300, 
          104400, 136600, 80100, 128000, 115700, 94700, 89400>:
HouseSalesData := DataFrame([bedrooms, area, price], columns = [Bedrooms, Area, Price]);

Note that the Bedrooms column has three distinct levels: 2, 3, and 4.

convert(HouseSalesData[Bedrooms], set);

The following returns the mean of all other columns for each distinct level in the column, Bedrooms:

Aggregate(HouseSalesData, Bedrooms);

Adding the columns option controls which columns are returned.

Aggregate(HouseSalesData, Bedrooms, columns = [Price])

Additionally, the tally option returns a tally for each of the levels.

Aggregate(HouseSalesData, Bedrooms, tally)

The function option allows for the specification of any command that can be applied to a DataSeries. For example, the Statistics:-Median command computes the median for each of the levels of Bedrooms.

Aggregate(HouseSalesData, Bedrooms, function = Statistics:-Median);

By default, Aggregate uses the SplitByColumn command to creates a separate sub-DataFrame for every discrete level in the column given by bycolumn.

with(Statistics);
ByRooms := SplitByColumn(HouseSalesData, Bedrooms);

We can create box plots of the price for subgroups of sales defined by number of bedrooms.

BoxPlot( map( (m)->m[Price], ByRooms), 
             deciles=false, 
             datasetlabels=["2 bdrms", "3 bdrms", "4 bdrms"], 
             color=["Red", "Purple", "Blue"]);

 

I have recorded a short video that walks through this example here:

The worksheet for this example can be downloaded here: Aggregate.mw

This is the second of three blog posts about working with data sets in Maple.

In my previous post, I discussed how to use Maple to access a large number of data sets from Quandl, an online data aggregator. In this post, I’ll focus on exploring built-in data sets in Maple.

Data is being generated at an ever increasing rate. New data is generated every minute, adding to an expanding network of online information. Navigating through this information can be daunting. Simply preparing a tabular data set that collects information from several sources is often a difficult and time consuming effort. For example, even though the example in my previous post only required a couple of lines of Maple code to merge 540 different data sets from various sources, the effort to manually search for and select sources for data took significantly more time.

In an attempt to make the process of finding data easier, Maple’s built-in country data set collects information on country-specific variables including financial and economic data, as well as information on country codes, population, area, and more.

The built-in database for Country data can be accessed programmatically by creating a new DataSets Reference:

CountryData := DataSets:-Reference( "builtin", "country" );

This returns a Reference object, which can be further interrogated. There are several commands that are applicable to a DataSets Reference, including the following exports for the Reference object:

exports( CountryData, static );

The list of available countries in this data set is given using the following:

GetElementNames( CountryData );

The available data for each of these countries can be found using:

GetHeaders( CountryData );

There are many different data sets available for country data, 126 different variables to be exact. Similar to Maple’s DataFrame, the columns of information in the built-in data set can be accessed used the labelled name.

For example, the three-letter country codes for each country can be returned using:

CountryData[.., "3 Letter Country Code"];

The three-letter country code for Denmark is:

CountryData["Denmark", "3 Letter Country Code"];

Built-in data can also be queried in a similar manner to DataFrames. For example, to return the countries with a population density less than 3%:

pop_density := CountryData[ .., "Population Density" ]:
pop_density[ `Population Density` < 3 ];

At this time, Maple’s built-in country data collection contains 126 data sets for 185 countries. When I built the example from my first post, I knew exactly the data sets that I wanted to use and I built a script to collect these into a larger data container. Attempting a similar task using Maple’s built-in data left me with the difficult decision of choosing which data sets to use in my next example.

So rather than choose between these available options, I built a user interface that lets you quickly browse through all of Maple’s collection of built-in data.

Using a couple of tricks that I found in the pages for Programmatic Content Generation, I built the interface pictured above. (I’ll give more details on the method that I used to construct the interface in my next post.)

This interface allows you to select from a list of countries, and visualize up to three variables of the country data with a BubblePlot. Using the preassigned defaults, you can select several countries and then visualize how their overall number of internet users has changed along with their gross domestic product. The BubblePlot visualization also adds a third dimension of information by adjusting the bubble size according to the relative population compared with the other selected countries.

Now you may notice that the list of available data sets is longer than the list of available options in each of the selection boxes. In order to be able to generate BubblePlot animations, I made an arbitrary choice to filter out any of the built-in data sets that were not of type TimeSeries. This is something that could easily be changed in the code. The choice of a BubblePlot could also be updated to be any other type of Statistical visualization with some additional modifications.

You can download a copy of this application here: VisualizingCountryDataSets.mw

You can also interact with it via the MapleCloud: http://maplecloud.maplesoft.com/application.jsp?appId=5743882790764544

I’ll be following up this post with an in-depth post on how I authored the country selector interface using programmatic content generation.

1 2 3 4 5 6 Page 3 of 6