SageTeX: Log Tables

Today's post is using SageTeX to produce log tables. It's very similar to the trig table post I did earlier but a little bit harder. The main problem is that the output for the log tables is 2 pages, and this creates a problem with $latex \LaTeX$. I used the supertabular package to get the code to run properly. The second, albeit minor, issue of complexity was that creating the table required 2 loops. One loop handles the values of N running down the lefthand column and the other loop counts off the each element of the row. As a result, more steps are needed to create each row than in the trig table example.

Here's the first page of output from the 2 page table:

One important point to mention with SageTex is the spacing in each for loop; I had to indent 4 spaces for each loop. Tabbing 4 spaces resulted in errors because the resulting .sage file doesn't get indented properly.

I've posted the .tex files and the PDF output for both natural logs and common logs on the Handouts page.

A train wreck in slow motion

If you teach in a U.S. public school then you know that, even at good schools, many students have a poor background in math. Teachers have to pass students even though they haven't mastered the basics and then these students go on to struggle in future classes because they haven't learned the basics. Is it any wonder so many students hate math when it frustrates them on a daily basis?

I've been alarmed, for example, at how many students I have who can't do long division, factor (numbers or polynomials), FOIL, and even have trouble adding and multiplying [especially when you include positive and negative numbers such as (-5.3)(7.7)]. Their problems make my job much more difficult. I don't have time to go back and properly fix these problems if I'm to cover the curriculum for the standardized testing of my course (which is how administration determines if I've done my job). That means I'll have to pass most of my failing students because it's a numbers problem: if a handful of students are poor then they have a problem. When most of the class is poor then the teacher has a problem: if you give lots of bad grades then parents complain and then administration will act to put the teacher in line. Other teachers aren't failing so many students, why are you? You're having a lot more parent and student complaints; why is that happening? The spotlight will come back to you with the purpose of answering one question: what are you doing wrong? Passing most of the students along to the next class means happy parents and happy administration. The headaches will come later, when students are unable to pass a proficiency exam to get a full high school diploma but the school has avoided years of numerous parent complaints by making sure all but the worst pass their math class. At that point you've got students who've passed every math class and can't  do math but now it's someone else's problem.

Students who are deficient in math yet need to be passed from course to course so they can graduate present a problem for many schools, so I found this recent article interesting: Illinois lawmakers, "have approved a proposal that would increase the number of courses counting as a high school math requirement. High school students could count vocational courses, such as drafting or wood shop, as math credits under Senate Bill 3244...".

The article makes 2 obvious points: " 'Math is not just a college need. Math is required for manufacturing careers, agriculture careers,...' " and,  " 'It came up at every single community college — that far too many students are not ready for college-level math,...' ". So how does the Illinois plan address the poor performance in math? Let's think for a minute! By making other classes eligible to receive math credits:

  1. A student has to take less math then before
  2. The level of mathematical difficulty/rigor covered in the "math" courses will drop
  3. Students can receive passing scores in these "math" classes by doing well on the non-math component of the course (e.g. a pretty wood shop project rather than math proficiency)
These points seem inconsistent with raising the math proficiency bar. What are they thinking? Read further, "The curriculum allows teachers and school administrators to decide what to teach and how to teach it. School districts have the option of using all or portions of the new curriculum.". Welcome to public school educational policy! More flexibility to sweep problems under the rug. They'll have several years to implement and evaluate the plan at which point, when it becomes clear students aren't succeeding, someone will design a new plan which will require several more years to implement and evaluate. Besides, the current people pushing this solution might have retired by that time, making it someone else's problem...to pass on to the next person. This proposed Illinois legislation is like watching a train wreck in slow motion. It's almost 30 years since 'Nation at Risk' was published and the performance of public education hasn't changed all that much.

 

An Important Limit

The limit $latex \lim_{x \to 0}\frac{\sin(x)}{x}=1$ is a fundamental result result in Calculus. The result follows from L'Hospital's rule but since that isn't typically covered in a first high school Calculus class it's nice to know you can lead your class to the result with a (relatively) simple mathematical argument. Leading your class through the argument is a pretty good exercise because it forces your class to recall important information about similar triangles and sectors of circles and apply it to a solving a different problem.

You can find all the details here: ImpLimit (PDF)

The figures are posted on the Graphics page. All of the files can be found on the Handouts page.

MetaPost function grapher

I've never understood why MetaPost isn't more popular; it does a great job on just about everything a typical user would ever draw. Donald Knuth, the inventor of $latex \TeX$ and author of The Art of Computer Programming relies on it for mathematical diagrams. A thumbs up from Knuth tells you MetaPost is a quality program.

MetaPost is bundled in with a typical tex installation so if you have $latex \LaTeX$ installed on your computer it shouldn't be difficult to try it out. I dabbled with MetaPost for just a little while, but I eventually moved on for 3 main reasons: there wasn't a lot of activity  in the project [try finding material after 2008], there didn't seem to be a lot of people who used it (unlike tikz), and I kept reading about Asymptote as being the continuation of MetaPost: more current, better with 3D graphics, and so on.

But recently I came across the function grapher, and was impressed by the 3D plotting of multiple functions:

Those 3D graphics look as good as anything I've ever seen, and the interface allows you to create the graphs without having to learn any MetaPost.  You can even  click on tabs on the sides of the image to rotate it (arrows will pop up when you mouse over the edges) until you've got the view you want. When you're ready you can choose the type of download (PDF and .svg and several others). Putting it into a $latex \LaTeX$ document is simple.

Regardless of whether you want to learn MetaPost, the function grapher is a convenient tool for creating 2D and 3D graphs you can use. I've added it to the collection of links on the sidebar.

Inkscape: Open Clip Art Library

As a teacher it's virtually guaranteed you'll want to put pictures into your $latex \LaTeX$ document. Creating pictures using tikz and PSTricks packages can take a lot of time though, so it's nice to know that there 's a quick way to get some simple graphics you can use: the Open Clip Art Library has public domain images that "...may be used in any project for free and with no restrictions.". That's good news for any teacher, regardless of the subject you teach. Although the site allows you to download the images as .png files, that format isn't ideal because increasing the size of the image can result in a blurry, pixelated image.  To avoid that, a vector graphics image is what you want; the extension is .svg. Luckily, the vector graphics editor Inkscape lets you search the Open Clip Art Library for images and export them to .svg, as well as pdf, .eps, and many other formats where the image quality is sharper after you increase the image size. You can even export the picture into tikz code provided that you've downloaded these files and followed the installation instructions.

Open up Inkscape, go to the "File" tab and select "Import from Open Clip Art Library".

You'll be presented with a search box to help you find what you want. I searched for "Thumb" because I wanted to look for a "thumbs up" graphic that I could add to my $latex \LaTeX$ document. After choosing the graphic I wanted and resizing it to fit onto the page it's time to save a copy. Go to "File" and "Save as..." and pick your extension. Saving to PDF is good enough for most, but if you've downloaded the Inkscape2tikz exporter I linked to (above) you'll have the option to convert the graphics to tikz code (which would give you more control if you plan to edit the image). Choose the "stand alone" option and Inkscape will create a .tex file that should compile successfully on your system.

As the link indicated, Inkscape2tikz is  a work in progress so it doesn't always work correctly. In this case, the resulting tex file Thumbs turned out perfectly.

The Open Clip Art Library is a useful resource for teachers which, combined with the power of Inkscape, gives you the power to create vector graphic images that can be easily resized for inclusion into your $latex \LaTeX$ document.

Thales' Theorem (1)

There are certain results that deserve to be covered during the course of a high school math class, even if they don’t appear in the book you're using. If you're teaching Geometry then Thales’ Theorem is a good example:

Thales’ Theorem: If A, B, and C are points on a circle and AB is a diameter of the circle
then ∠ ACB is a right angle.

The theorem is useful in a geometry class because it has many proofs that can be understood by the average high school student. Proofs should be a part of any decent math math class and the multiple proofs of Thales' Theorem gives you a lot of flexibility in deciding on when you want to introduce the result. It also gives you the choice of proving the theorem multiple times during the semester which will reinforce the result. Moreover, the theorem itself provides a way to motivate one of your lessons. So, for example, you might start by drawing a circle on the board and a triangle ABC such that AB is on a diameter of the circle. Draw several such triangles in the circle and tell them that it seems like all the triangles are right triangles; how might someone prove that these triangles are always a right triangle? That's going to be beyond them, but it gives you a hook: tell them that by the end of class they’ll be able to prove, no matter which point C they choose, that the triangle is a right triangle. Go through your lesson and end by proving Thales’ Theorem with the information you learned during the lesson.

Here's one such proof; it's the same one given on the Wikipedia link above.

ThalesTheorem1 (.tex)   ThalesTheorem1 (PDF)

I've posted these on the Handouts page. The 2 pictures along with the tex code have been posted on the Graphics page.

 

Chess: Opening Principles

Endgame knowledge is essential and mastering the basics such as queen and king versus king are essential for anybody trying to get better. But it's important to play, too. Today's post is on opening principles. If you follow the principles I've outlined, you shouldn't have any problem getting out of the opening. After that you're on your own!

The post on opening principles (both PDF output and tex source) can be found on the Chess page.

Sage: Text fields

If you want other people to look at your Sage notebooks then there'll be times when you want to put in some instructions/explanations so others can understand what you're doing. Sage gives you 2 ways to include text. The first option is to use a Sage cell (field), type %latex on the first line and then include the rest of your text. The second option is to create a text field and put your text in there.

Now I love  $latex \LaTeX$, but there are plenty of times when you'll find that creating a text field helps your notebook look even better. To create a text cell, move your mouse above a Sage cell until a purple line appears--like the one shown below:

While you've got that purple line, press Shift and (while holding it down) left click your mouse. That will create a text field like the one immediately above it. (Note: you can click on the image above to get a larger view). The text field gives you a lot of options: changing the font, highlighting, inserting images, inserting hyperlinks, and so on. When you finish typing in your text, click the "Save Changes" button.

Compare that with the Sage cell above that: you'll see I started the line with %latex, typed in some text, and then got $latex \LaTeX$ output. Here's a better picture:

The $latex \LaTeX$ output is followed by the text field output. You can see the text field gives you more choices in working with text. Being able to insert images and clickable hyperlinks (in purple) is convenient.

One final point worth mentioning: there's a drawback to using $latex \LaTeX$ in Sage that isn't so apparent. If you print your notebook as a PDF, the $latex \LaTeX$ output is likely to get cut off unless you keep it really short. Here's the PDF output from the notebook: TextFields. See that annoying scrollbar? Although the notebook looked fine, the PDF output doesn't. Text fields don't have these problems.

Text fields are a convenient way to annotate your Sage notebooks and make them look presentable. As much as I love $latex \LaTeX$, you're better off using text fields in a Sage notebook. I've posted the PDF output from TextFields on the Python/Sage page as well, so it can always be found easily.

Problems: Something "practical"?

I've already mentioned the well known result that if an altitude is dropped from the right angle of a right triangle then the 3 resulting triangles are all similar. There are 2 animated GIFs that were posted recently to illustrate the similarity of the triangles. In order to create the GIFs I needed to create a right triangle, so I picked the right triangle with sides of length 3, 4, and 5.

It's easy enough to draw a horizontal line of length 5 (the hypotenuse) in Sage but after that we need to know the point C and the point where the altitude intersected the hypotenuse. Knowing the intersection point of the altitude and hypotenuse is necessary to create an altitude that's perpendicular. It also allows us to define the point as the origin of the Cartesian plane which would simplify the rotational equations needed in programming the animated GIF. That's the motivation behind this "practical" problem. Dropping an altitude from the right angle of a triangle with sides of lengths 3, 4, and 5 breaks the hypotenuse into 2 pieces. Find the length of each piece of each piece as well as the height.

I used 2 variables to set up 2 equations (using the Pythagorean Theorem -- there are lots of right triangles). But don't give your class any hints unless they really need it. The problem is posted on the Problems page along with the $latex \LaTeX$ code and output. You can, of course, create other versions of this problem by starting with a different right triangle.

Google 3D Graphing

I'll bet most of you know that you can use the Google search box as a calculator; it's been that way for years. Type in something like: 5*(6^2-4)-7/2 and Google will calculate the answer of 156.5 and give you a link to the many different things you can put into the search box: weather in a city, stock quotes, movie showtimes, currency quotes, tracking packages, and so much more. Recently, Google has made it possible for you to graph a 2d function; try typing: f(x) = ln(x^2)  into the search box and press enter. You'll get a 2d graph that you can zoom in or zoom out of. Nice, but nothing that special.

Very recently, however, Google has made it possible to graph function of x and y. Here's what you get if you graph sin(x)*cos(y):

I've had trouble graphing multivariable functions on my Linux box, though. I get a message like this:

3D charts require a web browser and system that supportWebGL.

If you don't have any issues with WebGL, try graphing some of the examples hereThere are a lot of fancy demonstrations of the power of WebGL here If you aren't able to get it working then here's a nice video on what you're missing. An excellent job by Google!