66 lines
4.1 KiB
Markdown
66 lines
4.1 KiB
Markdown
|
---
|
||
|
title: Cramer's rule
|
||
|
id: 59713da0a428c1a62d7db430
|
||
|
challengeType: 5
|
||
|
videoUrl: ''
|
||
|
localeTitle: Regra de Cramer
|
||
|
---
|
||
|
|
||
|
## Description
|
||
|
<section id="description"><p> Na <a href="https://en.wikipedia.org/wiki/linear algebra" title="wp: álgebra linear">álgebra linear</a> , <a href="https://en.wikipedia.org/wiki/Cramer's rule" title="wp: regra de Cramer">a regra de Cramer</a> é uma fórmula explícita para a solução de um <a href="https://en.wikipedia.org/wiki/system of linear equations" title="wp: sistema de equações lineares">sistema de equações lineares</a> com tantas equações quanto as incógnitas, válidas sempre que o sistema tiver uma solução única. Ele expressa a solução em termos dos determinantes da matriz de coeficientes (quadrados) e das matrizes obtidas a partir dela substituindo uma coluna pelo vetor dos lados direitos das equações. </p><p> Dado </p><p><big></big></p><p> <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 & = {\ cor {vermelho} d_3} \ end {matrix} \ right. $</big> </p><p> que em formato de matriz é </p><p><big></big></p><p> <big>$ \ begin {bmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \ final {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> </p><p> Em seguida, os valores de $ x, y $ e $ z $ podem ser encontrados da seguinte forma: </p><p><big></big></p><p> <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 \ fim {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 \ final {vmatrix}}, \ text {e} z = \ frac {\ begin {vmatrix} a_1 & b_1 & {\ cor {vermelho} 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> </p> Tarefa <p> Dado o seguinte sistema de equações: </p><p> <big>$ \ begin {casos} 2w-x + 5y + z = -3 \\ 3w + 2x + 2y-6z = -32 \\ w + 3x + 3y-z = -47 \\ 5w-2x-3y + 3z = 49 \\ \ end {casos} $</big> </p><p> resolva por <big>$ w $, $ x $, $ y $</big> e <big>$ z $</big> , usando a regra de Cramer. </p></section>
|
||
|
|
||
|
## Instructions
|
||
|
<section id="instructions">
|
||
|
</section>
|
||
|
|
||
|
## Tests
|
||
|
<section id='tests'>
|
||
|
|
||
|
```yml
|
||
|
tests:
|
||
|
- text: <code>cramersRule</code> é uma função.
|
||
|
testString: 'assert(typeof cramersRule === "function", "<code>cramersRule</code> is a function.");'
|
||
|
- text: '<code>cramersRule([[2, -1, 5, 1], [3, 2, 2, -6], [1, 3, 3, -1], [5, -2, -3, 3]], [-3, -32, -47, 49])</code> deve retornar <code>[2, -12, -4, 1]</code> .'
|
||
|
testString: 'assert.deepEqual(cramersRule(matrices[0], freeTerms[0]), answers[0], "<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>.");'
|
||
|
- text: '<code>cramersRule([[3, 1, 1], [2, 2, 5], [1, -3, -4]], [3, -1, 2])</code> deve retornar <code>[1, 1, -1]</code> .'
|
||
|
testString: 'assert.deepEqual(cramersRule(matrices[1], freeTerms[1]), answers[1], "<code>cramersRule([[3, 1, 1], [2, 2, 5], [1, -3, -4]], [3, -1, 2])</code> should return <code>[1, 1, -1]</code>.");'
|
||
|
|
||
|
```
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Challenge Seed
|
||
|
<section id='challengeSeed'>
|
||
|
|
||
|
<div id='js-seed'>
|
||
|
|
||
|
```js
|
||
|
function cramersRule (matrix, freeTerms) {
|
||
|
// Good luck!
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
```
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
### After Test
|
||
|
<div id='js-teardown'>
|
||
|
|
||
|
```js
|
||
|
console.info('after the test');
|
||
|
```
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Solution
|
||
|
<section id='solution'>
|
||
|
|
||
|
```js
|
||
|
// solution required
|
||
|
```
|
||
|
</section>
|