Problema: resolver un sistema de ecuaciones lineales a11x1 + a12x a1nxn = b1 a21x1 + a22x a2nxn = b an1x1.

Slides:



Advertisements
Similar presentations
For(int i = 1; i
Advertisements

RECTAS EN EL ESPACIO. Algebra lineal Rectas en el espacio.
Matlab ones(1,5); % zeros(1,5); % :5; % :2:9; % linspace(0,1,5) ; %
MÉTODO DE GAUSS SISTEMAS DE ECUACIONES LINEALES Tema 3.6 * 1º BCS.
Unidad 1: ECUACIONES DIFERENCIALES DE PRIMER ORDEN
Ecuaciones diferenciales
 O: order of magnitude  Look at the loops and to see whether the loops are nested. ◦ One single loop: O(n) ◦ A nested loop: O(n 2 ) ◦ A nested loop.
Rational Numbers Conversion. Warm-Up Some students were asked to choose methods that make learning subjects more interesting. The results are shown. MethodNumber.
1/03/09 De 89 à 98. 1/03/09 De 89 à 98 1/03/09 De 89 à 98.
Ejemplo 4 Modificar el servlet contador de modo de generar una respuesta que muestre la IP de todos los computadores que lo han contactado hasta ahora.
1 More on Decisions Overview l The selection Operator l Grouping of Statements l Multiple branches (if else if) l Switch Statement.
Using Processing Stream. Predefined Streams System.in InputStream used to read bytes from the keyboard System.out PrintStream used to write bytes to the.
Minnet (=stacken) public static int fac(int n) { if (n == 0) return 1; else return fac(n-1) * n; }..... main(String [] a) { int x; x = fac(3); System.out.println(x);
1 2-D Arrays Overview l Why do we need Multi-dimensional array l 2-D array declaration l Accessing elements of a 2-D array l Declaration using Initializer.
Unit 191 Recursion General Algorithm for Recursion When to use and not use Recursion Recursion Removal Examples Comparison of the Iterative and Recursive.
1 More on 1-D Arrays Overview l Array as a return type to methods l Array of Objects.
String Tokenization What is String Tokenization?
1 Dynamic Arrays  Why Dynamic Arrays?  A Dynamic Array Implementation  The Vector Class  Program Example  Array Versus Vector.
Client/Server example. Server import java.io.*; import java.net.*; import java.util.*; public class PrimeServer { private ServerSocket sSoc; public static.
Unit 171 Algorithms and Problem Solving - II Algorithm Efficiency Primality Testing Improved Primality Testing Sieve of Eratosthenes Primality Testing.
SELECTION CSC 171 FALL 2004 LECTURE 8. Sequences start end.
1 Methods Overview l Closer Look at Methods l Parameter passing l Passing parameters by value l Passing parameters by reference.
1 Introduction to Console Input  Primitive Type Wrapper Classes  Converting Strings to Numbers  System.in Stream  Wrapping System.in in a Buffered.
Slides prepared by Rose Williams, Binghamton University Chapter 11 Recursion.
1 Search & Sorting Using Java API Searching and Sorting Using Standard Classes  Searching data other than primitive type.  Comparable interface.  Implementing.
1 Parameter Passing Revisited Overview l Parameter passing l Passing parameters by value l Passing parameters by reference l Some Examples l Preview: Introduction.
1 More on 1-D Array Overview l Array as a return type to methods l Array of Objects l Array Cloning l Preview: 2-D Arrays.
5 th Jeopardy Cap. 7 Multiplicar un decimal por un número entero Multiplicar un decimal por un decimal Dividir un decimal por un número entero Dividir.
Gauss-Seidel Jacobi Radio espectral Valor de k Gauss-Seidel vs. Jacobi.
Solución 3 (más natural) static public int mayor(int x, int y) { if( x > y ) return x; else return y; } ¿Significado? si x es mayor que y, entonces entregar.
Saravanan.G.
Department of Computer Engineering Recursive Problem Solving Computer Programming for International Engineers.
Two Ways to Store Data in a File Text format Binary format.
Linear Systems Gaussian Elimination CSE 541 Roger Crawfis.
From C++ to Java A whirlwind tour of Java for C++ programmers.
1 StringTokenization Overview l StringTokenizer class l Some StringTokenizer methods l StringTokenizer examples.
Public class Edo1 { private static double euler(double y, double h, double t, Derivada d) { return y + h * d.f(y, t); } public static void euler(double.
ICBT  Basura Ramanayaka  Eshani werapitiya  Hasitha Dananjaya.
State Design Pattern. Behavioral Pattern Allows object to alter its behavior when internal state changes Uses Polymorphism to define different behaviors.
S ystem P rogrammers' A ssociation for R esearching C omputer S ystems 4. Controlling Execution SPARCS JAVA Study.
CSI 3125, Preliminaries, page 1 Java I/O. CSI 3125, Preliminaries, page 2 Java I/O Java I/O (Input and Output) is used to process the input and produce.
Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have 45 – 90 seconds per question. Determine the output.
LOGO 형식언어와 오토마타 컴퓨터 공학부 4 학년 서정태
CSCI 1100/1202 January 23, Class Methods Some methods can be invoked through the class name, instead of through an object of the class These methods.
CiS 260: App Dev I. 2 Introduction to Arrays n An array is an object that contains a collection of components (_________) of the same data type. n For.
Another example of input import java.io.*; //import java.lang.Integer.*; class ExampleofInput2 { private static BufferedReader stdin = new BufferedReader(
Output Programs These slides will present a variety of small programs. Each program has a compound condition which uses the Boolean Logic that was introduced.
生产者一级消费者 二级消费者 1 、写出花坛中有可能出现的食物链,并用 连接植物、动物名 称 2 、试一试, 还可以怎样写, 来表示它们之间的关系呢 ?
。 33 投资环境 3 开阔视野 提升竞争力 。 3 嘉峪关市概况 。 3 。 3 嘉峪关是一座新兴的工业旅游城市,因关得名,因企设市,是长城文化与丝路文化交 汇点,是全国唯一一座以长城关隘命名的城市。嘉峪关关城位于祁连山、黑山之间。 1965 年建市,下辖雄关区、镜铁区、长城区, 全市总面积 2935.
DEFINITION OF A CIRCLE and example
Chapter 2 Clarifications
יסודות מדעי המחשב – תרגול 3
using System; namespace Demo01 { class Program
Math and String Examples
SOLVING EQUATIONS USING DETERMINANTS
Functions that Deal with Arrays CS 1111 Ryan Layer Feb 23, 2010
Guías Modulares de Estudio Cálculo integral B. Semana 1: La integral.
ECUACIONES LOGARITMICAS Para resolver ecuaciones logarítmicas vamos a tener en cuenta: 1Las propiedades de los logaritmos En las ecuaciones.
¿Qué es un número decimal? Son aquellos números que poseen una parte decimal. Se reconocen por la presencia de un signo llamado COMA decimal (, ) que.
Decision statements. - They can use logic to arrive at desired results
Operators Laboratory /11/16.
References and Objects
class PrintOnetoTen { public static void main(String args[]) {
Scope of variables class scopeofvars {
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Consider the following code:
State Design Pattern.
Escribir con palabras de transición
Instructor: Mainak Chaudhuri
Presentation transcript:

Problema: resolver un sistema de ecuaciones lineales a11x1 + a12x2 + ... + a1nxn = b1 a21x1 + a22x2 + ... + a2nxn = b2 . . . an1x1 + an2x2 + ... + annxn = bn import java.io.*; class Ecuaciones { static public void main(String[] args)throws IOException{ System.out.print("Numero de ecuaciones?"); BufferedReader I = new BufferedReader( new InputStreamReader(System.in)); int n = Integer.parseInt(I.readLine()); double[][] a = new double[n][n]; double[] b = new double[n];

//Lectura de los coeficientes y las soluciones for(int i=0; i<n; ++i){ System.out.println("Ecuacion " + (i+1) + " :"); for(int j=0; j<n; ++j){ System.out.print("a(" + (i+1) + "," + (j+1) + ") ? "); a[i][j] = Integer.parseInt(I.readLine()); } System.out.print("b(" + (i+1) + ") ? "); b[i] = Integer.parseInt(I.readLine());

//llamada a método para triangularizar matriz de coeficientes triangularizar(a,b,n); //calculo de resultados double[] x = new double[n]; for(int i=n-1; i>=0; --i){ double suma = 0; for(int j=i+1; j<n; ++j) suma += x[j]*a[i][j]; x[i] = (b[i]-suma)/a[i][i]; System.out.println("x(" + (i+1) + ") = " + x[i]); } } // main

static public void triangularizar(double[][]a, double[]b, int n){ for(int i=0; i<n; ++i){ //dividir fila i por primero de fila i double primero = a[i][i]; for(int j=i; j<n; ++j) a[i][j] /= primero; b[i] /= primero; //fila j = fila j - fila i * primero de fila j for(int j=i+1; j<n; ++j){ primero = a[j][i]; for(int k=i; k<n; ++k) a[j][k] -= a[i][k]*primero; b[j] -= b[i]*primero; } } // class Ecuaciones