banner.gif
On-Line Computer Graphics Notes
CRAMER'S RULE


Overview

Cramer's Rule is a determinant-based procedure utilized to solve systems of equations. In these notes we first discuss Cramer's Rule for systems of three linear equations with three unknowns and then state Cramer's rule for general systems of equations.


Cramer's Rule - Three Equations, Three Unknowns

Given a system of three linear equations, with three unknowns,

$\displaystyle d_1$ $\displaystyle = a_1 x + b_1 y + c_1 z$    
$\displaystyle d_2$ $\displaystyle = a_2 x + b_2 y + c_2 z$    
$\displaystyle d_3$ $\displaystyle = a_3 x + b_3 y + c_3 z$    

Cramer's rule helps us solve these equations by using four determinants. If we define $ D$ to be the determinant defined by

$\displaystyle D \: = \:
\left\vert
\begin{array}{ccc}
a_1 & a_2 & a_3 \\
b_1 & b_2 & b_3 \\
c_1 & c_2 & c_3
\end{array}\right\vert
$

and define the determinants $ D_1$, $ D_2$ and $ D_3$, to be

$\displaystyle D_1 \: = \:
\left\vert
\begin{array}{ccc}
d_1 & d_2 & d_3 \\
b_1 & b_2 & b_3 \\
c_1 & c_2 & c_3
\end{array}\right\vert
$

$\displaystyle D_2 \: = \:
\left\vert
\begin{array}{ccc}
a_1 & a_2 & a_3 \\
d_1 & d_2 & d_3 \\
c_1 & c_2 & c_3
\end{array}\right\vert
$

$\displaystyle D_3 \: = \:
\left\vert
\begin{array}{ccc}
a_1 & a_2 & a_3 \\
b_1 & b_2 & b_3 \\
d_1 & d_2 & d_3
\end{array}\right\vert
$

respectively, then Cramer's rule states that the solution $ (x,y,z)$ to the system of equations is given by

$\displaystyle x$ $\displaystyle = \frac{D_1}{D}$   ,    
$\displaystyle y$ $\displaystyle = \frac{D_2}{D}$   , and    
$\displaystyle z$ $\displaystyle = \frac{D_3}{D}$   .    

The determinants are easily generated since the columns of $ D$ are just the coefficients of $ x$, $ y$ and $ z$ respectively from the linear system and $ D_i$ is produced by replacing the $ i$th row by the row $ \left[ \begin{array}{ccc} d_1 & d_2 & d_3 \end{array} \right]$


Example

Suppose we are given a point $ {\bf P} $ in space and a frame $ {\cal F} = ( {\vec u} , {\vec v} , {\vec w} , {\bf O} )$. with

$\displaystyle {\bf P} = u {\vec u} + v {\vec v} + w {\vec w} + {\bf O}
$

and suppose we wish to find the coefficients $ (u,v,w)$. Now, $ < {\bf P} - {\bf O} > $ is a vector, and so we can write down the equations

$\displaystyle x_{po}$ $\displaystyle = x_u u + x_v v + x_w w$    
$\displaystyle y_{po}$ $\displaystyle = y_u u + y_v v + y_w w$    
$\displaystyle z_{po}$ $\displaystyle = z_u u + z_v v + z_w w$    

where $ <x_{po},y_{po},z_{po}>$ are the coordinates of $ < {\bf P} - {\bf O} > $, $ <x_u,y_u,z_u>$ is the representation of $ {\vec u} $, $ <x_v,y_v,z_v>$ is the representation of $ {\vec v} $ and $ <x_w,y_w,z_w>$ is the representation of $ {\vec w} $. By Cramer's Rule, we can solve this by defining the following four determinants

$\displaystyle D \: = \:
\left\vert
\begin{array}{ccc}
x_u & y_u & z_u \\
x_v & y_v & z_v \\
x_w & y_w & z_w
\end{array}\right\vert
$

$\displaystyle D_1 \: = \:
\left\vert
\begin{array}{ccc}
x_{po} & y_{po} & z_{po} \\
x_v & y_v & z_v \\
x_w & y_w & z_w
\end{array}\right\vert
$

$\displaystyle D_2 \: = \:
\left\vert
\begin{array}{ccc}
x_u & y_u & z_u \\
x_{po} & y_{po} & z_{po} \\
x_w & y_w & z_w
\end{array}\right\vert
$

$\displaystyle D_3 \: = \:
\left\vert
\begin{array}{ccc}
x_u & y_u & z_u \\
x_v & y_v & z_v \\
x_{po} & y_{po} & z_{po}
\end{array}\right\vert
$

and then calculating

$\displaystyle u$ $\displaystyle = \frac{D_1}{D}$    
$\displaystyle v$ $\displaystyle = \frac{D_2}{D}$    
$\displaystyle w$ $\displaystyle = \frac{D_3}{D}$    


The Homogeneous Case

Given a system of three linear equations with three unknowns,

$\displaystyle d_1$ $\displaystyle = a_1 x + b_1 y + c_1 z$    
$\displaystyle d_2$ $\displaystyle = a_2 x + b_2 y + c_2 z$    
$\displaystyle d_3$ $\displaystyle = a_3 x + b_3 y + c_3 z$    

the system is called homogeneous if $ d_1 = d_2 = d_3 = 0$. In this case, if $ D \not = 0$, then Cramer's rule above gives the solution $ x = y = z = 0$ - the trivial solution. However, if $ D = 0$, then the rank of the coefficient matrix is less than 3, and the system will have non-trivial solutions.


The Example without Determinants

If we look closely at the determinants in the above example, we can see that they can actually be expressed in terms of the vectors $ {\vec u} $, $ {\vec v} $, $ {\vec w} $, and $ < {\bf P} - {\bf O} > $. In particular,

$\displaystyle D$ $\displaystyle = {\vec u} \cdot ( {\vec v} \times {\vec w} ),$    
$\displaystyle D_1$ $\displaystyle = < {\bf P} - {\bf O} > \cdot ( {\vec v} \times {\vec w} ),$    
$\displaystyle D_2$ $\displaystyle = {\vec u} \cdot ( < {\bf P} - {\bf O} > \times {\vec w} ) \: {\rm and}$    
$\displaystyle D_3$ $\displaystyle = {\vec u} \cdot ( {\vec v} \times < {\bf P} - {\bf O} > )$    

So in three dimensions, we can ignore the determinants and utilize dot and cross products.


If Everything is Nice

It is worth looking at the vector-based Cramer's rule one more time for the case when the frame $ {\cal F} =( {\vec u} , {\vec v} , {\vec w} , {\bf O} )$ is orthonormal. If the vectors are all mutually perpendicular and of unit length then the above equations simplify significantly . In particular, if we assume that

$\displaystyle {\vec u}$ $\displaystyle = {\vec v} \times {\vec w}$    
$\displaystyle {\vec v}$ $\displaystyle = {\vec w} \times {\vec u}$    
$\displaystyle {\vec w}$ $\displaystyle = {\vec u} \times {\vec v}$    

which is the case in a right-handed orthonormal system, we have

$\displaystyle D$ $\displaystyle = {\vec u} \cdot ( {\vec v} \times {\vec w} )$    
  $\displaystyle = {\vec u} \cdot {\vec u}$    
  $\displaystyle = 1$    

$\displaystyle D_1$ $\displaystyle = < {\bf P} - {\bf O} > \cdot ( {\vec v} \times {\vec w} )$    
  $\displaystyle = < {\bf P} - {\bf O} > \cdot {\vec u}$    

$\displaystyle D_2$ $\displaystyle = {\vec u} \cdot ( < {\bf P} - {\bf O} > \times {\vec w} )$    
  $\displaystyle = - {\vec u} \cdot ( {\vec w} \times < {\bf P} - {\bf O} > )$    
  $\displaystyle = -( {\vec u} \times {\vec w} ) \cdot < {\bf P} - {\bf O} >$    
  $\displaystyle = ( {\vec w} \times {\vec u} ) \cdot < {\bf P} - {\bf O} >$    
  $\displaystyle = < {\bf P} - {\bf O} > \cdot {\vec v}$    

$\displaystyle D_3$ $\displaystyle = {\vec u} \cdot ( {\vec v} \times < {\bf P} - {\bf O} > )$    
  $\displaystyle = ( {\vec u} \times {\vec v} ) \times < {\bf P} - {\bf O} >$    
  $\displaystyle = < {\bf P} - {\bf O} > \cdot {\vec w}$    

So in an orthonormal frame, we only need dot products to calculate the determinants.

$\displaystyle D$ $\displaystyle = 1$    
$\displaystyle D_1$ $\displaystyle = < {\bf P} - {\bf O} > \cdot {\vec u}$    
$\displaystyle D_2$ $\displaystyle = < {\bf P} - {\bf O} > \cdot {\vec v}$    
$\displaystyle D_3$ $\displaystyle = < {\bf P} - {\bf O} > \cdot {\vec w}$    

No cross products are required.


The General Cramer's Rule

Given a system of $ n$ linear equations

$\displaystyle a_{11} x_1 + a_{12} x_2 + \cdots + a_{1n} x_n$ $\displaystyle = b_1$    
$\displaystyle a_{21} x_1 + a_{22} x_2 + \cdots + a_{2n} x_n$ $\displaystyle = b_2$    
  $\displaystyle \vdots$    
$\displaystyle a_{n1} x_1 + a_{n2} x_2 + \cdots + a_{nn} x_n$ $\displaystyle = b_n$    

If the determinant $ D$ of the coefficient matrix is not zero then the system has precisely one solution. This solution is given by the formulas

$\displaystyle x_1$ $\displaystyle = \frac{D_1}{D}$    
$\displaystyle x_2$ $\displaystyle = \frac{D_2}{D}$    
  $\displaystyle \vdots$    
$\displaystyle x_n$ $\displaystyle = \frac{D_n}{D}$    

where $ D_k$ is the determinant obtained from $ D$ by replacing the $ k$th row of $ D$ by the row with the entries

$\displaystyle \left[
\begin{array}{cccc}
b_1 & b_2 & \cdots & b_n
\end{array}\right]
$

Also, if the system is homogeneous and $ D \not = 0$, then it has only the trivial solution $ x_1 = x_2 = \cdots = x_n = 0$. If $ D = 0$, the homogeneous system has nontrivial solutions.


Bibliography

1
KREYSZIG, E.
Advanced Engineering Mathematics.
John Wiley and Sons, New York, NY, 1988.
ISBN 0-471-85824-2.


Return to the Graphics Notes Home Page
Return to the Geometric Modeling Notes Home Page
Return to the UC Davis Visualization and Graphics Group Home Page


This document maintained by Ken Joy

Mail us your comments

All contents copyright (c) 1996, 1997, 1998, 1999
Computer Science Department
University of California, Davis

All rights reserved.


Ken Joy
1999-12-06