In [ ]:
!jupyter nbconvert --to slides --post serve Presentation.ipynb
The Engineer uses science to build tools to improve others' quality of life.
In general I think we need more emphasis on computational literacy. Our students don't know how to use computers like engineers would in practice.
No significant development in course content has been made in the area of computational literacy since I was an undergraduate. This may reflect the scarce nature of computers in the early 1990's, but since I've been in univeristy our undergraduate's course looks just like the one I took many years ago.
(Disclaimer: this is a personal observation and in the area of computational materials research I'm left teaching students a lot of the information and methods myself. Their computational training is not commensurate with their mathematical, chemical, physical, reading, writing, etc. training.)
Undergraduate course that applies mathematical techniques to understand materials engineering topics such as materials structure, symmetry, diffusion, mechanics and physics of solids. The class uses examples from the materials science and engineering core courses to introduce mathematical concepts and materials-related problem solving skills. Topics include linear algebra, eigenvalues and eigenvectors, quadratic forms, tensor operations, symmetry operations, calculus of several variables, introduction to complex analysis, ordinary and partial differential equations, theory of distributions, and Fourier analysis, transformations, and calculus of variations .
More completely synthesize and augment students' abilities in the
area of mathematics and computational thinking. We attempt to
achieve this in the following manner:
The course seeks to help students develop an ability:
Why Python?
My main reasons for using Python with in the classroom setting are pragmatic.
Computer literacy is not a barrier.
Knowing that engineering students are generally used to "apps" and "office" suites, setting up a new programming/coding workflow on a student's computer is a barrier. Python distributions (Anaconda and Enthought, specifically) provide a one-click install that provides the student with the necessary tools to start working in my classroom. These environments are available for Linux, Windows and OSX. With some modest tutorials I can get the students into a notebook environment and reading my course notes with little effort. Approximately 2 out of 15 (or so) students will need direct intervention to help them get started on their personal computers. I can usually sort this out on the first day of class. This approach works well at schools where students all have (or are required to have) a laptop computer.
Alternatively, a shared filesystem and computer lab can be used. I worked with a very good team of computer technicians and was able to create the environment on a set of Windows PCs in two days.
Python is dynamically typed.
In some languages (e.g. C, Fortran) you must declare the type of the variable to allocate storage. In Python this happens dynamically. In the early stages of learning computation this is beneficial. I can postpone the discussion on representation of real numbers and memory allocation to later lectures where we discuss how to speed up code.
Python is interpreted rather than compiled.
This, plus the notebook format help the student make rapid progress in development of code and understanding of course material. Incremental, statement-by-statment development and assembly of complex functions from functioning parts can be used as a development paradigm right in the classroom.
The Jupyter Notebook is Immersive.
The documentation and interactive nature of Python/IPython/Notebook help the learning and development occur directly in the browser. You never have to take your eyes off the main window. (I will provide an example of this later.)
The Jupyter Notebook
The notebook provides a single interface for me and the student to interact with the course notes, presentation materials, and homework development. This is consciously part of what I call my "all-in-one" materials distribution strategy. The Notebook is a recent and still evolving project and that can be a bit of a challenge when major updates are released requiring minor tweaks to my code. In defense of the project, my code was the problem each time!
The Notebook works in the browser and this provides a familarity for the student as it is my impression that students spend a lot of their "idle" computer time in-app or in-browser. (E-mail, document creation, commerce, etc.)
Some good "notebook habits" have to be developed by the students, especially if they are used to programming in an IDE or with a compiled languge. The notebook launches a kernel for the selected language (there is more than just Python) and acts like a "state machine" where all the variables and symbols are accessed. This can be a problem at times, but can be remedied easily by re-launching and re-executing the cells when things go wrong.
A major strength of the Notebook is related to the synthesis of text input, equations, visualization and coding. I think students (and we) are used to compartmentalizing each of these activities. One familiar workflow might be to write a document in a word processor, manipulate data in a spreadsheet, edit equations in a plug-in, write code in a code editor or IDE and visualize data in a stand-alone visualization package.
I feel that this compartmentalization de-emphasizes the need of an engineer or researcher to explain their approach and methods, data collected, calculations, and intellectual contributions. To use the Notebook to develop a solution to a problem puts all of the options in front of the user - and the conspicuous absence of these elements could (should?) prompt the author to act to improve their communication.
Lastly, I use features that permit me to project my live-coding to the class. I feel that students' observation of my problem solving abilities and methods is instructive. Although it can be challenging for a student to see the meta-activity if they are focused on the results.
What is Markdown?
A markup language uses a command syntax inline with the content of a document. You are probably most familiar with HTML, but there are others.
These languages can be challenging to use if you are starting out or if you are not used to programming. HTML, in partcular, looks more like computer code then what you (ultimately) want to see on a webpage. This is off-putting for content developers.
Attitudes now favor writing the content of documents so that they are human readable, and then permitting software (that other people write) to transform your document into something that looks different (usually nicer or more professional) or displays the content in a different type of software where the software controls the formatting. LaTeX is a very mature example of a markup language that scientists and engineers use to prepare formal reports and journal articles. For the most part, a LaTeX document can easily be read by a non-LaTeX programmer.
Recently the idea of more humane markup languages has emerged. These languages can easily be read in raw form but they can also be translated by other computer programs into other types of documents.
If you've ever sent a text message and used quotes: " ", asterisks: , or underlines: around a word, then you've already written in a type of "markdown". Software intended for the web generally will have some form of markdown available.
We feel that focusing on human readable content is an appropriate activity for faculty. Sticking to markdown syntax makes it possible for other software packages to interpret your content and create interactive notebooks, slides, homework assignments, course notes, etc.
For example:
**Hello World!**
_Hello World!_
produces:
Hello World!
Hello World!
* Item 1
* Item 2
* Item 3
And equations:
$$
\frac{\partial c}{\partial t} = D \frac{\partial^2 c}{\partial x^2}
$$
renders as:
$$ \frac{\partial c}{\partial t} = D \frac{\partial^2 c}{\partial x^2} $$
In [6]:
import numpy as np
# Array
myArray = np.array([1,2,3,4,5])
myArray[1::]
Out[6]:
In [ ]:
# Broadcasting
5*myArray
In [9]:
# Slicing
myArray
Out[9]:
Broadcasting and slicing reduce/eliminate the need for slow loops in Python. All the looping is done in C and with appropriate optimization using additional Python tools can be made nearly equivalent to native C/Fortran.
In [12]:
# Plotting
import matplotlib.pyplot as plt
x = np.linspace(0, 5, 10)
y = x ** 2
fig = plt.figure()
axes1 = fig.add_axes([0.1, 0.1, 0.8, 0.8]) # main axes
axes2 = fig.add_axes([0.2, 0.5, 0.4, 0.3]) # inset axes
# main figure
axes1.plot(x, y, 'r')
axes1.set_xlabel('x')
axes1.set_ylabel('y')
axes1.set_title('title')
# insert
axes2.plot(y, x, 'g')
axes2.set_xlabel('y')
axes2.set_ylabel('x')
axes2.set_title('insert title');
plt.show()
In [13]:
import sympy as sp
sp.init_printing(use_latex=True)
x = sp.symbols('x')
# Symbolic Series Representation
sp.series(sp.sin(x),x,x0=0,n=10)
Out[13]:
In [16]:
# Calculus
sp.diff(sp.sin(2*x)*sp.cos(x),x,3)
Out[16]:
In [ ]:
# For example, if I were not already in a slide show:
!jupyter nbconvert --to slides --post serve Presentation.ipynb
In [20]:
# Example of Live Reveal
# Compute the squares from 0 to 9
[x**2 for x in range(10)]
Out[20]: