A brief introduction to Maple for kryptographers(This Maple files shows some things I demonstrated in a lecture on 2010-11-05. It is best viewed in Maple itself, but I also make it available as a PDF file.)Notice the two buttons above, one labeled Text and the other Math. When you start with an empty document you are in math mode, and can type formulas. The buttons let you change modes by clicking. You can use Maple as a simple calculator. Just type some formula in math mode and hit return while in the math mode field. The answer appears below, centered on a separate, numbered line:LUkiKkclKnByb3RlY3RlZEc2JCIjQiIjWg==print(); # input placeholderI typed that using an asterisk * for multiplication; Maple typesets even your input to make it look better.Maple can work with big numbers too:LUkiXkclKnByb3RlY3RlZEc2JCIjQiIjWg==print(); # input placeholderAnd I typed that as 23^47. If I wanted to, I could get the cursor out from the exponent position by hitting the right arrow, so I could perform further operations on the number.Maple can also work with variables:KiQsJiIjTSIiIkkieEc2IiIjQyIiJA==print(); # input placeholderThe percent operator % names the output of the previous command. Let's expand it:LUknZXhwYW5kRyUqcHJvdGVjdGVkRzYjSSIlRzYiprint(); # input placeholderWe can assign values to variables, but then they don't work the same way anymore:PkkieEc2IiIiJA==print(); # input placeholderKiQsJiIjTSIiIkkieEc2IiIjQyIiJA==print(); # input placeholderWe can force Maple not to evaluate the variable by quoting it:KiQsJiIjTSIiIi5JInhHNiIiI0MiIiQ=print(); # input placeholderAnd here is how to evaluate it after all:LUkmdmFsdWVHNiI2I0kiJUdGJA==print(); # input placeholderAnd here is what to do if we are tired of x having a value and just want it to be a boring old name again:LUkpdW5hc3NpZ25HNiQlKnByb3RlY3RlZEdJKF9zeXNsaWJHNiI2Iy5JInhHRic=JSFHKiQsJiIjTSIiIkkieEc2IiIjQyIiJA==print(); # input placeholderHelpIf you wish information on a Maple builtin function or operator, you can just evaluated its name with a question mark in front of it:LUklaGVscEc2IjYjUSRmb3JGJA==Evaluating the above takes you to the help page for the builtin for loop (and here, for is a hyperlink to the same help page).Modular arithmeticMaple does modular arithmetic using the builtin mod operator (go on, click on the link):LUkkbW9kRzYiNiQtSSIqRyUqcHJvdGVjdGVkRzYkIiNVIiNCIiNaprint(); # input placeholderBut note especially the use of the inert power operator &^ (it has no help page of its own):LUkjJl5HNiI2JCIjVSIjQg==print(); # input placeholderLUkkbW9kRzYiNiQtSSMmXkdGJDYkIiNVIiNCIiNaprint(); # input placeholder(Hence 42 is a quadratic residue modulo 47.)JSFHThe inert power operator doesn't do anything, but the mod operator recognizes it and computes powers modulo the given modulus efficiently. It will recognize inverse powers too:LUkkbW9kRzYiNiQtSSMmXkdGJDYkIiNVISIiIiNaprint(); # input placeholderLUkkbW9kRzYiNiQtSSIqRyUqcHJvdGVjdGVkRzYkIiNVIiNHIiNaprint(); # input placeholderTyping hints: Input &^ by typing it as &\134^. The backslash will disappear, but its presence stops the input processor from taking the ^ characters as a command to go into exponent mode.
Surround the operators &^ and mod by spaces, or else Maple may get confused.JSFHSome quick demosSome things I did in the lecture, without comment:JSFHLUkkbW9kRzYiNiQiKk1FPCpbIiNVprint(); # input placeholderprint(); # input placeholderLUkkbW9kRzYiNiQtSSMmXkdGJDYkIiIjIktfVndHZllQb0YpZmt0KUh2TSFIdlxCIiIkLCI=print(); # input placeholderLUkkbW9kRzYiNiQiIiMiJCwiprint(); # input placeholderLUkiXkclKnByb3RlY3RlZEc2JCIiIyIrTW5HSTc=print(); # input placeholderLUklaWdjZEclKnByb3RlY3RlZEc2JCIjVSIkIz4=print(); # input placeholderLUknaWdjZGV4RzYiNiYiI0MiJCwiLkkieEdGJC5JInlHRiQ=print(); # input placeholderSSJ4RzYiprint(); # input placeholderSSJ5RzYiprint(); # input placeholderLCZJInhHNiIiI0NJInlHRiQiJCwiprint(); # input placeholderLUkkbW9kRzYiNiQtSSMmXkdGJDYkIiNDISIiIiQsIg==print(); # input placeholderPkkibkc2IiI1dCo+JylwPClcajwpKg==print(); # input placeholderLUkkbW9kRzYiNiQtSSMmXkdGJDYkIiImLCZJIm5HRiQiIiIhIiJGLEYrprint(); # input placeholder(Note: Without the trailing colon below, Maple would print all the values of n in the loop. Trailing colons is a great way to get rid of unwanted output.)QyQ/KDYiIiIiRiVGJC1JIj5HJSpwcm90ZWN0ZWRHNiQtSSRtb2RHRiQ2JC1JIyZeR0YkNiQiIiMsJkkibkdGJEYlISIiRiVGMkYlPkYyLCZGMkYlRjBGJUYzprint(); # input placeholderSSJuRzYiprint(); # input placeholderLCZJIm5HNiIiIiIhIiJGJQ==print(); # input placeholderLUkiKkclKnByb3RlY3RlZEc2JCwmSSJuRzYiIiIiISIiRikjRikiIiM=print(); # input placeholderLUkkbW9kRzYiNiQsJiIiIkYnLUkjJl5HRiQ2JCIiJC1JIipHJSpwcm90ZWN0ZWRHNiQsJkkibkdGJEYnISIiRicjRiciIiNGJ0Yxprint(); # input placeholderLUkkbW9kRzYiNiRJIiVHRiRJIm5HRiQ=print(); # input placeholderLUkoaXNwcmltZUc2IjYjSSJuR0Ykprint(); # input placeholderLUkoaWZhY3Rvckc2IjYkLCZJIm5HRiQiIiIhIiJGKEklZWFzeUdGJA==print(); # input placeholderJSFH