Secant line approximation to tangent with animated GIFs

Derx2LAnimated GIF can be a useful tool in the classroom and Sage give you the ability to create them quickly and easily. The animated GIF above along with its mirror image of tangent lines from the left have been posted on the Sage in the Classroom page. The GIFs can be used to help bring to life the concept that the tangent line of a continuous function can be approximated by secant lines. The GIF above illustrates that from the right, the tangent looks like it is the horizontal line y=0.  I've actually created a second set of GIFs where xmin=-.2 and xmax=.2 to show the effect of zooming in. I think that will be useful for the class but I'm not posting it as the GIFs take up a lot of space and are essentially the same code.

And that code is remarkably simple: just 4 lines.

c = var('c')
p1 = plot(x^2,(x,-2,2))
a = animate([p1+point((c,c^2),rgbcolor='black',size=20)+plot(c*x,(x,-2,2),rgbcolor=(1,1/4,1/2)) for c in srange(1,0,-.05)],xmin=-2, xmax=2, ymin=-1,ymax=4)
a.show(delay=100)

The first line defines the variable c which is used to generate the moving point. The second line draws the function and axes. The 3rd line is where all the magic happens; animate consists of 3 objects being plotted: the function x^2, the point on the function which will move from frame to frame, and the secant line from (0,0) to that point (c, c^2). The options for each (eg point size and color) are set and the part for c in srange(1,0,-.05) tell us that 20 frames will be created since c is taking on the values from 1 to 0 (but not including 0) where c is decreased by .05. More frames will mean smoother movement but this will, not surprisingly, increase the amount of time to create the GIF

The 4th and final line shows the GIF and places a delay of 1 second between each frame (so 50 = .5 seconds).

Here are some things that caught my eye recently:

1. Komodo and Stockfish have made it to the final for TCEC. They had an equal score against one another in the earlier qualifying round. Stockfish has been the first to draw blood on Game 7. But you can see a potential issue:

SKgm7aNote the difference in time used. In this game, as well as a game that Stockfish lost in the qualifying round, time management has been best handled by Komodo. In the qualifying round Stockfish had a roughly equal position and collapsed when it was left to play moves using the 30 second increment. It will be interesting to see if this turns out to be a factor in the finals.

2. The 6th London Chess Classic is over and Anand had a little help en route to a tiebreak win over Kramnik. Chessbase has a report here.

3. Remember the student who made $300,000 trading penny stocks during class? Not to be outdone a student in NY claimed to have made $78 million. That might seem preposterous to you and I but the media took it and ran. ZeroHedge showed the hearty skepticism that was lacking from mainstream news. And sure enough, the story broke down. ZeroHedge with the follow up story here. From the article, "The story is already coming unglued as the commenters on New York’s site hammer the reporter for even thinking this was possible. New York has now altered its headline to back away from the $72 million figure but the story itself remains. Even if this working-class kid had somehow started with $100,000 as a high school freshman on day one at Stuy High, he’d have needed to average a compounded annualized return of something like 796% over the three years since. C’mon, man."

Plotting the floor function: exclude, point, and circle

Here's the output if you try to use Sage to plot the floor function with the command

plot(floor(x), (x, -2.5, 2.5),color='red', thickness=2)

SageFloorThere's no asymptote here but the problem of the connecting one point to the next for a discontinuous graph results in a plot which is no longer a function. To get rid of this there is a plot option called exclude. Since we know the problem points are the integers between -2.5 to 2.5 we make sure that Sage knows there is a gap there.

plot(floor(x), (x, -2.5, 2.5), exclude = [-2..2],color='red', thickness=2)

In this case Sage throws out -2, -1, 0, 1, 2 and the graph is more like we'd expect.

SageFloor2The documentation on exclude can be found on this page of the Sagemath site. Now we're missing the detail as to what happens on the ends of each piece.

P=plot(floor(x), (x, -2.5, 2.5), exclude = [-2..2],color='red', thickness=2)
H = point([(t, t) for t in range(-2, 3)], color='red',size=20)
P += H
P.show()

SageFloor3To get the open circles at the end we need the circles command.

P=plot(floor(x), (x, -2.5, 2.5), exclude = [-2..2],color='red', thickness=2)
H = point([(t, t) for t in range(-2, 3)], color='red',size=20)
P += H
disk((1,0), .2, (0,2*pi), color='red', fill=False, thickness=2)
for i in range(-2,3):
P+=circle((i,i-1),.02,facecolor='white',edgecolor='red',thickness=1,fill=True)
P.show()

SageFloor4I've added this useful information to the Sage Essentials page.

Here are some events that caught my eye recently:

1. The TCEC Stage 7 matches are still close. Here are the current standings

TCES7s4Stockfish has rallied and is now in clear 2nd place. Note that Stockfish hasn't lost a game to Komodo and has a winning record versus every computer challenger. Since the championship will be decided by a match between the top two computers, it's chances to retain its title are still intact. The games are live here.

2. There was a school shooting in Portland on Friday. Police have captured a suspect. Here's the local TV broadcast.

3. Does math make you happy? If so, you might like Happy Face Math.

4. Meanwhile, some of the worlds best human chess players battle in London. The games are live on Chess24.com.

SageTeX: Product Rule 1

ProductRule1The latest addition is a Product Rule problem not requiring the Chain Rule; it's posted on the Sagetex: Derivatives page.

Here are some issues that caught my eye.

  • It's here! Common Core testing begins in some states. From the article,"Across the country, 30,000 middle and high school students will be taking these math and English-language arts tests, and “millions more students in grades 3-11 will take such tests later in the winter and next spring,” according to an article on EducationWeek.org."
  • U.S. News.com reports on a new study which seems to suggest that students should discover their own math lessons. From the article, "The conclusion of this small and imperfect study was that the more a teacher used student-centered approaches, the more his or her students learned, and the better they did on an exam of complex problem-solving that resembles the PISA international test for 15-year-olds, on which the United States has historically done poorly.".
  • TCEC Season 7, a chess tournament for computers, continues live here. The top two computers will play in a match for the championship. Komodo has taken the lead and refuses to let go. But second place is definitely more interesting. Last year's champion Stockfish is the only computer, at this point, to have a plus score against Komodo. But Stockfish is in danger of not making second because it has lost numerous games to Gull. Some hard fought high level chess is going on.
  • Bobby Jindal claims that Common Core violates the 10th Ammendment. See the video here.

 

Teaching Point: motivating digraphs

RPSLSIf you have accelerated math students then I'm a firm supporter of supplementing their curriculum with discrete mathematics. Discrete mathematics deserves a prominent place in high school mathematics:

  • it's relevant to computer science
  • some topics (e.g . combinatorics, graph theory) don't require a strong mathematical foundation to appreciate
  • it can be more interesting than other math topics (such as in The Prediction)

Depending on the curriculum you teach, graphs can be incorporated into the topics. In combinatorics you can ask questions about graphs (what's the maximum number of edges a graph can have) and in matrices you can look at the adjacency matrix of a graph and see what happens when you raise it to a power. Or how about  exploring stochastic matrices? Unfortunately, the role of discrete mathematics in the high school curriculum is limited to a small dose of combinatorics and probability and a bigger dose of matrices.

I think "The Prediction" is a great way to motivate graph theory. I think a great way to motivate digraphs is with The Big Bang Theory's explanation of "Rock, Paper, Scissors, Lizard, Spock". I've put together the digraph to represent the game; it's posted on the Graphics page (PDF and tex file). So imagine playing the video for the class and asking them to explain the rules. If they haven't seen it they're going to have trouble remembering all the possible scenarios. Eventually you can put the teaching point, "Digraphs help us see the relationship between things." on the board along with the digraph above. This has been added to the Teaching Points page.

Here are some things that caught my eye recently:

Sage animated gif: unit circle (radians)

SinRadIn an earlier post, I created an animated GIF using Sage to illustrate how the sine function came from movement of a particle around the unit circle. At the time I mention "A radians version would be more useful to me; perhaps when I have more time.". I've finally put together a radians version--you can see the screenshot above. The animated gif can be downloaded on the Sage output page. Like the degree version, it's built on the code given here.

Here are some stories that have caught my eye:

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.

\begin{sagesilent}
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}"
\end{sagesilent}

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.

Current Events: November 17, 2014

A quick post as there has been a lot happening recently:

  • The World Chess Championship has 6 games completed. Magnus has the lead with 2 wins to 1. Game 6 featured a simple blunder by Carlsen and Anand misses the simple reply only to have his position collapse a little bit later. Chess.com has  coverage here. Fellow GMs were left scratching their heads at Anand's inability to find the winner. Kramnik had the harsh quote, “I didn't have many opportunities to win [a world championship game] in one move, but I when I did I wasn't missing them.”. On one level that's right: you can't give away free points. On another level, he's watching the match because his poor play couldn't win the qualifying tournament.
  • In "Big Numbers: Google Challenges Wolfram to Open Up Math", we learn "....Google throws down a gauntlet against claims of ownership of mathematical truths by the likes of Wolfram:

    Modern mathematics research is distinguished by its openness. The notion of “mathematical truth” depends on theorems being published with proof, letting the reader understand how new results build on the old, all the way down to basic mathematical axioms and definitions. These new results become tools to aid further progress.

    ".  The article praises Sage and Sagemath Cloud and points out that for Mathematica "the information generated by its software is novel, the results of its calculations may be subject to copyright by Wolfram." Exactly right. How'd you like to do some great research and find it was now Wolfram's? Moreover, Mathematica is a "black box" and like all software would be subject to bugs. For all you know, it might be giving you wrong output. Remember the Pentium FDIV bug?? Intel knew of the flaw and said, essentially, it was no big deal. With Sage, mistakes can be found and fixed and you can check for bugs. With Mathematica you can never really be sure.

  • Terry Tao is one of the most famous mathematicians alive. He made an appearance recently on The Colbert Report. Learn about "sexy primes" and maybe have a laugh or two.
  • E-books directory posted a nice Calculus and Analytic Geometry book. There are some problems with references and you'll see some ?? as if they forgot to LaTeX twice for the references but the book is worth downloading.
  • A school teacher in Texas was fired over some bad tweets. USA Today has the details and the local TV coverage here.
  • A shooting "drill" in Florida put a school on lock down and had police officers bursting into classrooms with guns drawn and scaring a lot of kids. They promptly texted there parents to spread the fear around. "The school sent an email out after the exercise, called a "lockdown active shooter drill," to let parents know it had taken place." but defended their decision to tell them after and not before in order for the response to be more realistic. "...some parents feel it was extreme for police to have their guns drawn.". The local TV station has an account here.

 

 

 

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"& "
else:
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.