Your SlideShare is downloading. ×
Codigo en java pdf
Codigo en java pdf
Codigo en java pdf
Codigo en java pdf
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Codigo en java pdf

5,015

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
5,015
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
197
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 2010 CODE IN JAVA FOR SIMPLE GAUSS BY:DUBAN CASTRO FLOREZ NUMERICS METHODS IN ENGINEERING PETROLEUM ENGINEERING
  • 2. ANEXOS 1 CODIGO DEL METODO EN JAVA package gauss; import javax.swing.JOptionPane; public class gauss { public static void main(String[] args) { JOptionPane.showMessageDialog(null,"SOLUCION DE ECUACIONES LINEALES POR EL METODO DE GAUSS"); int i,j,s,k,h,n; double d; double m[][]; double r[]; double x[]; //RECUERDE QUE EL NUMERO DE INCOGNITAS Y DE ECUACIONES DEBEN SER IGUALES n=Integer.parseInt(JOptionPane.showInputDialog("ingrese el numero de incognitas")); m= new double [n][n]; r= new double [n]; x= new double [n]; //RECUERDE QUE LA DIAGONAL PRINCIPAL DE LA MATRIZ DE COEFICIENTES NO PUEDE TENER CEROS for(i=0;i<=n-1;i++){ k=i+1;
  • 3. r[i]=Double.parseDouble(JOptionPane.showInputDialog("ingrese el elemento "+k+" del vector de soluciones")); x[i]=0; for(j=0;j<=n-1;j++){ h=j+1; m[i][j]=Double.parseDouble(JOptionPane.showInputDialog("ingrese el elemento "+k+h+" de la matriz de coeficientes")); } } //ESTE CICLO CONVIERTE LA TRIANGULAR INFERIOR EN CEROS for(i=0;i<n;i++){ for(j=i;j<n;j++){ if(i==j){ d=m[i][j]; for(s=0;s<n;s++){ m[i][s]=((m[i][s])/d); } r[i]=((r[i])/d); } else{ d=m[j][i]; for(s=0;s<n;s++){ m[j][s]=m[j][s]-(d*m[i][s]);
  • 4. } r[j]=r[j]-(d*r[i]); } } } //A CONTINUACION SE CALCULA EL VALOR DE LAS INCOGNITAS for(i=n-1;i>=0;i--){ double y=r[i]; for(j=n-1;j>=i;j--){ y=y-x[j]*m[i][j]; } x[i]=y; } for(i=0;i<n;i++){ k=i+1; JOptionPane.showMessageDialog(null,"el valor de la incognita x"+k+" es "+x[i]); } } }

×