#include<stdio.h>
#include<conio.h>
#include<math.h>
void main(void)
{
int matrix;
printf ("Press 1 for eigen values of 2 X 2 Matrix\n");
printf ("Press 2 for eigen values of 3 X 3 Matrix\n");
scanf ("%d",&matrix);
printf("\t\n");
switch(matrix)
{ case 1:
int a,b,c,d;
printf ("Enter the values of Matrix\n");
scanf("%d",&a);
scanf("%d",&b);
printf("\n");
scanf("%d",&c);
scanf("%d",&d);
printf("\t\n");
int l,l1;
l=((a+d)+sqrt((a+d)*(a+d)-4*((a*d)-(b*c))))/2;
l1=((a+d)-sqrt((a+d)*(a+d)-4*((a*d)-(b*c))))/2;
printf("The First Eigen Value is %d\n",l);
printf("The Second Eigen Value is %d\n",l1);
break;
case 2:
int a1,b1,c1,d1,e1,f1,g1,h1,i1;
printf("Enter the values of Matrix\n");
scanf("%d\n",&a1);
scanf("%d\n",&b1);
scanf("%d",&c1);
printf("\n");
scanf("%d\n",&d1);
scanf("%d\n",&e1);
scanf("%d",&f1);
printf("\n");
scanf("%d\n",&g1);
scanf("%d\n",&h1);
scanf("%d" ,&i1);
printf("\n");
int p,q,r;
p = a1+e1+i1;
q = -(a1*e1)-(a1*i1)-(e1*i1)-(f1*h1)+(b1*d1)+(c1*g1);
r = (a1*e1*i1)-(a1*f1*h1)-(b1*d1*i1)+(b1*f1*g1)+(c1*d1*h1)-(c1*g1*e1);
int l2,l3,l4;
l2 = r;
l3 = ( p + sqrt(p*p+ 4*(q+r) ) )/2;
l4 = ( p - sqrt(p*p+ 4*(q+r) ) )/2;
printf(" First Eigen Value is %d\n",l2 );
printf(" Second Eigen Value is %d\n",l3 );
printf(" Third Eigen Value is %d\n",l4 );
break;
default:
printf("You Are Supposed To Enter the Values from 1 & 2 only");
break;
}
}
To derive eigen values and eigen vectors for matrix upto order of 5*5
Page 1 of 1
To derive eigen values and eigen vectors for matrix upto order of 5*5 Source code Should be in C language
#1
Posted 25 February 2007 - 02:46 PM
I want to derive a program that calculates the eigen values and vectors for matrix upto order of 5 X 5. But im not finding a general program and i have to use the switch statement that makes my program extremely lengthy and also it is very difficult to solve it for 5 X 5 matrix. Here is my work.
#2
Posted 25 February 2007 - 09:47 PM
Ok I am sorry a never got arround to an example of converting a matrix to an upper triangular matrix. Here is some information on the subject from a ver good book "Numerical Recipes in C: The Art of Scientific Computing" This book is a great resource. (I miss the school library).
You want to look at chapter 11: here is the link. The book covers matrix methods in earlier chapters.
Basicly the process is not very hard and it can be automated to different size matricies. The problem comes in solving the resultant equations, which can be done with other numeric methods such as bisection and newtons method.
You want to look at chapter 11: here is the link. The book covers matrix methods in earlier chapters.
Basicly the process is not very hard and it can be automated to different size matricies. The problem comes in solving the resultant equations, which can be done with other numeric methods such as bisection and newtons method.
Page 1 of 1

Start a new topic
Add Reply




MultiQuote


| 


