2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								title: Cramer's rule
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								id: 59713da0a428c1a62d7db430
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								challengeType: 5
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 09:17:33 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								forumTopicId: 302239
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Description
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< section  id = 'description' > 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-23 13:57:59 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								In < a  href = "https://en.wikipedia.org/wiki/linear algebra"  title = "wp: linear algebra"  target = "_blank" > linear algebra< / a > , < a  href = "https://en.wikipedia.org/wiki/Cramer's rule"  title = "wp: Cramer's rule"  target = "_blank" > Cramer's rule< / a >  is an explicit formula for the solution of a < a  href = "https://en.wikipedia.org/wiki/system of linear equations"  title = "wp: system of linear equations"  target = "_blank" > system of linear equations< / a >  with as many equations as unknowns, valid whenever the system has a unique solution. It expresses the solution in terms of the determinants of the (square) coefficient matrix and of matrices obtained from it by replacing one column by the vector of right hand sides of the equations.
							 
						 
					
						
							
								
									
										
										
										
											2019-02-25 13:36:09 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Given
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< big > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  $\left\{\begin{matrix}a_1x + b_1y + c_1z& = {\color{red}d_1}\\a_2x + b_2y + c_2z& = {\color{red}d_2}\\a_3x + b_3y + c_3z& = {\color{red}d_3}\end{matrix}\right.$
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								< / big > 
							 
						 
					
						
							
								
									
										
										
										
											2019-02-25 13:36:09 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								which in matrix format is
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< big > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  $\begin{bmatrix} a_1 &  b_1 &  c_1 \\ a_2 &  b_2 &  c_2 \\ a_3 &  b_3 &  c_3 \end{bmatrix}\begin{bmatrix} x \\ y \\ z \end{bmatrix}=\begin{bmatrix} {\color{red}d_1} \\ {\color{red}d_2} \\ {\color{red}d_3} \end{bmatrix}.$
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / big > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Then the values of $x, y$ and $z$ can be found as follows:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< big > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  $x = \frac{\begin{vmatrix} {\color{red}d_1} &  b_1 &  c_1 \\ {\color{red}d_2} &  b_2 &  c_2 \\ {\color{red}d_3} &  b_3 &  c_3 \end{vmatrix} } { \begin{vmatrix} a_1 &  b_1 &  c_1 \\ a_2 &  b_2 &  c_2 \\ a_3 &  b_3 &  c_3 \end{vmatrix}}, \quad y = \frac {\begin{vmatrix} a_1 &  {\color{red}d_1} &  c_1 \\ a_2 &  {\color{red}d_2} &  c_2 \\ a_3 &  {\color{red}d_3} &  c_3 \end{vmatrix}} {\begin{vmatrix} a_1 &  b_1 &  c_1 \\ a_2 &  b_2 &  c_2 \\ a_3 &  b_3 &  c_3 \end{vmatrix}}, \text{ and }z = \frac { \begin{vmatrix} a_1 &  b_1 &  {\color{red}d_1} \\ a_2 &  b_2 &  {\color{red}d_2} \\ a_3 &  b_3 &  {\color{red}d_3} \end{vmatrix}} {\begin{vmatrix} a_1 &  b_1 &  c_1 \\ a_2 &  b_2 &  c_2 \\ a_3 &  b_3 &  c_3 \end{vmatrix} }.$
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / big > 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-01 17:10:50 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								< / section > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Instructions
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< section  id = 'instructions' > 
							 
						 
					
						
							
								
									
										
										
										
											2019-02-25 13:36:09 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Given the following system of equations:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< big > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  $\begin{cases}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  2w-x+5y+z=-3 \\
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  3w+2x+2y-6z=-32 \\
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  w+3x+3y-z=-47 \\
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  5w-2x-3y+3z=49 \\
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  \end{cases}$
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / big > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								solve for < big > $w$, $x$, $y$< / big >  and < big > $z$< / big > , using Cramer's rule.
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								< / section > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Tests
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< section  id = 'tests' > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```yml
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								tests:
							 
						 
					
						
							
								
									
										
										
										
											2019-11-20 07:01:31 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  -  text: < code > cramersRule</ code >  should be a function.
							 
						 
					
						
							
								
									
										
										
										
											2019-07-26 05:24:52 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    testString: assert(typeof cramersRule === 'function');
							 
						 
					
						
							
								
									
										
										
										
											2018-10-20 21:02:47 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  -  text: < code > cramersRule([[2, -1, 5, 1], [3, 2, 2, -6], [1, 3, 3, -1], [5, -2, -3, 3]], [-3, -32, -47, 49])</ code >  should return < code > [2, -12, -4, 1]</ code > .
							 
						 
					
						
							
								
									
										
										
										
											2019-07-26 05:24:52 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    testString: assert.deepEqual(cramersRule(matrices[0], freeTerms[0]), answers[0]);
							 
						 
					
						
							
								
									
										
										
										
											2018-10-20 21:02:47 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  -  text: < code > cramersRule([[3, 1, 1], [2, 2, 5], [1, -3, -4]], [3, -1, 2])</ code >  should return < code > [1, 1, -1]</ code > .
							 
						 
					
						
							
								
									
										
										
										
											2019-07-26 05:24:52 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    testString: assert.deepEqual(cramersRule(matrices[1], freeTerms[1]), answers[1]);
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / section > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Challenge Seed
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< section  id = 'challengeSeed' > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< div  id = 'js-seed' > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
									
										
										
										
											2019-02-26 17:07:07 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function cramersRule(matrix, freeTerms) {
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  // Good luck!
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  return true;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								### After Test
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< div  id = 'js-teardown' > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
									
										
										
										
											2018-10-20 21:02:47 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const matrices = [
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  [
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [2, -1, 5, 1],
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [3, 2, 2, -6],
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [1, 3, 3, -1],
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [5, -2, -3, 3]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  ],
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  [
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [3, 1, 1],
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [2, 2, 5],
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [1, -3, -4]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const freeTerms = [[-3, -32, -47, 49], [3, -1, 2]];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const answers = [[2, -12, -4, 1], [1, 1, -1]];
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / section > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Solution
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< section  id = 'solution' > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								/**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Compute Cramer's Rule
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @param   {array} matrix    x,y,z, etc. terms
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @param   {array} freeTerms
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @return  {array}           solution for x,y,z, etc.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function cramersRule(matrix, freeTerms) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  const det = detr(matrix);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  const returnArray = [];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  let i;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  for (i = 0; i <  matrix [ 0 ] . length ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const tmpMatrix = insertInTerms(matrix, freeTerms, i);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    returnArray.push(detr(tmpMatrix) / det);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  return returnArray;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								/**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Inserts single dimensional array into
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @param   {array} matrix multidimensional array to have ins inserted into
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @param   {array} ins single dimensional array to be inserted vertically into matrix
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @param   {array} at  zero based offset for ins to be inserted into matrix
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @return  {array}     New multidimensional array with ins replacing the at column in matrix
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function insertInTerms(matrix, ins, at) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  const tmpMatrix = clone(matrix);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  let i;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  for (i = 0; i <  matrix.length ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    tmpMatrix[i][at] = ins[i];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  return tmpMatrix;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								/**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Compute the determinate of a matrix.  No protection, assumes square matrix
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  function borrowed, and adapted from MIT Licensed numericjs library (www.numericjs.com)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @param   {array} m Input Matrix (multidimensional array)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @return  {number}   result rounded to 2 decimal
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function detr(m) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  let ret = 1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  let j;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  let k;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  const A = clone(m);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  const n = m[0].length;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  let alpha;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  for (j = 0; j <  n  -  1 ;  j + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    k = j;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for (let i = j + 1; i <  n ;  i + + )  {  if  ( Math . abs ( A [ i ] [ j ] )  >  Math.abs(A[k][j])) { k = i; } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if (k !== j) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const temp = A[k]; A[k] = A[j]; A[j] = temp;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      ret *= -1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const Aj = A[j];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for (let i = j + 1; i <  n ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const Ai = A[i];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      alpha = Ai[j] / Aj[j];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      for (k = j + 1; k <  n  -  1 ;  k  + =  2 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const k1 = k + 1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        Ai[k] -= Aj[k] * alpha;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        Ai[k1] -= Aj[k1] * alpha;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      if (k !== n) { Ai[k] -= Aj[k] * alpha; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if (Aj[j] === 0) { return 0; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ret *= Aj[j];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  return Math.round(ret * A[j][j] *  100) / 100;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								/**
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Clone two dimensional Array using ECMAScript 5 map function and EcmaScript 3 slice
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @param   {array} m Input matrix (multidimensional array) to clone
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @return  {array}   New matrix copy
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function clone(m) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  return m.map(a => a.slice());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / section >