Showing posts with label sagemath. Show all posts
Showing posts with label sagemath. Show all posts

Monday, 21 September 2015

Unit Circle

Recently I was asked to include a copy of the Trigonometry Unit Circle in a Year 10 Extension Maths exam. When I went looking for a good one on the Internet, I found plenty of Unit circles that were good for concept teaching, but weren't very detailed. Some had no angle labels at all.

We also had one that had been hand drawn and scanned, but it wasn't very accurate or neat. That unfortunately was the one I used, as the exam timetable was approaching fast.

So once I had some free time, I scratched one together using SageMath.

Saturday, 18 May 2013

RSA Two-Key Encryption

So everything in the last seven posts has lead up to this.
The RSA Encryption Algorithm is a mathematical method of generating two encryption keys. You then encrypt a message with one key, and decrypt it using the other key.
This allows you to keep one key private, and publish the other key to the entire world.

Then there are two ways you can use these keys:
  1. You look up the public key of your friend, and encrypt a message using their public key. You have guaranteed that no-one can read the message except your friend.
  2. You encrypt a message using your private key. Everyone can read it, but no-one else but you could have sent it.
So the same technology can be used to keep secrets, and prove identity. Cool.

Sunday, 13 January 2013

Why Linear Differential Equations are First Order

First, a note on format. Dn(y)x is the n-th differential of y with respect to x. 
I've used this format to keep it somewhat close to the format used by sagemath. However, I have broken down here and there and used y` to represent the first differential of y w.r.t. x.

It's a well-known fact that linear differential equations of the form:
Dn(y)x+ ... + a D(y)x + by =f(x)
are particularly easy to solve.

Since:
Dn(y+z)x = Dn(y)x + Dn(z)x 
it is easy to split the problem into several subproblems and add them all at the end.

But matrices allow us to rearrange linear differential equations of any order into a simple first order differential equation of the form:
D(y)x = ky

Cayley-Hamilton Theorem

My final post (so far) on matrix conjugation is the most useful of matrix theories and one of my personal favourites.

"In linear algebra, the Cayley–Hamilton theorem (named after the mathematicians Arthur Cayley and William Hamilton) states that every square matrix over a commutative ring (such as the real or complex field) satisfies its own characteristic equation."

This means that once you have the characteristic polynomial of a matrix M (for a 3x3 matrix in this example):
P(x) = a0 + a1x + a2x2 + x3= 0
then replacing x with M:
P(M) = a0I + a1M + a2M2 + M3= 0
will also be true.

Notice that we've replaced the constant term a0 with a0I, guaranteeing that this will give us a square matrix.

Matrix Powers - Uses of Diagonal Decomposition and Conjugation

As mentioned in a previous post, nearly any square matrix M can be decomposed into a diagonal matrix D, using the eigenmatrix V:
M = VDV-1

This process is referred to as diagonal decomposition and has some useful consequences. In this post, we'll focus on taking the matrix powers of M.

Say we want to calculate the 100th power of M:
M100

Matrix Trace, Determinants and Eigenvalues

This is the start of a quick series of posts showing some powerful properties (and proofs) of matrix eigenvalues. It is assumed that the reader can calculate eigenvectors/values.

However, the series refers to some basic algebra and matrix properties that, while used everywhere, usually don't have accessible or comprehensive  proofs available on the Internet (You can find them in good linear algebra textbooks). It is also a good place to show some neat tricks for sagemath.
There are better and more comprehensive proofs out there, but these are a good start.

We will start today with matrix traces and determinants, and their relationship to matrix eigenvalues. Basically we will be proving that for any n x n matrix, the eigenvalues add up to the sum of the diagonal elements, and multiply up to the determinant of the matrix.

Tuesday, 18 December 2012

Fractional Integrals = Blow Your Mind

The following is less of a resource for education, and more of a "cool math fact".
Let's start with the Cauchy Formula for Repeated Integration.

Given a function f, a lower value a, and a value n representing the number of integrations we want to do, we can calculate the value of f -n using a single integral of the following form:

Friday, 14 December 2012

SageMath and 3D Graphics

As mentioned in an earlier post, Sage Maths is a high-level mathematical system that combines a large variety of open-source (free) software into one powerful bundle.
In the classroom, one of the most exciting features is it's interactive 3D plots.


Network Graphic Objects in SageMath

See here for how to install SageMath:
http://australianteacher.blogspot.com.au/2012/12/installing-sage-mathematics-on-windows.html

At the end of this year, my school set our Year 10's some network theory as their last topic for assessment. I quickly needed a way to generate weighted networks for worksheets. Yes, hand-drawn would have worked, but like all things, once you put the effort into making a program, it's only a couple of edits and clicks to make multiple diagrams. Plus this way, I can also use the same SageMath worksheet to generate the answers as well.

Installing Sage Mathematics on a Windows machine

Introduction:

Sage maths is an open-source mathematics package that rivals Mathmatica in function and power.

From it's website (sagemath.org):
"Sage is built out of nearly 100 open-source packages and features a unified interface. Sage can be used to study elementary and advanced, pure and applied mathematics. This includes a huge range of mathematics, including basic algebra, calculus, elementary to very advanced number theory, cryptography, numerical computation, commutative algebra, group theory, combinatorics, graph theory, exact linear algebra and much more. It combines various software packages and seamlessly integrates their functionality into a common experience. It is well-suited for education and research."

This article describes how to install and run sage math on a Microsoft computer.



Install Emulator and Image

Sage math is built on a lot of packages, unfortunately most of which are only available on Linux. Efforts are underway to port sage math to windows, but in the meantime, you will want to run sage math inside an emulator.

  1. Download and install VirtualBox from www.virtualbox.org/wiki/Downloads
  2. Download the current sage math virtualbox image from the University of Sydney mirror. (Grab the latest file that ends with .ova).
  3. Open the VirtualBox program, and import the sage math image by clicking 'File', then 'Import Appliance'.
  4. Once VirtualBox finishes importing the image, you can start sage math by double-clicking on Sage-5.x in VirtualBox. If sage math asks for a user and a password, type admin for user and sage for password (Or depending on the release, sage and sage for both password and username).
Sage math runs a server and a Web-based graphical user interface. You can use the interface from within VirtualBox, but you can't copy-paste to other programs. The next section shows how to access the interface from your machine's normal web browser.

Resetting Local Port Address

As mentioned, sage math runs as a server that you can access by pointing your normal browser at localhost:8000 (or 127.0.0.1:8000).
However, when I first wrote this article, it was intended for fellow Education Queensland teachers who were using government-supplied laptops, which ran a piece of software called BlueCoat Proxy. This program already claimed port 8000, conflicting with Sage Math rather badly.
It is possible to reset the image's port address, this involves changing some settings in the VirtualBox software.

  1. In the running Sage-x.x window, click on the menu "Devices", then click on "Network Adaptors", then click on the button at the bottom called "Port Forwarding".
  2. There is an entry under Host Port with the number 8000. Change that to 8080. Leave the Guest Port number for that line as 8000. CLick on "OK" twice.
  3. This should take you back to the sage math image (which looks like a wall of text). In the menu "Machine", click on "ACPI Shutdown" to shut the sage math image down.

Running the Software

You will want to open your desktop browser to 127.0.0.1:8080. If it asks you to log in, you will need to use admin for the username and sage for the password. (Or sometimes sage and sage depending on who built the image).

Running from the desktop browser means that you will be able to copy equations from Sage and place them in Microsoft Office 2010+, as well as images.
It also enables you to download/upload sage files from/to the virtual server, an important feature as you upgrade the virtual image.

Sage math is now installed and correctly configured, and ready to run. A good place to start learning sage math is the tutorial available at:
http://sagemath.org/doc/tutorial/tour.html
Sage is based on a computer language called Python that is wonderfully easy to learn. Make sure to activate the "typeset" option box once you create a new page to get pretty equations.