Está en la página 1de 2

ALGORITMO DEL METODO DE JACOBI

import java.io.*;
public class jacobi {
public static void main (String[] args) {
double x1=0, x2=0, x3=0, tope1=0.1, tope2=0.1, tope3=0.1;
double x11,x21,x31;
double errorabsx1,errorabsx2,errorabsx3;
int numero=0;
while(tope1>=0.0001 && tope2>=0.0001 && tope3>=0.0001){
numero++;
System.out.println ("*** Iteracion "+numero+" ***");
x11=0.25*x2+0.25;
x21=0.25*x3+0.25;
x31=0.25*x2+0.25;
System.out.println ("Valoresde raices: x1: "+x11+" x2: "+x21+"
x3: "+x31);
errorabsx1=x11-x1;
if(errorabsx1>0){

tope1 = errorabsx1; }

else if(errorabsx1<0){

tope1 = errorabsx1*(-1);

errorabsx2=x21-x2;
if(errorabsx2>0){

tope2 = errorabsx2; }

else if(errorabsx2<0){

tope2 = errorabsx2*(-1);

errorabsx3=x31-x3;
if(errorabsx3>0){

tope3 = errorabsx3; }

else if(errorabsx3<0){

tope3 = errorabsx3*(-1);

System.out.println ("Errores absolutos x1: "+errorabsx1+" x2:


"+errorabsx2+" x3: "+errorabsx3);
x1=x11;
x2=x21;
x3=x31;

}
}
}

También podría gustarte