Wednesday, July 23, 2014

The Linear Regression Model y = a + bx

This is part of Mike's Big Data, Data Mining, and Analytics Tutorial 

Linear Regression of the form \( y = a + b x \) is the typical "go to" regression method that people generally use. It is often taught in many basic statistics and non-statistical mathematics courses. There are a large number of problems where linear regression of the form \( y = a + bx \) provides a correct answer and a large number of problems where it provides an acceptable answer. In future posts, we'll look at other models that may fit other data better.

By definition, the line \( y = a + b x \) is a straight line with the following characteristics:

  • The y axis intercept (the model evaluated at \( x = 0 \), in mathematical notation \( y = a +bx |_{x=0}  \) is equal to  \(a\).
  • The x axis intercept (the model evaluated at \( y = 0 \) and solved for x, in mathematical notation \( y = a + bx|_{y=0} \) is equal to \( \frac{-a}{b} \).
  • The slope of the line is equal to \( b \). This can be shown with either the typical "rise over run" or using the first derivative (there's really not a lot of distinction here, but I recognize that some readers may not have a calculus background).
    • Let's look at the "rise over run" part first. To make the math easy, let's assume that we want to compare the change in y (call the change in y \( \sigma \) when we make some arbitrary change in x ( let's say we add \(\delta\) )$$ y = a + b x $$ $$ y + \sigma = a + b(x + \delta) $$ Now let's look at the change: $$ y + \sigma - y = a + b (x + \delta) - (a + bx  ) $$ Simplifying, we get to $$ \sigma = b \delta $$ . The "rise over run" is equal to $$ \frac{\sigma}{\delta} = b$$. To take this a step further, assume \(\delta = 1\), the change is exactly \(b\)
    • Going back to basic first semester calculus, this can be shown using the first derivative (for non-calculus readers, the derivative is a measure of how quickly the slope of a particular curve changes) $$ \frac{d}{dx} a + bx = b $$

How do I calculate \( a \) and \( b \) for the line \( y =  a + b x \)?
 

Let's get into the calculation of the \( a \) and \( b \) values for the \( y= a  + b x \) model. Firstly, we need to set up a matrix \( A \)  with the relevant transformations of our input data. We'll get to that in a minute below. First, let's answer the question "How do I find a line between 2 points in the \( (x,y) \) plane?"

For a second, let's consider two of our points in our data: \( (x_1, y_1 )\) and \( (x_2, y_2 )\).  If we used just the two points, we can calculate \( a \) and \( b \) directly. First, let's define a couple of equations:

$$ y_1 = a + b x_1 $$
$$ y_2 = a + b x_2 $$

Doing a little bit of reorganization, let's solve for b first:

$$ y_2 - y_1  = a + b x_2 - (a + b x_1) $$

\( a \) cancels out and the right side simplifies to  \( b x_2 - b x_1 = b ( x_2 - x_1 ) \). Solving for \( b \):

$$ b = \frac{y_2 - y_1}{x_2 - x_1} $$

Either equation can be used to solve for \( a \). Using the first, \( a = y_1 - b x_1 \), using the second equation, \( a = y_2 - b x_2 \). Now, let's consider a matrix solution to the same problem. We'll set up matrices to solve the equation
 $$ A z = B $$

Here, lets define \( z \) and \( B \). \( z \) contains our unknowns... namely \( a \) and \( b \). \( B \) contains our Y values, namely \( y_1 \)  and \( y_2 \)

$$ z = \begin{pmatrix} a \\ b \end {pmatrix} \quad \quad B = \begin{pmatrix} y_1 \\ y_2 \end{pmatrix} $$

Let's take a little bit of extra time to talk about \( A \). Each column in \( A \) has to be a function of the data \( x_i \). Let's go back to our original equations and rewrite them slightly...

$$ y_1 = a + b x_1 \iff a \mathbf{x_1^0} + b x_1^{\mathbf{1}} $$
$$ y_2 = a + b x_2 \iff a \mathbf{x_2^0} + b x_2^{\mathbf{1}} $$

We know generally that almost anything raised to the "zero" power is equal to 1. Anything raised to the first power is equal to itself. Let's put our rewritten equations into their equivalent matrix format:

$$ A = \begin{pmatrix} x_1^0 & x_1^1 \\ x_2^0 & x_2^1 \end{pmatrix} \iff \begin{pmatrix} 1 & x_1 \\ 1 & x_2 \end{pmatrix} $$

Our resulting matrix \( A \) contains all of the data. The first column contains the data raised to the 0 power and the second column contains the data raised to the first power. Let's write our system of equations out in matrix form:

$$ A z = B $$
$$ \begin{pmatrix} 1 & x_1 \\ 1 & x_2 \end{pmatrix} \begin{pmatrix} a \\ b \end{pmatrix} = \begin{pmatrix} y_1 \\ y_2 \end{pmatrix} $$

This is a 2x2 system, so we can look up the inverse of a 2x2 matrix on my post here: http://mikemstech.blogspot.com/2014/07/inverse-of-2x2-matrix.html. We'll use the fact that

$$(A^{-1}) A z = (A^{-1}) B $$
$$ z = (A^{-1}) B $$

Calculating \( A^{-1} B \) yields

$$ \begin{pmatrix} \frac{y_1 x_2 - y_2 x_1}{ x_2 - x_1 } \\  \frac{y_2 - y_1}{x_2-x_1} \end{pmatrix} $$

Namely, \( a = \frac{y_1 x_2 - y_2 x_1}{ x_2 - x_1 } \) and \( b = \frac{y_2 - y_1}{x_2-x_1} \) for our two point example. A fair amount of algebra can be used to show the equivalence of the answers above and the answers to the matrix equations for \( a \) ( \( b \) is the same with either approach).

How to find \( a \) and \( b \) with more than two points.

We used the two point example as a conceptual introduction to how we set up the matrices, and now we want to consider the case with more than 2 points. We set up our system of equations using the least squares approach (minimizing the total sum of squared error for the model generated).

$$ A^T A z = A^T B $$

In this case,
$$  A = \begin{pmatrix} 1 & x_1 \\ \vdots & \vdots \\ 1 & x_n \end{pmatrix} \quad z = \begin{pmatrix} a \\ b \end{pmatrix} \quad B = \begin{pmatrix} y_1 \\ \vdots \\ y_n \end{pmatrix} $$








Now for the calculation of \( A^T A \) and \( A^T B \)

$$ A^T A = \begin{pmatrix} \sum \limits _{i = 1}^n 1 & \sum \limits _{i=1}^n x_i \\ \sum \limits _{i=1}^n x_i & \sum \limits _{i=1}^n x_i^2 \end{pmatrix} = \begin{pmatrix} n & \sum \limits _{i=1}^n x_i \\ \sum \limits _{i=1}^n x_i & \sum \limits _{i=1}^n x_i^2 \end{pmatrix} \quad \quad A^T B = \begin{pmatrix} \sum \limits _{i=1}^n y_i \\ \sum \limits _{i=1}^n x_i \cdot y_i \end{pmatrix} $$


This is a 2x2 system, so we can look up the inverse of a 2x2 matrix on my post here: http://mikemstech.blogspot.com/2014/07/inverse-of-2x2-matrix.html. Again, we'll use the following:

$$ (A^TA)^{-1} A^TA z = (A^TA)^{-1} B $$
$$ z = (A^TA)^{-1} B $$

Finding the inverse of \( A^T A \) yields

$$ (A^T A)^{-1} = \frac { 1 } { n \sum \limits _{i=1}^n x_i^2 - \left ( \sum \limits_{i=1}^n x_i \right )^2 } \begin{bmatrix} \sum \limits_{i=1}^n x_i^2 & -1 \cdot \sum \limits _{i=1}^n x_i \\ -1 \cdot \sum \limits _{i=1}^n x_i & n \end{bmatrix}$$

Calculating \( (A^T A)^{-1} B \) yields

$$ \begin{pmatrix} (A^T A)^{-1} B = \frac{\sum \limits_{i=1}^n x_i^2 \sum \limits_{i=1}^n y_i -  \sum \limits_{i=1}^n x_i \sum \limits_{i=1}^n x_i y_i}{n \sum \limits _{i=1}^n x_i^2 - \left ( \sum \limits_{i=1}^n x_i \right )^2 }  \\ \frac{n \sum \limits_{i=1}^n x_i y_i  -  \sum \limits_{i=1}^n y_i \sum \limits_{i=1}^n x_i }{n \sum \limits _{i=1}^n x_i^2 - \left ( \sum \limits_{i=1}^n x_i \right )^2 } \end{pmatrix} $$

So, for the regression model \( y = a + bx \)
$$ a = \frac{\sum \limits_{i=1}^n x_i^2 \sum \limits_{i=1}^n y_i -  \sum \limits_{i=1}^n x_i \sum \limits_{i=1}^n x_i y_i}{n \sum \limits _{i=1}^n x_i^2 - \left ( \sum \limits_{i=1}^n x_i \right )^2 } \quad \quad  b = \frac{n \sum \limits_{i=1}^n x_i y_i  -  \sum \limits_{i=1}^n y_i \sum \limits_{i=1}^n x_i }{n \sum \limits _{i=1}^n x_i^2 - \left ( \sum \limits_{i=1}^n x_i \right )^2 }   $$

Example: Calculate A Regression Line for 3 Collinear Points

Problem statement: Calculate a line in the form \( y = a + b x \) that goes through the points \( (1,5),(2,7),(3,9) \).

 

We derived the formula above, so now we need to focus on calculation.

$$ a = \frac{\sum \limits_{i=1}^n x_i^2 \sum \limits_{i=1}^n y_i -  \sum \limits_{i=1}^n x_i \sum \limits_{i=1}^n x_i y_i}{n \sum \limits _{i=1}^n x_i^2 - \left ( \sum \limits_{i=1}^n x_i \right )^2 } \quad \quad  b = \frac{n \sum \limits_{i=1}^n x_i y_i  -  \sum \limits_{i=1}^n y_i \sum \limits_{i=1}^n x_i }{n \sum \limits _{i=1}^n x_i^2 - \left ( \sum \limits_{i=1}^n x_i \right )^2 } $$

If calculating by hand, the easiest way is to organize the calculationsin a table.

Point \( x_i \) \( y_i \) \( x_i^2 \) \( x_i y_i \)
\((1,5)\) 1 5 1 5
\((2,7)\) 2 7 4 14
\((3,9)\) 3 9 9 27

\( \sum \limits_{i=1}^3 x_i = 1 + 2 + 3 = 6 \) \( \sum \limits_{i=1}^3 y_i = 5 + 7 + 9 = 21 \) \( \sum \limits_{i=1}^3 x_i^2 = 1 + 4 + 9 = 14 \) \( \sum \limits_{i=1}^3 x_i y_i = 5 + 14 + 27 = 46 \)
Now, for the calculation of \( a \)
$$ a = \frac{\sum \limits_{i=1}^n x_i^2 \sum \limits_{i=1}^n y_i -  \sum \limits_{i=1}^n x_i \sum \limits_{i=1}^n x_i y_i}{n \sum \limits _{i=1}^n x_i^2 - \left ( \sum \limits_{i=1}^n x_i \right )^2 } = \frac{ 14 \cdot 21 - 6 \cdot 46 }{ 3 \cdot 14 - 6^2 } = \frac{18}{6} = 3 $$

Now, for the calculation of \( b \)

$$ b = \frac{n \sum \limits_{i=1}^n x_i y_i  -  \sum \limits_{i=1}^n y_i \sum \limits_{i=1}^n x_i }{n \sum \limits _{i=1}^n x_i^2 - \left ( \sum \limits_{i=1}^n x_i \right )^2 } = \frac{3 \cdot 46 - 21 \cdot 6}{3 \cdot 14 - 6^2 } = \frac{12}{6} = 2 $$

The ending solution for \( y= a + b x \) that fits these three points is \( y = 3 + 2 x \)

Back to Mike's Big Data, Data Mining, and Analytics Tutorial 

Sunday, July 20, 2014

Mike's Big Data, Data Mining, and Analytics Tutorial

I've been looking for a good tutorial covering the topics of "Statistics," "Big Data," "Data Science," "Data Mining", and "Analytics" for a long time. Needless to say, I've found a lot of piecemeal information about the subjects out on the Internet, but I haven't seen anyone develop a good centralized tutorial for this information.

This tutorial is meant to provide a starting point for people who are interested in learning the topics and collected best practices from what I've learned over the past 11 years or so (Including introductory functions, statistics, trigonometry, pre-calculus, calculus, differential equations, linear algebra, intermediate and advanced applied statistics, data mining, machine learning, and analytics).

This tutorial is generally an "applied" tutorial (as opposed to a mathematical/theoretical statistics tutorial) and aims to help people become better at understanding statistics and performing analyses. Almost everywhere, there is a pervasive misuse of statistics and the only effective tool to fight it is knowledge.

Below are a list of topics that are either documented or are in-progress currently:


The Linear Model y = a

This is part of Mike's Big Data, Data Mining, and Analytics Tutorial

The simplest linear model that I am going to discuss in this series is the model \(y = a\). By the end of this post, I hope you'll walk away with the knowledge of what the model represents and how it is often used. By the end of this post, I hope you'll be able to answer the following questions:
  • What is the "null" model?
  • How is the "null" model used?
  • Why is the solution to the linear model \( y = a \) equal to the mean?
For a minute, let's consider a scenario where we have a set of interval or ratio data that we want to learn more about. In this scenario we are attempting to describe the relationship in the data that we have collected. We may or may not be interested in predicting other values. We are essentially asking the question "Why are things the way that they are?" and may be asking the question "How might things be if we collect more data?" As we work through our model, we will be attempting to describe the relationship between dependent and independent variables.

If your new to statistics, the words in the previous paragraph might not have a lot of meaning. Let's look at them in detail...

Interval/Ratio Data - The words "Interval" and "Ratio" refer to the measurement scale of the data in question. Most of the models in the tutorial will require an interval/ratio dependent variable. Some clues that help us end up at a description of this measurement level include:

  • "Zero on the scale" - the measurement scale typically has a 0 at some point. For ratio data, there is an absolute "zero" to the scale (i.e. it would be impossible for a collected data point to fall below "zero").
  • Sub-interval equality - The distance between subsequent points on the scale are equal. For example, we would generally consider the difference between 1 degree F and 2 degrees F to be equivalent to the difference between 3 degrees and 4 degrees F.
  • "Lots" of possible values on the scale. For example, in a bank account, we could have virtually any amount above or below zero, probably down to a resolution of $0.01 (for accounts denominated in the U.S. Dollar)

Some examples of interval/ratio data include:

  • Temperature: degrees of temperature are typically considered interval or ratio. Scales such as Celsius and Fahrenheit are typically considered interval (because they have a "zero" on the scale). Scales such as Kelvin and Rankin have an "absolute" zero on the scale, meaning there can't reasonably be values less than 0 on these scales.
  • Measurements of mass/weight/volume: Measurements of mass, weight, and volume typically have interval/ratio properties.
  • Measurements of economic value: Typical measurements of economic value are quoted in a currency or an amount of a good.
Some examples of things that aren't interval/ratio:

  • Demographic variables such as religion, sexual preference, and gender: These can't be given non-arbitrary numeric values. Additionally, there is no meaning between the numeric "differences" applied to these categories. For example, say Republican is coded as a 1, Democrat is coded as a 2, and Independent is coded as a 3. There is no meaningful difference by describing the difference between 1 and 2, much less comparing that to the difference between 3 and 4. these are sometimes referred to as "nominal" or "categorical" data.
  • Ratings and rankings: These typically arise from surveys/questionnaires. These might take the form of the common "agree/disagree" and "satisfied/dissatisfied" scales. In this case, we can say that certain values are different (and potentially less than or greater than) other values, but we don't have homogeneity in the scale. For example, someone responding "agree" to a question might not be the same as someone else responding "agree," but after repeated measurements of the same person we could probably conclude that "strongly agree" is larger in magnitude than "somewhat agree" or just "agree." These are sometimes referred to as "ordinal" data.
Relationships in Data/Prediction:

We don't generally set off on a course of research without some sort of purpose. This purpose is typically to understand or optimize something. We might be asking questions of the form "Is there a relationship between X an Y?" or "Are A and B correlated?" or "Can I use C or D (or some combination) to predict E?" The purpose of each of these questions is to help us understand relationships in the real world based on data collected from our observations.

We should be careful to remember that correlation does not imply causation. When we develop predictive models, we will be careful not to say things like "A is causing B" because we probably don't have sufficient basis to conclude such a thing... To be able to describe causation, we would likely need to step away from regression/classification and enter the realms of experimental design.

Dependent/Independent Variables

For our purposes, the dependent variable is the variable we are interested in describing. The independent variables are the variables that we could potentially use to describe the dependent variable.
Examples:

  • If we are predicting asset prices (ex. stocks, bonds, commodities), our dependent variable might be "price in the future", and we might be using independent variables such as "price in the past," economic variables, financial data, etc.
  • If we are predicting a students "GPA in a course" (dependent variable), we might use the following as independent variables: "hours spent per week," "percentage of lectures attended," scores on standardized tests such as the SAT, ACT, GED, GRE, MCAT, etc.
So now, let's dig into the "null model."

At a basic level, the null model is a model that minimizes the error when describing the dependent variable with a single number. Effectively, the overall error is minimized as measured from the horizontal (or vertical) line to each of the points. Below is a graphical depiction of the null model (generated in R):


The null model represents the best guess that we could use to describe the data if we didn't have or didn't use any of the possible dependent variables to describe the independent variable (y in the chart above).

Intuitively, we might conclude that this is the mean (or average) of the dependent variable. We can prove this below.

Without sinking too much into the proofs involved in linear algebra, let's first state the (provable) assumption that we can develop a "minimum error" solution to our system of equations by solving the linear system:

$$ A^T A x = A^T B $$

Here, \( A \) is a matrix that contains a transformation of the independent variables and \( B \) is a matrix containing all of the dependent variable values.

$$ A = \begin{pmatrix} 1 \\ \vdots \\ 1 \end{pmatrix} \quad B = \begin{pmatrix}y_1 \\ \vdots \\ y_n \end {pmatrix} $$

In this case, we don't have (or aren't using) any of the independent variable data to describe the dependent variable. Now let's calculate two of the items needed in the first equation:

$$ A^T A = \sum_{i=1}^n 1 = n \quad \quad A^T B = \sum_{i =1}^n 1 \cdot y_i $$

So... \( A^T A \) is simply the sample size and \( A^T B \) is the sum of the dependent variable observations. If we take the inverse of \( A^T A \) and multiply it both sides, we end up with our answer for \( a \). In this case, \( A^T A \) is a 1x1 matrix. I show how to find the inverse here: http://mikemstech.blogspot.com/2014/07/inverse-of-1x1-matrix.html

$$ (A^T A) ^{-1} (A^T A) x = (A^T A)^{-1} (A^T B) $$
$$ x = (A^T A)^{-1} (A^T B) $$

By the matrix inversion formula for the 1x1 matrix (linked above), we see that

$$  (A^T A)^{-1} (A^T B) = \frac{ \sum_{i=1}^n y_i}{n} = \bar{x} $$
Here we see that the answer to the null model is just the average of the dependent variable values.

Let's do a small example. Say that we have the following data:
$$ B = \begin{pmatrix} y_1 = 0 \\ y_2  = 5 \\ y_3 = 10 \end{pmatrix} $$

Let's determine the null model for this data.

$$ A = \begin{pmatrix} 1 \\ 1 \\ 1 \end{pmatrix} $$

$$ A^T A = \sum_{i=1}^{3} 1 = 3  \quad \quad  A^T B = (1 \cdot 0 + 1 \cdot 5 + 1 \cdot 10 = 15) $$

$$ (A^T A)^{-1} = \frac { 1} {3}$$

$$ (A^T A)^{-1} B = \frac { 15} {3} = 5 $$

Here the null model (average) for the data is y = 5.

The null model, besides being an interesting conceptual introduction, is also important for other practical reasons. When we evaluate other models, we will typically determine their goodness of fit based on a comparison with the null model for the same data. We are conceptually asking the question "Does our 'complicated' model describe the dependent variable better than the average?" There are tools that we can use to answer this question that will be discussed with the other models. Here it is also useful to initially define the total sum of squares.

The total sum of squares (TSS) for the model is the sum of the squared deviations from the average.

$$ TSS = \sum_{i=1}^n (y_i - \bar{y})^2 $$

This is also equal to

$$ TSS = \sum_{i=1}^n (\bar{y} - y_i)^2 $$
As an example, let's consider our data from above and calculate the TSS.

$$ TSS = \sum_{i=1}^n (y_i - \bar{y})^2  = (0 - 5)^2 + (5-5)^2 + (10-5)^2 = 50 $$

The ending value of 50 doesn't tell us a lot until we compare it with another model (normally to see if the other model "explains" more of the variability in the dependent variable).

Back to Mike's Big Data, Data Mining, and Analytics Tutorial 

Inverse of a 1x1 Matrix

In my previous post (http://mikemstech.blogspot.com/2014/07/c-matrix-inversion-with-latex-output.html) I demonstrated an application that can generate the steps to show the inversion of a matrix by Gauss Jordan elimination.

In a few posts, I plan to answer the following questions:
What is the inverse of a 1x1 Matrix?
What is the inverse of a 2x2 Matrix?
What is the inverse of a 3x3 Matrix?
What is the inverse of a 4x4 Matrix?

Back to Mike's Big Data, Data Mining, and Analytics Tutorial

The inverse of a 1x1 matrix is defined as follows. For a 1x1 matrix:

$$ A = \begin{pmatrix}a_{1,1}\end{pmatrix} $$

$$ A^{-1} = \begin{pmatrix}\frac{1}{a_{1,1}} \end {pmatrix} $$

Obviously, if $$a_{1,1} = 0$$ the matrix has no inverse.

The latex code generated for a 1x1 inverse is the following:

 
\documentclass{article}

% This is the output from LatexMatrixInverse 1.0 for a matrix with rank 1 
% For more information on this application, see
% http://mikemstech.blogspot.com

\usepackage{geometry}

% Note: you should probably use pdflatex to compiile this file. 
% Other processors are known to have some issues with using
% 'geometry' to set paper size

% Adjust the page size here if output is wrapping in a bad way.
% Default is 8.5 x 11 in (Letter)
\geometry{papersize={8.5in,11in}}

%Import AMS Latex packages
\usepackage{amsmath, amssymb}
\setcounter{MaxMatrixCols}{3}


%Variable definition

\begin{document}
% Definition of initial A
% A row 1
\newcommand{\ARbCb}{a_{1,1}}

% Definition of initial B
\newcommand{\BRb}{b_{1}}



LatexMatrixInverse 1.0 Output for rank 1, ShowIntermediateSteps is True.

For more information on this application, please see http://mikemstech.blogspot.com

Given the following initial matrices:
\begin{equation*}
A = \begin{pmatrix}\ARbCb
\end{pmatrix}B = \begin{pmatrix}\BRb\end{pmatrix}\end{equation*}
 We want to find $A^{-1}$ and $A^{-1} B$...
\begin{equation*}
\left ( \begin{array}{c|c|c}\ARbCb
&1
&\BRb\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{\frac{1}{\ARbCb} R_{1}}
\left ( \begin{array}{c|c|c}1
&\frac{1}{\ARbCb}
&\frac{\BRb}{\ARbCb}\end{array} \right )
\end{equation*}
\begin{equation*}
A^{-1} = \begin{pmatrix}\frac{1}{\ARbCb}
\end{pmatrix}A^{-1}B = \begin{pmatrix}\frac{\BRb}{\ARbCb}\end{pmatrix}\end{equation*}
\end{document}


Here is a screenshot of the generated file that shows all of the steps for a 1x1 matrix inverse:





Inverse of a 2x2 Matrix

In my previous post (http://mikemstech.blogspot.com/2014/07/c-matrix-inversion-with-latex-output.html) I demonstrated an application that can generate the steps to show the inversion of a matrix by Gauss Jordan elimination.

In a few posts, I plan to answer the following questions:
What is the inverse of a 1x1 Matrix?
What is the inverse of a 2x2 Matrix?
What is the inverse of a 3x3 Matrix?
What is the inverse of a 4x4 Matrix?

Back to Mike's Big Data, Data Mining, and Analytics Tutorial

The inverse of a 2x2 matrix is defined as follows. For a 2x2 matrix:

$$ A = \begin{pmatrix}a & b \\ c & d\end{pmatrix} $$

Unsimplified, the inverse is equal to:

$$ A^{-1} = \begin{pmatrix}\frac{1}{a} - \left (\frac{b}{a} \right )  \left ( \frac{0 - \left (c \right ) \left ( \frac{1}{a}\right )}{d - \left (c \right ) \left ( \frac{b}{a}\right )}\right )
&
0 - \left (\frac{b}{a} \right )  \left ( \frac{1}{d - \left (c \right ) \left ( \frac{b}{a}\right )}\right )
\\\frac{0 - \left (c \right ) \left ( \frac{1}{a}\right )}{d - \left (c \right ) \left ( \frac{b}{a}\right )}
&
\frac{1}{d - \left (c \right ) \left ( \frac{b}{a}\right )}
\end{pmatrix} $$

After simplifying, this is the inverse of a 2x2 matrix.

$$ A^{-1} = \frac{1}{ad-bc} \begin{pmatrix}  d & -b \\ -c & a  \end {pmatrix} $$

The latex code generated for a 2x2 inverse is the following (note that I changed the default variables to a, b, c, and d to match how most people learn the 2x2 matrix):

\documentclass{article}

% This is the output from LatexMatrixInverse 1.0 for a matrix with rank 2 
% For more information on this application, see
% http://mikemstech.blogspot.com

\usepackage{geometry}

% Note: you should probably use pdflatex to compiile this file. 
% Other processors are known to have some issues with using
% 'geometry' to set paper size

% Adjust the page size here if output is wrapping in a bad way.
% Default is 8.5 x 11 in (Letter)
\geometry{papersize={16in,11in}}

%Import AMS Latex packages
\usepackage{amsmath, amssymb}
\setcounter{MaxMatrixCols}{5}


%Variable definition

\begin{document}
% Definition of initial A
% A row 1
\newcommand{\ARbCb}{a}
\newcommand{\ARbCc}{b}

% A row 2
\newcommand{\ARcCb}{c}
\newcommand{\ARcCc}{d}

% Definition of initial B
\newcommand{\BRb}{e}
\newcommand{\BRc}{f}



LatexMatrixInverse 1.0 Output for rank 2, ShowIntermediateSteps is True.

For more information on this application, please see http://mikemstech.blogspot.com

Given the following initial matrices:
\begin{equation*}
A = \begin{pmatrix}\ARbCb
&\ARbCc
\\\ARcCb
&\ARcCc
\end{pmatrix}B = \begin{pmatrix}\BRb\\ \BRc\end{pmatrix}\end{equation*}
 We want to find $A^{-1}$ and $A^{-1} B$...
\begin{equation*}
\left ( \begin{array}{cc|cc|c}\ARbCb
&\ARbCc
&1
&0
&\BRb\\
\ARcCb
&\ARcCc
&0
&1
&\BRc\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{\frac{1}{\ARbCb} R_{1}}
\left ( \begin{array}{cc|cc|c}1
&\frac{\ARbCc}{\ARbCb}
&\frac{1}{\ARbCb}
&0
&\frac{\BRb}{\ARbCb}\\
\ARcCb
&\ARcCc
&0
&1
&\BRc\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{R_{2} - \left ( \ARcCb\right ) R_{1}}
\left ( \begin{array}{cc|cc|c}1
&\frac{\ARbCc}{\ARbCb}
&\frac{1}{\ARbCb}
&0
&\frac{\BRb}{\ARbCb}\\
0
&\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )
&0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )
&1
&\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} R_{2}}
\left ( \begin{array}{cc|cc|c}1
&\frac{\ARbCc}{\ARbCb}
&\frac{1}{\ARbCb}
&0
&\frac{\BRb}{\ARbCb}\\
0
&1
&\frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
&\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
&\frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{R_{1} - \left ( \frac{\ARbCc}{\ARbCb}\right ) R_{2}}
\left ( \begin{array}{cc|cc|c}1
&0
&\frac{1}{\ARbCb} - \left (\frac{\ARbCc}{\ARbCb} \right ) \linebreak \left ( \frac{0 - \left (\ARcCb \right ) 
\left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )
&0 - \left (\frac{\ARbCc}{\ARbCb} \right ) \linebreak \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )
&\frac{\BRb}{\ARbCb} - \left (\frac{\ARbCc}{\ARbCb} \right ) \linebreak \left ( \frac{\BRc - \left (\ARcCb \right ) 
\left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )\\
0
&1
&\frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
&\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
&\frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\end{array} \right )
\end{equation*}
\begin{equation*}
A^{-1} = \begin{pmatrix}\frac{1}{\ARbCb} - \left (\frac{\ARbCc}{\ARbCb} \right ) \linebreak \left ( \frac{0 - \left (\ARcCb \right ) 
\left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )
&
0 - \left (\frac{\ARbCc}{\ARbCb} \right ) \linebreak \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )
\\\frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
&
\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
\end{pmatrix}A^{-1}B = \begin{pmatrix}\frac{\BRb}{\ARbCb} - \left (\frac{\ARbCc}{\ARbCb} \right ) \linebreak \left ( \frac{\BRc - \left (\ARcCb \right ) 
\left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )\\ \frac{\BRc - \left (\ARcCb \right ) 
\left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
\end{pmatrix}\end{equation*}
\end{document}


Here is a screenshot of the work for calculating a 2x2 inverse (based on the compiled code above):































Inverse of a 3x3 Matrix

In my previous post
(http://mikemstech.blogspot.com/2014/07/c-matrix-inversion-with-latex-output.html)
I demonstrated an application that can generate the steps to show the
inversion of a matrix by Gauss Jordan elimination.

In a few posts, I plan to answer the following questions:
What is the inverse of a 1x1 Matrix?
What is the inverse of a 2x2 Matrix?
What is the inverse of a 3x3 Matrix?
What is the inverse of a 4x4 Matrix?

Back to Mike's Big Data, Data Mining, and Analytics Tutorial

The inverse of a 3x3 matrix is defined as follows. For a 3x3 matrix:

$$ A = \begin{pmatrix}a & b & c \\ d & e & f \\ g & h & i\end{pmatrix} $$

$$ A^{-1} = \begin{pmatrix}
\frac{f h-e i}{c e g-b f g-c d h+a f h+b d i-a e i}
& \frac{c h - b i}{- c e g + b f g + c d h - a f h - b d i + a e i}
& \frac{c e - b f}{c e g - b f g - c d h + a f g + b d i - a e i } \\
\frac{f g - d i}{- c e g + b f g + c d h - a f h - b d i + a e i}
& \frac{c g - a i}{c e g - b f g - c d h+ a f h + b d i - a e i}
& \frac{c d - a f}{- c e g + b f g + c d h - a f h - b d i + a e i} \\
\frac{e g - d h}{c e g - b f g - c d h + a f h + b d i - a e i}
& \frac{b g - a h}{- c e g + b f g + c d h - a f h - b d i + a e i}
& \frac{b d - a e}{c e g - b f g - c d h + a f h + b d i - a e i}
\end {pmatrix} $$

The latex code generated for a 3x3 inverse is the following:

\documentclass{article}

% This is the output from LatexMatrixInverse 1.0 for a matrix with rank 3 
% For more information on this application, see
% http://mikemstech.blogspot.com

\usepackage{geometry}

% Note: you should probably use pdflatex to compiile this file. 
% Other processors are known to have some issues with using
% 'geometry' to set paper size

% Adjust the page size here if output is wrapping in a bad way.
% Default is 8.5 x 11 in (Letter)
\geometry{papersize={40in,14in}}

%Import AMS Latex packages
\usepackage{amsmath, amssymb}
\setcounter{MaxMatrixCols}{7}


%Variable definition

\begin{document}
% Definition of initial A
% A row 1
\newcommand{\ARbCb}{a}
\newcommand{\ARbCc}{b}
\newcommand{\ARbCd}{c}

% A row 2
\newcommand{\ARcCb}{d}
\newcommand{\ARcCc}{e}
\newcommand{\ARcCd}{f}

% A row 3
\newcommand{\ARdCb}{g}
\newcommand{\ARdCc}{h}
\newcommand{\ARdCd}{i}

% Definition of initial B
\newcommand{\BRb}{j}
\newcommand{\BRc}{k}
\newcommand{\BRd}{l}



LatexMatrixInverse 1.0 Output for rank 3, ShowIntermediateSteps is True.

For more information on this application, please see http://mikemstech.blogspot.com

Given the following initial matrices:
\begin{equation*}
A = \begin{pmatrix}\ARbCb
&\ARbCc
&\ARbCd
\\\ARcCb
&\ARcCc
&\ARcCd
\\\ARdCb
&\ARdCc
&\ARdCd
\end{pmatrix}B = \begin{pmatrix}\BRb\\ \BRc\\ \BRd\end{pmatrix}\end{equation*}
 We want to find $A^{-1}$ and $A^{-1} B$...
\begin{equation*}
\left ( \begin{array}{ccc|ccc|c}\ARbCb
&\ARbCc
&\ARbCd
&1
&0
&0
&\BRb\\
\ARcCb
&\ARcCc
&\ARcCd
&0
&1
&0
&\BRc\\
\ARdCb
&\ARdCc
&\ARdCd
&0
&0
&1
&\BRd\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{\frac{1}{\ARbCb} R_{1}}
\left ( \begin{array}{ccc|ccc|c}1
&\frac{\ARbCc}{\ARbCb}
&\frac{\ARbCd}{\ARbCb}
&\frac{1}{\ARbCb}
&0
&0
&\frac{\BRb}{\ARbCb}\\
\ARcCb
&\ARcCc
&\ARcCd
&0
&1
&0
&\BRc\\
\ARdCb
&\ARdCc
&\ARdCd
&0
&0
&1
&\BRd\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{R_{2} - \left ( \ARcCb\right ) R_{1}}
\left ( \begin{array}{ccc|ccc|c}1
&\frac{\ARbCc}{\ARbCb}
&\frac{\ARbCd}{\ARbCb}
&\frac{1}{\ARbCb}
&0
&0
&\frac{\BRb}{\ARbCb}\\
0
&\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )
&\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )
&0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )
&1
&0
&\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )\\
\ARdCb
&\ARdCc
&\ARdCd
&0
&0
&1
&\BRd\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{R_{3} - \left ( \ARdCb\right ) R_{1}}
\left ( \begin{array}{ccc|ccc|c}1
&\frac{\ARbCc}{\ARbCb}
&\frac{\ARbCd}{\ARbCb}
&\frac{1}{\ARbCb}
&0
&0
&\frac{\BRb}{\ARbCb}\\
0
&\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )
&\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )
&0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )
&1
&0
&\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )\\
0
&\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )
&\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )
&0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right )
&0
&1
&\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} R_{2}}
\left ( \begin{array}{ccc|ccc|c}1
&\frac{\ARbCc}{\ARbCb}
&\frac{\ARbCd}{\ARbCb}
&\frac{1}{\ARbCb}
&0
&0
&\frac{\BRb}{\ARbCb}\\
0
&1
&\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
&\frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
&\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
&0
&\frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\\
0
&\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )
&\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )
&0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right )
&0
&1
&\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{R_{3} - \left ( \ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )\right ) R_{2}}
\left ( \begin{array}{ccc|ccc|c}1
&\frac{\ARbCc}{\ARbCb}
&\frac{\ARbCd}{\ARbCb}
&\frac{1}{\ARbCb}
&0
&0
&\frac{\BRb}{\ARbCb}\\
0
&1
&\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
&\frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
&\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
&0
&\frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\\
0
&0
&\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb 
\right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left 
( \frac{\ARbCc}{\ARbCb}\right )}\right )
&0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb 
\right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{0 - \left (\ARcCb \right ) 
\left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )
&0 - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( 
\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )
&1
&\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb 
\right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\BRc - \left (\ARcCb \right ) 
\left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
\right )\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{\frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc 
- \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb 
\right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )}\right )} R_{3}}
\left ( \begin{array}{ccc|ccc|c}1
&\frac{\ARbCc}{\ARbCb}
&\frac{\ARbCd}{\ARbCb}
&\frac{1}{\ARbCb}
&0
&0
&\frac{\BRb}{\ARbCb}\\
0
&1
&\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right )}
&\frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )}
&\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
&0
&\frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right )}\\
0
&0
&1
&\frac{0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc 
- \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) 
- \left (\ARdCc - \left (\ARdCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}
&\frac{0 - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{1}{\ARcCc -
 \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}
{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd 
- \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}
&\frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}
{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}
&\frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc 
- \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) 
- \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) 
\left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{R_{2} - \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb 
\right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right ) R_{3}}
\left ( \begin{array}{ccc|ccc|c}1
&\frac{\ARbCc}{\ARbCb}
&\frac{\ARbCd}{\ARbCb}
&\frac{1}{\ARbCb}
&0
&0
&\frac{\BRb}{\ARbCb}\\
0
&1
&0
&\frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} 
- \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} 
\right ) \linebreak \left ( \frac{0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb 
\right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - 
\left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )
&\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{0 - \left (\ARdCc - \left (\ARdCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd 
- \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) 
\right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )}\right )}\right )
&0 - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )} \right ) \linebreak \left ( \frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb 
\right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc 
- \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )
&\frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} 
- \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )} \right ) \linebreak \left ( \frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb 
\right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - 
\left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - 
\left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )\\
0
&0
&1
&\frac{0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) 
\left ( \frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd 
- \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( 
\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}
&\frac{0 - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb 
\right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}
&\frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )}\right )}
&\frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) 
\right ) \left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )}\right )}\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{R_{1} - \left ( \frac{\ARbCd}{\ARbCb}\right ) R_{3}}
\left ( \begin{array}{ccc|ccc|c}1
&\frac{\ARbCc}{\ARbCb}
&0
&\frac{1}{\ARbCb} - \left (\frac{\ARbCd}{\ARbCb} \right ) \linebreak \left ( \frac{0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) - 
\left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( 
\frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )
&0 - \left (\frac{\ARbCd}{\ARbCb} \right ) \linebreak \left ( \frac{0 - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) 
\right ) \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( 
\frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd 
- \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )
&0 - \left (\frac{\ARbCd}{\ARbCb} \right ) \linebreak \left ( \frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) 
- \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( 
\frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )
&\frac{\BRb}{\ARbCb} - \left (\frac{\ARbCd}{\ARbCb} \right ) \linebreak \left ( \frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) 
- \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\BRc - \left (\ARcCb \right ) 
\left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) 
\left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd 
- \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )\\
0
&1
&0
&\frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} - 
\left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )} \right ) \linebreak \left ( \frac{0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right )
 \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb 
\right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - 
\left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )
&\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( 
\frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{0 
- \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - 
\left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )
&0 - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )
 - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) 
\left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )
&\frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )} - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) - 
\left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\BRc - \left (\ARcCb \right ) 
\left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - 
\left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) 
\right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )\\
0
&0
&1
&\frac{0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right ) \right ) \left ( \frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - 
\left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}
&\frac{0 - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{1}{\ARcCc - \left (\ARcCb 
\right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc 
- \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}
&\frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc 
- \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}
&\frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) 
\right ) \left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - 
\left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\end{array} \right )
\end{equation*}
\begin{equation*}
\xrightarrow{R_{1} - \left ( \frac{\ARbCc}{\ARbCb}\right ) R_{2}}
\left ( \begin{array}{ccc|ccc|c}1
&0
&0
&\frac{1}{\ARbCb} - \left (\frac{\ARbCd}{\ARbCb} \right ) \linebreak \left ( \frac{0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) 
- \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{0 - \left (\ARcCb \right ) \left ( 
\frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) 
\left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( 
\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )}\right )}\right ) - \left (\frac{\ARbCc}{\ARbCb} \right ) \linebreak \left ( \frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( 
\frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{0 
- \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) 
\right ) \left ( \frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - 
\left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )\right )
&0 - \left (\frac{\ARbCd}{\ARbCb} \right ) \linebreak \left ( \frac{0 - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right ) \right ) \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb 
\right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) 
\left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )}\right )}\right ) - \left (\frac{\ARbCc}{\ARbCb} \right ) \linebreak \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )} - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb 
\right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{0 - \left (\ARdCc - \left (\ARdCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd 
- \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) 
\right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )}\right )}\right )\right )
&0 - \left (\frac{\ARbCd}{\ARbCb} \right ) \linebreak \left ( \frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) 
- \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( 
\frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right ) - \left (\frac{\ARbCc}{\ARbCb} 
\right ) \linebreak \left ( 0 - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) 
- \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( 
\frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )\right )
&\frac{\BRb}{\ARbCb} - \left (\frac{\ARbCd}{\ARbCb} \right ) \linebreak \left ( \frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) 
- \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) 
- \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) 
\left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right ) - \left (\frac{\ARbCc}{\ARbCb} 
\right ) \linebreak \left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} 
- \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) 
\linebreak \left ( \frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) 
\right ) \left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) 
\right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
\right )}\right )\right )\\
0
&1
&0
&\frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} - \left (\frac{\ARcCd 
- \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( 
\frac{0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( 
\frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - 
\left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( 
\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )
&\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{0 - \left (\ARdCc - \left (\ARdCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - 
\left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( 
\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )
&0 - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} 
\right ) \linebreak \left ( \frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )
&\frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} - \left (
\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) 
\linebreak \left ( \frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right ) \right ) \left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )}\right )}\right )\\
0
&0
&1
&\frac{0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( 
\frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - 
\left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( 
\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}
&\frac{0 - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}
&\frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) 
\right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )}\right )}
&\frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) 
\left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd 
- \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( 
\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\end{array} 
\right )
\end{equation*}
\begin{equation*}
A^{-1} = \begin{pmatrix}\frac{1}{\ARbCb} - \left (\frac{\ARbCd}{\ARbCb} \right ) \linebreak \left ( \frac{0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) 
- \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc
 - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc -
 \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc -
 \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right ) - \left (\frac{\ARbCc}{\ARbCb} \right ) \linebreak \left ( \frac{0 - \left (\ARcCb \right )
 \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( 
\frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{0 - \left (\ARdCb \right ) 
\left ( \frac{1}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{0 - \left (\ARcCb \right )
 \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( 
\frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) 
\left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )\right )
&
0 - \left (\frac{\ARbCd}{\ARbCb} \right ) \linebreak \left ( \frac{0 - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( 
\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) -
 \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right ) - \left (\frac{\ARbCc}{\ARbCb} \right ) \linebreak \left ( 
\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{0 - \left (\ARdCc - \left (\ARdCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - 
\left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) 
\left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
\right )}\right )\right )
&
0 - \left (\frac{\ARbCd}{\ARbCb} \right ) \linebreak \left ( \frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc 
- \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}
{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right ) - \left (\frac{\ARbCc}{\ARbCb} \right ) \linebreak \left ( 0 - 
\left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} 
\right ) \linebreak \left ( \frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )\right )
\\\frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} - \left (
\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) 
\linebreak \left ( \frac{0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) 
\right ) \left ( \frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd 
- \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd 
- \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )
&
\frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{0 - \left (\ARdCc - \left (\ARdCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - 
\left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) 
\left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
\right )}\right )
&
0 - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} 
\right ) \linebreak \left ( \frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right ) \right
 ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}
\right )}\right )
\\\frac{0 - \left (\ARdCb \right ) \left ( \frac{1}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) 
\left ( \frac{0 - \left (\ARcCb \right ) \left ( \frac{1}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd 
- \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( 
\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}
&
\frac{0 - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{1}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb 
\right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}
&
\frac{1}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) 
\right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}
\right )}\right )}
\end{pmatrix}A^{-1}B = \begin{pmatrix}\frac{\BRb}{\ARbCb} - \left (\frac{\ARbCd}{\ARbCb} \right ) \linebreak \left ( \frac{\BRd - \left (\ARdCb \right ) 
\left ( \frac{\BRb}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\BRc - \left (\ARcCb 
\right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) 
\left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb 
\right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right ) - \left (\frac{\ARbCc}{\ARbCb}
 \right ) \linebreak \left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( 
\frac{\ARbCc}{\ARbCb}\right )} - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) 
\left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) - \left (\ARdCc
 - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{\ARcCc
 - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right ) - \left (\ARdCc
 - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc
 - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )\right )\\ \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}\right )}{
\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} - \left (\frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )}{\ARcCc
 - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )} \right ) \linebreak \left ( \frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}\right ) 
- \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}\right )
 - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\right )\\ \frac{\BRd - \left (\ARdCb \right ) \left ( \frac{\BRb}{\ARbCb}
\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\BRc - \left (\ARcCb \right ) \left ( \frac{\BRb}{
\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}{\ARdCd - \left (\ARdCb \right ) \left ( \frac{\ARbCd}{\ARbCb}
\right ) - \left (\ARdCc - \left (\ARdCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right ) \right ) \left ( \frac{\ARcCd - \left (\ARcCb \right ) \left ( \frac{\ARbCd}{
\ARbCb}\right )}{\ARcCc - \left (\ARcCb \right ) \left ( \frac{\ARbCc}{\ARbCb}\right )}\right )}\end{pmatrix}\end{equation*}
\end{document}




Here is a link to the pdf showing all of the work for the inverse of a
3x3 matrix:

https://drive.google.com/file/d/0B0MeMQmnEH6ackxsa1VSMmlIVDA/edit?usp=sharing

Back to Mike's Big Data, Data Mining, and Analytics Tutorial 

Inverse of a 4x4 Matrix

In my previous post
(http://mikemstech.blogspot.com/2014/07/c-matrix-inversion-with-latex-output.html)
I demonstrated an application that can generate the steps to show the
inversion of a matrix by Gauss Jordan elimination.

In a few posts, I plan to answer the following questions:
What is the inverse of a 1x1 Matrix?
What is the inverse of a 2x2 Matrix?
What is the inverse of a 3x3 Matrix?
What is the inverse of a 4x4 Matrix?

Back to Mike's Big Data, Data Mining, and Analytics Tutorial

The inverse of a 4x4 matrix is defined as follows. For a 4x4 matrix:

$$ \begin{pmatrix}a

&b

&c

&d

\\e

&f

&g

&h

\\i

&j

&k

&l

\\m

&n

&o

&p

\end{pmatrix}

$$

The inverse of the matrix simplifies to:

Row 1, Column 1:

$$\frac{f k p-f l o-g j p+g l n+h j o-h k n}{p (a f k-a g j-b e k+b g
i)-a f l o+a g l n+a h j o-a h k n+b e l o-b g l m-b h i o+b h k m+c (e
j p-e l n-f i p+f l m+h i n-h j m)+d (-e j o+e k n+f i o-f k m-g i n+g j
m)}$$

Row 1, Column 2:

$$ \frac{-b k p+b l o+c j p-c l n-d j o+d k n}{p (a f k-a g j-b e k+b g
i)-a f l o+a g l n+a h j o-a h k n+b e l o-b g l m-b h i o+b h k m+c (e
j p-e l n-f i p+f l m+h i n-h j m)+d (-e j o+e k n+f i o-f k m-g i n+g j
m)} $$

Row 1, Column 3

$$\frac{b g p-b h o-c f p+c h n+d f o-d g n}{p (a f k-a g j-b e k+b g
i)-a f l o+a g l n+a h j o-a h k n+b e l o-b g l m-b h i o+b h k m+c (e
j p-e l n-f i p+f l m+h i n-h j m)+d (-e j o+e k n+f i o-f k m-g i n+g j
m)}$$

Row 1, Column 4

$$ \frac{d g j - c h j - d f k + b h k + c f l - b g l}{b h k m - b g l m -
a h k n + a g l n - b h i o + a h j o + b e l o - a f l o +
d (g j m - f k m - g i n + e k n + f i o - e j o) + (b g i -
a g j - b e k + a f k) p +
c (-h j m + f l m + h i n - e l n - f i p + e j p)} $$

Row 2, Column 1

$$ \frac{-e k p+e l o+g i p-g l m-h i o+h k m}{p (a f k-a g j-b e k+b g
i)-a f l o+a g l n+a h j o-a h k n+b e l o-b g l m-b h i o+b h k m+c (e
j p-e l n-f i p+f l m+h i n-h j m)+d (-e j o+e k n+f i o-f k m-g i n+g j
m)} $$

Row 2, Column 2

$$ \frac{-d k m + c l m + d i o - a l o - c i p + a k p}{b h k m - b g l m -
a h k n + a g l n - b h i o + a h j o + b e l o - a f l o +
d (g j m - f k m - g i n + e k n + f i o - e j o) + (b g i -
a g j - b e k + a f k) p +
c (-h j m + f l m + h i n - e l n - f i p + e j p)} $$

Row 2, Column 3

$$ \frac{-a g p+a h o+c e p-c h m-d e o+d g m}{p (a f k-a g j-b e k+b g
i)-a f l o+a g l n+a h j o-a h k n+b e l o-b g l m-b h i o+b h k m+c (e
j p-e l n-f i p+f l m+h i n-h j m)+d (-e j o+e k n+f i o-f k m-g i n+g j
m)} $$

Row 2, Column 4

$$ \frac{a g l-a h k-c e l+c h i+d e k-d g i}{p (a f k-a g j-b e k+b g
i)-a f l o+a g l n+a h j o-a h k n+b e l o-b g l m-b h i o+b h k m+c (e
j p-e l n-f i p+f l m+h i n-h j m)+d (-e j o+e k n+f i o-f k m-g i n+g j
m)} $$

Row 3, Column 1

$$ \frac{e j p-e l n-f i p+f l m+h i n-h j m}{p (a f k-a g j-b e k+b g
i)-a f l o+a g l n+a h j o-a h k n+b e l o-b g l m-b h i o+b h k m+c (e
j p-e l n-f i p+f l m+h i n-h j m)+d (-e j o+e k n+f i o-f k m-g i n+g j
m)} $$

Row 3, Column 2

$$ \frac{-a j p+a l n+b i p-b l m-d i n+d j m}{p (a f k-a g j-b e k+b g
i)-a f l o+a g l n+a h j o-a h k n+b e l o-b g l m-b h i o+b h k m+c (e
j p-e l n-f i p+f l m+h i n-h j m)+d (-e j o+e k n+f i o-f k m-g i n+g j
m)} $$

Row 3, Column 3

$$ \frac{a f p-a h n-b e p+b h m+d e n-d f m}{p (a f k-a g j-b e k+b g
i)-a f l o+a g l n+a h j o-a h k n+b e l o-b g l m-b h i o+b h k m+c (e
j p-e l n-f i p+f l m+h i n-h j m)+d (-e j o+e k n+f i o-f k m-g i n+g j
m)} $$

Row 3, Column 4

$$ \frac{-a f l+a h j+b e l-b h i-d e j+d f i}{p (a f k-a g j-b e k+b g
i)-a f l o+a g l n+a h j o-a h k n+b e l o-b g l m-b h i o+b h k m+c (e
j p-e l n-f i p+f l m+h i n-h j m)+d (-e j o+e k n+f i o-f k m-g i n+g j
m)} $$

Row 4, Column 1

$$ \frac{-e j o+e k n+f i o-f k m-g i n+g j m}{p (a f k-a g j-b e k+b g
i)-a f l o+a g l n+a h j o-a h k n+b e l o-b g l m-b h i o+b h k m+c (e
j p-e l n-f i p+f l m+h i n-h j m)+d (-e j o+e k n+f i o-f k m-g i n+g j
m)} $$

Row 4, Column 2

$$ \frac{a j o-a k n-b i o+b k m+c i n-c j m}{p (a f k-a g j-b e k+b g
i)-a f l o+a g l n+a h j o-a h k n+b e l o-b g l m-b h i o+b h k m+c (e
j p-e l n-f i p+f l m+h i n-h j m)+d (-e j o+e k n+f i o-f k m-g i n+g j
m)} $$

Row 4, Column 3

$$ \frac{c f m - b g m - c e n + a g n + b e o - a f o}{b h k m - b g l m -
a h k n + a g l n - b h i o + a h j o + b e l o - a f l o +
d (g j m - f k m - g i n + e k n + f i o - e j o) + (b g i -
a g j - b e k + a f k) p +
c (-h j m + f l m + h i n - e l n - f i p + e j p)} $$

Row 4, Column 4

$$ \frac{-c f i + b g i + c e j - a g j - b e k + a f k}{b h k m - b g l m -
a h k n + a g l n - b h i o + a h j o + b e l o - a f l o +
d (g j m - f k m - g i n + e k n + f i o - e j o) + (b g i -
a g j - b e k + a f k) p +
c (-h j m + f l m + h i n - e l n - f i p + e j p)} $$


Back to Mike's Big Data, Data Mining, and Analytics Tutorial