Computer
Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 1 of 69
CHEM 4331 Computer Experiment 1: Mathematics of Physical Chemistry
“Computer! Computer?… Hello, computer.”
Lieutenant Commander Montgomery “Scotty” Scott
Star Trek IV: The Voyage Home (1986)
Contents:
page #
1. Objectives and Notes on Completing the Exercises 1
2. Introduction to Mathematica 3
3. Solutions of Algebraic Equations 19
4. Differential Calculus 32
5. Geometrical Interpretation of Derivatives 45
6. Integral Calculus 54
7. References 69
1. Objectives and Notes on Completing the Exercises
The purpose of this first computer Physical Chemistry laboratory is to help you review [and,
perhaps, somewhat extend] the mathematical techniques learned in the Pre-Calculus and Calculus
courses, and apply those to solving simple problems in already familiar basic Physics and
Chemistry. In the process you will also be introduced to one of [if not the!] best computer algebra
software Mathematica [1,2,3] designed by Dr. Stephen Wolfram [4] (PhD in Particle Physics from
Caltech) and being developed by Wolfram Research [5]. The main goal of this lab is to help you
better understand the material presented in CHEM 4330, and, perhaps, demonstrate that
performing mathematical manipulations can be actually exciting and not very time-consuming!
The laboratory requires you to complete in Mathematica ten (10) exercises included in th
is
handout. Each exercise is worth 10 points. Mathematica notebooks for all exercises must be
submitted to a D2L dropbox by the date and time indicated in your syllabus.
Warning! Mathematica notebooks must be uploaded to D2L in the Mathematica notebook
format (which is the default):
http://reference.wolfram.com/language/ref/format/NB.html
Uploading a Mathematica notebook to D2L in the plain text format with the resulting loss of
all formatting:
http://reference.wolfram.com/language/ref/format/Text.html
will incur an automatic deduction of 50% per each file. Please, do not do that!
http://reference.wolfram.com/language/ref/format/NB.html
http://reference.wolfram.com/language/ref/format/Text.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 2 of 69
Each exercise contains a set of objectives listed as (a), (b), (c) etc.. A successful completion of
each objective includes obtaining
1) performing all calculations in Mathematica, and
1) obtaining the correct numerical value(s) and/or formula/equation(s), and
2) printing out the correct units (where applicable).
Even if one of those is incorrect or missing (for example, units!), no credit shall be given for the
objective. When in doubt, go back to the worked-out examples, and if it does not help, ask your
lab instructor.
Please note that all intermediate and final numerical values must be evaluated (calculated)
in Mathematica. That is, you are not allowed to simply copy answers to your Mathematica
notebook – it is a violation of the MTSU Academic Integrity policy!
In each Mathematica notebook, you must clearly indicate/label objectives (answers and graphs)
with symbols (a), (b), (c) … as instructed in the Exercises. For example:
(𝐚) 𝑣(𝑡) = 4.4 + 0.6𝑡2(m/s)
(𝐛) 𝑥(𝑡) = 1.4 + 4.4𝑡 + 0.2𝑡3 (m)
….
(𝐞) 𝑎(2 s) = 2.4 (m/s2)
….
Unlabeled answers will be ignored, i.e. no points shall be given for unlabeled answers.
When working on the exercises, it is permitted to consult with your classmates. In fact, we
encourage discussions that promote a creative learning environment. However, copying each
other’s code and/or using someone else’s file(s) is a violation of the MTSU Academic Integrity
policy, and is strictly prohibited! You absolutely must write your own code following the
guidelines and style of the worked-out examples provided in the handout. As such, you will have
to come up with your own comments and names for the variables/parameters used in your
calculations. Of course, make sure that those names are meaningful (see worked-out examples
provided in this handout). This is your chance to be creative – make good use of it!
A couple of [hopefully, useful] suggestions. When working with Mathematica notebooks, save
them often as it is not uncommon for Windows OS to crash. When done for the day, do not forget
to either copy all your files from the computer to your USB flash drive, or email the files to your
own email (home, college etc.) account. Alternatively, you can store files in the “cloud” – for
more information contact the MTSU IT department (ITD). This, of course, applies to ALL CHEM
4331 labs (not just this one)
Good luck!
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 3 of 69
2. Introduction to Mathematica
Mathematica is a an extremely powerful computer algebra software for numerical and
symbolic calculations. It is extensively used as a research tool in many scientific, engineering,
mathematical and computing disciplines [3].
Mathematica is split into two parts, the kernel and the front end [3]. The kernel interprets
expressions (Mathematica code) and returns result expressions [3]. The front end provides a GUI,
(graphical user interface) which allows the creation and editing of Notebook documents containing
program code with prettyprinting, formatted text together with results including typeset
mathematics, graphics, GUI components, tables, and sounds [3]. All contents and formatting can
be generated algorithmically or interactively edited [3]. Most standard word processing
capabilities are supported [3]. It includes a spell-checker but does not spell check automatically
as you type [3].
Documents can be structured using a hierarchy of cells, which allow for outlining and
sectioning of a document and support automatic numbering index creation [3]. Documents can be
presented in a slideshow environment for presentations [3]. Notebooks and their contents are
represented as Mathematica expressions that can be created, modified or analyzed by Mathematica
programs [3]. This allows conversion to other formats such as TeX or XML [3].
The front end includes development tools such as a debugger, input completion and
automatic syntax coloring [3].
To start Mathematica, click on the Mathematica icon located on your desktop
or go through the Windows “Start” menu: “Start” → “All Programs” → “Wolfram Mathematica”
→ “Wolfram Mathematica”:
Note that in this tutorial we will be using Mathematica 10.1, while you may be using Mathematica
9, 11 or 12. Not to worry – the interface and functionality of these versions are almost the same!
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 4 of 69
After the program is loaded, you will see a welcoming screen
Note that because we have already worked with Mathematica, we have several projects listed
under the “Open Recent” menu. Now, left-click on the “New Document” button (or choose the
“Notebook” option in the “New Document”
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 5 of 69
Whatever the case, a new Mathematica notebook will open.
The Mathematica fully-interactive notebook interface looks almost like a text editor, and is quite
intuitive. There is a menu bar, and an empty [for now] notebook canvas. Several short tutorials
on how to start working with a notebook are available on the Mathematica website at:
https://reference.wolfram.com/language/tutorial/UsingANotebookInterface.html
https://reference.wolfram.com/language/guide/MenuItems.html
https://reference.wolfram.com/language/guide/NotebookBasics.html
https://reference.wolfram.com/language/tutorial/WorkingWithTheNotebookInterfaceOverview.html
Let’s perform a couple of very simple calculations. In your empty notebook, type in “2+2”
(without the double quotes, of course) and hit the key combination to perform a
computation:
Note how Mathematica labels the input (In[n]) commands and the output (Out[n]), where n is a
greater-than-zero integer number. Usually, for each input command, there is an output. On the
right side of the notebook canvas there are cell (inner) and group (outer) brackets. Each input cell
can contain one or more commands. At this time, there is only one input command in the first cell
(i.e. “2+2” in cell In[1]). If you wish to add another command, for example “2-2”, you can add it
to the first input cell (In[1]) by positioning the mouse cursor inside that cell and typing the text.
When done, hit to get Mathematica to do a computation:
https://reference.wolfram.com/language/tutorial/UsingANotebookInterface.html
https://reference.wolfram.com/language/guide/MenuItems.html
https://reference.wolfram.com/language/guide/NotebookBasics.html
https://reference.wolfram.com/language/tutorial/WorkingWithTheNotebookInterfaceOverview.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 6 of 69
Alternatively, you can open a new cell by positioning the cursor below the last output cell, and
type in the command (of course, do not forget the “magic” key combination!):
If at any time you wish to delete all your output cells, you can do so by using the “Delete All
Output” option under the “Cell” menu:
If you wish to delete a particular cell (input or output), simply left-click the bracket of the cell you
wish to get rid of, and hit the “Delete” button on your keyboard. Now, delete all output and the
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 7 of 69
bottom set of cells, and, using the “File” menu, save the notebook to the Windows desktop as
“Test-1.nb”. Now select all previously entered input and delete all cells to leave a blank notebook.
Mathematica obviously can do much more than a simple addition and subtraction. To
multiply the two numbers, use the “*”symbol. To divide the two numbers, use the “/”symbol.
Note the difference between the results of the two divisions. Division of 6 by 3 gives 2 which is
an exact number. Why didn’t Mathematica do the same for the 2/3 operation? This is NOT
because Mathematica does not know how to divide 2 by 3, but rather because it knows that the
result is 0.6666666666. Thus, rather than truncating the number at some arbitrary decimal, it keeps
it as a fraction. If you want to get a numerical value, use the N[…] operator:
https://reference.wolfram.com/language/ref/N.html?q=N
By the way, to make input easier, you can use the good old copy-and-paste option. First, select
the text you wish to copy using the “left-click and drag” technique. Then, select “Copy” from the
“Edit” menu (or simply hit “Ctrl+C” on the keyboard), and paste using either the “Paste” option
from the “Edit” menu or the “Ctrl+V” key combination. Trust me, it makes working with
Mathematica a lot easier!
https://reference.wolfram.com/language/ref/N.html?q=N
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 8 of 69
Note how the N[2 3⁄ ] command evaluates the fraction to some default number of decimals. The
N[2 3⁄ , 20] command evaluates the same to 20 decimal points. N[2 3⁄ , 80] gives the result to 80
decimals. How about that?!
When fractions are entered using the “/” symbol, the code is not very readable. The Wolfram
System’s notebook interface is a very powerful typesetting system that allows you to enter
formulas as they are written in mathematical literature, using two-dimensional notation such as
superscripts, subscripts, and so on. For example, try entering the “2/3” fraction using the
key combination:
https://reference.wolfram.com/language/tutorial/EnteringInputInNotebooks.html
Looks much better, doesn’t it?
Another useful option in Mathematica is its ability to store the result of a mathematical operation
(numerical or symbolic) in a named variable.
For example,
WARNING!!! Do not use subscripts, superscripts, and special symbols such as but not
limited to ( ) [ ] & % $ # @ etc., in the names of the Mathematica variables because it can
easily lead to program errors and wrong results !
https://reference.wolfram.com/language/tutorial/EnteringInputInNotebooks.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 9 of 69
To see what is stored in a given variable, simply type in its name, or use the Print[]
command:
https://reference.wolfram.com/language/ref/Print.html
Note how in the last statement (Print[“variable c = “, c]) we have supplemented the printout with
text. This type of output can be very helpful when writing a code, and will be required when
processing the exercises.
If you wish to clear the value or definition of a given variable, use the Clear[] command:
Clearing the declared values as they are no longer needed is definitely a good habit [6]. Beginning
a new Mathematica session, like starting with a clean slate, for each problem is a good practice
[6].
https://reference.wolfram.com/language/ref/Print.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 10 of 69
An alternative, almost as good as starting with a clean slate, is to execute the command
Clear[“Global` ∗ “] which clears the values for all symbols in the Global` context, except those that
are protected [6]. Note that symbol “ ` ” is not an apostrophe, it is the so-called “grave accent”:
https://en.wikipedia.org/wiki/Grave_accent
which can be located in your keyboard as shown below [7]:
Here is an example that shows how to use the Clear[“Global` ∗ “] statement:
If you wish to execute the entire notebook automatically (one cell after another), use the “Evaluate
Notebook” option in the “Evaluation” menu. Keep in mind, that Mathematica keeps definitions
and assignments of all variables in memory as it executes notebook(s). Sometimes, you want to
start over, and erase all those assignments. In this case, use option “Quit Kernel” → “Local” in
the same “Evaluation” menu, and re-evaluate the cells of interest, or use the “Evaluate Notebook”
option to evaluate all cells in your notebook. To clear the output only, use the “Cell” → “Delete
All Output” option.
https://en.wikipedia.org/wiki/Grave_accent
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 11 of 69
Now, let’s try some other familiar mathematical operations. To raise a number or a variable
(including a symbolic variable) to a power, you can either use the “^” symbol or . To take
square root, you can use the Sqrt[] function, or .
As you can see, the readability of the notebook improves dramatically when using the Mathematica
typesetting system. Consider the following example.
Recall that another way to take a square root is to use the power of ½ , for example, 9½.
Alternatively, 9½ can be entered as 9^(1/2) which, despite being more a cumbersome expression,
gives the same result:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 12 of 69
However, sometimes students forget about the order of the mathematical operations (
https://en.wikipedia.org/wiki/Order_of_operations ) and type in “9^1/2”, which naturally gives a
very different result (91/2 = 9/2 = 4.5):
In order to avoid mishaps like that, we strongly suggest that you use the Mathematica typesetting
system.
Note that a variable need not have an assigned numerical value for Mathematica to apply a certain
mathematical operation to it. This comes in very handy when doing symbolic computations (we
will get to that in just a moment).
Perhaps you have noted that Mathematica always prints out variables and parameters as they are
defined. If you do not want Mathematica to do that, terminate a command with the semicolon
symbol (“;”). For example, compare the two seemingly identical sequences:
https://en.wikipedia.org/wiki/Order_of_operations
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 13 of 69
In this lab, we require your Mathematica notebooks to have user-friendly printouts of parameters
using the Print[] option. In the following, we show how to do that:
Note how the values of parameters a, b, and c are not printed out as they are defined because each
command is terminated with the semicolon. Indeed, rather than printing them out one by one
without annotation, it makes much more sense to print out their values in a separate Print[]
statement with accompanying [self-explanatory] text.
It is often desirable to separate two printout statements by a blank line. While one can use the
]” Print[” option to print out a blank line, a more elegant solution is to include the newline
character “\n” in the second Print[] statement.
https://reference.wolfram.com/language/tutorial/StringsAndCharacters.html#21585
For example,
By default, Mathematica prints out all numbers in some default output format. Only very large
and very small numbers are given in the scientific notation:
Note that we used the curly brackets to collect several numerical values in a list:
https://reference.wolfram.com/language/howto/WorkWithLists.html
https://reference.wolfram.com/language/tutorial/StringsAndCharacters.html#21585
https://reference.wolfram.com/language/howto/WorkWithLists.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 14 of 69
To force Mathematica to print out numbers in scientific notation, use the ScientificForm[] option:
There are many other number output formats available. For more information, refer to
https://reference.wolfram.com/language/guide/DisplayOfNumbers.html
Note how all the Mathematica built-in functions (Print[], Clear[], N[], Sqrt[] etc. are spelled with
the first character in upper case followed by a set of square brackets “[]”, while all characters that
follow are in lower case. If you misspell a name of the function and omit the square brackets,
the function will not work! At the same time, the name of the unrecognized function will be
highlighted in blue:
Also note that when entering mathematical expressions, do not use the square and curly
brackets, i.e. “[]” and “{}”, as these are reserved for functions and lists, respectively. As such,
regardless of how the mathematical equation is written on paper, always use the round brackets
“()”, also called parentheses. Let’s consider an example. Suppose we wish to code in Mathematica
the following equation:
𝑓 = [
(𝑎 + 𝑏){𝑐 + 𝑑}
𝑔
]
1/
2
If you use the square and curly brackets in the expression typed in Mathematica, you will get an
error:
https://reference.wolfram.com/language/guide/DisplayOfNumbers.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 15 of 69
The issue is easily fixed by replacing the square and curly brackets in mathematical expressions
with parentheses:
When it comes to using the Mathematica typesetting system, there is no need to remember all the
special key combinations for symbols of mathematical operations – you can always use the
“Palettes” option. Left-click on the “Palettes” menu and choose the “Basic Math Assistant” option
(actually, it is not very basic at all!):
You will immediately get a new “Basic Math Assistant” palette, which has two options” “Basic”
and “Advanced”. Try switching between those to see the difference. Note that in addition to a
number of algebraic and trigonometric functions,
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 16 of 69
it has many Calculus-related options, such as derivatives, limits, sums, and integrals:
If you ever need to use the Greek letters in Mathematica, for example:
you may find the following tutorial useful:
https://reference.wolfram.com/language/guide/GreekLetters.html
Of course, constants, such as , i, and e can also be entered using the “Basic Math Assistant”
palette. Alternatively, you can use the “Special Characters” palette under the “Palettes” menu.
Finally, before you can start working on the exercises, let’s go over a couple of other very useful
functions.
Functions Simplify[], FullSimplify[], and Refine[] :
http://reference.wolfram.com/language/ref/Simplify.html
http://reference.wolfram.com/language/ref/FullSimplify.html
https://reference.wolfram.com/language/ref/Refine.html
request simplification of the specified equation(s). These functions are extremely powerful
because Mathematica knows how to handle a lot of mathematical identities.
For example, here is a familiar simplification:
https://reference.wolfram.com/language/guide/GreekLetters.html
http://reference.wolfram.com/language/ref/Simplify.html
http://reference.wolfram.com/language/ref/FullSimplify.html
https://reference.wolfram.com/language/ref/Refine.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 17 of 69
Perhaps, something a little more complicated involving a trigonometric function:
If you need to learn more about the use of trigonometric functions in Mathematica, see the
following guide:
https://reference.wolfram.com/language/guide/TrigonometricFunctions.html
In the following example, we illustrate a more general use of the Simplify[] function:
1) define function f that depends on variables 𝑥, 𝑦, and 𝑧, which we usually write as 𝑓(𝑥, 𝑦, 𝑧),
2) differentiate 𝑓(𝑥, 𝑦, 𝑧) with respect to (w.r.t.) 𝑥, and
3) simplify the resulting expression:
Note that taking a derivative of function 𝑓(𝑥, 𝑦, 𝑧) w.r.t. variable 𝑥 is very easy in Mathematica.
Alternatively, we could have written:
However, from our point of view the first way is more efficient because one may want to do
something else with function 𝑓(𝑥, 𝑦, 𝑧), i.e. re-use the definition of function 𝑓. Perhaps, you know
that when a function of several variables is differentiated w.r.t. one of the variables, the result is
called a partial derivative of the function with respect to the variable. For example, when
differentiating function 𝑓(𝑥, 𝑦, 𝑧) w.r.t. parameter x, we get partial derivative
𝜕𝑓(𝑥,𝑦,𝑧)
𝜕𝑥
. Because
function 𝑓(𝑥, 𝑦, 𝑧) depends on three parameters, there will be three partial derivatives. The
remaining two partial derivatives are
𝜕𝑓(𝑥,𝑦,𝑧)
𝜕𝑦
and
𝜕𝑓(𝑥,𝑦,𝑧)
𝜕𝑧
. The total derivative (aka differential
https://reference.wolfram.com/language/guide/TrigonometricFunctions.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 18 of 69
change or total differential) of function 𝑓(𝑥, 𝑦, 𝑧), denoted usually as d𝑓(𝑥, 𝑦, 𝑧), is the sum of all
of its partial derivatives:
d𝑓(𝑥, 𝑦, 𝑧) =
𝜕𝑓(𝑥, 𝑦, 𝑧)
𝜕𝑥
d𝑥 +
𝜕𝑓(𝑥, 𝑦, 𝑧)
𝜕𝑦
d𝑦 +
𝜕𝑓(𝑥, 𝑦, 𝑧)
𝜕𝑧
d𝑧
where each of d𝑥, d𝑦, and d𝑧 is called simply a differential.
Ok, now that you know how to do some basic [and not very basic] things in Mathematica, let’s
see how you can use it to perform familiar scientific computations.
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 19 of 69
3. Solutions of Algebraic Equations
Before diving into Calculus (which is what Physical Chemistry is all about), let’s learn how to
solve equations with Mathematica. In this section we limit ourselves to solving [relatively simple]
algebraic equations: quadratic, cubic, and quartic. For example, we wish to solve a standard
quadratic equation in the form
𝑎𝑥2 + 𝑏𝑥 + 𝑐 = 0 (1)
Of course, everyone knows that the two solutions for x are
the equilibrium constant 𝐾 (𝐾𝑝) is equal to 977. In this particular example, the equilibrium
constant is given by
𝑥 =
−𝑏 ± √𝑏2 − 4𝑎𝑐
2
𝑎
(2)
Let’s see if Mathematica can do that. In this case, we use the Solve[] option:
http://reference.wolfram.com/language/ref/Solve.html
Yes, it can! Note how we have used the “= =” symbol
https://reference.wolfram.com/language/ref/Equal.html
to define the equality telling Mathematica that the right had side of the equation (rhs) is equal to
the left-hand side (lhs).
Actually, according to the Mathematica documentation,
“[b]uilt into the Wolfram Language is the world’s largest collection of both numerical and
symbolic equation solving capabilities—with many original algorithms, all automatically accessed
through a small number of exceptionally powerful functions. The Wolfram Language’s symbolic
architecture allows both equations and their solutions to be conveniently given in symbolic form,
and immediately integrated into computations and visualizations.”
http://reference.wolfram.com/language/guide/EquationSolving.html
http://reference.wolfram.com/language/ref/Solve.html
https://reference.wolfram.com/language/ref/Equal.html
http://reference.wolfram.com/language/guide/EquationSolving.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 20 of 69
Example 3.1. Let’s consider the following exercise taken from your Physical Chemistry textbook
[8]. At a certain temperature, for reaction
N2(𝑔) + 3H2(𝑔) ↔ 2NH3(𝑔) (3)
the equilibrium constant 𝐾 (𝐾𝑝) is equal to 977. In this particular example, the equilibrium
constant is given by
𝐾 = 𝐾𝑝 =
𝑝NH3
2
𝑝𝑁2 𝑝𝐻2
3
(4)
where 𝑝J is the partial pressure of substance J divided by the standard pressure of 1 bar,
i.e.
𝑝J ← 𝑝J/
𝑝
o (5)
where 𝑝o= 1 bar. Note that the equilibrium constant 𝐾 is a dimensionless (unitless) quantity which
is given by the value of the reaction quotient Q at equilibrium. Thus, for a general chemical
reaction of the form
[8]:
𝑎 A + 𝑏 B ↔ 𝑐 C + 𝑑 D (6)
the equilibrium constant is given by [8]
𝐾 = 𝑄equilibrium = (
𝛼C
𝑐 𝛼D
𝑑
𝛼A
𝑎𝛼B
𝑏
)
equilibrium
(7)
where 𝑎J is the activity of species J [8]. For perfect gases, 𝛼J = 𝑝J/𝑝
o, the partial pressure of J
relative to the standard pressure 𝑝o= 1 bar [8]. For solutes in very dilute solutions, 𝛼J = [J]/𝑐
o,
the molar concentration (molarity) of J relative to the standard value 𝑐o= 1 mol L-1 (M) [8]. The
activities of pure solids at 1 bar and pure liquids at 1 bar are all taken to be equal to 1 [8].
Table. Activities and standard states * [9].
If one wishes to discuss a gas-phase reaction in terms of molar concentrations (the amount of gas
molecules in moles divided by the volume of the container, [J] = 𝑛J/𝑉), rather than partial
pressures, the equilibrium constant 𝐾𝑝 is replaced with 𝐾𝑐 [8]:
𝐾𝑐 =
[C]𝑐 [D]𝑑
[A]𝑎[B]𝑏
(8)
where each molar concentration (or, rather its numerical value) is raised to a power equal to the
stoichiometric coefficient of the species in the chemical equation [8]. As usual, we have replaced
[J]/𝑐o by [J] itself, which represents the numerical value of the molar concentration of the gas J
[8].
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 21 of 69
For example, for the chemical reaction shown in equation (3) [8]
𝐾𝑐 =
[NH3]
2
[N2][H2]
3
(9)
The conversion between 𝐾𝑐 and 𝐾𝑝 for reaction
𝑎 A + 𝑏 B ↔ 𝑐 C + 𝑑 D
is given by [8]:
𝐾𝑝
= 𝐾𝑐 (
𝑐o𝑅𝑇
𝑝o
)
(𝑐+𝑑)−(𝑎+𝑏)
= 𝐾𝑐 (
𝑐o𝑅𝑇
𝑝o
)
Δ𝜈gas
(10)
where 𝑇 is the temperature, 𝑅 is the ideal gas constant, and Δ𝜈gas is the difference in the
stoichiometric coefficients of the gas-phase species, products minus reactants [8]. Substituting the
values of 𝑐o, 𝑝o, and 𝑅 into equation (10) gives a simple and convenient form of this expression
[8]:
𝐾𝑝 = 𝐾𝑐 (
𝑇
12.027 K
)
Δ𝜈gas
(11)
where the temperature 𝑇 must be given in kelvin (K).
Now, let’s go back to our example. Suppose we mix in 1.00 bar of N2(𝑔) with 3.00 bar of H2(𝑔).
We need to find the equilibrium partial pressures of all three gases: (a) nitrogen, (b) hydrogen, and
(c) ammonia, and (d) verify our results by comparing the equilibrium constant calculated from the
equilibrium partial pressures with the one given in the question. After setting up the ICE table [8],
we get:
𝐾 =
(2𝑥)2
(1.00 − 𝑥)(3.00 − 3𝑥)3
(12)
Because the highest power of 𝑥 is 4, the resulting equation is quartic! Mathematica can easily
solve this equation:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 22 of 69
Note how we used the N[] function to get Mathematica to output numerical values. Because this
is a quartic equation, we get four solutions. Which one is correct? Well, mathematically all of
them are correct! However, according to Physical Chemistry, partial pressure (or any other
physically observable quantity) can not be a complex number (i.e. number which includes the
imaginary component with 𝑖 = √−1). Thus, solutions two and three are not physical, and should
be discarded! In fact, in Thermodynamics and Kinetics we are usually interested in real solutions
only
https://en.wikipedia.org/wiki/Real_number
If x is real, it must belong to a domain of real numbers. In the language of Mathematics, it can be
written as 𝑥 ∈ ℝ, where the symbol “∈” means “is an element of” and the symbol “ℝ” denotes the
set of ALL real numbers. How about that! Anyway, if we are interested only in real solutions of
a given equation, the Solve[] command can be modified as follows:
Note how we have reduced the number of solutions to two. But which one (or both) is (are)
physically meaningful? Recall that in our ICE table, x denotes the change in partial pressure. The
equilibrium partial pressures of N2(𝑔) and H2(𝑔) are (1.00-x) bar and (3.00-3x) bar. Solution x =
1.1173 bar would give us negative equilibrium pressures of N2(𝑔) and H2(𝑔), and thus is not
physically meaningful. This leaves us with only one solution: x = 0.895018 bar. Now we can
calculate the final partial pressures of all three gases. Here is our Mathematica code that does that:
https://en.wikipedia.org/wiki/Real_number
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 23 of 69
Let me explain what we are doing in each cell:
In[1]: Solve equation, get numerical solutions, and store all solutions in a variable (to be more
precise, a list of variables) called “solutions”
In[2]: Extract the first solution (command “solutions[[1]]”), and put it in variable “x” using
command “/.”. For example, command a2/. a → 2 means: evaluate “a2” while replacing
“a” with 2 ( the symbol → can be typed in Mathematica as “->”; for more information
about this so-called “\[Rule]” option, see
https://reference.wolfram.com/language/ref/character/Rule.html
beware that \[Rule] is not the same as \[RightArrow] ! ). Naturally, the answer is 4.
To do the same with several variables is not much more difficult:
A detailed information on the “/.” command can be obtained here:
http://reference.wolfram.com/language/ref/ReplaceAll.html
In[3]: Calculate the final partial pressures of all three gases and store them in variables pN2, pH2,
and pNH3. Note how the names of variables are self-explanatory. This is VERY
important !
Note on using units in Mathematica: Each scientific calculation must include units. In general,
Mathematica can use units:
https://reference.wolfram.com/language/guide/Units.html
However, the interface is not very user-friendly. Thus, for now, we shall ignore this functionality
when doing calculations in Mathematica.
https://reference.wolfram.com/language/ref/character/Rule.html
https://reference.wolfram.com/language/ref/character/RightArrow.html
http://reference.wolfram.com/language/ref/ReplaceAll.html
https://reference.wolfram.com/language/guide/Units.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 24 of 69
That said, in every single Mathematica notebook you absolutely must include comments that
describe your calculation steps, and the units of variables used. A comment in Mathematica is any
text entered between symbol sequences “(*” and “*)”
Note how we have also added a check for 𝐾: the numerical value of the reaction quotient at
equilibrium must be equal to the equilibrium constant (𝐾 = 977). The difference between the
equilibrium constant that was calculated using the equilibrium partial pressures of the three gases
and the given value is below 10-12, which means that the final equilibrium partial pressures must
be correct!
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 25 of 69
Now we tweak the processing of variables (to make the code more transparent and portable, and
less cluttered), and add the project number, author name, date, the Clear[“Global` ∗ “] command,
and user-friendly output of calculated properties. See for yourself:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 26 of 69
Note how we suppressed the default Mathematica printout by terminating each command (except
for the Solve[] statement) with a semicolon. This eliminates unnecessary printout from the final
version of the code (we suggest you do so only in the final version of the code, after you have
made sure that it produces correct results, and when you are ready to upload it to D2L).
Finally, once you are satisfied with your code, go through the following checklist before
submitting your Mathematica notebook to D2L:
1) Make sure that the header of the Mathematica notebook includes the exercise number, your
name, and the creation date.
2) Make sure that the first executable statement in your Mathematica code is
Clear[“Global` ∗ “];
3) Make sure that all required answers are printed out using the Print[] statement.
4) Verify that each Print[] statement includes the appropriate label, i.e.
Print[“(a) …… “];
Print[“(b) …… “];
Print[“(c) …… “]; etc.
5) Suppress output from lines that do not contain printout of answers.
6) Remove all output cells (go to the “Cell” option of the notebook menu and select “Delete
All Output”)
7) Merge all input cells, which can be done using the following two steps:
a. go to the “Edit” option of the notebook menu and select “Select All” (or simply use
the “Ctrl+A” key combination)
b. go to the “Cell” option of the notebook menu and select “Merge Cells” (or simply
use the “Shift + Ctrl + M”
8) Save the notebook, and upload it to D2L.
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 27 of 69
Here is the final version of our Mathematica notebook for Example 3.1:
Note that your Mathematica notebook for this example should look very similar!
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 28 of 69
Perhaps now is a good time to also demonstrate how to use the Mathematica Solve[]
function
http://reference.wolfram.com/language/ref/Solve.html
to solve two equations for two unknowns simultaneously. For example,
{
𝑎𝑥 + 𝑦 = 7
𝑏𝑥 − 𝑦 =
1
where 𝑥 and 𝑦 are the unknowns, and 𝑎 and 𝑏 are constants:
Note how we used the “&&” symbol to specify the logical AND function. Suppose, we wish to
save the solutions to some variables. Here is how we save the solution for 𝑥 to a variable called
xs:
, and the same for 𝑦:
If numerical values for 𝑎 and 𝑏 are known, xs and ys can be easily evaluated. For example,
Not bad!
Mathematica can solve even more complicated equations. For example, determining the real
solutions for the following system of equations:
{
(𝑥2 − 𝑦2)𝑥𝑦 = 180
𝑥2 − 𝑥𝑦 − 𝑦2 = −11
is easy in
Mathematica:
http://reference.wolfram.com/language/ref/Solve.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 29 of 69
You can then use the replacement rule
https://reference.wolfram.com/language/tutorial/TransformationRulesAndDefinitions.html
to extract numerical values of x and y for any or all of the solutions. For example,
This technique allows you to use variables x1, y1, x2, y2 etc. that contain the solutions in some
other calculations. For example,
How about a system of three equations for three unknowns? No problem! Here is an example
{
𝑥 + 𝑦 + 𝑧 = 13
𝑥2 + 𝑦2 + 𝑧2 = 61
𝑥𝑦 + 𝑥𝑧 = 2𝑦𝑧
, and its solution in Mathematica:
Extracting numerical values for any of the solutions is also straightforward:
Isn’t it nice?!
https://reference.wolfram.com/language/tutorial/TransformationRulesAndDefinitions.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 30 of 69
Note that if you are also interested in the complex solutions, simply remove the “Reals” option:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 31 of 69
Now that we have shown you how to perform this kind of calculations, it is your turn to do some.
Exercise 3.1. In the same chemical reaction as discussed in Example 3.1 but at a different
temperature, the nitrogen, hydrogen, and ammonia gases are mixed at partial pressures of 4.56 bar,
9.87 bar, and 3.21 bar, respectively, and allowed to reach equilibrium under conditions when K =
86.4. Using the final notebook from Example 3.1 as a template, create a Mathematica notebook
to calculate the equilibrium partial pressures (bar) of all three substances: (a) N2(g), (b) H2(g), (c)
NH3(g), and (d) perform the check for 𝐾𝑝. Save the notebook as “Exercise_3.1.nb”. Warning!
All the calculation steps must be performed in your Mathematica notebook, and all items (a-
d) must be clearly labelled using the Print[] functions, or the score for this exercise will be
zero!
Answers: (a) … (b) 0.858 bar (c) … (d) …
Exercise 3.2. In a study of the equilibrium,
A2 + B2 ⇌ 2 AB
1.0 mol of A2 and 3.0 mol of B2 gave rise at equilibrium to x mol of AB. Addition of a further 2.0
mol of A2 gave an additional x mol of AB. In Mathematica, (a) determine the value of x (mol),
and (b,c) evaluate the equilibrium constant via each of the two expressions that you set up to
determine (a). Save the notebook as “Exercise_3.2.nb”. Warning! All the calculation steps
must be performed in your Mathematica notebook, and all items (a-c) must be clearly labelled
using the Print[] function, or the score for this exercise will be zero! Hint: two ICE tables is
twice as much fun…
Answers: (a) 1.5 (b) … (c) 4.0
Exercise 3.3. Consider the following gas-phase dissociation reaction:
A2(g) ⇌ 2 A(g)
In Mathematica, derive a symbolic expression for the degree of dissociation of A2(g) at equilibrium
{ratio of the change in the partial pressure of A2(g) to the initial partial pressure of A2(g)}, , as a
function of the volume of the reaction vessel, V (liters), temperature, T (kelvins), initial chemical
amount of A2(g), n (moles), the equilibrium constant, 𝐾𝑝 (dimensionless), and the gas constant, R
(J K-1 mol-1). Do not assign numerical value to the gas constant yet! Use your newly derived
formula to calculate the degree of dissociation of A2(g) in a (b) 5.0 L and (c) 20 L reaction vessel
when 0.10 mol of A2(g) is dissociating at 2000 K, and the equilibrium constant is 0.570. Save the
notebook as “Exercise_3.3.nb”. Warning! All the calculation steps must be performed in
your Mathematica notebook, and all items (a-c) must be clearly labelled using the Print[]
functions, or the score for this exercise will be zero! Hints: the easiest way to evaluate an
expression numerically without permanent assignment of the variables is to use the rule option;
for example, (a + b)2/. {a−> 2, b−> 3} and (a + b)2/. {a−> 14, b−> 15}.
Answers: (a)
10𝐾𝑝𝑉
5𝐾𝑝𝑉+√𝐾𝑝𝑉(4𝑛𝑅𝑇+25𝐾𝑝𝑉)
(b) … (c) 0.34
https://reference.wolfram.com/language/ref/Rule.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 32 of 69
4. Differential Calculus
In this part of the lab, we are going to review some of the most fundamental physical concepts,
and at the same time refresh your knowledge of Differential Calculus.
Displacement [10]. Pretty much everything around [and inside] us is in motion. Motion involves
the displacement of an object from one place in space and time to another. Describing motion
requires some convenient coordinate system and a specified origin. A frame of reference is a
choice of coordinate axes that defines the starting point for measuring any quantity, an essential
first step in solving virtually any problem in mechanics. The displacement Δ𝑥 of an object is
defined as its change in position and is given by
Δ𝑥 = 𝑥𝑓 − 𝑥𝑖 (13)
where 𝑥𝑖 is the coordinate of the initial position of the object and 𝑥𝑓 is the coordinate of the objects’
final position (here, indices 𝑖 and 𝑓 stand for initial and final, respectively). The SI unit of
displacement is a meter (m).
Because displacement has both a magnitude (size) and a direction, it is a vector quantity.
In general, a vector quantity is characterized by having both a magnitude and a direction. By
contrast, a scalar quantity has magnitude, but no direction. Scalar quantities such as mass and
temperature are completely specified by a numeric value with appropriate units; no direction is
involved.
Velocity and speed [10]. In everyday usage the terms speed and velocity are interchangeable. In
physics, however, there’s a clear distinction between them: speed is a scalar quantity, having only
magnitude, whereas velocity is a vector quantity, having both magnitude and direction. However,
the two quantities share the same SI unit: meter per second (m/s).
The average speed of an object over a given time interval is the length of the path it travels
divided by the total elapsed time:
timeelapsed
lengthpath
speed Average = (14)
Unlike average speed, average velocity is a vector quantity, having both a magnitude and a
direction. The average velocity �̅� during a time interval Δ𝑡 is the displacement, Δ𝑥, divided by
the elapsed time, Δ𝑡:
�̅� =
∆𝑥
∆𝑡
=
𝑥𝑓 − 𝑥𝑖
𝑡𝑓 −
𝑡𝑖
(15)
While the average speed is always non-negative, the average velocity of an object in one dimension
can be either zero, or positive or negative, depending on the sign of the displacement. (The time
interval Δ𝑡 is always positive.)
The instantaneous velocity v is the limit of the average velocity as the time interval Δ𝑡
becomes infinitesimally small:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 33 of 69
𝑣 = lim
Δ𝑡→
0
∆𝑥
∆𝑡
(16)
The notation lim
Δ𝑡→0
means that the ratio Δ𝑥/Δ𝑡 is repeatedly evaluated for smaller and smaller time
intervals Δ𝑡. Notice that the displacement Δ𝑥 approaches zero as ∆𝑡 approaches zero, so the ratio
looks like 0/0 [11]. While this ratio may appear to be difficult to evaluate, it does have a specific
value. As Δ𝑥 and ∆𝑡 become smaller and smaller, the ratio Δ𝑥/Δ𝑡 approaches a value equal to the
slope of the line tangent to the 𝑥-versus- 𝑡 curve, which is defined as the instantaneous velocity
(Figure 1).
Figure 1. The instantaneous x-velocity v at any given point equals the slope of the tangent to the
𝑥 − 𝑡 curve at that point [12].
In the Calculus notation, this limit is called the derivative of x with respect to (w.r.t.) t, written as
𝑑𝑥/𝑑𝑡 [11]
𝑣 = lim
Δ𝑡→0
∆𝑥
∆𝑡
=
𝑑𝑥
𝑑𝑡
(17)
The instantaneous speed of an object, which is a scalar quantity, is defined as the magnitude of
the instantaneous velocity. Like average speed, instantaneous speed (which we will usually call,
simply, “speed”) has no direction associated with it and hence carries no algebraic sign.
Acceleration, a [10]. The changing of an object’s velocity with time is called acceleration. The
average acceleration �̅� during the time interval ∆𝑡 is the change in velocity ∆𝑣 divided by ∆𝑡:
�̅� =
∆𝑣
∆𝑡
=
𝑣𝑓 −
𝑣𝑖
𝑡𝑓 − 𝑡𝑖
(18)
Acceleration is a vector quantity having dimensions of length divided by the time squared. In the
SI system of units, acceleration has dimensions of meters per second per second ( (m/s)/s, which
is usually written as m s-2 ). Acceleration is a vector quantity. For the case of motion in a straight
line, the direction of the velocity of an object and the direction of its acceleration are related as
follows: When the object’s velocity and acceleration are in the same direction, the speed of the
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 34 of 69
object increases with time. When the object’s velocity and acceleration are in opposite directions,
the speed of the object decreases with time (this type of acceleration is often called deceleration).
a) b)
Figure 2. (a) A car, modeled as a particle, moving along the x axis from A to B, has velocity 𝑣𝑖
at 𝑡 = 𝑡𝑖 and velocity 𝑣𝑓 at 𝑡 = 𝑡𝑓 . (b) Velocity–time graph (red-brown) for the particle moving
in a straight line. [11]
The value of the average acceleration often differs in different time intervals, so it is useful to
define the instantaneous acceleration, which is analogous to the instantaneous velocity discussed
above. The instantaneous acceleration a is the limit of the average acceleration as the time interval
∆𝑡 goes to zero:
𝑎 = lim
Δ𝑡→0
∆𝑣
∆𝑡
(19)
Here again, the notation lim
Δ𝑡→0
means that the ratio ∆𝑣/∆𝑡 is evaluated for smaller and smaller
values of ∆𝑡. The closer ∆𝑡 gets to zero, the closer the ratio gets to a fixed number, which is the
instantaneous acceleration.
In the language of Calculus, instantaneous acceleration equals the derivative of the velocity
with respect to time:
𝑎 = lim
Δ𝑡→0
∆𝑣
∆𝑡
=
𝑑𝑣
𝑑𝑡
(20)
which, by definition, is the slope of the velocity–time graph [11]. The slope of the green line in
Figure 2b is equal to the instantaneous acceleration at point B. Notice that Figure 2b is a velocity–
time graph, not a position–time graph like Figure 1. Therefore, we see that just as the velocity of
a moving particle is the slope at a point on the particle’s 𝒙 − 𝑡 graph, the acceleration of a particle
is the slope at a point on the particle’s 𝒗 − 𝑡 graph. One can interpret the derivative of the velocity
with respect to time as the time rate of change of velocity. If 𝑎 is positive, the acceleration is in
the positive 𝑥 direction; if 𝑎 is negative, the acceleration is in the negative 𝑥 direction (often called
deceleration) [11].
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 35 of 69
Because 𝑣 = 𝑑𝑥/𝑑𝑡, the acceleration can also be written as
𝑎 =
𝑑𝑣
𝑑𝑡
=
𝑑
𝑑𝑡
(𝑣) =
𝑑
𝑑𝑡
(
𝑑𝑥
𝑑𝑡
) =
𝑑2𝑥
𝑑
𝑡2
(21)
That is, in one-dimensional motion, the acceleration also equals the second derivative of x with
respect to time [11].
Figure 3 [11] illustrates how an
acceleration–time graph is related to a velocity–
time graph. The acceleration at any time is the
slope of the velocity–time graph at that time.
Positive values of acceleration correspond to those
points in Figure 3 where the velocity is increasing
in the positive 𝑥 direction. The acceleration
reaches a maximum at time 𝑡A, when the slope of
the velocity–time graph is a maximum. The
acceleration then goes to zero at time 𝑡B, when the
velocity is a maximum (that is, when the slope of
the 𝑣 − 𝑡 graph is zero). The acceleration is
negative when the velocity is decreasing in the
positive 𝑥 direction, and it reaches its most
negative value at time 𝑡C [11].
Figure 3 [11]. (a) The velocity–time
graph for a particle moving along the x
axis. (b) The instantaneous acceleration
can be obtained from the velocity–time
graph.
Example 4.1. Consider a particle moving along the x axis according to the equation
𝑥(𝑡) = 𝒜 + ℬ 𝑡 + 𝒞 𝑡2 (22)
where 𝑥 is in meters (m), 𝑡 is in seconds (s), and 𝒜, ℬ, and 𝒞 are some constants. Using
Mathematica, derive general expressions for (a) velocity, and (b) acceleration as a function of time
𝑡 and general coefficients 𝒜, ℬ, and 𝒞. If 𝒜 = 2.00 m, ℬ = 3.00 m/s, and 𝒞 = −1.00 m/s2,
calculate (c) the position of the particle, (d) its velocity, and (e) its acceleration at 𝑡 = 3.00 s. Plot
(f) 𝑥 vs 𝑡, (g) 𝑣 vs 𝑡 , and (h) 𝑎 vs 𝑡 for 𝑡 = 0…5 seconds.
Open a new Mathematica notebook, and name it “Example_4.1.nb”. After typing in the project
number and clearing all the variables, define function 𝑥(𝑡) given above:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 36 of 69
Note that in order to match the notation for constants 𝒜, ℬ, and 𝒞 in equation (22), we used the
Mathematica “script capital” option when entering in the names of the variables:
https://reference.wolfram.com/language/ref/character/ScriptCapitalA.html
https://reference.wolfram.com/language/ref/character/ScriptCapitalB.html
https://reference.wolfram.com/language/ref/character/ScriptCapitalC.html
To learn more about letters and letter-like forms in Mathematica, see
https://reference.wolfram.com/language/tutorial/MathematicalAndOtherNotation.html#19606
First, we derive a general expression for velocity at any 𝑣, i.e. find 𝑣(𝑡). Recall that
𝑣(𝑡) =
𝑑𝑥(𝑡)
𝑑𝑡
,
so we need to differentiate 𝑥(𝑡) with respect to (w.r.t.) 𝑡. In Mathematica, differentiation can be
performed using the command D[]
https://reference.wolfram.com/language/ref/D.html?q=D
or using the button in the section of the “Basic Math Assistant” palette:
https://reference.wolfram.com/language/ref/character/ScriptCapitalA.html
https://reference.wolfram.com/language/ref/character/ScriptCapitalB.html
https://reference.wolfram.com/language/ref/character/ScriptCapitalC.html
https://reference.wolfram.com/language/tutorial/MathematicalAndOtherNotation.html#19606
https://reference.wolfram.com/language/ref/D.html?q=D
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 37 of 69
Here is my code that demonstrates how to use both options (of course, you should use only one,
whichever makes more sense!):
As expected, the two differentiation commands give the same result. Thus, 𝑣(𝑡) = ℬ + 2 𝒞 𝑡
Note how we used the Print[] statement to print out the answer for (a).
How about the acceleration? Well, according to equation (20), we get 𝑎(𝑡) by differentiating 𝑣(𝑡)
w.r.t. 𝑡 once, or by differentiating 𝑥(𝑡) w.r.t. 𝑡 twice: 𝑎(𝑡) =
𝑑𝑣(𝑡)
𝑑𝑡
=
𝑑2𝑥(𝑡)
𝑑𝑡2
. Both methods can be
easily implemented in Mathematica (of course, use only one, whichever makes more sense!):
Again, as expected, 𝑎 is the same regardless of the method used. Note that since 𝑎 does not depend
on 𝑡, we are dealing with a case of the constant acceleration, i.e., 𝑎 = 2 𝒞 m/s2 (units come directly
from the question) at any time 𝑡. To summarize,
𝑥(𝑡) = 𝒜 + ℬ 𝑡 + 𝒞 𝑡2, where 𝑡 is in seconds, and 𝑥 is in meters,
𝑣(𝑡) = ℬ + 2 𝒞 𝑡, where 𝑡 is in seconds, and 𝑣 is in m/s.
𝑎(𝑡) = 2 𝒞 at any 𝑡, where 𝑎 is in m/s2.
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 38 of 69
Now we need to define the numerical values for constants 𝒜, ℬ, and 𝒞. There are several ways
one can do that. The first way is quite straightforward:
However, the second way, using the Mathematica list option,
https://reference.wolfram.com/language/howto/CreateLists.html
is more elegant and uses less space in the notebook:
Of course, you should use only one method, whichever makes more sense! Then, finding 𝑥, 𝑣,
and especially 𝑎 at 𝑡 = 3.00 s is easy:
Note how the numerical value of 𝑡 is defined in one place only which makes the code much more
portable. Also note how we use the Print[] statements to create a user-friendly output. Finally,
note that acceleration, 𝑎, is of course constant at -2.00 m/s2.
Now, let’s get to a fun part. We can easily plot 𝑥(𝑡), 𝑣(𝑡), and 𝑎(𝑡) in Mathematica using the
Plot[] function. In the following, we show how to do it for 𝑡 = 0…5 s:
First, we define the range for 𝑡 using variables that we are going to call tmin and tmax:
https://reference.wolfram.com/language/howto/CreateLists.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 39 of 69
Alternatively, you can use a more conventional way to define tmin and tmax:
Now, we plot 𝑥(𝑡) in the range of 𝑡 from tmin to tmax:
While the plot looks nice, it is missing labels for the x- and y- axes, and the plot label (legend).
Those can be added to any Mathematica plot as follows:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 40 of 69
Much better! Note that we used Mathematica’s function SetOptions[Plot, BaseStyle →
{FontSize → 14}] to increase the font size in the plot, and italicized “𝑡” and “𝑥” in the AxisLabel
and PlotLabel commands.
The SetOptions[Plot … . ] command applies to all plots that follow it, so there is no need to repeat
it separately for each new plot. To make changes to the plot style, simply insert another
SetOptions[Plot … . ] command with a new set of options.
Finally, let’s plot 𝑣(𝑡) and 𝑎(𝑡):
Note that in all three graphs, we specify the range for 𝑡 using variables tmin and tmax that are
defined only once!
We also hope that you can see that because velocity changes uniformly with time (i.e. the 𝑣 − 𝑡
plot is a straight line), acceleration is constant, and vice versa.
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 41 of 69
Here is our final notebook for Example 4.1:
Finally, it may be worth the time to demonstrate how easy it is to plot two or more function on the
same graph in Mathematica. Consider the following three functions
𝑦1 = 1 + 2𝑥, 𝑦2 = 10 − 3𝑥, 𝑦3 = −5 + 𝑥
2
that we wish to plot on the same graph for 50 x . First, we define the functions:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 42 of 69
Then, we define the font size for the plot and the minimum and maximum values for x:
Because in this example we have terminated each command with a semicolon, there is no output
from either one of them. Finally, we plot all three functions on the same plot using the same
command Plot[] which is used to plot a single function:
Note how we have included a sequence of functions that we want to plot in the curly brackets thus
forming a so-called “list”:
https://reference.wolfram.com/language/howto/CreateLists.html
Also note that in addition to already familiar options AxesLabel and PlotLabel, we added the
PlotLegends option that, as you can guess from its name, adds a legend to the graph.
https://reference.wolfram.com/language/howto/CreateLists.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 43 of 69
Sometimes Mathematica does not plot the entire range for the 𝑥 and/or 𝑦 variable(s). For example,
To fix that, simply add the PlotRange→Full option to either the Plot[] or SetOptions[Plot…]
command:
Note how in all the plots, we always italicize symbols for variables and physical quantities,
i.e. 𝑥, 𝑦, 𝑣, 𝑡, 𝑎, etc.
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 44 of 69
Ok, it is now your turn to perform a couple of calculations in Mathematica.
Exercise 4.1. An object moves along the x axis according to the equation
𝑥(𝑡) = −𝒜 + ℬ 𝑡2 − 𝒞 𝑡3
where 𝑥 is the distance in centimeters (cm), 𝑡 is the time in seconds (s), and 𝒜, ℬ, and 𝒞 are some
constants. Using the notebook from Example 4.1 as a template, write a Mathematica code to
derive expressions for (a) velocity and (b) acceleration as a function of time and general
coefficients 𝒜, ℬ and 𝒞. Suppose 𝒜 = −45. cm, ℬ = 0.67 cm s−2, and 𝒞 = 3.2×10−2 cm
s-3. Calculate (c) the distance, (d) velocity, and (e) acceleration at 𝑡 = 8.5 s. Plot (f) 𝑥 vs 𝑡, (g)
𝑣 vs 𝑡, and (h) 𝑎 vs 𝑡 for 𝑡 = 0 … 15 s. Save the notebook as “Exercise_4.1.nb”. Warning! All
the calculation steps must be performed in your Mathematica notebook, and all items (a-h)
must be clearly labelled in the Print[] functions and/or the PlotLabel option in the Plot[]
commands, or the score for this exercise
will be zero!
Answers: (a) … (b) …
(c) 74 cm (d) … (e) -0.29 cm s-2
(f,g,h) …
Exercise 4.2. An object moves along the x axis according to the equation
𝑥(𝑡) = (𝑔 +
√𝑡3
ℎ
) (1 − 𝑒−𝑘𝑔𝑡 ) −
𝑡2
𝑛
where 𝑥 is the distance in meters (m), 𝑡 is the time in seconds (s), 𝑒 is the base of the natural
logarithm, and 𝑔, ℎ, 𝑘, and 𝑛 are some constants. Using the notebook from Example 4.1 as a
template, write a Mathematica code to derive expressions for (a) velocity and (b) acceleration as
a function of time and general coefficients 𝑔, ℎ, 𝑘, and 𝑛. Suppose 𝑔 = 12. m , ℎ = 0.19 s3/2
m−1, 𝑘 = 1.6×10−2 m−1 s−1, and 𝑛 = 0.76 s2 m−1. Calculate (c) the distance, (d) velocity, and
(e) acceleration at 𝑡 = 6.7 s. Plot (f) 𝑥 vs 𝑡, (g) 𝑣 vs 𝑡, and (h) 𝑎 vs 𝑡 for 𝑡 = 0 … 11 s. Save
the notebook as “Exercise_4.2.nb”. Warning! All the calculation steps must be performed in
your Mathematica notebook, and all items (a-h) must be clearly labelled in the Print[]
functions and/or the PlotLabel option in the Plot[] commands, or the score for this exercise
will be zero!
Answers: (a) … (b) … (c) … (d) 2.6 m s-1 (e) …
(f,g,h) …
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 45 of 69
5. Geometrical interpretation of derivatives [13]
In the previous section we introduced the idea that in the limiting case the derivative represents an
instantaneous rate of change of two variables [13]. Hence, if, for example, 𝑦 = 𝑓(𝑥) is plotted in
a two-dimensional Cartesian coordinate system, then 𝑑𝑦/𝑑𝑥 is the slope of the curve at any point
(𝑥, 𝑦) on the curve. With exception of the function 𝑦(𝑥) = constant, functions either increase or
decrease as the value of 𝑥 increases. By looking at the derivative (or slope) evaluated at the point
(𝑥, 𝑦), we can determine whether the function 𝑓(𝑥) is increasing or decreasing as 𝑥 increases
without having to graph the function. If 𝑑𝑦/𝑑𝑥is positive, then 𝑓(𝑥) increases as 𝑥 increases. If
𝑑𝑦/𝑑𝑥 is negative, then 𝑓(𝑥) decreases as 𝑥 increases
[13].
Certain functions, such as parabolas (Figure 4a), or functions of higher order, such as cubic
functions (Figure 4b), have either a maximum or a minimum value, or both [13]. Differential
calculus can be used to help us determine the point or points along the curve where maxima or
minima occur. Since the slope of the curve must be zero at these points, the first derivative also
must be zero [13].
a) 𝑦 = 2𝑥2 − 3𝑥 + 2
b) 𝑦 = 2𝑥3 − 6𝑥 + 2
Figure 4 [13]. Sample graphs of (a) quadratic and (b) cubic functions.
For example, the parabola shown in Figure 4a is described by the equation [13]
𝑦(𝑥) = 2𝑥2 − 3𝑥 + 2 (23)
Taking the first derivative gives [13]
𝑑𝑦
𝑑𝑥
= 4𝑥 − 3 (24)
Setting the first derivative equal to zero and solving for x, we have [13]
4𝑥 − 3 = 0 or 𝑥 =
3
4
(25)
Substituting 𝑥 =
3
4
into the equation 𝑦(𝑥), yields 𝑦 = 0.875, which indicates the minimum point
on the curve [13]. In Mathematica, the same calculation can be performed as follows:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 46 of 69
In order to determine whether the curve is a maximum or a minimum at a point without actually
plotting the curve, we can substitute values for x that are greater than the value at the point where
the derivative is zero and the values for 𝑥 that are smaller than the value at the point where the
derivative is zero (a.k.a. stationary point). Then we note the behavior of 𝑦. A simpler way to test
whether the function is a maximum or a minimum is to look at the second derivative of the function
[13].
If 0
2
2
dx
yd
, then the function is a maximum.
If 0
2
2
dx
yd
, then the function is a minimum.
If 0
2
2
=
dx
yd
, then the function is at a point of inflection – a point on the curve where the curve
changes from one that exhibits a maximum at some point (i.e., is “concave
downward”) to one that exhibits a minimum at some point (i.e., is “concave
upward”), or vice versa; note that inflections points may be stationary points (as
shown in Figure 5), but are not local maxima or local minima.
Figure 5 [14]. Example of an inflection point (𝑑2𝑦/𝑑𝑥2 = 0) which is also a stationary point
(𝑑𝑦/𝑑𝑥 = 0).
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 47 of 69
Thus, in the parabola example, the second derivative at x = ¾ (and, incidentally, everywhere else)
is
This makes sense because parabola shown in Figure 4a is “concave upward” everywhere…
Now, consider the cubic function shown in Figure 4b [13]:
𝑦 = 2𝑥3 − 6𝑥 + 2 (26)
Taking the first derivative and setting it equal to zero yields [13]
𝑑𝑦
𝑑𝑥
= 6𝑥2 − 6 = 0; 𝑥2 − 1 = 0; 𝑥 = ±1 (27)
which indicates that there is maximum or a minimum at 𝑥 = +1 and 𝑥 = −1 [13]. Taking the
second derivative of this cubic equation gives
𝑑2𝑦
𝑑𝑥2
= 12𝑥 (28)
For 𝑥 = +1, 𝑑2𝑦/𝑑𝑥2 = 12, which indicates that the curve is a minimum at this point. For 𝑥 =
−1, 𝑑2𝑦/𝑑𝑥2 = −12, which indicates that the curve is a maximum at this point.
In Mathematica, these calculations can be done as follows:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 48 of 69
You may wonder at which point the sign of the curvature changes from negative (maximum) to
positive (minimum). Well, clearly it should be at a point where the second derivative vanishes,
i.e.
𝑑2𝑦
𝑑𝑥2
= 12𝑥 = 0 (29)
It follows that 𝑥 = 0 is an inflection point of this function. Mathematica can easily find this point:
Example 5.1. The mathematical expression that tells us the probability, P, that the molecules in
a sample of gas have a speed that lies in a particular range at any instant is called the distribution
of molecular speeds [15]. The precise form of the distribution was worked out by James Clerk
Maxwell (1831-1879) towards the end of the nineteenth century, and his expression is known as
the Maxwell distribution of speeds [15]. A sample Maxwell distribution of molecular speeds for
the argon gas at 500 K is shown in Fig 6 [16].
Figure 6 [16]. The Maxwell distribution of molecular speeds for the argon gas at 500 K.
According to Maxwell’s equation, the probability 𝑃(𝑣, 𝑣 + Δ𝑣) that the molecules have a speed
in a narrow range between 𝑣 and 𝑣 + Δ𝑣 (for example, between 300 m/s and 301 m/s,
corresponding to 𝑣 = 300 m/s and Δ𝑣 = 1 m/s) is [15]
𝑃(𝑣, 𝑣 + ∆𝑣) = 𝜌(𝑣)∆𝑣 with
𝜌(𝑣) = 4𝜋 (
𝑀
2𝜋𝑅
𝑇
)
3/2
𝑣2𝑒
−
𝑀𝑣2
2𝑅𝑇 (30)
where 𝑀 is the molar mass of the gas, 𝑅 is the (ideal) gas constant, and 𝑇 is the temperature. We
wish to derive an expression for the most probable speed (identified as 𝑣most prob in Figure 6).
Note that the most probable speed is the speed at which the probability is a maximum. Thus, we
must maximize the function 𝜌(𝑣),
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 49 of 69
𝜌(𝑣) = 4𝜋 (
𝑀
2𝜋𝑅𝑇
)
3/2
𝑣 2𝑒
−
𝑀𝑣2
2𝑅𝑇 (31)
with respect to 𝑣, set the derivative to zero, and solve for 𝑣. This is a simple task for Mathematica.
We always start with the project title (and so should you!). Then, we define function 𝜌(𝑣):
Note that an exponential can be taken using the Exp[] function, or using the button in the
“Basic Math Assistant” palette
Naturally, the result is the same:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 50 of 69
Now, we calculate the derivative of 𝜌(𝑣) w.r.t. v,
𝑑𝜌(𝑣)
𝑑𝑣
, and store the result in variable d𝜌dv:
In order to make the final result more “visually appealing”, we can ask Mathematica to try to
simplify the expressions using command Simplify[], FullSimplify[], or Refine[]:
https://reference.wolfram.com/language/ref/Simplify.html
https://reference.wolfram.com/language/ref/FullSimplify.html
http://reference.wolfram.com/language/ref/Refine.html
When simplifying expressions, it is recommended to include (whenever possible) the Assuming[]
function
http://reference.wolfram.com/language/ref/Assuming.html
Consider the following example:
The symbol “&&” is the logical AND function:
http://reference.wolfram.com/language/ref/And.html
In the following, we simplify the expression for
𝑑𝜌(𝑣)
𝑑𝑣
stored in variable d𝜌dv:
https://reference.wolfram.com/language/ref/Simplify.html
https://reference.wolfram.com/language/ref/FullSimplify.html
http://reference.wolfram.com/language/ref/Refine.html
http://reference.wolfram.com/language/ref/Assuming.html
http://reference.wolfram.com/language/ref/And.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 51 of 69
We set the derivative (stored in variable d𝜌dv) to zero, and use the Solve[] function to solve the
equation for 𝑣:
We can simply the resulting expressions by applying one of Mathematica’s “simplifying”
functions, for example FullSimplify[]:
Note how we have specified that 𝑅 (gas constant), 𝑀 (molar mass), and 𝑇 (temperature) are all
positive.
There are three solutions. While all of them are mathematically correct, the first two solutions are
not physically meaningful (we hope you see why…). Thus, the only acceptable solution is number
three, which we then copy to variable vmostprob, and print it out:
Now, compare the expression derived in Mathematica to that given in [almost] every single
Physical Chemistry textbook [8,9,14,15,16]:
𝑣most prob = (
2𝑅𝑇
𝑀
)
1/2
(32)
Not bad, eh?!
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 52 of 69
Well, it is now your time to differentiate a couple of functions in Mathematica.
Exercise 5.1. Consider the following function:
𝑔(𝑥) = 4𝑥3 + 9𝑥2 − 12𝑥 + 5
Using the final notebook from Example 5.1 as a template, determine the numerical values of 𝑥 for
the stationary and inflection points in the function 𝑔(𝑥). Save the notebook as
“Exercise_5.1.nb”. Warning! All the calculation steps must be performed in your
Mathematica notebook, or the score for this exercise will be zero! Your Mathematica
notebook must include the following items in the printout, all clearly labelled using the
Print[] function or the PlotLabel option in the Plot[] command:
(a) define function 𝑔(𝑥);
(b) derive and simplify formula for the first derivative of 𝑔(𝑥) with respect to (w.r.t.) 𝑥,
𝑑𝑔/𝑑𝑥;
(c) locate the stationary points in 𝑔(𝑥) by determining the values of 𝑥 at which 𝑑𝑔/𝑑𝑥 = 0
(solutions: −2,
1
2
);
(d) derive and simplify formula for the second derivative of 𝑔(𝑥) w.r.t. 𝑥, 𝑑2𝑔/𝑑𝑥2;
(e,f) for each stationary point found at step (c), calculate numerical value of the second
derivative, 𝑑2𝑔/𝑑𝑥2, and decide whether 𝑔(𝑥) at this point is a minimum, a maximum, or
an inflection point;
(g) locate the inflection points by determining the values of 𝑥 at which 𝑑2𝑔/𝑑𝑥2 = 0 (solution:
−
3
4
);
(h) plot 𝑔(𝑥) vs 𝑥 for −4 ≤ 𝑥 ≤ 3 to confirm your conclusions for (e-g).
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 53 of 69
Exercise 5.2. Suppose, the following equation of state for a non-ideal gas is proposed:
𝑝 =
𝑅𝑇
𝑉m − 𝑏
𝑒
−
𝑎
𝑅𝑇3/2𝑉m (5.2.a)
where 𝑝 is pressure, 𝑇 is temperature, 𝑅 is the (ideal) gas constant, 𝑉m is the molar volume (i.e.
volume per mole of substance, 𝑉m = 𝑉/𝑛 ) [8,14], 𝑎 and 𝑏 are constants characteristic of the gas,
and 𝑒 is the base of the natural logarithm. Note that if 𝑏 ≪ 𝑉m and 𝑎 ≪ 𝑅𝑇
3/2𝑉m, equation (5.2.a)
reduces to the ideal gas law:
𝑝 =
𝑅𝑇
𝑉m
(5.2.b)
If equation (5.2.a) is to be applicable to a real gas, is must also predict the existence of a critical
point. The critical point terminates the vapor-liquid phase boundary (see your Physical Chemistry
textbook [8,9,14,15]), and is characterized by the critical constants of a gas: 𝑉c, 𝑇c, and 𝑝c, which
must all be positive. Considering that the critical point is an inflection and stationary point in the
𝑝 − 𝑉 curve, use Mathematica to derive expressions for 𝑉c, 𝑇c, and 𝑝c in terms of 𝑎, 𝑏, and R. Use
the final notebook from Example 5.1 as a template. Save the notebook as “Exercise_5.2.nb”.
Warning! All the calculation steps must be performed in your Mathematica notebook, or the
score for this exercise will be zero! Your Mathematica notebook must include the following
items in the printout, all clearly labelled using the
Print[] function:
(a) define 𝑝 as a function of 𝑉m as given in equation (5.2.a);
(b) derive formula for the first derivative of 𝑝 with respect to 𝑉m, 𝑑𝑝/𝑑𝑉m;
(c) derive formula for the second derivative of 𝑝 with respect to 𝑉m, 𝑑
2𝑝/𝑑𝑉m
2;
(d) since at the critical point both the first and second derivatives are zero, set 𝑑𝑝/𝑑𝑉m = 0
and 𝑑2𝑝/𝑑𝑉m
2 = 0, and solve the two equations simultaneously for 𝑉m and 𝑇; the resulting
solutions should give you the expressions for 𝑉c and 𝑇c;
(e) select, simplify, and print out the appropriate solution for 𝑉c;
(f) select, simplify and print out the appropriate solution for 𝑇c;
(g) insert 𝑉c and 𝑇c into equation (5.2.a) defined at step (a), and simplify and print out the
expression for 𝑝c.
Answers: 𝑉c = 2𝑏 𝑇c = (
𝑎
4𝑏𝑅
)
2/3
𝑝c =
𝑅
𝑏
(
𝑎
4𝑏𝑅
)
2/3
𝑒−2
Hint: It seems that in this exercise, Refine[] works better than Simplify[] and FullSimplify[].
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 54 of 69
6. Integral Calculus
In Section 4 we discussed that the velocity of a particle moving in a straight line can be obtained
if its position as a function of time is known [11]. Mathematically, the velocity equals the
derivative of the position with respect to time [11], i.e.
𝑣(𝑡) =
𝑑𝑥(𝑡)
𝑑𝑡
It is also possible to find the position of a particle if its velocity is known as a function of time
[11]. In calculus, the procedure used to perform this task is referred to either as integration or as
finding the antiderivative. Graphically, it is equivalent to finding the area under a curve [11].
Figure 7 [11]. Velocity versus time for a particle moving along the x axis. The total area under
the curve is the total displacement of the particle [11].
Suppose the 𝑣 − 𝑡 graph for a particle moving along the x axis is as shown in Figure 7 [11].
Let us divide the time interval 𝑡𝑓 − 𝑡𝑖 into many small intervals, each of duration ∆𝑡𝑛. From the
definition of average velocity, we see that the displacement of the particle during any small
interval, such as the one shaded in Figure 7, is given by ∆𝑥𝑛 = 𝑣𝑛,avg∆𝑡𝑛, where 𝑣𝑛,avg is the
average velocity in that interval [11]. Therefore, the displacement during this small interval is
simply the area of the shaded rectangle in Figure 7 [11]. The total displacement for the interval
𝑡𝑓 − 𝑡𝑖 is the sum of the areas of all the rectangles from 𝑡𝑖 to 𝑡𝑓
[11]:
Δ𝑥 =
∑ 𝑣𝑛,avgΔ𝑡𝑛
𝑛
(33)
Now, as the intervals are made smaller and smaller, the number of terms in the sum increases and
the sum approaches a value equal to the area under the curve in the velocity–time graph [11].
Therefore, in the limit 𝑛 → ∞, or Δ𝑡 → 0, the displacement is [11]
Δ𝑥 =
lim
Δ𝑡𝑛→0
∑ 𝑣𝑛,avgΔ𝑡𝑛
𝑛
(34)
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 55 of 69
If we know the 𝑣 − 𝑡 graph for motion along a straight line, we can obtain the displacement during
any time interval by measuring the area under the curve corresponding to that time interval [11].
The limit of the sum shown in equation (34) is called a definite integral and is written [11]
lim
Δ𝑡𝑛→0
∑ 𝑣𝑛,avgΔ𝑡𝑛
𝑛
= ∫ 𝑣(𝑡)𝑑𝑡
𝑡𝑓
𝑡𝑖
(35)
where 𝑣(𝑡) denotes the velocity at any time 𝑡 [11]. If the explicit functional form of 𝑣(𝑡) is known
and the limits are given, the integral can be evaluated [11].
Sometimes the 𝑣 − 𝑡 graph for a moving particle has a shape much simpler than that shown
in Figure 7 [11]. For example, suppose an object is described with the particle under a constant
velocity model [11]. In this case, the 𝑣 − 𝑡 graph is a horizontal line as in Figure 8 and the
displacement of the particle during the time interval Δ𝑡 is simply the area of the shaded rectangle
[11]:
Δ𝑥 = 𝑣𝑖,avgΔ𝑡 (when 𝑣 = 𝑣𝑖 = constant) (36)
Figure 8 [11]. The velocity–time curve for a particle moving with constant velocity 𝑣𝑖 . The
displacement of the particle during the time interval 𝑡𝑓 − 𝑡𝑖 is equal to the area of the shaded
rectangle.
Recall, that the acceleration is defined as
𝑎 =
𝑑𝑣
𝑑𝑡
First, we rewrite this equation as
𝑑𝑣 = 𝑎𝑑𝑡 (37)
We now integrate the two sides between the initial (𝑖) and final (𝑓) values:
∫ 𝑑𝑣
𝑣𝑓
𝑣𝑖
= ∫ 𝑎𝑑𝑡
𝑡𝑓
𝑡𝑖
(38)
The left hand side (lhs) is trivial as it evaluates to Δ𝑣:
∫ 𝑑𝑣
𝑣𝑓
𝑣𝑖
= 𝑣𝑓 − 𝑣𝑖 = Δ𝑣 (39)
In Mathematica, integration is easy. You can either type in the command Integrate[]
http://reference.wolfram.com/language/ref/Integrate.html
http://reference.wolfram.com/language/ref/Integrate.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 56 of 69
or use the integral buttons in the section of the “Basic Math Assistant” palette:
Here is my Mathematica code that demonstrates how to use both options:
As expected the result is the same, and, of course, agrees with that given in equation (39). Now
we deal with the right hand side (rhs) of equation (38). Note that we integrate between the initial
time (ti) and final time (tf). By convention, the initial time is set to zero, i.e. 𝑡𝑖 = 0: recall that
when you time an event, you usually start at zero, i.e. 𝑡 = 0! On the contrary, the initial velocity
is not necessarily zero (the object can be moving when we start the timer), so 𝑣𝑖 = 𝑣0 (which may
or may not be zero). Then, we can drop the index (𝑓) on the final time, 𝑡 = 𝑡𝑓 , and velocity (𝑣 =
𝑣𝑓 ) and write:
Δ𝑣 = 𝑣 − 𝑣0 = ∫ 𝑎𝑑𝑡
𝑡
0
(40)
This shows that the change in the x-velocity is the time integral of the x-acceleration. In general,
acceleration may change with time, 𝑎 = 𝑎(𝑡), which gives:
𝑣 = 𝑣0 + ∫ 𝑎(𝑡)𝑑𝑡
𝑡
0
(41)
Using the same arguments, we can rewrite the equation for the displacement as
𝑥 = 𝑥0 + ∫ 𝑣(𝑡)𝑑𝑡
𝑡
0
(42)
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 57 of 69
Here 𝑥 and 𝑣 are the position and 𝑥-velocity at time 𝑡. If we know the 𝑥-acceleration as a function
of time and we know the initial velocity we can use equation (41) to find the 𝑥-velocity at any
time, i.e., as a function of time. Once we know this function, and given the initial position we can
use equation (42) to find the position 𝑥 at any time.
Equations (41) and (42) are called the kinematic equations. Unfortunately, the right-hand
side of each equation is impossible to evaluate without the explicit knowledge of a time-
dependence of velocity or acceleration, i.e. 𝑣(𝑡) and 𝑎(𝑡).
In your basic Physics course, you considered the special case in which the acceleration is
constant, 𝑎 = constant. Recall that a constant can be moved out of an integral. As such, the
integral in equation (41) can be evaluated as
Which gives a very simple formula for the time-dependence of velocity v(t):
𝑣 = 𝑣0 + ∫ 𝑎𝑑𝑡
𝑡
0
= 𝑣0 + 𝑎 ∫ 𝑑𝑡
𝑡
0
= 𝑣0 + 𝑎(𝑡 − 0) = 𝑣0 + 𝑎𝑡 (43)
This powerful expression enables us to determine an object’s velocity at any time t if we know the
object’s initial velocity v0 and its (constant) acceleration 𝑎 [11]. A velocity–time graph for this
constant-acceleration motion is shown in Figure 9a [11]. The graph is a straight line, the slope of
which is the acceleration a; the (constant) slope is consistent with 𝑎 = 𝑑𝑣/𝑑𝑡 being a constant
[11]. Notice that the slope is positive, which indicates a positive acceleration [11]. If the
acceleration were negative, the slope of the line in Figure 9a would be negative [11]. When the
acceleration is constant, the graph of acceleration versus time (Figure 9b) is a straight line having
a slope of zero [11].
a)
b)
Figure 9 [11]. A particle under constant acceleration a moving along the x axis:
(a) the velocity–time graph, and (b) the acceleration–time graph [11].
Because we know how velocity depends on time, 𝑣 = 𝑣0 + 𝑎𝑡, we can use this expression to
evaluate the integral on the right-hand side of equation (42):
𝑥 = 𝑥0 + ∫ (𝑣0 + 𝑎𝑡)𝑑𝑡
𝑡
0
(44)
First we recall that the integral of a sum is a sum of integrals, i.e.
𝑥 = 𝑥0 +
∫ 𝑣0𝑑𝑡
𝑡
0
+ ∫ (𝑎𝑡)𝑑𝑡
𝑡
0
(45)
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 58 of 69
The first integral is easy because the initial velocity (𝑣0) is a constant (naturally, it does not change
with time), so we get:
∫ 𝑣0𝑑𝑡
𝑡
0
= 𝑣0 ∫ 𝑑𝑡
𝑡
0
= 𝑣0(𝑡 − 0) = 𝑣0𝑡 (46)
The second integral is not much more complicated. Because acceleration is constant, we get:
∫ 𝑎𝑡𝑑𝑡
𝑡
0
= 𝑎 ∫ 𝑡𝑑𝑡
𝑡
0
= 𝑎 (
𝑡2
2
−
02
2
) =
1
2
𝑎𝑡2 (47)
Combining the results for the two integrals, we get:
𝑥 = 𝑥0 + 𝑣0𝑡 +
1
2
𝑎𝑡2 (48)
This equation provides the final position of the particle at time t in terms of the initial position, the
initial velocity, and the constant acceleration. Of course in Mathematica, equation (48) can be
obtained from equation (44) in one simple step:
Example 6.1. Suppose, a car is moving along a straight highway. At exactly 4 hours (h) after
beginning its journey, it is 200 km from the starting point (𝑥0), and the speed is 120 km/h (𝑣0). At
this point the driver begins to decrease the speed exponentially (with a constant acceleration) such
that at 𝑡 = 5 h the car’s speed is 16.240 km/h. (a) Calculate the numerical value of acceleration
Find expressions for (b) 𝑥-velocity 𝑣 and (c) position 𝑥 as functions of time after 𝑡 = 4 hours.
Compute the (d) velocity and (e) distance of the car from its starting point at 𝑡 = 6 hours. Plot (f)
𝑥 vs 𝑡, and (g) 𝑣 vs 𝑡 for 𝑡 = 4…7 hours
In the first cell, we specify the project number:
In the following statements we define 𝑥0 and 𝑣0 as
given in the question:
Note that because we do not wish to print those out, we terminate each statement with the “;”
symbol. Now there is a more difficult part. The question says that speed decreases exponentially
with time but acceleration is constant, i.e. 𝑒−𝑎𝑡, where 𝑡 is time (in h) 𝑎 is the acceleration (in
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 59 of 69
km/h2). Note that in this equation 𝑡 is being counted from 4 hours (because that is when
deceleration started). To bring 𝑡 to the absolute time scale (i.e. counting 𝑡 from the beginning of
the journey), we modify 𝑡 in 𝑒−𝑎𝑡 to 𝑡 − 4, i.e. 𝑒−𝑎(𝑡−4). Note that this equation shows the change
in speed, but the initial speed was 𝑣0, so we append it to 𝑒
−𝑎(𝑡−4) thus completing the expression
for 𝑣(𝑡):
𝑣(𝑡) = 𝑣0𝑒
−𝑎(𝑡−4) for 𝑡 ≥ 4 hours (49)
where 𝑣 is speed (in km/h) after 𝑡 = 4 hours, 𝑡 is time (in h), and 𝑎 is the acceleration (in km/h2).
Of course, this equation is valid only for 𝑡 4 hours, because we have no knowledge of how the
car was moving between 𝑡 = 0 and 𝑡 = 3.99999… hours. Now we enter this expression into
Mathematica and include a bunch of comments (so we do not forget what we are doing):
Note that in this expression acceleration, 𝑎, is not known. But we can certainly determine it
because we know that at 𝑡 = 5 h the speed (𝑣) was 16.240 km/h. All we need to do is insert these
values of 𝑡 and 𝑣 into the formula for 𝑣(𝑡) (equation 49) and solve it for 𝑎 :
Once 𝑎 is known, we can complete the expression for 𝑣(𝑡)
If 𝑣(𝑡) is known, we can determine 𝑥(𝑡) using equation (42):
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 60 of 69
Note that 𝑥0 is given in the question. We can easily verify that our expressions for 𝑥(𝑡) and 𝑣(𝑡)
are correct, by using 𝑡 = 4 h and 𝑡 = 5 h and comparing the calculated values of 𝑥 and 𝑣 with those
given in the question:
They agree!!! Now we can calculate 𝑥 and 𝑣 at 𝑡 = 6 hours:
Finally, plotting 𝑥(𝑡) is straightforward:
Note that we, again, used Mathematica’s function SetOptions[Plot, BaseStyle → {FontSize →
14}] to increase the font size in the plot(s).
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 61 of 69
Let’s see what the 𝑣(𝑡) plot looks like:
Now, that wasn’t too bad, was it?!
Integral Calculus is, in general, not easy, so we shall consider another example. This time it is
your [possibly] favorite subject – Chemistry!
Example 6.2. Consider the following chemical reaction [8,14,15]
PA ⎯→⎯
k
(50)
where A is a reactant, P is a product, and k is the rate constant [10,6]. Suppose the reaction follows
the first order mechanism, which means that the rate of consumption of A is proportional to the
first power of the concentration of A, [A]:
[A]
[A]
k
dt
d
=− (51)
We need to (a) derive the expression for [A] = f(t) (called the integrated rate law), and (b)
determine the expression for the parameter half-life, t1/2 at which the concentration [A] falls to half
of its original concentration [A]0.
Before we get to Mathematica, we need to rearrange equation (51) in such a way as to
collect terms related to the concentration of A (i.e. [A] and d[A]) on one side of the equation
(suppose, left hand side, lhs) and terms related to time (t) on the other side (suppose, right hand
side, rhs). It does not matter where you put constants such as k and (-1) because they always factor
out of integrals. To this purpose, we rearrange equation (51) as
kdtd −=
[A]
[A]
1
(52)
In the next step, we need to integrate both sides. Suppose, the left hand side is integrated between
the initial concentration [A]0 and concentration [A] at time t. Then, the right hand side is integrated
between the initial time (which we always consider as zero), and time t at which the concentration
of A falls to [A]. The following equation demonstrates that:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 62 of 69
−=
t
kdtd
0
[A]
[A]0
[A]
[A]
1
(53)
Now, it is time to go to Mathematica. As always, the first cell contains the project number:
Then, we add a comment summarizing the preliminary steps:
We now integrate the left hand side:
Note that because Mathematica always thinks that a given symbolic parameter may be complex,
we had to give it additional information about the integrand and the limits of the integration.
Indeed, the initial concentration [A]0 must always be positive, while [A] is always less than [A]0.
Note that while in general, [A] = [A]0 at t = 0, in this particular case it is safer to use the relationship
shown above. As you can see, we make use of the Mathematica command Assumptions:
http://reference.wolfram.com/language/ref/Assumptions.html
As expected, the integral on rhs evaluates to
0
[A]
[A]
ln . Note that in Mathematica the natural
logarithm is entered as Log[ ],
http://reference.wolfram.com/language/ref/Log.html
while the base-10 logarithm is written as Log10[]:
http://reference.wolfram.com/language/ref/Log10.html
http://reference.wolfram.com/language/ref/Assumptions.html
http://reference.wolfram.com/language/ref/Log.html
http://reference.wolfram.com/language/ref/Log10.html
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 63 of 69
Ok, now we need to evaluate the right-hand side of equation (53). It is easy to do so in
Mathematica:
Now we combine the two sides, and solve for [A]:
Note how we told Mathematica that we are interested in Real solutions only (concentrations can
not be complex!). In the next step, we copy the solution to variable “A” and print it out:
This is exactly the same result as given in your Physical Chemistry textbook [8,14,15].
kt
e
−
=
0
[A][A] (54)
Now, all we need to do is solve this equation for half-life (t1/2). From the definition of half-life, it
is time (t) at which [A] falls to [A]0/2. We can certainly do that in Mathematica:
Compare our formula with that given in your Physical Chemistry textbook [8,14,15],
𝑡1/2 =
ln( 2)
𝑘
(55)
The agreement is perfect!
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 64 of 69
Exercise 6.1. An object is moving along the 𝑥-axis with acceleration 𝑎(𝑡) given by the equation
𝑎(𝑡) = Φ(𝑡 + Ω)𝑒−Θ𝑡 (56)
where 𝑎 is in cm/s2, and 𝑡 is seconds (s). Using your Mathematica notebook from Example 6.1
as a template, determine the object’s (a) 𝑥-velocity and (b) 𝑥-position as a function of time, the
general constants Φ, Ω, and Θ, and some (yet unknown) initial position 𝑥0 and initial velocity 𝑣0.
Suppose, Φ = 3.5 cm/s3, Ω = 1.2 s, and Θ = 0.47 s−1. Determine the numerical values for (c)
𝑥0 (cm) and (d) 𝑣0 (cm/s) if it is known that at 𝑡 = 1.2 s, the velocity of the object was 13. cm/s,
and it was located at +14. cm. Plot (e) 𝑥 vs 𝑡, (f) 𝑣 vs 𝑡, and (g) 𝑎 vs 𝑡 for 𝑡 = 0 … 15 s. Save the
notebook as “Exercise_6.1.nb”. Warning! All the calculation steps must be performed in
your Mathematica notebook, and all items (a-g) must be clearly labelled using the Print[]
and/or PlotLabel[] function, or the score for this exercise will be zero!
Answers: (a) … (b) …
(c) 1.8 cm (d) …
(e,f,g) …
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 65 of 69
Exercise 6.2. For a closed system in the absence of non-expansion work and at constant
composition, the variation of the molar Gibbs energy, 𝐺m, with pressure, 𝑝, and temperature, 𝑇, is
given by the following equation:
𝑑𝐺m = 𝑉m𝑑𝑝 − 𝑆m𝑑𝑇 (6.2.a)
where 𝑉m is the molar volume (i.e. volume per mole of substance, 𝑉m = 𝑉/𝑛 ) and 𝑆m is the molar
entropy (i.e. entropy per mole of substance, 𝑆m = 𝑆/𝑛) [8,14]. To determine the change in the
molar Gibbs energy for the isothermal (𝑇 = const.) reversible expansion from initial pressure 𝑝i
to final pressure 𝑝f, we set 𝑑𝑇 = 0 which gives
𝑑𝐺m = 𝑉m𝑑𝑝 (6.2.b)
and integrate:
Δ𝐺m = 𝐺m(𝑝f) − 𝐺m(𝑝i) = ∫ 𝑉m𝑑𝑝
𝑝f
𝑝i
(6.2.c)
This expression is applicable to any phase of matter, but to evaluate it we need to know how the
molar volume, 𝑉m, depends on the pressure [8,14]. For an ideal gas, we rearrange 𝑝𝑉m = 𝑅𝑇 as
𝑉m = 𝑅𝑇/𝑝, and substitute it into the integral (6.2.c).
Δ𝐺m = ∫ 𝑉m𝑑𝑝
𝑝f
𝑝i
= ∫
𝑅𝑇
𝑝
𝑑𝑝
𝑝f
𝑝i
(6.2.d)
Because 𝑅𝑇 is a constant (the process is isothermal), we get:
Δ𝐺m = 𝑅𝑇 ∫
1
𝑝
𝑑𝑝
𝑝f
𝑝i
= 𝑅𝑇 ln
𝑝f
𝑝i
(6.2.e)
This very important expression, which applies to ideal gases, shows that when the pressure is
increased tenfold at room temperature, the molar Gibbs energy increases by 𝑅𝑇 ln 10 ≈
6 kJ mol−1 [8,14]. In Mathematica, the very same formula can be obtained using the following
code:
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 66 of 69
Note that when integrating, we had to tell Mathematica that 𝑝i is positive (𝑝i>0), and that 𝑝f is
greater than 𝑝i (𝑝f>𝑝i) and thus, positive as well. Also note that the natural logarithm (ln) in
Mathematica is written as Log[], while the base 10 (common) logarithm, log10, is named Log10[].
Suppose, a certain real gas obeys the following equation of state:
𝑝𝑉m = 𝑅𝑇 {1 +
9
128
(
𝑝
𝑝𝑐
) (
𝑇𝑐
𝑇
) [1 − 6 (
𝑇𝑐
𝑇
)
2
]} (6.2.f)
where 𝑝𝑐 and 𝑇𝑐 are the critical pressure and temperature of the gas, respectively. Using the sample
code given above and the final notebook from Example 6.1 or Example 6.2 as a template, create a
Mathematica code to derive and simplify as much as possible an expression for Δ𝐺m for the
isothermal (𝑇 = const.) reversible expansion of the real gas that obeys equation (6.2.f) from initial
pressure 𝑝i to final pressure 𝑝f, and verify that your result agrees with the literature expression
Δ𝐺m = 𝑅𝑇 ln
𝑝f
𝑝i
+
9𝑅
128
(
𝑇𝑐
𝑝𝑐
) {1 − 6 (
𝑇𝑐
𝑇
)
2
} (𝑝f − 𝑝i). Save the resulting notebook as
“Exercise_6.2.nb”. Warning! All the calculation steps (see below) must be performed in
your Mathematica notebook, or the score for this exercise will be zero! Your Mathematica
notebook must include the following items in the printout, all clearly labelled using the
Print[] function:
(a) define the left-hand side (l.h.s) of equation (6.2.f);
(b) define the right-hand side (r.h.s) of equation (6.2.f);
(c) solve l.h.s = r.h.s. for 𝑉m;
(d) determine Δ𝐺m by evaluating the integral (6.2.c);
(e) verify that your answer is identical to the literature expression; Hint: recall that there are
two easy ways to show mathematically that the two expressions / formulas / numerical
values 𝑎 and 𝑏 are the same: 𝑎 − 𝑏 = 0 or 𝑎/𝑏 = 1.
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 67 of 69
Exercise 6.3. The construction of many thermometers is based on the fact that a column of
mercury (Hg) changes its length when its temperature is changed. The length of a solid or the
volume of a gas at constant pressure are also used in some thermometers. Consider a relationship
between the length of the mercury column 𝑙 and centigrade temperature 𝜃. First, we assign its
length the value 𝑙100 when it is at thermal equilibrium with boiling water at 1 atm pressure. Then,
we assign its length the value 𝑙0 when it achieves a thermal equilibrium with melting ice exposed
to 1 atm pressure. Assuming a linear relationship between the temperature 𝜃 and the length, and
assuming 100 divisions between the fixed marks, allows us to write
𝜃 =
𝑙𝜃 − 𝑙0
𝑙100 − 𝑙0
× 100℃ (6.3.a)
where 𝑙𝜃 is the length at temperature 𝜃, and 𝑙0 and 𝑙100 are the lengths at the freezing and boiling
water temperatures, respectively.
Suppose you calibrate a mercury thermometer at 0°C and 100°C. The thermal expansion
coefficient, 𝛼, for mercury is
𝛼 =
1
𝑉0
(
𝜕𝑉
𝜕𝑇
)
𝑝
= 𝑎 + 𝑏 𝜃 + 𝑐 𝜃2 (6.3.b)
where 𝑉 is volume, 𝑇 is the absolute (kelvin) temperature, 𝜃 is the value of the Celsius temperature,
𝑉0 = 𝑉 at 𝜃 = 0℃, and 𝑎, 𝑏, and 𝑐 are the empirical parameters. The quantity (𝜕𝑉/𝜕𝑇)𝑝, which
is ordinarily read a partial of 𝑉 with respect to 𝑇 at constant 𝑝, is the derivative of 𝑉 in which
pressure and temperature are independent variables. As such, the thermal expansion coefficient 𝛼
gives the fractional increase of volume per unit rise of temperature at constant pressure. Switching
from length to volume modifies equation (6.3.a) as follows:
𝜃 =
𝑉𝜃 − 𝑉0
𝑉100 − 𝑉0
× 100℃ =
Δ𝑉𝜃
Δ𝑉100
× 100℃ (6.3.c)
where 𝑉𝜃 is the volume at temperature 𝜃, Δ𝑉100 is the change in volume that accompanies the
temperature increase from 0℃ to 100℃, and Δ𝑉𝜃 is the change in volume at temperature 𝜃 relative
to that at 0℃. Note that Δ𝑉𝜃 can be conveniently obtained by integrating the expression for
(𝜕𝑉/𝜕𝑇)𝑝 = 𝛼𝑉0 between 0℃ and 𝜃:
Δ𝑉𝜃 = 𝑉𝜃 − 𝑉0 = ∫ 𝛼𝑉0 𝑑𝜃
𝜃
0
(6.3.d)
Using your Mathematica notebook from Example 6.1 or Example 6.2 as a template, determine the
temperature that would appear on the mercury thermometer scale at 50°C given that for mercury,
𝑎 = 1.817 × 10−4, 𝑏 = 5.90 × 10−9 and 𝑐 = 3.45 × 10−10. Warning! All the calculation
steps (see below) must be performed in your Mathematica notebook, or the score for this
exercise will be zero! Your Mathematica notebook must include the following items in the
printout, all clearly labelled using the Print[] function:
(a) define the expansion coefficient using the right-hand side (r.h.s) of equation (6.3.b); do
not assign numerical values to the coefficients 𝑎, 𝑏, and 𝑐 yet!
(b) obtain the analytical expression for Δ𝑉𝜃 by evaluating the integral (6.3.d);
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 68 of 69
(c) assign the given numerical values to the parameters 𝑎, 𝑏, and 𝑐;
(d) using formula (6.3.c), the expression for Δ𝑉𝜃 derived at (b), and the numerical parameters
defined at (c), calculate the temperature 𝜃Hg (to three significant digits) that would appear
on the mercury scale at 50°C.
Answers: (a) … (b) … (c) … (d) 49.7°C
Believe it or not, but this concludes our brief Mathematica tutorial. We hope that we have been
able to convince you that this amazing software can provide a significant help in learning many
concepts in Mathematics, Physics, and Chemistry (recall that Physical Chemistry = Mathematics
+ Physics + Chemistry).
Computer Experiment 1: Mathematics of Physical Chemistry revision 1/10/22
page 69 of 69
7. References
1. Wolfram Research, Inc. Mathematica 9.0. Champaign, Illinois, USA,
2012.
2. http://www.wolfram.com/mathematica
3. https://en.wikipedia.org/wiki/Mathematica
4. https://en.wikipedia.org/wiki/Stephen_Wolfram
5. https://en.wikipedia.org/wiki/Wolfram_Research
6. Tam, P. T. A Physicist’s Guide to Mathematica, 2nd edition, Academic Press, 2008.
7. https://www.duolingo.com/comment/15264140/How-To-Type-Accented-Characters-On-An-
English-Keyboard-Windows-10-Tutorial
8. Atkins, P; de Paula, J. Elements of Physical Chemistry, 5th edition, W. H. Freeman, New York,
2009.
9. Atkins, P; de Paula, J. Physical Chemistry for the Life Sciences, 1st edition, W. H. Freeman,
New York, 2006
10. Serway, R. A., Vuille, C. College Physics, 9th edition, Cengage Learning, 2011.
11. Serway, R. A., Jewett, J. W. Physics for Scientists and Engineers with Modern Physics, 9th
edition, Brooks Cole, 2013.
12. Young, H. D., Freedman, R. A., Ford, A. L. Sears and Zemansky’s University Physics with
Modern Physics, 13th edition. Pearson Education, Inc., 2012.
13. Barrante, J. R. Applied Mathematics for Physical Chemistry, 3rd edition, Prentice Hall; 2003.
14. Atkins, P; de Paula, J. Physical Chemistry, 8th edition, W. H. Freeman and Company, New
York, 2006.
15. Atkins, P; de Paula, J. Elements of Physical Chemistry, 6th edition, W. H. Freeman, New York,
2012.
16. Ball, D. W. Physical Chemistry, 1st edition, Cengage Learning; 2002.
http://www.wolfram.com/mathematica
https://en.wikipedia.org/wiki/Mathematica
https://en.wikipedia.org/wiki/Stephen_Wolfram
https://en.wikipedia.org/wiki/Wolfram_Research
https://www.duolingo.com/comment/15264140/How-To-Type-Accented-Characters-On-An-English-Keyboard-Windows-10-Tutorial
https://www.duolingo.com/comment/15264140/How-To-Type-Accented-Characters-On-An-English-Keyboard-Windows-10-Tutorial