Sagetex: Derivative 5/6 without the Chain Rule


I've added two more problems (Problems 5 and 6) to the Sagetex: Derivatives page. Problem 5 requires the student to calculate the derivative of a product of polynomials using the Product Rule. Problem 6 looks like a Quotient Rule but the derivative is more easily calculated by carrying out division before taking the derivative.

Here are some stories which caught my eye:

  • L.A. Times reports 9 students at Venice High School were arrested and 14 accused, " connection with a series of sex crimes that began more than a year ago and involved at least two female classmates. All but one of the arrests were on campus; authorities were attempting to locate five other students." No doubt this story will continue to evolve.
  • Mathematically challenged: it could cost you your marriage. The New York Post reports "Bride Walks out on groom after he botches simple math problem". In a country of arranged marriages, it was a sign to the bride she had been "misled" about his education. "“The groom’s family kept us in the dark about his poor education,” said Mohar Singh, the bride’s father. “Even a first-grader can answer this.”"
  • LaTeX Community has a nice piece on "Why I like the TikZ Math library".
  • Welcome to school today: a student intentionally runs into a school security officer " what has been described as an attempt to ‘chest bump’ the officer...". This knocks the officer to the ground. The officer gets up, grabs the boy and according to Infowars, which has the video posted: "The video shows Hardin lifting the 13-year-old child into the air with a chokehold. The child kicks and flails around before becoming limp and lifeless. Hardin then drops the student to the ground, resulting in what a doctor has described as “an injury to the brain” due to loss of blood flow.". Be aware of the graphic nature before you watch this.
  • It's obvious to "older" people that school quality has dropped dramatically over the years (think Calculus students who struggle with fractions) but at least the students of today are tech-savy, right? According to this Fortune article, no. "American Millennials are among the world's least skilled" reports that a new study shows, "...Millennials in the U.S. fall short when it comes to the skills employers want most: literacy (including the ability to follow simple instructions), practical math, and — hold on to your hat — a category called “problem-solving in technology-rich environments.” Not only do Gen Y Americans lag far behind their overseas peers by every measure, but they even score lower than other age groups of Americans."

Odds and Ends, February 12, 2015


  1. I've added another math article template to the LaTeX page. This one uses the Classic Thesis style.
  2. Three chess packages were added to the LaTeX page.
  3. The Problem page has another problem, due to Leibniz; he demonstrated that \sqrt{6}=\sqrt{1+\sqrt{-3}}+\sqrt{1-\sqrt{-3}}.
  4. Carlsen tied with Naiditsch at the Grenke Chess classic with Magnus winning on tiebreaks. Chessbase has the report here.
  5. Have you ever gotten tired of keeping your students off the portable distraction devices. It might be addiction! If you saw the recent viral photo of someone checking their cell phone while missing the giant humpback whale nearby or saw the report on Japanese teenage girls spending 7 hours on their phones you will have no trouble believing Science Daily's article on the use of mobile technology by children. "The authors question whether heavy device use during young childhood could interfere with development of empathy, social and problem solving skills that are typically obtained by exploring, unstructured play and interacting with peers....."'Until more is known about its impact on child development quality family time is encouraged, either through unplugged family time, or a designated family hour," added Radesky."
  6. Voice of America asks, "Is America in a Math Crisis?". Well known mathematician and author Albert Posamentier asserts, “Elementary school teachers in this country, and Europe as well, are part of that general population and consequently they bring that dislike of mathematics subconsciously, sometimes consciously at other times, to the classroom and as a result the teaching mathematics at the elementary school level lacks motivation, lacks enthusiasm.  The enthusiasm of the teacher  is extremely important in turning kids on to the subject matter". Let's also remember that 1/3 of high school math teachers don't have a degree in mathematics. The problems aren't just limited to elementary school.
  7. A 10 year old Chinese girl made the Wuhan Evening News for her poem on the tortures of math: “Math is the root of death and it makes life like hell. It wears out children and worries parents. It expels the vitality of school and slowly takes away life.”. Needless to say, I disagree.
  8. An 8th grader who through the American flag out of a classroom window is now in serious trouble: From the article, "The principal called the school resource officer with Rio Arriba County, but because it is a federal offense they referred him to the FBI. “I want to report it to them because it is a federal law, so it’s in their hands,” Archuleta said. Last week, he suspended the 14-year-old last week for 10 days, but he is recommending long-term suspension or expulsion."

Handouts: Stern-Brocot/listing rationals


In earlier posts I mentioned the Stern-Brocot sequence and how it can be used to create another sequence that lists the positive rationals in lowest form exactly one time each. There was a lot of information on the subject so I put together a PDF containing that information plus a little bit more--it's posted on the Handouts page.  In addition to the Numberphile, the link to the Caulkin, Wilf paper, the tree of rationals, and Sage Code I've included an algorithm along with a dry run (shown above) along with some other information from the Caulkin-Wilf paper and some sample questions/tasks that can help flesh out a lesson to your class:


The "Fact" box above as well as the box containing the Sage Code below were created using the tcolorbox package.


So, if you plan on using the Stern-Brocot sequence there is now 1 resource containing all the components of the Stern-Brocot sequence.

Here are a few things that caught my eye recently:

  • The Grenke Chess Classic 2015 has one round to go with Carlsen and Naiditsch tied for first and several others in striking distance. In the even of a tie there will be blitz games to decide the winner of the tournament. The games stream here. (Click "Live")
  • In the last post there was an item about the shift in the debate over Common Core. Rather than deal with constant criticism the new approach is to say Common Core is about standards, not content. That's misleading from my experience because standards drive content. So schools look to buy Common Core aligned material which help set the level of difficulty and subject matter. The problem of 4 ways to subtract caused a backlash because it was showing up in the textbooks. And as RT notes in this video,  Common Core has legible handwriting taught in kindergarten and first grade only. This skill, no longer being required at higher levels is replaced with other content. As a result, many schools have stopped teaching cursive. The result are kids who can't read or write cursive. It's a piece with a lot of interesting arguments.

Python/Sage: Stern-Brocot sequence


In the last post I mentioned Numberphile's excellent video on the Stern-Brocot sequence. The explanation of how the sequence is formed is clear enough but extra time will be needed to make sure students know how the sequence is formed. That would mean discussing the algorithm for how the sequence is formed, using the algorithm to create the sequence and then getting them to calculate some terms of the sequence on their own. I put together a quick Python program to create some terms of the sequence and then show the sequence of positive rational numbers. Having a list of both sequences will help to catch any mistakes you might make from, say, getting distracted/interrupted fielding questions along the way. The code is posted on the Python/Sage page.

Here are some other events that caught my eye recently.

1. The 13th Tradewise Gibraltar Masters tournament has ended with Hikaru Nakamura in clear first place followed by David Howell second and a big tie for 3-11. Now all eyes are on Grenke which will continue with round 4. You can follow the game here. (Click Video)

2. I stumbled onto a PhD Dissertation on "Students' Errors in Graphing Calculator Based Precalculus Classes". It's worth looking at some of the misconceptions and examples that caused students to struggle.

3. Politifact weighs in on the Texas governor's claim, "it takes "more than a minute" to teach a student "how to add nine plus six."". Lost in the claims and counter claims (Common Core is standards not content) is the fact that the new materials which are aligned to common core have this bizarre new math. Remember, for example, the 4 methods of subtraction? It's in the books that teachers have to teach out of and wasn't in books before Common Core.

4. An excellent web page on Using Writing in Mathematics.


Counting the Rationals


In The Most Important Lesson of High School Math I mentioned that I thought the goal of the high school math curriculum should be to get students to the point that the rational numbers have measure zero (while avoiding such technical speak). The video I linked to (How Big is Infinity) took students through Cantor's diagonal argument that the positive rational numbers can be listed. That list, however, has different forms of the same number (4/2=2/1=8/4=...). But I frecently found a post by Numberphile on the Stern-Brocot sequence. This sequence has a nice property: take the ratio of consecutive terms  \frac{a_n}{a_{n+1}} to create another sequence which lists every positive rational in lowest terms exactly once. A brief paper by Caulkin and Wilf has more of the mathematics. I've put together a tree diagram that was used to explain how the rational numbers are created. You can find the PDF and tex file on the Graphics page. The Stern-Brocot sequence and the rational sequence resulting from the ratio of consecutive terms would be a good example to put into your coverage of sequences.

Some other points of interest:

  • I found a minor mistake in the code for the last post. If you look at the screen shot I've got y_coords and y1_coords used in the same IF statement. I've fixed the file and uploaded it.
  • I've started a list of LaTeX packages that are important/useful to me when I'm using LaTeX; it's on the LaTeX page. There's been a big increase in packages over the years and I'm finding new packages that weren't around years ago. Since I can't keep always remember the package or the commands, I'm listing the packages which are linked to the CTAN documentation.
  • The Gibraltar tournament is into round 7 of 9 and Nakamura is in the lead. Meanwhile, the Grenke Chess Classic 2015 has started. It's got Carlsen, Anand and many other top players. You can follow the games by clicking on the link and then pressing the "Video" tab.
  • CBS MoneyWatch has an article on "Teacher Pensions: the Math Adds Up to a Crisis". From the article, "Teacher pension plans across the country are staggering from a half-trillion dollars in debt. Put in perspective, that's more than $10,000 worth of debt for every student in the nation's primary and secondary schools.".
  • The Houston Chronicle tells us: "Teachers would be able to use deadly force against students, and would be safe from prosecution, under legislation filed last week in the state House. The Teacher’s Protection Act by Rep. Dan Flynn, R-Van, would allow educators to use force or deadly force  if they feel they need to protect themselves against a student or anyone else on school grounds.". The article references, "The bill was filed just days before a video of a New Jersey physics teacher being body slammed by his 9th grade student went viral. In the video, it’s clear the teacher is avoiding fighting back or touching the student." Check out the video of the teacher being slammed; he's remarkably calm during the attack. But is giving a teacher the right to use deadly force a solution?

Sagetex: Derivatives page and problem

Diff1I've started a page for derivatives using SageTex and posted the first problem. The link to the page is located on the sidebar or you can click here. The first problem is taking the derivative of a polynomial to an integral power, using the Chain Rule. You can see a screen shot above.

Here are some things which caught my eye recently:

  • ABC news reports that students in Florida were caught running a high school prostitution ring. You can read the lurid details here.
  • The NYPost reports that East Side Community HS ran a 2 day course on how students should deal with police officers. The article states, "Principal Mark Federman said he brought in the NYCLU because students told teachers they had bad experiences with being stopped by police. He said the training also was relevant to history classes studying the Ferguson, Mo., shooting.".
  • Learning LaTeX?  Dickimaw Books has a  free book "LaTeX for Complete Novices" which can be downloaded here.

Problem: Combinatorics

TrianglesI've added another problem to the Problems page: How many triangles have vertices using the points above?

Here are some things which caught my eye:

Sagetex: Random pictures

CombGraphIn an earlier post I experimented with random bipartite graphs. With a little more practice under my belt, I've incorporated the same basic idea to create a random picture that is used in the latest addition to the Sagetex:Combinatorics/Probability page; problem 14. There are actually 3 problem variations here, depending on how deep you want to go into the classic problem of finding the number of shortest paths in a grid. There are several random aspects of the problem: the number of vertical lines in the grid, the number of horizontal lines in the grid, and the placement of the point M in the grid that all "special" paths must go through.

The basic idea for these problems is that your LaTeX file is a string and a part of the string will be created in sagesilent and then inserted into your latex document with a statement like \sagestr{output}. By creating the string in the sagesilent environment you're getting the power of Python and Sage commands. LaTeX was made for typesetting, so it's computational skills are limited. By tapping into Sage's calculating power combined with Python commands (for loops, strings) the sagetex package vastly increases the power of what can be accomplished in LaTeX.

The latest problem has you determine:

  • the number of shortest paths from A to Z (bottom left to top right)
  • the number of shortest paths from A to Z that go through M
  • the probability that a randomly chosen shortest path goes through M

Here is the sagesilent code from the latest problem. Note that the blog has destroyed the indentation which is necessary in Python. You should download the template (problem 14 on Sagetex: Combinatorics/Probability) for correct formatting.

k = Integer(randint(6,9))
n = Integer(randint(5,6))
m2 = Integer(randint(n-4,n-2))
m1 = Integer(randint(k-5,k-2))
output = r""
output += r"\begin{tikzpicture}[scale=.7]"
for i in range(0,n+1):
output += r"\draw (0,%s)--(%s,%s);"%(i,k,i)
for i in range(0,k+1):
output += r"\draw (%s,0)--(%s,%s);"%(i,i,n)
output += r"\draw [fill] (0,0) circle [radius=2pt];"
output += r"\node [left] at (0,0) {$A$};"
output += r"\draw [fill] (%s,%s) circle [radius=2pt];"%(k,n)
output += r"\node [right] at (%s,%s) {$Z$};"%(k,n)
output += r"\draw [fill] (%s,%s) circle [radius=2pt];"%(m1,m2)
output += r"\node [above left] at (%s,%s) {$M$};"%(m1,m2)
output += r"\end{tikzpicture}"

For the code above k and n are the length and width of the rectangle, so there are k+1 vertical lines and n+1 horizontal lines. Point M will have the coordinates (m1, m2). After choosing n, k, m1, and m2 randomly the picture that you would normally create in the body of your latex document is "typed" in sagesilent as a string, called output. The command: output += r"\begin{tikzpicture}[scale=.7]" starts building the string. The r occurs before the " symbol to indicate that a raw string is used. This is needed because LaTeX has various symbols, such as \, that aren't treated properly if output was a normal string. The default scale is 1, I've dropped it to .7 to make the picture smaller. This allows me you put have a bigger grid for your picture without it running out of the margins.

Python for loops create the horizontal lines

for i in range(0,k+1):
output += r"\draw (%s,0)--(%s,%s);"%(i,i,n)

and vertical lines

for i in range(0,k+1):
output += r"\draw (%s,0)--(%s,%s);"%(i,i,n)

The %s is the string content that will be filled in. In

output += r"\draw (%s,0)--(%s,%s);"%(i,i,n)

there are 3 strings that have data that needs to be determined by Python. The respective values will be i, i, and n, which are varying depending on where you are in the for loop.

The placement of points is determined through commands like

output += r"\draw [fill] (%s,%s) circle [radius=2pt];"%(m1,m2)

There are 2 strings that need to be filled. The first string is that random value m1 and the second string will be the random m2 value.

Creating random test/quiz problems save you time in creating tests, provide you with a solution, and eliminate potential mistakes. Have a student who missed your test? Create a different version quickly.

Here are some current events that caught my eye.

  • As you probably know, Asia is the land of fakes. Whether it's fake Rolex watches, fake DVD's, fake designer bags, or fake Ferraris, appearances can be deceptive. You need to be alert to fake doctors, fake teachers (with fake diplomas) and fake monks. It should be no surprise that cheating is rampant in Asia; it's so "advanced" there you might call it an art form. A great example of this is the cheating scandal a couple of years ago. Lots of students tried cheating, and some teachers caught them. That led to a firestorm, "By late afternoon, the invigilators were trapped in a set of school offices, as groups of students pelted the windows with rocks. Outside, an angry mob of more than 2,000 people had gathered to vent its rage, smashing cars and chanting: "We want fairness. There is no fairness if you do not let us cheat."". So it should be no surprise to hear about the latest cheating in China. First up is the cheating on SATs in Asia. From the article: "Bob Schaeffer, public education director of the nonprofit National Center for Fair & Open Testing, known as FairTest, said that his organization had received several e-mails from sources in Asia alleging that the SAT given on Nov. 8 was circulating among students before it was administered. One message included a screen shot of what appeared to be an entire SAT exam in Chinese.". Technically, this cheating allegation hasn't been confirmed but anyone with experience in Asia knows it has to be true. In fact, the article mentions, "Many local educators believe that the test-makers did not aggressively pursue cheating claims to protect the reputation of their flagship product, the SAT.", so I suspect this will get swept under the rug. You can get more details from an earlier story.
  • The Daily Mail highlights some of China's attempts to crack down on cheating in high school. From the article, "With thousands of Chinese students resorting to 007-style gadgets such as pinhole cameras and radio transmitter bras to cheat in their exams, one college decided to take a stand....

    Security staff in Jinlin, Jiangsu and Guangdong provinces revealed that students started using sophisticated radio vests in order to receive help from someone outside the hall.

    Pupils were also taking pictures of the tests using a button-hole camera hidden in a pen or watch, then using a copper antenna loop stitched into their clothing to beam it out of the hall to someone sitting with a receiver".

  • 2440 students were caught cheating in China on a pharmacy exam. Here's a video of news coverage.
  • ZeroHedge had a piece that illustrates how high school quality has dropped: the article says, "The number of college students taking at least one remedial course rose to 2.7 million in the 2011-2012 academic year from 1.04 million in 1999-2000, federal data show. During the same span, the amount of federal grants spent by undergraduates enrolled in at least one remedial course rose 380%, after inflation, Education Department figures show. There was also a drastic rise in remedial students taking on student debt."
  • RT reports that a racist high school administrator tweet led to a student walk out.
  • LA Times tells us about 6 students getting arrested after fights break out. The school had to go into lockdown. Education is not what it used to be.

SageTex: Tables with a random number of columns/rows

ProbDiceThe sagetex package documentation has, on page 9, a passage on one of the most useful applicaations of sagetex: making it write your code for you. The documentation gives an example of creating a table. At this site, I've already used it to create a trig table and a log table. Today I've added another problem to the SageTeX: Combinatorics/Probability page that creates a table that has a random number of columns/rows; you can download the tex file and play with it yourself in Sagemath Cloud. The problem type has the form: Imagine you have two 7-sided dice in which the sides of each die are equally likely to occur. Create a chart to show all possible outcomes and use it to find the probability that the sum is prime. You can see a screenshot above showing the code and output. The value of 7 is random (I allow it to be between 4 and 7 so that creating the chart isn't too easy or too difficult) and the goal, in this cas "the sum is prime", is random as well. The solution then will involve creating a table of random size.

Tinkering with the rows is trivial: just print more lines. Adjusting the columns is a bit more complicated: it uses the idea that, in Python, 'my string'*5 will print out 'my string' 5 times. The table is created in the sagesilent environment and the random number of columns is set by

output += r"\begin{tabular}{c|"
output += 'c'*n
output += r"}"

where string 'c' is repeated n times (n has already been defined as a random integer between 4 and 7). That simple construction is all you need. But sagetex also helps us construct the table entries and compute the answer we seek thereby eliminating mistakes. The row construction is here:

for i in range(1,n+1):
output += r"%s &"%(i)
for j in range(1,n+1):
output += r"%s "%(i+j)
if j < n:
output += r"& "
output += r"\\"

and the part worthy of comment is that the IF statement is there because, as long as we aren't at the last column we need to add an ampersand (&) otherwise, we're at the end of the line, so start a new line. Finally, there are 3 different events to calculate. The code is set up so you can easily add your own cases. Getting used to producing LaTeX code as a Python string takes a little time but it's well worth it. How long would it take you to create the trig table or log table that I've posted without using sagetex?

Here are some issues that caught my eye:

  • Have you ever had the annoying "When will I ever use this?" question come up in your class? Douglas Corey of Brigham Young University has some answers.
  • An annoying article, "Why Homework Is Bad for Kids". This sorting of thinking infects the public school system and is one reason for poor student performance in mathematics. You simply can't get the repetition needed to build mathematical skills during the school day and homework is the test of whether a student has mastered what was covered in class (when nobody is around to help them). The author writes, "We like to think all of this makes sense: It is well tested and, besides, it is what everyone is doing worldwide. No wonder we lose our markets to Japanese, Chinese, and Korean kids. Their schools are more strict and they study harder.Yet every element of this familiar equation is questionable.". It DOES make sense and of course, the author avoids coming up with another reason for why these other nations do better. The author points out that "...even in countries as workaholic as Japan, the number of hours kids are forced to study is becoming an issue of concern.". Note how lame this argument is, without more facts. IF a US student spends 20 minutes on homework and IF a Japanese student spends 4 hours on homework then arguing that Japan's push for less homework justifies our having 20 minutes (instead of 1 hour) doesn't make sense. But of course, the author doesn't give you the important information to put the issue into context.
  • It's not math related but "I F@$#ing love science" has a nice video on "10 Lies You Were Probably Taught in School". This is a good site for any science teachers out there. WARNING: DO NOT open their Facebook page or Twitter feed at school. Some users have inappropriate avatars.


Inquiry Based Learning

Inquiry Based Learning (IBL) is a teaching method "that engages students in sense-making activities.  Students are given tasks requiring them to solve problems, conjecture, experiment, explore, create, and communicate... all those wonderful skills and habits of mind that Mathematicians engage in regularly.". The website I linked to has lots of information on running a class using IBL. While I don't think it's practical to run a standard classroom that way because the curriculum couldn't be covered, I do think it's an important part of teaching. With 1100+ pages of material that needs to be covered for my accelerated precalculus class, finding time for IBL is not always so easy. Most of the time I have to resort to bonus problems in order give an IBL type problem. But finding these more nuanced problems isn't always easy. In an earlier post, I gave a link to the problems that Phillips Exeter Academy posts on their website. The IBL site I linked to above has lots of links to helpful resources. The goldmine, for me is Art of Mathematics website which has 11 free PDF books that you are free to download. The books have titles: Art & Sculpture, Calculus, Dance, Games & Puzzles, Geometry, Knot Theory, Music, Number Theory, Patterns, The Infinite, Truth, Reasoning, Certainty, & Proof. There's something for everybody. And the materials are well thought out. If you look around the site, there's plenty of useful information to get you started on the road to IBL. One of the links is to a site for IBL Calculus.

I've added Exeter's problems and the Art of Mathematics books to the mathematical links on the sidebar.

Here are some things that caught my eye: