{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Eliminate from (general) A to (upper triangular) U" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Demonstrate Gaussian Elimination (page 51 of GS)\n", "\n", "(Reminder: Julia programming syntax will not be tested in this class, but that doesn't mean you can't learn from\n", "watching the code being executed)\n", "\n", "(If you are familiar with Jupyter notebooks and wish to execute yourself, you can download this notebook \n", "using the download button in the upper right, but WARNING: right click to \"download as\", or OPTION-click (MAC) or ALT-Click (Linux and Windows I think) on the download icon, or you won't get an ipynb file.) You can then drag into Jupyter." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "using Plots" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "lookat (generic function with 1 method)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# nice viz for matrices\n", "function lookat(A; redrow=0, rounding=2, showtext=true)\n", " n = size(A,1)\n", " plot(legend=false, axis=false)\n", " rowcolor = redrow > 0 ? :red : :black \n", " for i=1:n, j=1:n \n", " scatter!( [j],[i], ann= showtext ? (j,i,round(A[i,j],digits=rounding), :white ) : (j,i,\"\") ,\n", " color=abs(A[i,j]) > .0001 ? (i==redrow ? rowcolor : :black) : :white, \n", " marker=:square, markersize=30, aspectratio=1, yflip=true, yaxis=[.5,n+.5],xaxis=[.5,n+.5])\n", " end\n", " plot!()\n", "end" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4×4 Array{Float64,2}:\n", " 4.0 9.0 4.0 9.0\n", " 4.0 7.0 6.0 6.0\n", " 2.0 9.0 8.0 6.0\n", " 7.0 1.0 6.0 8.0" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A = rand(1.0:9,4,4)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4×4 Array{Float64,2}:\n", " 0.0 0.0 0.0 0.0\n", " 0.0 0.0 0.0 0.0\n", " 0.0 0.0 0.0 0.0\n", " 0.0 0.0 0.0 0.0" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L = fill(0.0,4,4)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "4.0\n", "\n", "\n", "9.0\n", "\n", "\n", "4.0\n", "\n", "\n", "9.0\n", "\n", "\n", "4.0\n", "\n", "\n", "7.0\n", "\n", "\n", "6.0\n", "\n", "\n", "6.0\n", "\n", "\n", "2.0\n", "\n", "\n", "9.0\n", "\n", "\n", "8.0\n", "\n", "\n", "6.0\n", "\n", "\n", "7.0\n", "\n", "\n", "1.0\n", "\n", "\n", "6.0\n", "\n", "\n", "8.0\n", "\n", "\n" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lookat(A)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What multiple of row 1 must we subtract from row 2 to zero out the (2,1) entry?" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.0" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L[2,1] = A[2,1] / A[1,1]" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "4.0\n", "\n", "\n", "9.0\n", "\n", "\n", "4.0\n", "\n", "\n", "9.0\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.0\n", "\n", "\n", "2.0\n", "\n", "\n", "-3.0\n", "\n", "\n", "2.0\n", "\n", "\n", "9.0\n", "\n", "\n", "8.0\n", "\n", "\n", "6.0\n", "\n", "\n", "7.0\n", "\n", "\n", "1.0\n", "\n", "\n", "6.0\n", "\n", "\n", "8.0\n", "\n", "\n" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# A[2,:] = A[2,:] - L[2,1] * A[1,:]\n", "A[2,:] -= L[2,1] * A[1,:] # subtract that multiple of the first row from the second\n", "lookat(A, redrow=2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What multiple of row 1 must we subtract from row 3 to zero out the (3,1) entry?" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.5" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L[3,1] = A[3,1] / A[1,1]" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "4.0\n", "\n", "\n", "9.0\n", "\n", "\n", "4.0\n", "\n", "\n", "9.0\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.0\n", "\n", "\n", "2.0\n", "\n", "\n", "-3.0\n", "\n", "\n", "0.0\n", "\n", "\n", "4.5\n", "\n", "\n", "6.0\n", "\n", "\n", "1.5\n", "\n", "\n", "7.0\n", "\n", "\n", "1.0\n", "\n", "\n", "6.0\n", "\n", "\n", "8.0\n", "\n", "\n" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A[3,:] -= L[3,1] * A[1,:]\n", "lookat(A, redrow=3)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "4.0\n", "\n", "\n", "9.0\n", "\n", "\n", "4.0\n", "\n", "\n", "9.0\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.0\n", "\n", "\n", "2.0\n", "\n", "\n", "-3.0\n", "\n", "\n", "0.0\n", "\n", "\n", "4.5\n", "\n", "\n", "6.0\n", "\n", "\n", "1.5\n", "\n", "\n", "0.0\n", "\n", "\n", "-14.75\n", "\n", "\n", "-1.0\n", "\n", "\n", "-7.75\n", "\n", "\n" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L[4,1] = A[4,1] / A[1,1]\n", "A[4,:] -= L[4,1] * A[1,:]\n", "lookat(A, redrow=4)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-2.25" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L[3,2] = A[3,2] / A[2,2]" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "4.0\n", "\n", "\n", "9.0\n", "\n", "\n", "4.0\n", "\n", "\n", "9.0\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.0\n", "\n", "\n", "2.0\n", "\n", "\n", "-3.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "10.5\n", "\n", "\n", "-5.25\n", "\n", "\n", "0.0\n", "\n", "\n", "-14.75\n", "\n", "\n", "-1.0\n", "\n", "\n", "-7.75\n", "\n", "\n" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A[3,:] -= L[3,2] * A[2,:]; lookat(A, redrow=3)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "4.0\n", "\n", "\n", "9.0\n", "\n", "\n", "4.0\n", "\n", "\n", "9.0\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.0\n", "\n", "\n", "2.0\n", "\n", "\n", "-3.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "10.5\n", "\n", "\n", "-5.25\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "-15.75\n", "\n", "\n", "14.38\n", "\n", "\n" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L[4,2] = A[4,2] / A[2,2]; A[4,:] -= L[4,2] * A[2,:]; lookat(A, redrow=4)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0.83\n", "\n", "\n", "-2.19\n", "\n", "\n", "-0.62\n", "\n", "\n", "0.22\n", "\n", "\n", "-0.29\n", "\n", "\n", "-1.33\n", "\n", "\n", "0.98\n", "\n", "\n", "-1.62\n", "\n", "\n", "-1.59\n", "\n", "\n", "0.32\n", "\n", "\n", "-1.21\n", "\n", "\n", "1.29\n", "\n", "\n", "-0.75\n", "\n", "\n", "0.96\n", "\n", "\n", "0.14\n", "\n", "\n", "0.8\n", "\n", "\n", "0.38\n", "\n", "\n", "-0.84\n", "\n", "\n", "-0.91\n", "\n", "\n", "0.35\n", "\n", "\n", "-0.54\n", "\n", "\n", "1.41\n", "\n", "\n", "0.33\n", "\n", "\n", "1.27\n", "\n", "\n", "-0.21\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0.83\n", "\n", "\n", "-2.19\n", "\n", "\n", "-0.62\n", "\n", "\n", "0.22\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.54\n", "\n", "\n", "-2.62\n", "\n", "\n", "-1.23\n", "\n", "\n", "-0.15\n", "\n", "\n", "-1.21\n", "\n", "\n", "1.29\n", "\n", "\n", "-0.75\n", "\n", "\n", "0.96\n", "\n", "\n", "0.14\n", "\n", "\n", "0.8\n", "\n", "\n", "0.38\n", "\n", "\n", "-0.84\n", "\n", "\n", "-0.91\n", "\n", "\n", "0.35\n", "\n", "\n", "-0.54\n", "\n", "\n", "1.41\n", "\n", "\n", "0.33\n", "\n", "\n", "1.27\n", "\n", "\n", "-0.21\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0.83\n", "\n", "\n", "-2.19\n", "\n", "\n", "-0.62\n", "\n", "\n", "0.22\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.54\n", "\n", "\n", "-2.62\n", "\n", "\n", "-1.23\n", "\n", "\n", "-0.15\n", "\n", "\n", "0.0\n", "\n", "\n", "-1.9\n", "\n", "\n", "-1.66\n", "\n", "\n", "1.28\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.8\n", "\n", "\n", "0.38\n", "\n", "\n", "-0.84\n", "\n", "\n", "-0.91\n", "\n", "\n", "0.35\n", "\n", "\n", "-0.54\n", "\n", "\n", "1.41\n", "\n", "\n", "0.33\n", "\n", "\n", "1.27\n", "\n", "\n", "-0.21\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0.83\n", "\n", "\n", "-2.19\n", "\n", "\n", "-0.62\n", "\n", "\n", "0.22\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.54\n", "\n", "\n", "-2.62\n", "\n", "\n", "-1.23\n", "\n", "\n", "-0.15\n", "\n", "\n", "0.0\n", "\n", "\n", "-1.9\n", "\n", "\n", "-1.66\n", "\n", "\n", "1.28\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.0\n", "\n", "\n", "2.51\n", "\n", "\n", "-0.24\n", "\n", "\n", "-1.12\n", "\n", "\n", "0.63\n", "\n", "\n", "-0.54\n", "\n", "\n", "1.41\n", "\n", "\n", "0.33\n", "\n", "\n", "1.27\n", "\n", "\n", "-0.21\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0.83\n", "\n", "\n", "-2.19\n", "\n", "\n", "-0.62\n", "\n", "\n", "0.22\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.54\n", "\n", "\n", "-2.62\n", "\n", "\n", "-1.23\n", "\n", "\n", "-0.15\n", "\n", "\n", "0.0\n", "\n", "\n", "-1.9\n", "\n", "\n", "-1.66\n", "\n", "\n", "1.28\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.0\n", "\n", "\n", "2.51\n", "\n", "\n", "-0.24\n", "\n", "\n", "-1.12\n", "\n", "\n", "0.63\n", "\n", "\n", "0.0\n", "\n", "\n", "-0.01\n", "\n", "\n", "-0.07\n", "\n", "\n", "1.42\n", "\n", "\n", "-0.4\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0.83\n", "\n", "\n", "-2.19\n", "\n", "\n", "-0.62\n", "\n", "\n", "0.22\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.54\n", "\n", "\n", "-2.62\n", "\n", "\n", "-1.23\n", "\n", "\n", "-0.15\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.3\n", "\n", "\n", "2.2\n", "\n", "\n", "-0.17\n", "\n", "\n", "0.0\n", "\n", "\n", "2.51\n", "\n", "\n", "-0.24\n", "\n", "\n", "-1.12\n", "\n", "\n", "0.63\n", "\n", "\n", "0.0\n", "\n", "\n", "-0.01\n", "\n", "\n", "-0.07\n", "\n", "\n", "1.42\n", "\n", "\n", "-0.4\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0.83\n", "\n", "\n", "-2.19\n", "\n", "\n", "-0.62\n", "\n", "\n", "0.22\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.54\n", "\n", "\n", "-2.62\n", "\n", "\n", "-1.23\n", "\n", "\n", "-0.15\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.3\n", "\n", "\n", "2.2\n", "\n", "\n", "-0.17\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.82\n", "\n", "\n", "-2.34\n", "\n", "\n", "0.48\n", "\n", "\n", "0.0\n", "\n", "\n", "-0.01\n", "\n", "\n", "-0.07\n", "\n", "\n", "1.42\n", "\n", "\n", "-0.4\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0.83\n", "\n", "\n", "-2.19\n", "\n", "\n", "-0.62\n", "\n", "\n", "0.22\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.54\n", "\n", "\n", "-2.62\n", "\n", "\n", "-1.23\n", "\n", "\n", "-0.15\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.3\n", "\n", "\n", "2.2\n", "\n", "\n", "-0.17\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.82\n", "\n", "\n", "-2.34\n", "\n", "\n", "0.48\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "-0.07\n", "\n", "\n", "1.42\n", "\n", "\n", "-0.4\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0.83\n", "\n", "\n", "-2.19\n", "\n", "\n", "-0.62\n", "\n", "\n", "0.22\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.54\n", "\n", "\n", "-2.62\n", "\n", "\n", "-1.23\n", "\n", "\n", "-0.15\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.3\n", "\n", "\n", "2.2\n", "\n", "\n", "-0.17\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "18.4\n", "\n", "\n", "-1.14\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "-0.07\n", "\n", "\n", "1.42\n", "\n", "\n", "-0.4\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0.83\n", "\n", "\n", "-2.19\n", "\n", "\n", "-0.62\n", "\n", "\n", "0.22\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.54\n", "\n", "\n", "-2.62\n", "\n", "\n", "-1.23\n", "\n", "\n", "-0.15\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.3\n", "\n", "\n", "2.2\n", "\n", "\n", "-0.17\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "18.4\n", "\n", "\n", "-1.14\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "1.91\n", "\n", "\n", "-0.44\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0.83\n", "\n", "\n", "-2.19\n", "\n", "\n", "-0.62\n", "\n", "\n", "0.22\n", "\n", "\n", "-0.29\n", "\n", "\n", "0.0\n", "\n", "\n", "-2.54\n", "\n", "\n", "-2.62\n", "\n", "\n", "-1.23\n", "\n", "\n", "-0.15\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.3\n", "\n", "\n", "2.2\n", "\n", "\n", "-0.17\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "18.4\n", "\n", "\n", "-1.14\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "0.0\n", "\n", "\n", "-0.32\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "n = 5\n", "A = randn(n,n)\n", "L = fill(0.0,n,n)\n", "display(lookat(A))\n", "for j=1:n, i=(j+1):n\n", " L[i,j] = A[i,j]/A[j,j]\n", " A[i,:] -= L[i,j] * A[j,:]\n", " display(lookat(A,redrow=i))\n", "end" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "0.07\n", "\n", "\n", "-0.93\n", "\n", "\n", "0.69\n", "\n", "\n", "0.76\n", "\n", "\n", "0.67\n", "\n", "\n", "0.83\n", "\n", "\n", "-0.25\n", "\n", "\n", "0.23\n", "\n", "\n", "-0.45\n", "\n", "\n", "-0.07\n", "\n", "\n", "0.12\n", "\n", "\n", "-0.52\n", "\n", "\n", "0.48\n", "\n", "\n", "-1.65\n", "\n", "\n", "0.74\n", "\n", "\n", "1.63\n", "\n", "\n", "0.23\n", "\n", "\n", "-0.84\n", "\n", "\n", "1.13\n", "\n", "\n", "-2.09\n", "\n", "\n", "-0.55\n", "\n", "\n", "-1.4\n", "\n", "\n", "0.3\n", "\n", "\n", "2.64\n", "\n", "\n", "-1.12\n", "\n", "\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "n = 5\n", "A = randn(n,n)\n", "L = fill(0.0,n,n)\n", "Akeep = [copy(A)]\n", "row = [0]\n", "display(lookat(A))\n", "for j=1:n, i=(j+1):n\n", " L[i,j] = A[i,j]/A[j,j]\n", " A[i,:] -= L[i,j] * A[j,:]\n", " push!(Akeep,copy(A))\n", " push!(row,i)\n", "end" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", " Unable to load WebIO. Please make sure WebIO works for your Jupyter client.\n", " For troubleshooting, please see \n", " the WebIO/IJulia documentation.\n", " \n", "

\n" ], "text/plain": [ "HTML{String}(\"\\n\\n Unable to load WebIO. Please make sure WebIO works for your Jupyter client.\\n For troubleshooting, please see \\n the WebIO/IJulia documentation.\\n \\n

\\n\")" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "using Interact" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "application/vnd.webio.node+json": { "children": [ { "children": [ { "children": [ { "children": [ { "children": [ { "children": [ "" ], "instanceArgs": { "namespace": "html", "tag": "label" }, "nodeType": "DOM", "props": { "className": "interact ", "style": { "padding": "5px 10px 0px 10px" } }, "type": "node" } ], "instanceArgs": { "namespace": "html", "tag": "div" }, "nodeType": "DOM", "props": { "className": "interact-flex-row-left" }, "type": "node" }, { "children": [ { "children": [], "instanceArgs": { "namespace": "html", "tag": "input" }, "nodeType": "DOM", "props": { "attributes": { "data-bind": "numericValue: index, valueUpdate: 'input', event: {change: function (){this.changes(this.changes()+1)}}", "orient": "horizontal", "type": "range" }, "className": "slider slider is-fullwidth", "max": 11, "min": 1, "step": 1, "style": {} }, "type": "node" } ], "instanceArgs": { "namespace": "html", "tag": "div" }, "nodeType": "DOM", "props": { "className": "interact-flex-row-center" }, "type": "node" }, { "children": [ { "children": [], "instanceArgs": { "namespace": "html", "tag": "p" }, "nodeType": "DOM", "props": { "attributes": { "data-bind": "text: formatted_val" } }, "type": "node" } ], "instanceArgs": { "namespace": "html", "tag": "div" }, "nodeType": "DOM", "props": { "className": "interact-flex-row-right" }, "type": "node" } ], "instanceArgs": { "namespace": "html", "tag": "div" }, "nodeType": "DOM", "props": { "className": "interact-flex-row interact-widget" }, "type": "node" } ], "instanceArgs": { "handlers": { "changes": [ "(function (val){return (val!=this.model[\"changes\"]()) ? (this.valueFromJulia[\"changes\"]=true, this.model[\"changes\"](val)) : undefined})" ], "index": [ "(function (val){return (val!=this.model[\"index\"]()) ? (this.valueFromJulia[\"index\"]=true, this.model[\"index\"](val)) : undefined})" ] }, "id": "17084213940907812968", "imports": { "data": [ { "name": "knockout", "type": "js", "url": "/assetserver/2618192f019dfcc40a9013ef31cb09a511d8ea26-knockout.js" }, { "name": "knockout_punches", "type": "js", "url": "/assetserver/df29ad18e8884e98d1d36dd0c339f642f729bf96-knockout_punches.js" }, { "name": null, "type": "js", "url": "/assetserver/860bb4a9e1927248d6fb4a7d59e926f541e3bfc2-all.js" }, { "name": null, "type": "css", "url": "/assetserver/4b164c07c3632d5e274899a8ab8726c70dab4aff-style.css" }, { "name": null, "type": "css", "url": "/assetserver/67252656a23d4f0f6f4ba7ab8e8eb9ffc4ae9b5d-bulma_confined.min.css" } ], "type": "async_block" }, "mount_callbacks": [ "function () {\n var handler = (function (ko, koPunches) {\n ko.punches.enableAll();\n ko.bindingHandlers.numericValue = {\n init: function(element, valueAccessor, allBindings, data, context) {\n var stringified = ko.observable(ko.unwrap(valueAccessor()));\n stringified.subscribe(function(value) {\n var val = parseFloat(value);\n if (!isNaN(val)) {\n valueAccessor()(val);\n }\n });\n valueAccessor().subscribe(function(value) {\n var str = JSON.stringify(value);\n if ((str == \"0\") && ([\"-0\", \"-0.\"].indexOf(stringified()) >= 0))\n return;\n if ([\"null\", \"\"].indexOf(str) >= 0)\n return;\n stringified(str);\n });\n ko.applyBindingsToNode(\n element,\n {\n value: stringified,\n valueUpdate: allBindings.get('valueUpdate'),\n },\n context,\n );\n }\n };\n var json_data = {\"formatted_vals\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"10\",\"11\"],\"changes\":WebIO.getval({\"name\":\"changes\",\"scope\":\"17084213940907812968\",\"id\":\"ob_10\",\"type\":\"observable\"}),\"index\":WebIO.getval({\"name\":\"index\",\"scope\":\"17084213940907812968\",\"id\":\"ob_09\",\"type\":\"observable\"})};\n var self = this;\n function AppViewModel() {\n for (var key in json_data) {\n var el = json_data[key];\n this[key] = Array.isArray(el) ? ko.observableArray(el) : ko.observable(el);\n }\n \n [this[\"formatted_val\"]=ko.computed( function(){\n return this.formatted_vals()[parseInt(this.index())-(1)];\n }\n,this)]\n [this[\"changes\"].subscribe((function (val){!(this.valueFromJulia[\"changes\"]) ? (WebIO.setval({\"name\":\"changes\",\"scope\":\"17084213940907812968\",\"id\":\"ob_10\",\"type\":\"observable\"},val)) : undefined; return this.valueFromJulia[\"changes\"]=false}),self),this[\"index\"].subscribe((function (val){!(this.valueFromJulia[\"index\"]) ? (WebIO.setval({\"name\":\"index\",\"scope\":\"17084213940907812968\",\"id\":\"ob_09\",\"type\":\"observable\"},val)) : undefined; return this.valueFromJulia[\"index\"]=false}),self)]\n \n }\n self.model = new AppViewModel();\n self.valueFromJulia = {};\n for (var key in json_data) {\n self.valueFromJulia[key] = false;\n }\n ko.applyBindings(self.model, self.dom);\n}\n);\n (WebIO.importBlock({\"data\":[{\"name\":\"knockout\",\"type\":\"js\",\"url\":\"/assetserver/2618192f019dfcc40a9013ef31cb09a511d8ea26-knockout.js\"},{\"name\":\"knockout_punches\",\"type\":\"js\",\"url\":\"/assetserver/df29ad18e8884e98d1d36dd0c339f642f729bf96-knockout_punches.js\"}],\"type\":\"async_block\"})).then((imports) => handler.apply(this, imports));\n}\n" ], "observables": { "changes": { "id": "ob_10", "sync": false, "value": 0 }, "index": { "id": "ob_09", "sync": true, "value": 1 } }, "systemjs_options": null }, "nodeType": "Scope", "props": {}, "type": "node" } ], "instanceArgs": { "namespace": "html", "tag": "div" }, "nodeType": "DOM", "props": { "className": "field interact-widget" }, "type": "node" }, { "children": [ { "children": [], "instanceArgs": { "id": "ob_16", "name": "obs-node" }, "nodeType": "ObservableNode", "props": {}, "type": "node" } ], "instanceArgs": { "handlers": {}, "id": "12708210615104101939", "imports": { "data": [], "type": "async_block" }, "mount_callbacks": [], "observables": { "obs-node": { "id": "ob_16", "sync": false, "value": { "children": [ { "children": [], "instanceArgs": { "namespace": "html", "tag": "div" }, "nodeType": "DOM", "props": { "setInnerHtml": "\n\n\n \n \n \n\n\n\n \n \n \n\n\n\n \n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n0.07\n\n\n-0.93\n\n\n0.69\n\n\n0.76\n\n\n0.67\n\n\n0.83\n\n\n-0.25\n\n\n0.23\n\n\n-0.45\n\n\n-0.07\n\n\n0.12\n\n\n-0.52\n\n\n0.48\n\n\n-1.65\n\n\n0.74\n\n\n1.63\n\n\n0.23\n\n\n-0.84\n\n\n1.13\n\n\n-2.09\n\n\n-0.55\n\n\n-1.4\n\n\n0.3\n\n\n2.64\n\n\n-1.12\n\n\n" }, "type": "node" } ], "instanceArgs": { "namespace": "html", "tag": "div" }, "nodeType": "DOM", "props": { "className": "interact-flex-row interact-widget" }, "type": "node" } } }, "systemjs_options": null }, "nodeType": "Scope", "props": {}, "type": "node" } ], "instanceArgs": { "namespace": "html", "tag": "div" }, "nodeType": "DOM", "props": {}, "type": "node" }, "text/html": [ "\n", " \n", "\n" ], "text/plain": [ "Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Scope(Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :label), Any[nothing], Dict{Symbol,Any}(:className => \"interact \",:style => Dict{Any,Any}(:padding => \"5px 10px 0px 10px\")))], Dict{Symbol,Any}(:className => \"interact-flex-row-left\")), Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :input), Any[], Dict{Symbol,Any}(:max => 11,:min => 1,:attributes => Dict{Any,Any}(:type => \"range\",Symbol(\"data-bind\") => \"numericValue: index, valueUpdate: 'input', event: {change: function (){this.changes(this.changes()+1)}}\",\"orient\" => \"horizontal\"),:step => 1,:className => \"slider slider is-fullwidth\",:style => Dict{Any,Any}()))], Dict{Symbol,Any}(:className => \"interact-flex-row-center\")), Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Node{WebIO.DOM}(WebIO.DOM(:html, :p), Any[], Dict{Symbol,Any}(:attributes => Dict(\"data-bind\" => \"text: formatted_val\")))], Dict{Symbol,Any}(:className => \"interact-flex-row-right\"))], Dict{Symbol,Any}(:className => \"interact-flex-row interact-widget\")), Dict{String,Tuple{Observables.AbstractObservable,Union{Nothing, Bool}}}(\"changes\" => (Observable{Int64} with 1 listeners. Value:\n", "0, nothing),\"index\" => (Observable{Int64} with 2 listeners. Value:\n", "1, nothing)), Set(String[]), nothing, Asset[Asset(\"js\", \"knockout\", \"/Users/alanedelman/.julia/packages/Knockout/1sDlc/src/../assets/knockout.js\"), Asset(\"js\", \"knockout_punches\", \"/Users/alanedelman/.julia/packages/Knockout/1sDlc/src/../assets/knockout_punches.js\"), Asset(\"js\", nothing, \"/Users/alanedelman/.julia/packages/InteractBase/9mFwe/src/../assets/all.js\"), Asset(\"css\", nothing, \"/Users/alanedelman/.julia/packages/InteractBase/9mFwe/src/../assets/style.css\"), Asset(\"css\", nothing, \"/Users/alanedelman/.julia/packages/Interact/SbgIk/src/../assets/bulma_confined.min.css\")], Dict{Any,Any}(\"changes\" => Any[WebIO.JSString(\"(function (val){return (val!=this.model[\\\"changes\\\"]()) ? (this.valueFromJulia[\\\"changes\\\"]=true, this.model[\\\"changes\\\"](val)) : undefined})\")],\"index\" => Any[WebIO.JSString(\"(function (val){return (val!=this.model[\\\"index\\\"]()) ? (this.valueFromJulia[\\\"index\\\"]=true, this.model[\\\"index\\\"](val)) : undefined})\")]), WebIO.ConnectionPool(Channel{Any}(sz_max:32,sz_curr:0), Set(AbstractConnection[]), Base.GenericCondition{Base.AlwaysLockedST}(Base.InvasiveLinkedList{Task}(Task (runnable) @0x000000010ae28250, Task (runnable) @0x000000010ae28250), Base.AlwaysLockedST(1))), WebIO.JSString[WebIO.JSString(\"function () {\\n var handler = (function (ko, koPunches) {\\n ko.punches.enableAll();\\n ko.bindingHandlers.numericValue = {\\n init: function(element, valueAccessor, allBindings, data, context) {\\n var stringified = ko.observable(ko.unwrap(valueAccessor()));\\n stringified.subscribe(function(value) {\\n var val = parseFloat(value);\\n if (!isNaN(val)) {\\n valueAccessor()(val);\\n }\\n });\\n valueAccessor().subscribe(function(value) {\\n var str = JSON.stringify(value);\\n if ((str == \\\"0\\\") && ([\\\"-0\\\", \\\"-0.\\\"].indexOf(stringified()) >= 0))\\n return;\\n if ([\\\"null\\\", \\\"\\\"].indexOf(str) >= 0)\\n return;\\n stringified(str);\\n });\\n ko.applyBindingsToNode(\\n element,\\n {\\n value: stringified,\\n valueUpdate: allBindings.get('valueUpdate'),\\n },\\n context,\\n );\\n }\\n };\\n var json_data = {\\\"formatted_vals\\\":[\\\"1\\\",\\\"2\\\",\\\"3\\\",\\\"4\\\",\\\"5\\\",\\\"6\\\",\\\"7\\\",\\\"8\\\",\\\"9\\\",\\\"10\\\",\\\"11\\\"],\\\"changes\\\":WebIO.getval({\\\"name\\\":\\\"changes\\\",\\\"scope\\\":\\\"17084213940907812968\\\",\\\"id\\\":\\\"ob_10\\\",\\\"type\\\":\\\"observable\\\"}),\\\"index\\\":WebIO.getval({\\\"name\\\":\\\"index\\\",\\\"scope\\\":\\\"17084213940907812968\\\",\\\"id\\\":\\\"ob_09\\\",\\\"type\\\":\\\"observable\\\"})};\\n var self = this;\\n function AppViewModel() {\\n for (var key in json_data) {\\n var el = json_data[key];\\n this[key] = Array.isArray(el) ? ko.observableArray(el) : ko.observable(el);\\n }\\n \\n [this[\\\"formatted_val\\\"]=ko.computed( function(){\\n return this.formatted_vals()[parseInt(this.index())-(1)];\\n }\\n,this)]\\n [this[\\\"changes\\\"].subscribe((function (val){!(this.valueFromJulia[\\\"changes\\\"]) ? (WebIO.setval({\\\"name\\\":\\\"changes\\\",\\\"scope\\\":\\\"17084213940907812968\\\",\\\"id\\\":\\\"ob_10\\\",\\\"type\\\":\\\"observable\\\"},val)) : undefined; return this.valueFromJulia[\\\"changes\\\"]=false}),self),this[\\\"index\\\"].subscribe((function (val){!(this.valueFromJulia[\\\"index\\\"]) ? (WebIO.setval({\\\"name\\\":\\\"index\\\",\\\"scope\\\":\\\"17084213940907812968\\\",\\\"id\\\":\\\"ob_09\\\",\\\"type\\\":\\\"observable\\\"},val)) : undefined; return this.valueFromJulia[\\\"index\\\"]=false}),self)]\\n \\n }\\n self.model = new AppViewModel();\\n self.valueFromJulia = {};\\n for (var key in json_data) {\\n self.valueFromJulia[key] = false;\\n }\\n ko.applyBindings(self.model, self.dom);\\n}\\n);\\n (WebIO.importBlock({\\\"data\\\":[{\\\"name\\\":\\\"knockout\\\",\\\"type\\\":\\\"js\\\",\\\"url\\\":\\\"/assetserver/2618192f019dfcc40a9013ef31cb09a511d8ea26-knockout.js\\\"},{\\\"name\\\":\\\"knockout_punches\\\",\\\"type\\\":\\\"js\\\",\\\"url\\\":\\\"/assetserver/df29ad18e8884e98d1d36dd0c339f642f729bf96-knockout_punches.js\\\"}],\\\"type\\\":\\\"async_block\\\"})).then((imports) => handler.apply(this, imports));\\n}\\n\")])], Dict{Symbol,Any}(:className => \"field interact-widget\")), Observable{Any} with 0 listeners. Value:\n", "Node{WebIO.DOM}(WebIO.DOM(:html, :div), Any[Plot{Plots.GRBackend() n=25}], Dict{Symbol,Any}(:className => \"interact-flex-row interact-widget\"))], Dict{Symbol,Any}())" ] }, "execution_count": 24, "metadata": { "application/vnd.webio.node+json": { "kernelId": "491971e1-5e20-4d24-b021-08a27ca47da3" } }, "output_type": "execute_result" } ], "source": [ "@manipulate for i=slider(1:length(Akeep),value=1)\n", " lookat(Akeep[i],redrow=row[i],showtext=true)\n", "end" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "using LinearAlgebra" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5×5 Array{Float64,2}:\n", " 1.0 0.0 0.0 0.0 0.0\n", " 11.2268 1.0 0.0 0.0 0.0\n", " 1.65127 0.100262 1.0 0.0 0.0\n", " 22.1736 2.04623 -7.9508 1.0 0.0\n", " -7.45666 -0.817478 -7.32798 1.03327 1.0" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "U = Akeep[end]\n", "A = Akeep[1]\n", "L += I" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5×5 Array{Float64,2}:\n", " 0.0737129 -0.934928 0.686715 0.756193 0.665156\n", " 0.827557 -0.250188 0.22969 -0.451796 -0.067432\n", " 0.12172 -0.516531 0.479388 -1.64916 0.735843\n", " 1.63448 0.234953 -0.837002 1.12689 -2.08616 \n", " -0.549652 -1.40446 0.295059 2.6386 -1.12414 " ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L*U" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5×5 Array{Float64,2}:\n", " 0.0737129 -0.934928 0.686715 0.756193 0.665156\n", " 0.827557 -0.250188 0.22969 -0.451796 -0.067432\n", " 0.12172 -0.516531 0.479388 -1.64916 0.735843\n", " 1.63448 0.234953 -0.837002 1.12689 -2.08616 \n", " -0.549652 -1.40446 0.295059 2.6386 -1.12414 " ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "true" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L*U ≈ A" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "@webio": { "lastCommId": "eae5c4a469c94994884bdc3fd65a736a", "lastKernelId": "6c0e5fe2-1c02-40cc-b0c7-24e073bb3e7d" }, "kernelspec": { "display_name": "Julia 1.3.1", "language": "julia", "name": "julia-1.3" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.3.1" } }, "nbformat": 4, "nbformat_minor": 2 }