<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<div class="PlainText">Da uma olhada neste site e verifique se os códigos te atendem.<br>
<br>
<a href="http://morotalab.org/Mrode2005/mme/mme.html#section0002">http://morotalab.org/Mrode2005/mme/mme.html#section0002</a><br>
<br>
Att.<br>
<br>
Tiago.<br>
<br>
Wecsley Prates <woprates@gmail.com> escreveu:<br>
<br>
</div>
<div>
<div dir="ltr">Olá a todos...
<div><br>
</div>
<div>Gostaria de saber se alguém tem o algoritmo do Método de Jacobi em linguagem do r para encontrar solução de equações lineares. Encontrei uma programação, mas está dando erro.</div>
<div><br>
</div>
<div>Essa programação me fornece um erro do tipo</div>
<div><br>
</div>
<div>
<div>Erro em a[i, j] <- a[i, j] - m * a[k, j] : </div>
<div>  substituto tem comprimento zero.</div>
</div>
<div><br>
</div>
<div>Como resolvo???</div>
<div><br>
</div>
<div>Agradeço a atenção</div>
<div><br>
</div>
<div>
<div>a = matriz dos coeficientes</div>
<div>b <- vetor das constantes</div>
<div>x <- chute inicial do vetor das variáveis</div>
<div><br>
</div>
<div>for (k in 1:length(x)-1){</div>
<div><br>
</div>
<div><span class="" style="white-space:pre"></span>for (i in k+1:length(x)){</div>
<div><br>
</div>
<div><span class="" style="white-space:pre"></span>m <- a[i,k]/a[k,k]</div>
<div><br>
</div>
<div><span class="" style="white-space:pre"></span>a[i,k] <- 0</div>
<div><span class="" style="white-space:pre"></span>for(j in k+1:length(x)){</div>
<div><br>
</div>
<div><span class="" style="white-space:pre"></span>a[i,j] <- a[i,j]-m*a[k,j]</div>
<div><br>
</div>
<div><span class="" style="white-space:pre"></span>b[i] <- b[i]-m*b[k]</div>
<div><span class="" style="white-space:pre"></span>}</div>
<div><span class="" style="white-space:pre"></span>}</div>
<div>}</div>
<div><br>
</div>
<div>x[length(x)] <- b[length(x)]/a[length(x),length(x)]</div>
<div><br>
</div>
<div>for (k in length(x)-1:1){</div>
<div><br>
</div>
<div><span class="" style="white-space:pre"></span>s <- 0</div>
<div><span class="" style="white-space:pre"></span>for (j in k+1:length(x)){</div>
<div><br>
</div>
<div><span class="" style="white-space:pre"></span>s <- s+a[k,j]*x[j]</div>
<div><span class="" style="white-space:pre"></span>}</div>
<div><span class="" style="white-space:pre"><br>
</span></div>
<div><span class="" style="white-space:pre"></span>x[k] <- (b[k]-s)/a[k,k]</div>
<div>}</div>
<div><br>
</div>
<div><br>
</div>
-- <br>
<div class="x_gmail_signature">
<div style="text-align:left"><b><i><font face="verdana, sans-serif"><font color="#000099"> </font><font color="#006600">                      <u><font size="4">Wecsley O. Prates</font></u></font></font></i></b></div>
<div style="text-align:left"><b><i><font face="verdana, sans-serif"><font color="#006600"><u><font size="4"><br>
</font></u></font></font></i></b></div>
<div style="text-align:left"><b><i><font color="#006600" face="verdana, sans-serif"><u>Doutorando em Estatística - Universidade Federal de Minas Gerais<br>
</u></font></i></b><span style="color:rgb(0,102,0); font-family:verdana,sans-serif"> </span></div>
<div><font color="#006600"><b><i></i></b> </font></div>
</div>
</div>
</div>
</div>
</body>
</html>