{ "cells": [ { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "%html\n", "
To create a vector in Sage, use the vector command.
\n", "Exercise: Create the vector $x = (1, 2, \\ldots, 100)$.
" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "%html\n", "\n", "
Note: vectors in Sage are row vectors! | \n", "
Exercise: Create the vector $y = (1^2, 2^2, \\ldots, 100^2)$.
" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "%html\n", "Exercise: Type x. and hit tab to see the available methods for vectors. Find the norm (length) of the vectors x and y.
" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "%html\n", "Exercise: Find the dot product of x and y.
" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "%html\n", "[The above problems are essentially the first problem on Exercise Set 1 of William Stein's Math 480b.]
\n", "Exercise: Use the matrix command to create the following matrix over the rational numbers (hint: in Sage, QQ denotes the field of rational numbers).
\n", "$$\\left(\\begin{array}{rrrrrr}
3 & 2 & 2 & 1 & 1 & 0 \\\\
2 & 3 & 1 & 0 & 2 & 1 \\\\
2 & 1 & 3 & 2 & 0 & 1 \\\\
1 & 0 & 2 & 3 & 1 & 2 \\\\
1 & 2 & 0 & 1 & 3 & 2 \\\\
0 & 1 & 1 & 2 & 2 & 3
\\end{array}\\right)$$
Exercise: For what values of $k$ is the determinant of the following matrix $0$?
\n", "$$\\left(\\begin{array}{rrr}
1 & 1 & -1 \\\\
2 & 3 & k \\\\
1 & k & 3
\\end{array}\\right)$$
[K. R. Matthews, Elementary Linear Algebra, Chapter 4, Problem 8]
" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "%html\n", "Exercise: Prove that the determinant of the following matrix is $-8$.
\n", "$$\\left(\\begin{array}{rrr}
{n}^{2} & {\\left( n + 1 \\right)}^{2} & {\\left( n + 2
\\right)}^{2} \\\\
{\\left( n + 1 \\right)}^{2} & {\\left( n + 2 \\right)}^{2} &
{\\left( n + 3 \\right)}^{2} \\\\
{\\left( n + 2 \\right)}^{2} & {\\left( n + 3 \\right)}^{2} & {\\left( n + 4 \\right)}^{2}\\end{array}\\right)$$
[K. R. Matthews, Elementary Linear Algebra, Chapter 4, Problem 3]
" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "%html\n", "Exercise: Prove that if $a \\neq c$, then the line through the points $(a,b)$ and $(c,d)$ is given by the following equation.
$$\\det\\left(\\begin{array}{rrr}
x & y & 1 \\\\
a & b & 1 \\\\
c & d & 1
\\end{array}\\right) = 0.$$
Exercise: Find the determinant of the following matrices.
\n", "$$\\left(\\begin{array}{r}Make a conjecture about the determinant of an arbitrary matrix in this sequence. Can you prove it your conjecture?
\n", "[Adapted from: K. R. Matthews, Elementary Linear Algebra, Chapter 4, Problem 19]
" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "%html\n", "Exercise: What is the largest determinant possible for a $3\\times3$ matrix whose entries are $1, 2, \\dots, 9$ (each occurring exactly once, in any order). How many matrices $M$ achieve this maximum?
\n", "(Hint: You might find the command Permutations useful. The following code will construct all the lists that have the entries $1, 2, 3, 4$, each appearing exactly once.)
\n", "for P in Permutations(4):" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "for P in Permutations(4):\n", " L = list(P)\n", " print L" ] } ], "metadata": { "kernelspec": { "display_name": "SageMath (stable)", "language": "sagemath", "metadata": { "cocalc": { "description": "Open-source mathematical software system", "priority": 10, "url": "https://www.sagemath.org/" } }, "name": "sagemath" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.15" } }, "nbformat": 4, "nbformat_minor": 0 }
L = list(P)
print L