Wolfram Computation Meets Knowledge

Using the Wolfram Language in the Classroom: Chemistry

Welcome to day three of the Wolfram Language in the Classroom series. I hope you’ve enjoyed the lessons so far. Today I want to show you how data built into the Wolfram Language can be used in the chemistry classroom. The Wolfram Language has information on over 44,000 chemicals and thus provides a perfect environment for chemistry students to do comparative, data-driven analysis.

The unique advantage of using the Wolfram Language for computational thinking in a chemistry class is that it allows students to analyze curated data to create hypotheses and show correlations in a new way.

Lesson title: Data-Mining Chemical Properties
Grades: 9–12
Student goals:
– Formulate problems in a way that enables the students to use a computer to solve them
– Automate solutions through algorithmic thinking
– Abstract data into a model

– Have students explore chemical properties for single chemicals and groups of chemicals
– Compare physical properties in a group of chemicals to find trends
– Fit a simple model to a dataset

This lesson is intended to be used as a guided exercise for your students. They should follow the steps laid out here and be encouraged to explore ways of changing the code on their own.

To get started, use ChemicalData to produce a list of the chemicals the Wolfram Language has data on. Give this list of chemicals the name allchemicals for easy use later:

List of all chemicals known in the Wolfram Language

You can check out the properties of a chemical by using ChemicalData[] again:

Checking the properties of a chemical using ChemicalData

Get a list of all properties like this:

List of properties

Often chemical properties are not measured or publicly available. In that case, ChemicalData returns Missing[NotAvailable]:

ChemicalData returns chemical properties not measured or publicly available

To create a targeted inquiry, pare down the number of chemicals by taking a subset. For example, restrict the scope to chemicals whose common name ends in “acid”:

Creating a targeted inquiry

Next, get the density of each acid in the group, sort them, and plot them all. Delete any chemicals for which the information is unavailable:

Plotting the density of each acid

Now look for correlations between physical properties of the acids. It might be reasonable to assume that the density of an acid is related to its boiling point. Pull all the known densities and boiling points and plot them together to see if they look correlated. ListPlot will automatically remove any chemical where either property is unknown:

Looking for correlations between physical properties using ListPLot

Well, those don’t look correlated at all! Instead of trying to find correlations by hand, employ some computational thinking methods and use the Wolfram Language to automatically plot every combination of properties, which can then be visually inspected. For brevity in this example, I will use a hand-picked list of common properties, but one could easily use all known properties:

Using the Wolfram Language to plot every combination of properties

Using the Wolfram Language to plot every combination of properties

The graph comparing the boiling points with the melting points seems to show a linear correlation. Quantify that by fitting the data to a linear model:

Fitting data to a linear model

Now show the fitted line and the data together:

Showing the fitted line and data together

With a very small amount of code, you can create plots of multiple datasets to inspect for correlations, rather than trying to pick and construct them by hand. Having found a possible correlation, you are then able to quantify this correlation. Now the next step would be to have the students hypothesize if this correlation is real and why it has the relationship that it does. Using the capabilities of the Wolfram Language, you can move students beyond just looking for facts—you can ask them to interpret and analyze as well.

To see more posts in this series, please click here.

Download this post as a Computable Document Format (CDF) file.


Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.


  1. How can I ensure access to curated data if my connexion is down ?

  2. I see a problem in this being presented to children.

    The inintial density v. boiling point shows nearly no correlation. (this is likely because their place on the periodic table is more important, ie, )

    On the other hand boiling point and melting point are both related to heat and transformation, and that things which take more of one take more of another is something people are used to seeing in every day life. Also it i a self-supported conclusion.

    Any information I can see shows (states of matter) being related to bonds not mass.

    The problem is children should not be lead to create poor results and self-supported conclusions.

    • Thanks for your comment. The spirit of this lesson is more in line with a scientific method approach to data-mining, rather than a directed lesson on bond structure or heat capacity. The idea is to look for trends in previously measured data, which can then lead to hypotheses, which can then lead to further explorations. We have not inferred any conclusions about the causality relating melting points to boiling points–but have merely shown how to find such correlations which then might warrant further study. We could see a lesson like this acting as a precursor to a more in-depth discussion of states of matter or as a capstone activity used to measure the students’ ability to synthesize everything they’ve learned about heat capacity, bond structure, etc