Tag Archives: mathematica

Some demos of families of functions

I have posted on abstractmath.org a CDF file of families of functions whose parameters you can control interactively. It is fascinating to play with them and see phenomena you (or at least I) did not anticipate.  Some of them have questions of the sorts you might ask students to discuss or work out.  Working out explanations for many of the phenomena demand some algebra skills, and sometimes more than that.

The Mathematica command that sets up one of the families looks like this:

Manipulate[
Plot[{Sin[a x], a Cos[a x]}, {x, -2 Pi, 2 Pi},
PlotRange -> {{-4, 4}, {-4, 4}}, PlotStyle -> {Blue, Red},
AspectRatio -> 1], {{a, 1}, -4, 4, Appearance -> “Labeled”}]

It would be straightforward to make a command something like

PlotFamily[functionlist, domain, plotrange]

with various options for colors, aspect ratio and so on that would do these graphs.  But I found it much to easy to simply cut and paste and put in the new inputs and parameters as needed.

This sort of Mathematica programming is not hard if you have an example to copy, but you do need to get over the initial hump of learning the basic syntax.   I know of no other language where it would be as easy as the example above to produce an interactive plot of a family of functions.

But many people simply hate to learn a new language.  If this sort of interactive example turns out to be worthwhile, someone could design an interface that would allow you to fill in the blanks and have the command constructed for you.  (I could say the same about some of other cdf files I have posted on this blog recently.) But that someone won’t be me.  I have too much fun coming up with new ideas for math  exposition to have to spend time working out all the details.  And all my little experiments are available to use under the Creative Commons License.

I would appreciate comments and suggestions.

 

Send to Kindle

Prechunking

The emerging theory of how the brain works gives us a new language to us for discussing how we teach, learn and communicate math.

Modules

Our minds have many functionalities.  They are implemented by what I called modules in Math and modules of the mind because I don’t understand very much about what cognitive scientists have learned about how these functionalities are carried out.  They talk about a particular neuron, a collection of neurons, electrical charges flowing back and forth, and so on, and it appears there is no complete agreement about these ideas.

The functions the modules implement are physical structures or activities in the brain.  At a certain level of abstraction we can ignore the mechanism.

Most modules carry out functionalities that are hidden from our consciousness.

  • When we walk, the walking is carried out by a module that operates without our paying (much) attention to it.
  • When we recognize someone, the identity of the person pops into our consciousness without us knowing how it got there.  Indeed, we cannot introspect to see how the process was carried out; it is completely hidden.

Reasoning, for example if you add 56 and 49 in your head, has part of the process visible to your introspection, but not all of it.  It uses modules such as the sum of 9 and 6 which feel like random access memory.  When you carry the addition out, you (or at least I) are conscious of the carry: you are aware of it and aware of adding it to 9 to get 10.

Good places to find detailed discussion of this hiddenness are references [2] and [4] below.

Chunking

Math ed people have talked for years about the technique of chunking in doing math.

  • You see an algebraic expression, you worry about how it might be undefined, you gray out all of it except the denominator and inspect that, and so on.  (This should be the subject of a Mathematica demo.)
  • You look at a diagram in the category of topological spaces.  Each object in the diagram stands for a whole, even uncountably infinite, space with lots of open and closed subsets and so on, but you think of it just as a little pinpoint in the diagram to discover facts about its relationship with other spaces.  You don’t look inside the space unless you have to to verify something.

Students have a hard time doing that.  When an experienced mathematician does this, they are very likely to chunk subconsciously; they don’t think, “Now I am chunking”.  Nevertheless, you can call it to their attention and they will be aware of the process.

There are modules that perform chunking whose operation you cannot be aware of even if you think about it.  Here are two examples.

Example 1. Consider these two sentences from [2], p. 137:

  • “I splashed next to the bank.”
  • “There was a run on the bank.”

When you read the first one you visualize a river bank.  When you read the second one you visualize a bank as an institution that handles money.  If these two sentences were separated by a couple of paragraphs, or even a few words, in a text you are likely not to notice that you have processed the same word in two different ways.  (When they are together as above it is kind of blatant.)

The point is the when you read each sentence your brain directly presents you with the proper image in each case (different ones as appropriate).  You cannot recover the process that did that (by introspection, anyway).

Example 2. I discussed the sentence below in the Handbook.  The sentence appears in references [3].

…Richard Darst and Gerald Taylor investigated the
differentiability of functions f^p (which for our
purposes we will restrict to (0,1)) defined for
each p\geq1 by

In this sentence, the identical syntax (a,b) appears twice; the first occurrence refers to the open interval from 0 to 1 and the second refers to the GCD of integers m and n.  When I first inserted it into the Handbook’s citation list, I did not notice that (I was using it for another phenomenon, although now I have forgotten what it was).  Later I noticed it.  My mind preprocessed the two occurrences of the syntax and threw up two different meanings without my noticing it.

Of course, “restricting to (0, 1)” doesn’t make sense if (0, 1) means the GCD of 0 and 1, and saying “(m, n) = 1doesn’t make sense if (m, n) is an interval.  This preprocessing no doubted came to its two different conclusions based on such clues, but I claim that this preprocessing operated at a much deeper level of the brain than the preprocessing that results in your thinking (for example) of a topological space as a single unstructured object in a category.

This phenomenon could be called prechunking.  It is clearly a different phenomenon that zooming in on a denominator and then zooming out on the whole expression as I described in [1].

This century’s metaphor

In the nineteenth century we came up with a machine metaphor for how we think.  In the twentieth century the big metaphor was our brain is a computer.  This century’s metaphor is that of a bunch a processes in our brain and in our body all working simultaneously, mostly out of our awareness, to enable us to live our life, learn things, and just as important (as Davidson [4] points out) to unlearn things.  But don’t think we have Finally Discovered The Last Metaphor.

References

  1. Zooming and chunking in abstractmath.org.
  2. Mark Changizi, The vision revolution.  Benbella Books, 2009.
  3. Mark Frantz, “Two functions whose powers make fractals”.  American Mathematical Monthly, v 105, pp 609–617 (1998).
  4. Cathy N. Davidson, Now you see it.  Viking Penguin, 2011.  Chapters 1 and 2.
  5. Math and modules of the mind (previous post).
  6. Cognitive science in Wikipedia.
  7. Charles Wells, The handbook of mathematical discourse, Infinity Publishing Company, 2003.
Send to Kindle

Showing categorical diagrams in 3D

The interactive examples in this post require installing Wolfram CDF player, which is free and works on most desktop computers using Firefox, Safari and Internet Explorer, but not Chrome. The source code is the Mathematica Notebook algebra1.nb, which is available for free use under a Creative Commons Attribution-ShareAlike 2.5 License. The notebook can be read by CDF Player if you cannot make the embedded versions in this post work.

In Graph-Based Logic and Sketches, Atish Bagchi and I needed to construct a lot of cones based on fairly complicated diagrams. We generally show the base diagram and left the reader to imagine the cone. This post is an experiment in presenting such a diagram in 3D, with its cone and other constructions based on it.

To understand this post, you need a basic understanding of categories, functors and limit cones (see References).

The notebook and CDF files that generate this display may be downloaded from here:

These files may be used and modified as you wish according to the Creative Commons rule listed under “Permissions” (at the top of the window).

The sketch for categories: composition

A finite-limit sketch (FL sketch) is a category with finite limits given by specifying certain  nodes and arrows, commutative diagrams using these nodes and arrows, and limit cones based on diagrams using the given nodes and arrows.  A model of an FL sketch is a finite-limit-preserving functor from the FL sketch into some category \mathcal{C}.  Detailed descriptions of FL-sketches are  in References [1], [2] and [3] (below).

Categories themselves may be sketched by FL-sketches. Here I will present the part of the sketch that constructs (in a model) the object of composites of two arrows.  This is the specification for composite:

  1. The composite of two arrows f:A\to B and g:B'\to C is defined if and only if B=B'.
  2. The composite is denoted by gf.
  3. The domain of gf is A and the codomain is C.

We start with a diagram in the FL sketch for categories that gives the data corresponding to two arrows that may be composed.  This diagram involves nodes ob and ar, which in a model become the object of objects and the object of arrows of the category object in \mathcal{C}.  (Suppose \mathcal{C} is the category of sets; then the model is simply a small category.  The node ob goes to the set of objects of the small category and ar goes to the set of arrows.)  The arrows labeled dom and cod take (in a model) an arrow to its domain and codomain respectively. Here is the diagram:

You can move the diagram around in three dimensions to see it from different perspectives. (Of course it isn’t really in three dimensions. Your eyes-to-brain module reconstructs the illusion of three dimensions when you twirl the diagram around.)

Note that this is a diagram, not a directed graph (digraph). (In the paper, Atish and I, like most category theorists, say “graph” instead of “digraph”.) It has an underlying digraph (see Chapter 2 of Graph-Based Logic and Sketches), but the labeling of several different nodes of the underlying digraph by the name of the same node of the sketch is meaningful. 

Here, the key fact is that in the diagram there are two arrows, one labeled dom and the other cod, to the same node labeled ob, and two other arrows to two different nodes labeled ob. 

Now click c1.

This shows a cone over the diagram.  One of the nodes in the sketch must be cp (in other words given beforehand; that is, we are specifying not only that the blue stuff is a limit cone but that the limit is the node cp.)   In a model, this cone must become a limit cone.  It follows from the properties of limits that the elements of cp in the model in Sets are pairs of arrows with the property that one has a codomain that is the same as the domain of the other.  The label “cp” stands for “compatible pairs”.

Now click c2.

The green stuff is a diagram showing two arrows from the node labeled ar to the left and right nodes labeled ob in the original black diagram.  This is not a cone; it is just a diagram.  In a model, any arrow in the vertex must have domain the same as the domain of one of the arrows in the compatible pair, and codomain the same as the codomain of the other arrow of the pair.  Thus in the model, an arrow living in the set labeled with “ar” in green must satisfy requirement 3 in the specification for composition given above.

Note that the requirement that the green diagram be commutative in a model is vacuous, so it doesn’t matter whether we specify it specifically as a diagram in the sketch or not.

Now click c3.

The arrow labeled comp must be specified as an arrow in the sketch.  We want its value to be the composite of an element of cp in a model, in other words a compatible pair of arrows.  At this point that will not necessarily be true.  But all can be saved:

Now click c4.

We must specify that the diagram given by the thick arrows must be a diagram of the sketch.  The fact that it must become commutative in a model means exactly that the red arrow comp from cp to ar takes a compatible pair to an arrow that satisfies requirements 1–3 of the specification of composite shown above.

References

  1. Peter T. Johnstone, Sketches of an Elephant: A Topos Theory Compendium, Volume 2 (Oxford Logic Guides 44), by Oxford University Press, ISBN 978-0198524960.
  2. Michael Barr and Charles Wells, Category theory for computing science (1999).    (This is the easiest to start with but it doesn’t get very far.)
  3. Michael Barr and Charles Wells, Toposes, Triples and Theories (2005).  Reprints in Theory and Applications of Categories 1.

 
\mathcal{C}

Send to Kindle

Picturing derivatives

The CDF files in G&G posts no longer work. I have been unable to find out why.I expect to produce another document on abstractmath.org that will include this example and others. A link willl be posted here when it is done.

This is my first experiment at posting an active Mathematica CDF document on my blog. To manipulate the graph below, you must have Wolfram CDF Player installed on your computer. It is available free from their website.

This is a new presentation of old work. It is a graph of a certain fifth degree polynomial and its first four derivatives.

The buttons allow you to choose how many derivatives to show and the slider allows you to show the graphs from x=-4 up to a certain point.

How graphs like this could be used for teaching purposes

You could show this in class, but the best way to learn from it would be to make it part of a discussion in which each student had access to a private copy of the graph.  (But you may have other ideas about how to use a graph like this.  Share them!)

Some possible discussion questions:

  1. Click button 1. Now you see the function and the derivative. Move the slider all the way to the left and then slowly move it to the right.  When the function goes up the derivative is positive.  What other things do you notice when you do this?
  2. If you were told only that one of the functions is the derivative of the other, how would you rule out the wrong possibility?
  3. What can you tell about the zeroes of the function by looking at the derivative?
  4. Look at the interval between x=1.5 and x=1.75.  Does the function have one or two zeroes in that interval?  On my screen it looks as if the curve just barely  gets above the x axis in that interval.  What does that say about it having one or two zeroes?  How could you verify your answer?
  5. Click button 2.  Now you have the function and first and second derivatives.  What can you say about maxima, minima and concavity of the function?
  6. Find relationships between the first and second derivatives.
  7. Now click button 4.  Evidently the 4th derivative is a straight line with positive slope.  Assume that it is.  What does that tell you about the graph of the third derivative?
  8. What characteristics of the graph of the function can you tell from knowing that the fourth derivative is a straight line of positive slope?
  9. What can you say about the formula for the function knowing that the fourth derivative is a straight line of positive slope?
  10. Suppose you were given this graph and told that it was a graph of a function and its first four derivatives and nothing else.  Specifically, you do not know that the fourth derivative is a straight line.  Give a detailed explanation of how to tell which curve is the function and which curve is each specific derivative.

Making this manipulable graph

I posted this graph and a lot of others several years ago on abstractmath.org.  (It is the ninth graph down).  I fiddled with this polynomial until I got the function and all four derivatives to be separated from each other.  All the roots of the function and all its derivatives are real and all are shown.  Isn’t this gorgeous?

To get it to show up properly on the abmath site I had to thicken the graph line.  Otherwise it still showed up on the screen but when I printed it on my inkjet printer the curves disappeared. That seems to be unnecessary now.

Mathematica 8.0 has default colors for graphs, but I kept the old colors because they are easier to distinguish, for me anyway (and I am not color blind).

Inserting CDF documents into html

A Wolfram document explains how to do this.  I used the CDF plugin for WordPress.  WordPress requires that, to use the plugin, you operate your blog from your own server, not from WordPress.com.  That is the main reason for the recent change of site.

The Mathematica files are New5thDegreePolynomial.nb and New5thDegreePolynomial.cdf on my public folder of Mathematica files.  You may download the .cdf file directly and view it using CDF player if you have trouble with the embedded version. To see the code you need to download the .nb file and open all cells.

Here are some notes and questions on the process.  When I find learn more about any of these points I will post the information.

  1. At the moment I don’t know how to get rid of the extra space at the top of the graph.
  2. I was surprised that I could not click on the picture and shrink or expand it.
  3. It might be annoying for a student to read the questions above and have to go up and down the screen to see the graph.  I had envisioned that the teacher would ask the questions and have the students play with the graph and erupt with questions and opinions.  But you could open two copies of the .cdf file (or this blog) and keep one window showing the graph while the other window showed the questions.
  4. Which raises a question:  Could it be possible to program the graph with a button that when pushed would make the graph (only) appear in another window?

Other approaches

  1. I have experimented with Khan Academy type videos using CDF files.  I made a screen shot and at a certain point I pressed a button and the graph appropriately changed.   I expect to produce an example video which I can make appear on this blog (which supposedly can show videos, but I haven’t tried that yet.)
  2. It should be possible to have a CDF in which the student saw the graph with instructional text underneath it equipped with next and back buttons.  The next button would trigger changes in the picture and replace the text with another sentence or two.  This could be instead of spoken stuff or additional to it (which would be a lot of work).  Has anyone tried this?

Note

My reaction to Khan Academy was mostly positive.  One thing that struck me that no one seems to have commented on is that the lectures are short. They cover one aspect (one definition or one example or what one theorem says) in what felt to me like ten or fifteen minutes.  This means that you can watch it and easily go back and forth using the controls on the video display.  If it were a 50-minute lecture it would be much harder to find your way around.

I think most students are grasshoppers:  When reading text, they jump back and forth, getting the gist of some idea, looking ahead to see where it goes, looking back to read something again, and so on.  Short videos allow you to do this with spoken lectures. That seems to me remarkably useful.

Send to Kindle

Riemann clouds improved

In my post Playing with Riemann Sums I showed a couple of clouds of points, each representing a particular Riemann sum for a particular function.   I have extended the code in a couple of ways.

The new code is in the Mathematica notebook and CDF file called MoreRiemann in the Mathematica section of abstractmath.   The .nb form is a Mathematica Notebook, which requires Mathematica to run and allows you to manipulate the objects and change the code in the notebook as you wish.  In particular, you can rerun the commands generating the clouds to get a new random result.  The .cdf file contains the same material and can be viewed using Mathematica CDF Player, which is available free here.  Both files have several other examples besides the ones shown below.

As always, my code is one-time code to show the ideas, but it is available freely via the Creative Commons Attribution – ShareAlike 3.0 License. I hope people will feel free to develop it further for use in teaching or for their own purposes.

Below is a cloud for \int_0^2 \sqrt{4-x^2} dx, the area of a quarter circle of radius 2, which is \pi.  The blue dots are arbitrary random Riemann sums with mesh shown on the horizontal axis and value on the vertical axis.  The partitions and the point in each subinterval are both random.  The red dots are arbitrary Riemann sums with random partitions but using the midpoint for value.

The next cloud shows random blue dots with the same meaning as above.  The red dots are Riemann sums with uniform subintervals evaluated at midpoints.  Possible discussion question for both of the clouds above:

  • Why do the red dots trend upward?

The following cloud is like the cloud above  with the addition of green dots representing uniform partitions evaluated at the left endpoint or right endpoint. (But the mesh scale is extended, giving different proportions to the picture.)

Of course the left endpoint gives the upper sums and the right endpoint gives the lower sums.

  • Explain the slight downward curvature of both green streaks.
  • Explain the big gap between the blue dots and the green dots.  (Requires some machinations with probability.)
  • Would there be blue dots a lot nearer the green dots if I ran the command asking for many more blue dots?

(These are idle questions I haven't thought about myself, but I'll bet they could be turned into good projects in analysis classes.)

Here is a cloud for \int_0^{\pi}\sin x dc with everything random for the blue dots and random partitions but midpoints for the red dots.

  • Why do these red dots trend upward?

The cloud below is for the same integral but uses uniform subintervals for the midpoint and adds green points for both the left endpoint and the right endpoint of uniform subinterval.

  • Why on earth do all the green dots trend downward???

This is a similar picture for \int_0^1 x^2 dx.  There are red dots but they are kind of drowned out.

And finally, here is \int_{\frac{1}{2}}^2 \frac{1}{x} dx:

Send to Kindle

A tiny step towards killing string-based math

I discussed endographs of real functions in my post  Endographs and cographs of real functions.  Endographs of finite functions also provide another way of thinking about functions, and I show some examples here.  This is not a new idea; endographs have appeared from time to time in textbooks, but they are not used much, and they have the advantage of revealing some properties of a function instantly that cannot be seen so easily in a traditional graph or cograph.

In contrast to endographs of functions on the real line, an endograph of a finite function from a set to itself contains all the information about the function.  For real functions, only some of the arrows can be shown; you are dependent on continuity to interpolate where the infinite number of intermediate arrows would be, and of course, it is easy to produce a function, with, say, small-scale periodicity, that the arrows would miss, so to speak.  But with an endograph of a finite function, WYSIATI (what you see is all there is).

Here is the endograph of a function.  It is one function.  The graph has four connected components.

You can see immediately that it is a permutation  of the set \{1,2,3,4,5,6\}, and that it is involution (a permutation f for which f f=\text{id}).  In cycle notation, it is the permutation (1 2)(5 6), and the connected components of the endograph correspond to the cycle structure.

Here is another permutation:

You can see that to get f^n=\text{id} you would have to have n=6, since you have to apply the 3-cycle 3 times and the transposition twice to get the identity.   The cycle structure (1 2 4)(0 3) tells you this, but you have to visualize it acting to see that.  The endograph gives the newbie a jumpstart on the visualization.  “The power to understand and predict the quantities of the world should not be restricted to those with a freakish knack for manipulating abstract symbols” (Brett Victor).   This is an argument for insisting that this permutation is the endograph, and the abstract string of symbols (1 2 4)(0 3) is a representation of secondary importance.  [See Note 1.]

Here is the cograph of the same function.  It requires a bit of visualization or tracing arrows around to see its cycle structure.

If I had rearranged the nodes like this

the cycle structure would be easier to see.  This does not indicate as much superiority of the endograph metaphor over the cograph metaphor as you might think:  My endograph code [Note 2] uses Mathematica’s graph-displaying algorithm, which automatically shows cycles clearly.   The cograph code that I wrote specifies the placement of the nodes explicitly, so I rearranged them to obtain the second cograph above using my knowledge of the cycle structure.

The following endographs of functions that are not permutations exhibit the general fact that the graph of a finite function consists of cycles with trees attached.   This structure is obvious from the endographs, and it is easy to come up with a proof of this property of finite functions by tracing your finger around the endographs.

This is the endograph of the polynomial 2 n^9+5 n^8+n^7+4 n^6+9 n^5+1 over the finite field of 11 elements.

Here is another endograph:

I constructed this explicitly by writing a list of rules, and then used Mathematica’s interpolating polynomial to determine that it is given by the polynomial

6 x^{16}+13 x^{15}+x^{14}+3 x^{13}+10 x^{12}+5  x^{11}\\ +14 x^{10}+4 x^9+9 x^8+x^7+14 x^6\\ +15  x^5+16 x^4+14 x^3+4 x^2+15 x+11

in GF[17].

Quite a bit is known about polynomials over finite fields that give permutations.  For example there is an easy proof using interpolating polynomials that a polynomial that gives a transposition must have degree q-2.  The best reference for this stuff is Lidl and Niederreiter, Introduction to Finite Fields and their Applications

The endographs above raise questions such as what can you say about the degree or coefficients of a polynomial that gives a digraph like the function f below that is idempotent (f f=f).  Students find idempotence vs. involution difficult to distinguish between.  Digraphs show you almost immediately what is going on.  Stare at the digraph below for a bit and you will see that if you follow f to a node and then follow  it again you stay where you are (the function is the identity on its image).  That’s another example of the insights you can get from a new metaphor for a mathematical object.

The following function is not idempotent even though it has only trivial loops.  But the digraph does tell you easily that it satisfies f^4=f^3.

Notes

[1] Atish Bagchi and I have contributed to this goal in Graph Based Logic and Sketches, which gives a bare glimpse of the possibility of considering that the real objects of logic are diagrams and their limits and morphisms between them, rather than hard-to-parse strings of letters and logical symbols.  Implementing this (and implementing Brett Victor’s ideas) will require sophisticated computer support.  But that support is coming into existence.  We won’t have to live with string-based math forever.

[2] The Mathematica notebook used to produce these pictures is here.  It has lots of other examples.

Send to Kindle

Experiment with abstractmath.org

This is a rant about technical problems with creating abstractmath.org.  You will not get great new insights into mathematical language.  You will not get any purty pictures, either.  But if you read the following anyway and have suggestions, I would appreciate them no end.

I have long been frustrated with the process I used to create articles for abstractmath.  The process has been this:  I write the article in Word using MathType, then use their facility for generating an html file that uses pictures (stored in separate files) for the more complicated math expressions, then load them into the abstractmath website.

There are many good and bad things about this. Two of the most aggravating:

  • It is difficult to change links if I reorganize something.  With a TeX file I could write WinEdt macros to do it, but the Word macro language makes manipulating links (and doing many other things) a %#!!*.
  • The documents look different in different browsers.  IE Explorer 8 does the best job, Chrome looks uglier, and Firefox is the ugliest.  After a document has been posted for a while, sometimes I open it to discover weird things, such as the recent discovery that some of my bullets had turned into copyright signs (Firefox turns bullets into double hyphens that are close to invisible).

For the past few weeks I have experimented with generating PDF documents using PDFLaTeX.   I did this with the section called Functions: Notation and Terminology, the only one that is posted so far.  Posting it required 45 minutes  of fixing links in other articles by hand.

Creating that section in TeX was a pain.  I used GrindEQ Math to convert the original document to TeX, which required a great deal of preprocessing (mostly to recover the links, but for some formatting things too) and postprocessing to fix many many things.  I also had to recreate the sidebars by hand; I used wrapfig. Wrapfig does not work well.

In the process of converting this and some other files that I may post later, I created a bunch of macros in the Word macro language (horrible, although in principle I believe in OOP) and the WindEdt macro language, which is pretty good.  Even with the macros, it is a lot of labor to do the conversion.

I have decided to abandon the effort.  I may post a few more articles that I have already transferred to  PDF, but I doubt I will revise any more from scratch.

One thing that has changed since I started doing the conversions was that a recent revision of MathType allows you to type the equations directly in TeX and to toggle back and forth between MathType form and TeX form.  Before that you had to select symbols from a palette.  That was the single most frustrating thing about using Word with MathType.  I type fluently in TeX but I couldn’t use it.  Now that I can type the TeX in directly the prospect of editing articles and writing new ones using Word is much less painful.

So one direction I will go in is to revise the articles already on the web using Word and MathType.  I also expect to kill a good many of the incomplete or less well thought out ones in favor of links to Wikipedia.

But there is another direction, opened up by Mathematica’s Computable Document files.  I have published some experiments with this in the last four posts here.  I expect to be able to turn some of the articles in abstractmath.org into computable documents.  The reader will have to have to have the free CDF Player on their computer, but if you download it once you have it forever.

Send to Kindle

Computable algebraic expressions in tree form

Invisible algebra

  1. An  expression such as $4(x-2)=6$ has an invisible abstract structure.  In this simple case it is

using the style of presenting trees used in academic computing science.  The parentheses are a clue to the structure; omitting them results in  $4x-2=6$, which has the different structure

By the time students take calculus they supposedly have learned to perceive and work with this invisible structure, but many of them still struggle with it.  They have a lot of trouble with more complex expressions, but even something like $\sin x + y$ gives some of them trouble.

Make the invisible visible

The tree expression makes the invisible structure explicit. Some math educators such as Jason Dyer and Bret Victor have experimented with the idea of students working directly with a structured form of an algebraic expression, including making the structured form interactive.

How could the tree structure be used to help struggling algebra students?

1) If they are learning on the computer, the program could provide the tree structure at the push of a button. Lessons could be designed to present algebraic expressions that look similar but have different structure.

2) You could point out things such as:

a) “inside the parentheses pushes it lower in the tree”
b) “lower in the tree means it is calculated earlier”

3) More radically, you could teach algebra directly using the tree structure, with the intention of introducing the expression-as-a-string form later.  This is analogous to the use of the initial teaching alphabet for beginners at reading, and also the use of shape notes to teach sight reading of music for singing.  Both of these methods have been shown to help beginners, but the ITA didn’t catch on and although lots of people still sing from shape notes (See Note 1) they are not as far as I know used for teaching in school.

4) You could produce an interactive form of the structure tree that the student could use to find the value or solve the equation.  But that needs a section to itself.

Interactive trees

When I discovered the TreeForm command in Mathematica (which I used to make the trees above), I was inspired to use it and the Manipulate command to make the tree interactive.


This is a screenshot of what Mathematica shows you.  When this is running in Mathematica, moving the slide back and forth causes the dependent values in the tree also change, and when you slide to 3.5, the slot corresponding to $ 4(x-2)$ becomes 6 and the slot over “Equals” becomes “True”:

As seen in this post, these are just screen shots that you can’t manipulate.  The Mathematica notebook Expressions.nb gives the code for this and lets you experiment with it.  If you don’t have Mathematica available to you, you can still manipulate the tree with the slider if you download the CDF form of the notebook and open it in Mathematica CDF Player, which is available free here.  The abstractmath website has other notebooks you may want to look at as well.

Moving the slider back and forth constitutes finding the correct value of x by experiment.  This is a peculiar form of bottom-up evaluation.   With an expression whose root node is a value rather than an equation, wiggling the slider constitutes calculating various values with all the intermediate steps shown as you move it.  Bret Victor s blog shows a similar system, though not showing the tree.

Another way to use the tree is to arrange to show it with the calculated values blank.  (The constants and the labels showing the operation would remain.)   The student could start at the top blank space (over Times)  and put in the required value, which would obviously have to be 6 to make the space over Equals change to “True”.  Then the blank space over Plus would have to be 1.5 in order to make multiplying it by 4 be 6.  Then the bottom left blank space would have to be 3.5 to make it equal to 1.5 when -2 is added.  This is top down evaluation.

You could have the student enter these numbers in the blank spaces on the computer or print out the tree with blank spaces and have them do it with a pencil.  Jason Dyer’s blog has examples.

Implementation

My example code in the notebook is a kludge.  If you defined a  special VertexRenderingFunction for TreeForm in Mathematica, you could create a function that would turn any algebraic expression into a manipulatable tree with a slider like the one above (or one with blank spaces to be filled in).  [Note 2]. I expect I will work on that some time soon but my main desire in this series of blog posts is to through out ideas with some Mathematica code attached that others might want to develop further. You are free to reuse all the Mathematica code and all my blog posts under the Creative Commons Attribution – ShareAlike 3.0 License.  I would like to encourage this kind of open-source behavior.

Notes

1. Including me every Tuesday at 5:30 pm in Minneapolis (commercial).

2. There is a problem with Equals.  In the hacked example above I set the increment the value jumps by when the slider is moved to 0.1, so that the correct value 3.5 occurs when you slide.  If you had an equation with an irrational root this would not work.  One thing that should work is to introduce a fuzzy form of Equals with the slide-increment smaller that the latitude allowed in the fuzzy Equals.

Send to Kindle

Endograph and cograph of real functions

This post is covered by the Creative Commons Attribution – ShareAlike 3.0 License, which means you may use, adapt and distribute the work provided you follow the requirements of the license.

Introduction

In the article Functions: Images and Metaphors in abstractmath I list a bunch of different images or metaphors for thinking about functions. Some of these metaphors have realizations in pictures, such as a graph or a surface shown by level curves. Others have typographical representations, as formulas, algorithms or flowcharts (which are also pictorial). There are kinetic metaphors — the graph of {y=x^2} swoops up to the right.

Many of these same metaphors have realizations in actual mathematical representations.

Two images (mentioned only briefly in the abstractmath article) are the cograph and the endograph of a real function of one variable. Both of these are visualizations that correspond to mathematical representations. These representations have been used occasionally in texts, but are not used as much as the usual graph of a continuous function. I think they would be useful in teaching and perhaps even sometimes in research.

A rough and unfinished Mathematica notebook is available that contains code that generate graphs and cographs of real-valued functions. I used it to generate most of the examples in this post, and it contains many other examples. (Note [1].)

The endograph of a function

In principle, the endograph (Note [2]) of a function {f} has a dot for each element of the domain and of the codomain, and an arrow from {x} to {f(x)} for each {x} in the domain. For example, this is the endograph of the function {n\mapsto n^2+1 \pmod 11} from the set {\{0,1,\ldots,10\}} to itself:


“In principle” means that the entire endograph can be shown only for small finite functions. This is analogous to the way calculus books refer to a graph as “the graph of the squaring function” when in fact the infinite tails are cut off.

Real endographs

I expect to discuss finite endographs in another post. Here I will concentrate on endographs of continuous functions with domain and codomain that are connected subsets of the real numbers. I believe that they could be used to good effect in teaching math at the college level.

Here is the endograph of the function {y=x^2} on the reals:

I have displayed this endograph with the real line drawn in the usual way, with tick marks showing the location of the points on the part shown.

The distance function on the reals gives us a way of interpreting the spacing and location of the arrowheads. This means that information can be gleaned from the graph even though only a finite number of arrows are shown. For example you see immediately that the function has only nonnegative values and that its increase grows with {x}.(See note [3]).

I think it would be useful to show students endographs such as this and ask them specific questions about why the arrows do what they do.

For the one shown, you could ask these questions, probably for class discussion rather that on homework.

  • Explain why most of the arrows go to the right. (They go left only between 0 and 1 — and this graph has such a coarse point selection that it shows only two arrows doing that!)
  • Why do the arrows cross over each other? (Tricky question — they wouldn’t cross over if you drew the arrows with negative input below the line instead of above.)
  • What does it say about the function that every arrowhead except two has two curves going into it?

Real Cographs

The cograph (Note [4] of a real function has an arrow from input to output just as the endograph does, but the graph represents the domain and codomain as their disjoint union. In this post the domain is a horizontal representation of the real line and the codomain is another such representation below the domain. You may also represent them in other configurations (Note [5]).

Here is the cograph representation of the function {y=x^2}. Compare it with the endograph representation above.

Besides the question of most arrows going to the right, you could also ask what is the envelope curve on the left.

More examples

Absolute value function

Arctangent function

Notes

[1] This website contains other notebooks you might find useful. They are in Mathematica .nb, .nbp, or .cdf formats, and can be read, evaluated and modified if you have Mathematica 8.0. They can also be made to appear in your browser with Wolfram CDF Player, downloadable free from Wolfram site. The CDF player allows you to operate any interactive demos contained in the file, but you can’t evaluate or modify the file without Mathematica.

The notebooks are mostly raw code with few comments. They are covered by the Creative Commons Attribution – ShareAlike 3.0 License, which means you may use, adapt and distribute the code following the requirements of the license. I am making the files available because I doubt that I will refine them into respectable CDF files any time soon.

[2] I call them “endographs” to avoid confusion with the usual graphs of functions — — drawings of (some of) the set of ordered pairs {x,f(x)} of the function.

[3] This is in contrast to a function defined on a discrete set, where the elements of the domain and codomain can be arranged in any old way. Then the significance of the resulting arrangement of the arrows lies entirely in which two dots they connect. Even then, some things can be seen immediately: Whether the function is a cycle, permutation, an involution, idempotent, and so on.

Of course, the placement of the arrows may tell you more if the finite sets are ordered in a natural way, as for example a function on the integers modulo some integer.

[4] The text [1] uses the cograph representation extensively. The word “cograph” is being used with its standard meaning in category theory. It is used by graph theorists with an entirely different meaning.

[5] It would also be possible to show the domain codomain in the usual {x-y} plane arrangement, with the domain the {x} axis and the codomain the {y} axis. I have not written the code for this yet.

References

[1] Sets for Mathematics, by F. William Lawvere and Robert Rosebrugh. Cambridge University Press, 2003.

[2] Martin Flashman’s website contains many exampls of cographs of functions, which he calls mapping diagrams.

Send to Kindle