{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "using SymPy" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "E (generic function with 2 methods)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Create an n x n (default 3), i,j elimination matrix\n", "function E(i,j,n=3)\n", " E = sympy\"eye\"(n) # start with the identity\n", " E[i,j] = - symbols(\"m$i$j\") # insert the negative multiplier\n", " E\n", "end" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{bmatrix}A_{11}&A_{12}&A_{13}\\\\A_{21}&A_{22}&A_{23}\\\\A_{31}&A_{32}&A_{33}\\end{bmatrix}" ], "text/plain": [ "3×3 Array{SymPy.Sym,2}:\n", " A11 A12 A13\n", " A21 A22 A23\n", " A31 A32 A33" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Create a symbolic 3x3 A matrix\n", " A = [symbols(\"A$i$j\") for i=1:3, j=1:3]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{bmatrix}1&0&0\\\\- m_{21}&1&0\\\\0&0&1\\end{bmatrix}" ], "text/plain": [ "3×3 Array{SymPy.Sym,2}:\n", " 1 0 0\n", " -m21 1 0\n", " 0 0 1" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "E(2,1) " ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "