# Odds and Ends: September 30, 2013

Some odds and ends:

• The WebEquations link no longer works and was removed. The WriteLaTex link was moved as Sagemath Cloud, with support for Sage, is now the only tool you need.
• A helpful reader found some mistakes in the Trig formulas PDF posted on the Handouts page. The PDF and LaTeX code were fixed and I've updated those files.
• I've run across a nice post at Un peu de math which has a lot of interesting links to explore: a wiki with "...a gallery of all images — illustrations, diagrams and animations"  created by LucasVB. I've already downloaded 2 animated gifs on radians that will be useful when I get to trig and one on the transpose of a matrix. A nice article on the use of computers in mathematical proofs from Quanta Magazine. Another link about computers in math and the  "curse of computing". Of course the Sage Interacts on graph theory were nice, too.

An important point worth emphasizing from the above articles. Sage, being open source, can be checked for the accuracy of the code. Closed source mathematical programs are "black box"; the underlying code might be (and sometimes is) wrong, but how do you know until you spot the error.

Trusting closed source math programs violates the very spirit of math and science.

# Sagetex: polynomials

I've added a page for using sagetex to create problems (and their solution) regarding the division of 2 polynomials. Click on Sagetex: Polynomials here or on the sidebar.

You can see the code and output running in Sagemath Cloud. The approach may seem a little odd, but in order to get better control over the problem (degree of the polynomial, remainder, divisor, etc.) the quotient, divisor and remainder polynomials are created first (randomly). Using the Division Algorithm the polynomial to go with that problem is created. The code is available available on the Sagetex: Polynomials page and can be easily inserted into your tests.

# Sage Essentials: set_verbose command

If you use Sage for graphing you've almost certainly encountered some not so welcome warnings when you plot:

Notice also that Sage didn't plot from -1 to 4 like you asked. To turn of the warnings, you can use the set_verbose command. To fix the values of x that it is plotted over, store the plot in a variable and specify the xmin and xmax with show. Here's the code:

set_verbose(-1)
p=plot(sqrt(x),(x,-1,4))
p.show(xmin=-1)

Which results in this output:

The warnings are off and the plotting parameters are as you specified. To turn the warnings back on, use set_verbose(0). I've added this information to the Sage Essentials page.

# SageTex Problems: Lines

I've added another SageTex problem on lines to the SageTex problems page devoted to lines. You can see it running in Sagemath Cloud. The problem involves creating 2 lines, each defined by 2 points and we want to determine whether the lines are parallel, perpendicular, or neither. Randomly choosing points to will mostly result in lines which are neither parallel nor perpendicular. We also have to worry about the same point being chosen as well as vertical lines (which have an undefined slope). The code was built to deal with those problems.

This part of the code (indentation doesn't show properly)
while x1 == x2:
x2 = randint(-9,9) #avoid vertical line

avoids vertical lines but does allow for horizontal lines. To make sure the 3 choices of parallel, perpendicular, or neither are seen frequently, that gets decided first. The slope of the first line is calculated (it will be defined since it isn't vertical) and then the third point is created which is just a shift of the first point.
Choice = ["parallel", "perpendicular", "neither"]
i = Integer(randint(0,2))

slope1 = (y2-y1)/(x2-x1)
shiftx = Integer(randint(1,9))
shifty = Integer(randint(1,9))
x3 = x1 - shiftx
y3 = y1 - shifty

Now that the 3rd point is created, the 4th point is plotted based on whether the lines are parallel, perpendicular, or neither. If they're parallel, then the 4th point shifts the second point equally:

if i==0:
x4 = x2 - shiftx
y4 = y2 - shifty

If they're perpendicular, then the 4th point is determined by the slope of the first line. Since the slope of perpendicular lines are negative reciprocals, we just reverse the rise over run (and adjust for the negative sign)

elif i==1:
x4 = x3-(y2-y1)
y4 = y3+(x2-x1)

If neither, just add in an extra (random) shift

x4 = x3+(x2-x1)+Integer(randint(1,9))
y4 = y3+(y2-y1)

Since we know the result (parallel,perpendicular, or neither) we can just print it out in our solution.

if i == 0:
output=" the lines are parallel."
elif i == 1:
output=" the lines are perpendicular."
else:
output=" the lines are neither parallel nor perpendicular."

# Sagemath Cloud

Sagemath Cloud is the latest and greatest contribution to the world of \$latex \LaTeX\$ and Sage. It was announced to the world by the Sage sage himself, Dr. William Stein, on the Planet Sage blog on August 28. As he indicates, Sagemath Cloud has some advantages and disadvantages over Share LaTeX and WriteLaTeX:  Although you need to sign up for a free account, the main benefit (from my perspective) is that Sagetex is fully supported.You can see the output in the screenshot above. Sagemath Cloud has forward and inverse search capability, gives you a terminal to run "arbitrary purpose programs", and even the ability to work collaboratively on \$latex \LaTeX\$ documents. See his post for a longer list with a more detailed explanation. The main disadvantages:

• not much has been done to properly deal with multi-file LaTeX documents

Of course, I would expect Sagemath Cloud to make improvements over time. There are some directions for navigating Sagemath Cloud posted here. After creating the account (tied to your e-mail address) and logging in you can click on your e-mail and set some of your  preferences. Pressing the project button (upper left hand side) will let you create a project; you'll need to pick whether you want it public or private:

Once you've created your project, click on it. Now you need to fill it with your documents. I created a new \$latex \LaTeX\$ document by clicking on +New :

The orange button is set for Folder, so after typing Sagemath Cloud I had to press the \$latex x^2\$ \$latex \LaTeX\$ in order to create a \$latex \LaTeX\$ document.

After that you're ready to go. Type your document and after pressing Save you'll get a preview of the output. Sagemath Cloud, like Sage Cell Server, is another winner! I've added a link to the Sagemath Cloud site; it's on the sidebar under the LaTeX links

# Odds and Ends: Sept 2, 2013

I've posted another problem on the Lines page of SageTex problems.

Later on today is the final game of the World Cup Final in chess. Dmitri Andreikin is white against Kramnik, who is one game up. It's a must win situation for Andreikin and he's going to need something special to beat Kramnik. You can follow the game as it unfolds on ChessBomb.

There's an interesting chess/logic puzzle here. Looking at the site, which features "Quant, Math, and Computer Science Puzzles for Interview Preparation and Brain Teasing", you can certainly find some problems that can be used in the classroom.