Maplesoft Blog

The Maplesoft blog contains posts coming from the heart of Maplesoft. Find out what is coming next in the world of Maple, and get the best tips and tricks from the Maple experts.

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.

We've added a collection of thermal engineering applications to the Application Center. You could think of it as an e-book.

This collection has a few features that I think are pretty neat

  • The applications are collected together in a Workbook; a single file gives you access to 30 applications
  • You can navigate the contents using the Navigator or a hyperlinked table of contents
  • You can change working fluids and operating conditions, while still using accurate thermophysical data

If you don't have Maple 2016, you can view and navigate the applications (and interactive with a few) using the free Player.

The collection includes these applications.

  • Psychrometric Modeling
    • Swamp Cooler
    • Adiabatic Mixing of Air
    • Human Comfort Zone
    • Dew Point and Wet Bulb Temperature
    • Interactive Psychrometric Chart
  • Thermodynamic Cycles
    • Ideal Brayton Cycle
    • Optimize a Rankine Cycle
    • Efficiency of a Rankine Cycle
    • Turbine Analysis
    • Organic Rankine Cycle
    • Isothermal Compression of Methane
    • Adiabatic Compression of Methane
  • Refrigeration
    • COP of a Refrigeration Cycle
    • Flow Through an Expansion Valve
    • Food Refrigeration
    • Rate of Refrigerant Boiling
    • Refrigeration Cycle Analysis 1
    • Refrigeration Cycle Analysis 2
  • Miscellaneous
    • Measurement Error in a Manometer
    • Particle Falling Through Air
    • Saturation Temperature of Fluids
    • Water Fountain
    • Water in Piston
  • Heat Transfer
    • Dittus-Boelter Correlation
    • Double Pipe Heat Exchanger
    • Energy Needed to Vaporize Ethanol
    • Heat Transfer Coefficient Across a Flat Plate
  • Vapor-Liquid Equilibria
    • Water-Ethanol

I have a few ideas for more themed Maple application collections. Data analysis, anyone?

Maple T.A. MAA Placement Test Suite  2016 is now available. It leverages all the improvements found in Maple T.A. 2016, including:

  • A redesigned authoring workflow that makes it faster and easier to create and modify questions and assignments
  • A new content repository that makes it substantially easier to manage and search for content
  • New built-in connectivity options for integration with course management systems

To learn more, visit What’s New in Maple T.A. MAA Placement Test Suite 2016.

Jonny
Maplesoft Product Manager, Online Education Products

A few people have asked me how I created the sections in the Maple application in this video: https://youtu.be/voohdmfTRn0?t=572

Here's the worksheet (Maple 2016 only). As you can see, the “sections” look different what you would normally expect (I often like to experiment with small changes in presentation!)

These aren't, however, sections in the traditional Maple sense; they're a demonstration of Maple 2016's new tools for programmatically changing the properties of a table (including the visibility of its rows and columns). @dskoog gets the credit for showing me the technique.

Each "section" consists of a table with two rows.

  • The table has a name, specified in its properties.
  • The first row (colored blue) contains (1) a toggle button and (2) the title of each section (with the text in white)
  • The second row (colored white) is visible or invisible based upon the state of the toggle button, and contains the content of my section.

Each toggle button has

  • a name, specified in its properties
  • + and - images associated with its on and off states (with the image background color matching the color of the first table row)
  • Click action code that enables or disables the visibility of the second row

The Click action code for the toggle button in the "Pure Fluid Properties" section is, for example,

tableName:="PureFluidProperties_tb":
buttonName:="PureFluidProperties_tbt":
if DocumentTools:-GetProperty(buttonName, 'value') = "false" then   
     DocumentTools:-SetProperty([tableName, 'visible[2..]', true]);
else
     DocumentTools:-SetProperty([tableName, 'visible[2..]', false]);
end if;

As I said at the start, I often try to make worksheets look different to the out-of-the-box defaults. Programmatic table properties have simply given me one more option to play about with.

Disclaimer: This blog post has been contributed by Prof. Nicola Wilkin, Head of Teaching Innovation (Science), College of Engineering and Physical Sciences and Jonathan Watkins from the University of Birmingham Maple T.A. user group*. 

Written for Maple T.A. 2016. For Maple T.A. 10 users, this question can be written using the queston designer.

 

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.

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

In 2013, I wrote a library for Maple that used the HTTP package to access the Quandl data API and import data sets into Maple. I was motivated by the fact that, when I was downloading data, I often used multiple data sources, manually updated data when updates were available, and cleaned or manipulated the data into a standardized form (which left me spending too much time on the data acquisition step).

Simply put, I needed a source for data that would provide me with a searchable, stable data API, which would also return data in a form that did not require too much post-processing.

My initial library had really just scratched the surface of what was possible.

Maple 2015 introduced the new DataSets package, which fully integrated a data set search into core library routines and made its functionality more discoverable through availability in Maple’s search bar.

Accessing online data suddenly became much easier. From within Maple, I could now search through over 12 million time series data sets provided by Quandl, and then automatically import the data into a format that I could readily work with.

If you’re not already aware of this online service, Quandl is an online data aggregator that delivers a wide variety of high quality financial and economic data. This includes the latest data on stocks and commodities, exchange rates, and macroeconomic indicators such as population, inflation, unemployment, and so on. Quandl collects both open and proprietary data sets from many sources, such as the US Federal Reserve System, OECD, Eurostat, The World Bank, and Open Data for Africa. Best of all, Quandl's powerful API is free to use.

One of the first examples for the DataSets package that I constructed was in part based on the inspirational work of Hans Rosling. I was drawn in by his ability to use statistical visualizations to break down complex multidimensional data sets and provide insight into underlying patterns; a key example investigating the correlation between rising incomes and life expectancy.

As well as online data, the DataSets package had a database for country data. Hence it seemed fitting to add an example that explored macroeconomic indicators for several countries. Accordingly, I set out to create an example that visualized variables such as Gross Domestic Product, Life Expectancy, and Population for a collection of countries.

I’ll now describe how I constructed this application.

The three key variables are Gross Domestic Product at Power Purchasing Parity, Life Expectancy, and Population. Having browsed through Quandl’s website for available data sets, the World Bank and Open Data for Africa projects seemingly had the most available relevant data; therefore I chose these as my data sources.

Pulling data for a single country from one of these sources was pretty straight forward. For example, the DataSets Reference for the Open Data for Africa data set on GDP at PPP for Canada is:

DataSets:-Reference("quandl", "ODA/CAN_PPPPC"));

In this command, the second argument is the Quandl data set code. If you are on Quandl’s website, this is listed near the top of the data set page as well as in the last few characters of the web address itself: https://www.quandl.com/data/ODA/CAN_PPPPC . Deconstructing the code, “ODA” stands for Open Data for Africa and the rest of the string is constructed from the three letter country code for Canada, “CAN”, and the code for the GDP and PPP. Looking at a small sample of other data set codes, I theorized that both of the data sources used a standardized data set name that included the ISO-3166 3-letter country code for available data sets. Based on this theory, I created a simple script to query for available data and discovered that there was data available for many countries using this standardized code. However, not every country had available data, so I needed to filter my list somewhat in order to pick only those countries for which information was available.

The script that I had constructed required three letter country codes. In order to test all available countries, I created a table to house the country names and three-letter country codes using data from the built-in database for countries:

ccdata := DataSets:-Builtin:-Reference("country")[.., "3 Letter Country Code"];
cctable := table([seq(op(GetElementNames(ccdata[i])) = ccdata[i, "3 Letter Country Code"], 
i = 1 .. CountRows(ccdata))]):

My script filtered this table, returning a subset of the original table, something like:

Countries := table( [“Canada” = “CAN”, “Sweden” = “SWE”, … ] );

You can see the filtered country list in the code edit region of the application below.

With this shorter list of countries, I was now ready to download some data. I created three vectors to hold the data sets by mapping in the DataSets Reference onto the “standardized” data set names that I pulled from Quandl. Here’s the first vector for the data on GDP at PPP.

V1 := Vector( [ (x) -> Reference("quandl", cat("ODA/", x, "_PPPPC"))
                   ~([entries(Countries, nolist, indexorder)])]):
#Open Data for Africa GDP at PPP

Having created three data vectors consisting of 180 x 3 = 540 data sets, I was finally ready to visualize the large set of data that I had amassed.

In Maple’s Statistics package, BubblePlots can use the horizontal axis, vertical axis and the relative bubble size to illustrate multidimensional information. Moreover, if incoming data is stored as a TimeSeries object, BubblePlots can generate animations over a common period of time.

Putting all of this together generated the following animation for 180 available countries.

This example will be included with the next version of Maple, but for now, you can download a copy here:DataSetsBubblePlot.mw

*Note: if you try this application at home, it will download 540 data sets. This operation plus the additional BubblePlot construction can take some time, so if you just want to see the finished product, you can simply interact with the animation in the Maple worksheet using the animation toolbar.

A more advanced example that uses multiple threads for data download can be seen at the bottom of the following page: https://www.maplesoft.com/products/maple/new_features/maple19/datasets_maple2015.pdf You can also interact with this example in Maple by searching for: ?updates,Maple2015,DataSets

In my next post, I’ll discuss how I used programmatic content generation to construct an interactive application for data retrieval.

When Maple 2016 hit the road, I finally relegated my printed Mollier charts and steam tables to a filing cabinet, and moved my carefully-curated spreadsheets of refrigerant properties to a distant part of my hard drive. The new thermophysical data engine rendered those obsolete.

Other than making my desk tidier, what I find exciting is that I can compute with fluid properties in a tool that has numerical integrators, ODE solvers, optimizers, programmatic visualisation and more.

Here are several small examples that demonstrate how you can use fluid properties with Maple’s math and visualization tools (this worksheet contains the complete examples).

Work Done in Compressing a Gas

The work done (per unit mass) in compressing a fluid at constant temperature is

where V1 and V2 are specific volumes and p is pressure.

You need a relationship between pressure and specific volume (either theoretical or experimental) to calculate the work done.

Assuming the ideal gas law, the work done becomes

where R is the ideal gas constant, T is the temperature (in K) and M is the molecular mass (in kg mol-1), and V is the volume.

 Ideal gas constant

Molecular mass of propane

Hence the work done predicted by the Ideal Gas Law is

Let’s now use real fluid properties instead and numerical integrators to compute the work done.

Here, the work done predicted with the Ideal Gas Law and real fluid properties is similar. This isn’t, however, always the case for all gases (try experimenting with ammonia – its strong intermolecular forces result in non-ideal behavior).

Minimum Specific Heat Capacity of Water

The specific heat capacity of water varies with temperature like so.

Let's find the temperature at which the specific heat capacity of water is the lowest.

The lowest specific heat capacity occurs at 309.4 K; this is the temperature at which water requires the least energy to raise or lower its temperature.

Incidentally, this isn’t that far from the standard human body temperature of 310.1 K (given that the human body is largely water, one might hazard a guess why we have evolved to maintain this temperature).

Temperature-Entropy Plot for Water

Maple 2016 generates pressure-enthalpy-temperature charts and psychrometric charts out of the box. However, you can create your own customized thermodynamic visualizations.

This, for example, is a temperature-entropy chart for water, together with the two-phase vapor dome (the worksheet contains the code to generate this plot).

I'm also working on a lumped-parameter heat exchanger model with fluid properties (and hence heat transfer coefficients) that change with temperature. That'll be more complex than these simple examples, and will use Maple's numeric ODE solver.

I’m pleased to announce the release of Maple T.A. 2016, our online assessment system.

For this release, we put a lot of effort into streamlining the authoring experience. We worked closely with customers to find out how they authored content, the places where they found the interface awkward, the tasks that took longer than they should have, and what they’d like to see changed. Then we made it better.

Right away you’ll notice that questions and assignments are no longer in separate places in Maple T.A. All your content is stored in a convenient location that makes it simple to browse your content. Contextual navigation, filtering options, sorting tools, question details, drag and drop organization, combined import feature, and more make it easier than ever to find and organize your content. The Maple T.A. Cloud also sees improvements. Not only can questions be shared, but assignments and entire course modules can be as well.

For question creation, we consolidated all question authoring into the question designer, so you have a single starting point no matter what kind of question you want to create. We have also refined the text editor to help authors find the tools they need to modify their questions. This includes embedding external content, importing questions from the repository, text formatting options, and more.

Of course, once you have questions, you’ll want to put them into an assignment, and assignment creation is now easier than ever. A key change is that you can now create and modify questions while you are creating an assignment, without having to leave the assignment editor. There are also changes to how you preview questions, set properties, and even save your assignments, all of which contribute to making assignment creation simpler and faster.

Of course, there’s more than just a significantly improved author workflow. Here are some highlights:

  • Assignment groups for efficient organization, both in the content repository and on the class homepage.
  • Easy-to-create sorting questions – no coding required!
  • HTML questions, which can be authored directly in the question designer.
  • Clickable image questions are Java-free and easier to author.
  • Maximum word counts and other improvements to the essay question type.
  • A new scanned document feature lets instructors upload and even grade scanned documents.
  • Officially certified LTI integration for connectivity with a wide range of course management systems

See What’s New in Maple T.A. 2016 for more information on these and other new features.

Jonny Zivku
Maplesoft Product Manager, Online Education Products

A wealth of knowledge is on display in MaplePrimes as our contributors share their expertise and step up to answer others’ queries. This post picks out one such response and further elucidates the answers to the posted question. I hope these explanations appeal to those of our readers who might not be familiar with the techniques embedded in the original responses.

The Question: Transforming functions to names

Bendesarts wanted to know how to make programmatic changes to characters in a list. He wrote:

I have this list :

T:=[alpha(t),beta(t)]

I would like to create this list automatically:

Tmod:=[alpha_,beta_]

In other words, how can I remove the 3 characters "(t)" and replace it by "_"

Do you have ideas to do so ?

Thanks a lot for your help

Joe Riel provided a complete answer that had three different approaches. He wrote:

Map, over the list, a procedure that extracts the name of the function and catenates an underscore to it. The function name is extracted via the op procedure, e.g. op(0,f(a,b,c)) evaluates to f. Thus 

map(f->cat(op(0,f),_),T);

Note that this fails if the name of a function is indexed, e.g. f[2](a). No error is generated but the catenation doesn't evaluate to a symbol. Presumably that isn't an issue here.  One way to handle that case is to first convert the indexed name to a symbol, then catenate the underscore.  So a more robust version is

map(f->cat(convert(op(0,f),'symbol'),_),T);

However, if you are actually dealing with indexed names you might want a different result. Another way to do the conversion, and combine it with the catenation, is to use nprintf, which generates a name (symbol). Thus

map(f -> nprintf("%a_", op(0,f)),T);

 

Let’s discuss each approach by understanding the definitions and functionalities of the commands used. 

The map command, map(fcn, expr, arg1, ..., argN) applies a procedure or name, fcn, to the operands or elements of an expression, expr. The result of a call to map is a copy of expr with the ith operand of expr replaced by the result of applying fcn to the ith operand.  This concept is easier to grasp by looking at a few examples related to the usage of map in this question.

Example 1.  map(x-> x2,x+y)         returns     x2+y2                    

Example 2. map(a -> a-b, sin(x))    returns     sin(x-b)

 

The cat function, cat(a,b,c,…), is commonly used to concatenate (or join) string and names together. This function’s parameters: a,b,c…, can be any expressions.

Example 1. cat(a,2)                      returns     a2

Example 2.  cat(“a”,3,sin(x))          returns    “a3sin(x)”

 

The op function, op(i..j,e), extracts operands from an expression. The parameters i and j are the integers indicating positions of the operands and e is the expression. For functions, as in this example, op(0,e) is the name of the function.

Example 1.  op(0,alpha(t))            returns   the symbol alpha

Example 2.  op(0, sin(x))              returns    sin

 

Now analyzing Joe Riel's code will be easier.

  1. map(f->cat(op(0,f),_),T);

In this approach Joe is extracting the name of the functions, alpha and beta, and then concatenating it to the underscore symbol. Then using the mapping function he applies the previous procedure to the list T.

  1. map(f->cat(convert(op(0,f),'symbol'),_),T);

This approach is a lot similar to the previous one, but he added the convert function in case the function inside of map was indexed. Convert(expr, form, arg3,..), is used to change an expression from one form to another. In this example op(0,f) has been changed from type name to type symbol.

  1. map(f -> nprintf("%a_", op(0,f)),T);

Again this is a similar approach but it uses nprintf. This command, nprintf(fmt,x1,..xn), is based on a C standard library command of the same name. It uses the format specifications in the fmt string to format and writes the expression into a Maple symbol, which is returned. In this example the format specified is the algebraic format “%a”.

 

This blog was written by Maplesoft’s intern Pia under the supervision of Dr. Robert Lopez. We both hope that you find this useful. If there is a particular question on MaplePrimes that you would like further explained, please let us know. 

The attached worksheet shows a small selection of new and improved results in integration for Maple 2016. Note that integration is a vast topic, so there will always be more improvements that can be made, but be sure that we are working on them.

Maple2016_Integration.mw

A selection of new and improved integration results for Maple 2016

New answers in Maple 2016

 

 

Indefinite integrals:

 

int(sqrt(1+sqrt(z-1)), z);

(4/5)*(1+(z-1)^(1/2))^(5/2)-(4/3)*(1+(z-1)^(1/2))^(3/2)

(1.1)

int(arctan((-1+sec(x))^(1/2))*sin(x), x);

-arctan((-(1/sec(x)-1)*sec(x))^(1/2))/sec(x)+(1/2)*(-1+sec(x))^(1/2)/sec(x)+(1/2)*arctan((-1+sec(x))^(1/2))

(1.2)

int(((1+exp(I*x))^2+(1+exp(-I*x))^2)/(1-2*c*cos(x)+c^2), x);

-x-2*x/c-x/c^2+I*exp(I*x)/c-I*exp(-I*x)/c-I*c*ln(exp(I*x)-1/c)/(c-1)-I*ln(exp(I*x)-1/c)/(c-1)-I*ln(exp(I*x)-1/c)/(c*(c-1))-I*ln(exp(I*x)-1/c)/(c^2*(c-1))+I*c*ln(-c+exp(I*x))/(c-1)+I*ln(-c+exp(I*x))/(c-1)+I*ln(-c+exp(I*x))/(c*(c-1))+I*ln(-c+exp(I*x))/(c^2*(c-1))

(1.3)

int(x^4/arccos(x)^(3/2),x);

(1/4)*(-x^2+1)^(1/2)/arccos(x)^(1/2)-(1/4)*2^(1/2)*Pi^(1/2)*FresnelC(2^(1/2)*arccos(x)^(1/2)/Pi^(1/2))+(3/8)*sin(3*arccos(x))/arccos(x)^(1/2)-(3/8)*2^(1/2)*Pi^(1/2)*3^(1/2)*FresnelC(2^(1/2)*3^(1/2)*arccos(x)^(1/2)/Pi^(1/2))+(1/8)*sin(5*arccos(x))/arccos(x)^(1/2)-(1/8)*2^(1/2)*Pi^(1/2)*5^(1/2)*FresnelC(2^(1/2)*5^(1/2)*arccos(x)^(1/2)/Pi^(1/2))

(1.4)

 

Definite integrals:

int(arcsin(sin(z)), z=0..1);

1/2

(1.5)

int(sqrt(1 - sqrt(1+z)), z=0..1);

((4/5)*I)*(2^(1/2)-1)^(3/2)*2^(1/2)+((8/15)*I)*(2^(1/2)-1)^(3/2)

(1.6)

int(z/(exp(2*z)+4*exp(z)+10),z = 0 .. infinity);

(1/20)*dilog((I*6^(1/2)-3)/(-2+I*6^(1/2)))-((1/60)*I)*6^(1/2)*dilog((I*6^(1/2)-3)/(-2+I*6^(1/2)))+(1/20)*dilog((I*6^(1/2)+3)/(2+I*6^(1/2)))+((1/60)*I)*6^(1/2)*dilog((I*6^(1/2)+3)/(2+I*6^(1/2)))+((1/120)*I)*6^(1/2)*ln(2+I*6^(1/2))^2-((1/120)*I)*6^(1/2)*ln(2-I*6^(1/2))^2+(1/40)*ln(2+I*6^(1/2))^2+(1/40)*ln(2-I*6^(1/2))^2+(1/60)*Pi^2

(1.7)

simplify(int(sinh(a*abs(x-y)), y=0..c, 'method'='FTOC'));

(1/2)*(piecewise(x < 0, 0, 0 <= x, 2*exp(-a*x))+piecewise(x < 0, 0, 0 <= x, -4)+2*piecewise(c <= x, -cosh(a*(-x+c))/a, x < c, (cosh(a*(-x+c))-2)/a)*a-exp(-a*x)+piecewise(x < 0, 0, 0 <= x, 2*exp(a*x))+4-exp(a*x))/a

(1.8)

int(ln(x+y)/(x^2+y), [x=0..infinity, y=0..infinity]);

infinity

(1.9)


Definite integrals with assumptions on the parameters:

int(x^(-ln(x)),x=0..b) assuming b > 0;

(1/2)*erf(ln(b)-1/2)*Pi^(1/2)*exp(1/4)+(1/2)*Pi^(1/2)*exp(1/4)

(1.10)

int(exp(-z)*exp(-I*n*z)*cos(n*z),z = -infinity .. infinity) assuming n::integer;

undefined

(1.11)


Integral of symbolic integer powers of sin(x) or cos(x):

int(sin(x)^n,x) assuming n::integer;

` piecewise`(0 < n, -(Sum((Product(1+1/(n-2*j), j = 1 .. i))*sin(x)^(n-2*i-1), i = 0 .. ceil((1/2)*n)-1))*cos(x)/n+(Product(1-1/(n-2*j), j = 0 .. ceil((1/2)*n)-1))*x, n < 0, (Sum((Product(1-1/(n+2*j+1), j = 0 .. i))*sin(x)^(n+2*i+1), i = 0 .. -ceil((1/2)*n)-1))*cos(x)/n+(Product(1+1/(n+2*j-1), j = 1 .. -ceil((1/2)*n)))*ln(csc(x)-cot(x)), x)

(1.12)

int(cos(x)^n,x) assuming n::negint;

-(Sum((Product(1-1/(n+2*j+1), j = 0 .. i))*cos(x)^(n+2*i+1), i = 0 .. -ceil((1/2)*n)-1))*sin(x)/n+(Product(1+1/(n+2*j-1), j = 1 .. -ceil((1/2)*n)))*ln(sec(x)+tan(x))

(1.13)

int(cos(x)^n,x) assuming n::posint;

(Sum((Product(1+1/(n-2*j), j = 1 .. i))*cos(x)^(n-2*i-1), i = 0 .. ceil((1/2)*n)-1))*sin(x)/n+(Product(1-1/(n-2*j), j = 0 .. ceil((1/2)*n)-1))*x

(1.14)

Improved answers in Maple 2016

 

int(sqrt(1+sqrt(x)), x);

(4/5)*(1+x^(1/2))^(5/2)-(4/3)*(1+x^(1/2))^(3/2)

(2.1)

int(sqrt(1+sqrt(1+z)), z= 0..1);

-(8/15)*2^(1/2)-(8/15)*(1+2^(1/2))^(3/2)+(4/5)*(1+2^(1/2))^(3/2)*2^(1/2)

(2.2)

int(signum(z^k)*exp(-z^2), z=-infinity..infinity) assuming k::real;

(1/2)*(-1)^k*Pi^(1/2)+(1/2)*Pi^(1/2)

(2.3)

int(2*abs(sin(x*p)*sin(x)), x = 0 .. Pi) assuming p> 1;

-2*(sin(Pi*p)*signum(sin(Pi*p))*cos(Pi/p)-p*sin(Pi/p)*cos(Pi*(floor(p)+1)/p)+sin(Pi*(floor(p)+1)/p)*cos(Pi/p)*p-sin(Pi*p)*signum(sin(Pi*p))-sin(Pi*(floor(p)+1)/p)*p+sin(Pi/p)*p)/((cos(Pi/p)-1)*(p^2-1))

(2.4)

int(1/(x^4-x+1), x = 0 .. infinity);

-(sum(ln(-_R)/(4*_R^3-1), _R = RootOf(_Z^4-_Z+1)))

(2.5)


In Maple 2016, this multiple integral is computed over 3 times faster than it was in Maple 2015.

int(exp(abs(x1-x2))*exp(abs(x1-x3))*exp(abs(x3-x4))*exp(abs(x4-x2)), [x1=0..R, x2=0..R, x3=0..R, x4=0..R], AllSolutions) assuming R>0;

(1/8)*exp(4*R)-29/8+(7/2)*exp(2*R)-5*R*exp(2*R)+2*exp(2*R)*R^2-(5/2)*R

(2.6)

Austin Roche
Mathematical Software, Maplesoft

You, I, and others like us, are the beneficiaries of decades of software evolution.

From its genesis as a research project at the University of Waterloo in the early 80s, Maple has continually evolved to meet the challenges of technical computing.

Disclaimer: This blog post has been contributed by Dr. Nicola Wilkin, Head of Teaching Innovation (Science), College of Engineering and Physical Sciences and Jonathan Watkins from the University of Birmingham Maple T.A. user group*. 

We all know the problem. During the course of a degree, students become experts at solving problems when they are given the sets of equations that they need to solve. As anyone will tell you, the skill they often lack is the ability to produce these sets of equations in the first place. With Maple T.A. it is a fairly trivial task to ask a student to enter the solution to a system of equations and have the system check if they have entered it correctly. I speak with many lecturers who tell me they want to be able to challenge their students, to think further about the concepts. They want them to be able to test if they can provide the governing equations and boundary conditions to a specific problem.

With Maple T.A. we now have access to a math engine that enables us to test whether a student is able to form this system of equations for themselves as well as solve it.

In this post we are going to explore how we can use Maple T.A. to set up this type of question. The example I have chosen is 2D Couette flow. For those of you unfamiliar with this, have a look at this wikipedia page explaining the important details.

In most cases I prefer to use the question designer to create questions. This gives a uniform interface for question design and the most flexibility over layout of the question text presented to the student.

  1. On the Questions tab, click New question link and then choose the question designer.
  2. For the question title enter "System of equations for Couette Flow".
  3. For the question text enter the text

    The image below shows laminar flow of a viscous incompressible liquid between two parallel plates.



    What is the system of equations that specifies this system. You can enter them as a comma separated list.

    e.g. diff(u(y),y,y)+diff(u(y),y)=0,u(-1)=U,u(h)=0

    You then want to insert a Maple graded answer box but we'll do that in a minute after we have discussed the algorithm.

    When using the questions designer, you often find answers are longer than width of the answer box. One work around is to change the width of all input boxes in a question using a style tag. Click the source button on the editor and enter the following at the start of the question

    <style id="previewTextHidden" type="text/css">
    input[type="text"] {width:300px !important}
    </style>


    Pressing source again will show the result of this change. The input box should now be significantly wider. You may find it useful to know the default width is 186px.
  4. Next, we need to add the algorithm for this question. The teacher's answer for this question is the system of equations for the flow in the picture.

    $TA="diff(u(y),y,y) = 0, u(0) = 0, u(h) = U";
    $sol=maple("dsolve({$TA})");


    I always set this to $TA for consitency across my questions. To check there is a solution to this I use a maple call to the dsolve function in Maple, this returns the solution to the provided system of equations. Pressing refresh on next to the algorithm performs these operations and checks the teacher's answer.

    The key part of this question is the grading code in the Maple graded answer box. Let's go ahead and add the answer box to the question text. I add it at the end of the text we added in step 3. Click Insert Response area and choose the Maple-graded answer box in the left hand menu. For the answer enter the $TA variable that we defined in the algorithm. For the grading code enter

    a:=dsolve({$RESPONSE}):
    evalb({$sol}={a}) 


    This code checks that the students system of equations produces the same solution as the teachers. Asking the question in this way allows a more open ended response for the student.

    To finish off make sure the expression type is Maple syntax and Text entry only is selected.
  5. Press OK and then Finish on the Question designer screen.

That is the question completed. To preview a working copy of the question, have a look here at the live preview of this question. Enter the system of equations and click How did I do?

  

I have included a downloadable version of the question that contains the .xml file and image for this question. Click this link to download the file. The question can also be found on the Maple T.A. cloud under "System of equations for Couette Flow".

* Any views or opinions presented are solely those of the author(s) and do not necessarily represent those of the University of Birmingham unless explicitly stated otherwise.

Disclaimer: This blog post has been contributed by Dr. Nicola Wilkin, Head of Teaching Innovation (Science), College of Engineering and Physical Sciences and Jonathan Watkins from the University of Birmingham Maple T.A. user group*.

 

If you have arrived at this post you are likely to have a STEM background. You may have heard of or had experience with Maple T.A or similar products in the past. For the uninitiated, Maple T.A. is a powerful system for learning and assessment designed for STEM courses, backed by the power of the Maple computer algebra engine. If that sounds interesting enough to continue reading let us introduce this series of blog posts for the mapleprimes website contributed by the Maple T.A. user group from the University of Birmingham(UoB), UK.

These posts mirror conversations we have had amongst the development team and with colleagues at UoB and as such are likely of interest to the wider Maple T.A. community and potential adopters. The implementation of Maple T.A. over the last couple of years at UoB has resulted in a strong and enthusiastic knowledge base which spans the STEM subjects and includes academics, postgraduates, undergraduates both as users and developers, and the essential IT support in embedding it within our Virtual Learning Environment (VLE), CANVAS at UoB.

By effectively extending our VLE such that it is able to understand mathematics we are able to deliver much wider and more robust learning and assessment in mathematics based courses. This first post demonstrates that by comparing the learning experience between a standard multiple choice question, and the same material delivered in a Maple TA context.

To answer this lets compare how we might test if a student can solve a quadratic equation, and what we can actually test for if we are not restricted to multiple choice. So we all have a good understanding of the solution method, let's run through a typical paper-based example and see the steps to solving this sort of problem.

Here is an example of a quadratic

To find the roots of this quadratic means to find what values of x make this equation equal to zero. Clearly we can just guess the values. For example, guessing 0 would give

So 0 is not a root but -1 is.

There are a few standard methods that can be used to find the roots. The point though is the answer to this sort of question takes the form of a list of numbers. i.e. the above example has the roots -1, 5. For quadratics there are always two roots. In some cases two roots could be the same number and they are called repeated roots. So a student may want to answer this question as a pair of different numbers 3, -5, the same number repeated 2, 2 or a single number 2. In the last case they may only list a repeated roots once or maybe they could only find one root from a pair of roots. Either way there is quite a range of answer forms for this type of question.

With the basics covered let us see how we might tackle this question in a standard VLE. Most are not designed to deal with lists of variable length and so we would have to ask this as a multiple choice question. Fig. 1, shows how this might look.

VLE Question

Fig 1: Multiple choice question from a standard VLE

Unfortunately asking the question in this way gives the student a lot of implicit help with the answer and students are able to play a process of elimination game to solve this problem rather than understand or use the key concepts.

They can just put the numbers in and see which work...

Let's now see how we may ask this question in Maple T.A.. Fig. 2 shows how the question would look in Maple T.A. Clearly this is not multiple choice and the student is encouraged to answer the question using a simple list of numbers separated by commas. The students are not helped by a list of possible answers and are left to genuinely evaluate the problem. They are able to provide a single root or both if they can find them, and moreover the question is not fussy about the way students provide repeated roots. After a student has attempted the question, in the formative mode, a student is able to review their answer and the teacher's answer as well as question specific feedback, Fig. 3. We'll return to the power of the feedback that can be incorporated in a later post.

Maple T.A. Question

Fig. 2: Free response question in Maple T.A.

  

Maple T.A. Answer

Fig. 3: Grading response from Maple T.A.

The demo of this question and others presented in this blog, are available as live previews through the UoB Maple T.A. user group site.

Click here for a live demo of this question.

The question can be downloaded from here and imported as a course module to your Maple T.A. instance. It can also be found on the Maple TA cloud by searching for "Find the roots of a quadratic". Simply click on the Clone into my class button to get your own version of the question to explore and modify.

* Any views or opinions presented are solely those of the author(s) and do not necessarily represent those of the University of Birmingham unless explicitly stated otherwise.

This January 28th, we will be hosting another full-production, live streaming webinar featuring an all-star cast of Maplesoft employees: Andrew Rourke (Director of Teaching Solutions), Jonny Zivku (Maple T.A. Product Manager), and Daniel Skoog (Maple Product Manager). Attend the webinar to learn how educators all around the world are using Maple and Maple T.A. in their own classrooms.

Any STEM educator, administrator, or curriculum coordinator who is interested in learning how Maple and Maple T.A. can help improve student grades, reduce drop-out rates, and save money on administration costs will benefit from attending this webinar.

Click here for more information and registration.

First 15 16 17 18 19 20 21 Last Page 17 of 34