Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 27

INDEX

S.NO. EXPERIMENT DATE REMARKS


1. W.A.P. to solve a set of simultaneous -
linear equation using Gauss Elimination
Method.

2. W.A.P. to formulate y bus by a non-singular


transformation y bus=[A]t[Y][A]
where t= Transpose of matrix A

3. W.A.P. to do the following mathematical


operation
(1) Transpose of a matrix
(2) Multiplication of two matrices
(3) Addition of two matrices
(4) Subtraction of two matrices.

4. W.A.P. to make element node incidence


matrix and convert it into y bus incidence
matrix A by choosing any bus as reference.

5. W.A.P. to find the solution of the


following equation using gauss seidel
method.

6. W.A.P. to compute the system demand


from 1990 t0 2008 on yearly basis. Also
calculates average yearly demand over
this period.
ALGORITHM:1

OBJECTIVE:-
Develop a program to solve a set of four simultaneous linear
equation using Gaussian elimination

Algorithm:-

(1) enter the equation in the form of ax+by+cz

(2) enter the cofficient of x,y,z

(3) check ifa[0][0]=0

(4) if yes than first valve of x is 0.

(5) r=a[i][0]/a[0][0]

(6) a[1][i]=a[1][i]-a[0][i]*r2

(7) r2=a[2][0]/a[0][0]

(8) a[2][i]=a[2][i]-a[i][1]*r3

(9) apply logic for calculation

(10) z=a[3][3]/a[2][2]

(11) y=a[1][3]-(a[1][2]*z/a[1][1])

(12) x=a[0][3]-a[0][2]*z-a[0][1]*y/[0][0]
PROGRAM NO: 1
/*Program to solve a set of simultaneous linear equation
using Gauss Elimination Method */

#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
float a[3][4],r1,r2,r3,x,y,z;
int i;
clrscr();
printf("\n\n GAUSS ELIMINATION METHOD");
printf("\n\n Equation is in the form ax+by+cz=d\n");
printf("\n\n ENTER the cofficints of x,y,z and enter d");
for(i=0;i<=3;i++)
{
printf("\n\n enter the %d row:\n",i+1);
scanf("%f%f%f%f",&a[i][1],&a[i][2],&a[i][3]);
}
if(a[0][0]==0)
{
printf("\n as first value of x is '0' ");
printf("so this method cannot be implemented::::::");
getch();
exit(0);
}
else
{
r1=a[1][0]/a[0][0];
for(i=0;i<=3;i++)
{
a[1][i]=a[1][i]-a[0][i]*r1;
r2=a[2][0]/a[0][0];
for(i=0;i<=3;i++)
{
a[2][i]=a[2][i]-a[1][i]*r2;
}
r3=a[2][1]/a[1][1];
for(i=0;i<=3;i++)
{
a[2][i]=a[2][i]-a[1][i]*r2;
}
z=a[2][3]/a[2][2];
y=a[1][3]-(a[1][2]*z)/a[1][1];
x=a[0][3]-(a[0][2]*z)-(a[0][1]*y)/a[0][0];
printf("\n x:%f",x);
printf("\n y:%f",y);
printf("\n z:%f",z);
getch();
}
}
}
OUTPUT:

GAUSS ELIMINATION METHOD


EQUATION IS OF THE FORM AX+BY+CZ=D
ENTER THE COFFICIENT OF X, Y, Z AND ENTER D

ENTER THE FIRST ROW


1
4
-1
-5
ENTER THE FIRST ROW
1
1
-6
-12
ENTER THE FIRST ROW
3
-1
-1
4

X: 1.6437887
Y: 1.140845
Z: 2.2084507
ALGORITHM:2

OBJECTIVE:-
Write a program to formulate ybus by non singular transformation
ybus=[A]t[y][A]

Algorithm:-

(1) enter the no. of rows in the the incidence matrix.


(2) enter the no. of columns in the the incidence matrix.
(3) enter the elements of the incidence matrix.
(4) logic for the formulation of element node incidence matrix
(5) for (i=0;i<n;i++)
rw=4;
(6) for(j=0;j<n;j++)
(7) check if incd[i][j]=+1;
rw=rw+4;
(8)cl=cl+3;
(9) check the calculation of transpose of a matrix
(10) for=(i=0;i<n;i++)
(11) check if for(j=0;j<m;j++) transpose incd[i][j]=incd[i][j];
(12) logic for multiplication of incidence matrixand primitive admittance
matrix
for(i=0;i<n;i++)
and for(k=0;k<n;k++)
check c[i][k]=c[i][k]+incd[i][j]*ybus[j][k];
(13) calcualtebus admittance matrix
ybus[i][j]=ybus[i][j]+c[i][k]*incd[k];
(14) check the result and exit.
PROGRAM NO: 2

/* Program to formulate y bus by a non-singular


transformation y bus=[A]t[Y][A] where t= Transpose of
matrix A */

#include<stdio.h>
#include<conio.h>
void main ()
{
int incd[100][100],yprm[100][100],tincd[100][100];
int i,j,k,m,n,rw,cl;
static int ybus[100][100],c[100][100];
clrscr();
printf("enter the no. of rows incidence matrix: ");
scanf("%d",&m);
printf("enter the no. of colums incidence matrix: ");
scanf("%d",&n);
printf("\nenter the element of incidence matrix: ");
cl=8;
for(i=0;i<m;i++)
{
rw=4;
for(j=0;j<n;j++)
{
gotoxy(rw,cl);
scanf("%d",&incd[i][j]);
rw=rw+4;
}
cl=cl+3;
printf("\n\n press any key to continue ");
getch();
clrscr();
//
printf("\n enter the element of primitive admittance matrix");
cl=8;
for(i=0;i<m;i++)
{
rw=4;
for(j=0;j<m;j++)
{
gotoxy(rw,cl);
scanf("%d",&yprm[i][j]);
rw=rw+4;
}
cl=cl+3;
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
tincd[i][j]=incd[i][j];
}
printf("\n\npress any key to continue..");
getch();
clrscr();
//
printf("the transpose of primitive incidence matrix is");
cl=8;
for(i=0;i<n;i++)
{
rw=4;
for(j=0;j<m;j++)
{
gotoxy(rw,cl);
printf("%d",&yprm[i][j]);

rw=rw+4;
}
cl=cl+3;
//multiplying.......
for(i=0;i<n;i++)
{
for(k=0;k<m;k++)
{
for(j=0;j<m;j++)
c[i][j]=c[i][j]+tincd[i][j]*yprm[j][k];
}
}
//calculate
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
for(k=0;k<n;k++)
ybus[i][j]=ybus[i][j]+c[i][j]*incd[k][j];
}
}
printf("\n\npress any key to continue");
getch();
clrscr();
//
printf("the bus admittance matrix is");
cl=8;
for(i=0;i<m;i++)
{
rw=4;
for(j=0;j<n;j++)
{
gotoxy(rw,cl);
printf("%d",ybus[i][j]);
rw=rw+6;
}
cl=cl+3;
}
printf("\n\npress any key to exit");
getch();
}
}
}
OUTPUT:

enter the no of rows in the incidence matrix: 2


enter the no of columns in the incidence matrix: 2

Enter the element of incident matrix

3 2
1 7

press any key to contniue........

Enter the element of primitive admittance matrix


2 5
7 1

press any key to continue.....


3 2
2 7

press any key to continue.....

the bus admittance matrix is

98 154
249 546
ALGORITHM:3

OBJECTIVE:
Develop a program to do the following mathematical operation

(1) Transpose of a matrix


(2) Multiplication of two matrices
(3) Addition of two matrices
(4) Subtraction of two matrices

Algorithm:
(1) enter the condition of switch statement
(2) enter the choice
(3) enter the no of rows in the matrix
(4) enter the no of columns in the matrix
(5) print enter the matrix
(6) logic to calculate transpose of a matrix
c[i][j]=a[i][j]
(7) enter case 2
(8) enter the same no rows and columns in the matrix
(9) logic of adding two matrix
(10) enter case 3
(11) enter the same no rows and columns in the matrix
(12) logic of subtraction of two matrix
(13) c[i][j]=a[i][j]-b[i][j]
(14) enetr case 4
(15) enter the same no rows and columns in the matrix
(16) logic to calculate product of two matrices
(17) c[i][j]=c[i][j]+a[i][j]*b[j][k]
(18) print the result
(19) stop
PROGRAM NO: 3

/* Program to do the following mathematical operation


(1) Transpose of a matrix
(2) Multiplication of two matrices
(3) Addition of two matrices
(4) Subtraction of two matrices */
#include<stdio.h>
#include<conio.h>
#include<process.h>
void main ()
{
int a[25][25],b[25][25];
static int c[25][25];
int i,j,l,m,n,o,p,k,ch,rw,cl;
clrscr();
printf("\n\n press 1:: to calculate the transposs of a matrices!");
printf("\n\n press 2:: to add two matrices matrices!");
printf("\n\n press 3:: to sustract two matrices! ");
printf("\n\n press 4:: to multiply two matrices! ");
printf("\n\n press 5:: to exit from the program!");
printf("\n\n enter your choice(between 1 to 5):::::: ");
scanf("%d",&ch);
clrscr();
switch(ch)
{
case 1:
printf("\nenter the no. of rows in the matrix:: ");
scanf("%d",&m);
printf("\nenter the no. of columns in the matrix:: ");
cl=8;
for(i=0;i<m;i++)
{
rw=10;
for(j=0;j<n;j++)
{
gotoxy(rw,cl);
scanf("%d",&a[i][j]);
rw=rw+5;
}
cl=cl+3;
}
clrscr();
printf("::the transpose of the matrix is :: ");
cl=3;
for(i=0;i<n;i++)
{
rw=10;
for(j=0;j<m;j++)
{
c[i][j]=a[i][j];
gotoxy(rw,cl);
printf("%d",c[i][j]);
rw=rw+5;
}
cl=cl+3;
}
getch();
break;
case 2:
printf("\n\nenter the no. of rows in the first matrix:: ");
scanf("%d",&m);
printf("\nenter the no. of columns in the first matrix:: ");
scanf("%d",&n);
printf("\nenter the no. of rows in the second matrix:: ");
scanf("%d",&p);
printf("\nenter the no. of columns in the second matrix:: ");
scanf("%d",&o);
clrscr();
if(m==p&&n==0)
{
printf("\n::enter the first matrix::");
cl=3;
for(i=0;i<m;i++)
{
gotoxy(rw,cl);
scanf("%d",&a[i][j]);
rw=rw+5;
}
cl=cl+3;
}
clrscr();
printf("\n:: enter the second matrix::");
cl=3;
for(i=0;i<m;i++)
{
rw=10;
for(j=0;j<n;j++)
{
gotoxy(rw,cl);
scanf("%d",&b[i][j]);
rw=rw+5;
}
cl=cl+3;
}
clrscr();
// logic to add two matrices
printf("::the sum of the two matrices is:: ");
cl=3;
for(i=0;i<m;i++)
{
rw=10;
for(j=0;j<n;j++)
{
c[i][j]=a[i][j]+b[i][j];
gotoxy(rw,cl);
printf("%d",c[i][j]);
rw=rw+5;
}
cl=cl+3;
}
else
printf("the sum can not be found");
getch();
break;
case 3:
printf("\nenter the no. of rows in the first matrix:: ");
scanf("%d",&m);
printf("\nenter the no. of columns in the first matrix:: ");
scanf("%d",&n);
printf("\nenter the no. of rows in the second matrix:: ");
scanf("%d",&p);
printf("\nenter the no. of columns in the second matrix:: ");
scanf("%d",&o);
clrscr();
if(m==p&&n==o)
{
printf("\n::enter the first matrix::");
cl=3;
for(i=0;i<m;i++)
{
rw=10;
for(j=0;j<n;j++)
{
gotoxy(rw,cl);
scanf("%d",a[i][j]);
rw=rw+5;
}
cl=cl+3;
}
clrscr();
printf("\nenter the second matrix: ");
cl=3;
for(i=0;i<m;i++)
{
rw=10;
for(j=0;j<n;j++)
{
gotoxy(rw,cl);
scanf("%d",&b[i][j]);
rw=rw+5;
}
cl=cl+3;
}
clrscr();
// logic to obtain the difference of two matrices
printf("the differnce of two matrices is: ");
cl=3;
for(i=0;i<m;i++)
{
rw=10;
for(j=0;j<n;j++)
{
c[i][j]=a[i][j]-b[i][j];
gotoxy(rw,cl);
printf("%d",c[i][j]);
rw=rw+5;
}
cl=cl+3;
}
}
else
printf("the sum can not be found");
getch();
break;
case 4;
printf("\n\n enter the no. of rows in the first matrix:: ");
scanf("%d",&m);
printf("\n enter the no. of columns in the first matrix:: ");
scanf("%d",&n);
printf("\n enter the no. of columns in the second matrix:: ");
scanf("%d",&p);
printf("\n enter the no. of columns in the second matrix:: ");
scanf("%d",&o)
clrscr();
if(n==p)
{
printf("\n enter the first matrix: ");
cl=3;
for(i=0;i<m;i++)
{
gotoxy(rw,cl)
scanf("%d",&a[i][j]);
rw=rw+5;
}
cl=cl+3;
}
clrscr();
printf("\n enter the second matrix: ");
cl=3;
for(i=0;i<m;i++)
{
rw=10;
for(j=0;j<n;j++);
{
cl=cl+3;
}
clrscr();
// logic to multiply the two matrices
cl=3;
for(i=0;i<m;i++)
{
for(k=0;k<o;k++)
{
for(j=0;j<n;j++)
c[i][j]=c[i][k]+a[i][j]*b[j][k];
}
}
printf("::the product of the two matrices is :: ");
for(i=0;i<m;i++)
{
rw=10;
for(j=0;j<o;j++)
{
gotoxy(rw,cl);
printf("%d",c[i][j]);
rw=rw+5;
}
cl=cl+3;
}
}
else
printf("the product could not be found");
getch();
break;
case 5: exit(0);

OUTPUT:
press 1: to calculate the transpose
press 2: to add two matrices
press 3: to subtract two matrices
press 4: to multiply two matrices
press 5: to exit

enter your choice:: 1


enter the number of rows in the matrix :3
enter the number of rows in the matrix:3
enter the number of columns in the matrix :3
enter the matrix
8 7 5
7 4 2
9 1 3
the transpose of the matrix is
8 7 9
7 4 1
5 2 3
enter your choice ::2
enter the number of rows in the matrix:3
enter the number of columns in the matrix : 3
enter the first matrix
8 7 5
7 4 2
9 1 3
enter the second matrix
8 7 9
7 4 1
5 2 3
the sum of the two marices is
16 14 14
14 8 3
14 3 6
enter your choice::4
enter the number of rows in the matrix: 2
enter the number of columns in the matrix:2
enter the first matrix
4 5
2 1
enter the second matrix
1 2
1 0
the product of two matrices
9 8
3 4
enter your choice::5

ALGORITHM:4

OBJECTIVE:
You have been giving with network data consisting of element no, starting
node and end node .Develop a program to make element node and convert it into
ybus incidence matrix A by choosing any bus as reference

Algorithm:-

(1) enter the no of nodes in the graph


(2) enter the total no of employees in the graph
(3) enter the starting nodes
(4) logic for the formation of element node incidence matrix
(5) print the let matrix
(6) check if(j==5+[i])
incd[i][j]=+1;
if(j==end[i])
incd[i][j]=-1;
(7) logic to form the bus incidence matrix
set cl=5;
for(j=0;j<5;j++)
rw=8;
for(j=0;j<e;j++)
if( j==a)
(8) increment j by j=j+1;
PROGRAM NO: 4
/* Program to make element node incidence matrix and convert it into
ybus incidence matrix A by choosing any bus as reference.*/

#include<stdio.h>
#include<conio.h>
void main ()
{
clrscr();
int a,i,j,e,s,rw,cl;
static st[100],end[100],incd[100][100];
printf("enter the number of nodes in the graph: ");
scanf("%d", &e);
printf("\nenter the number of element in the graph: ");
scanf("%d",&s);
printf("\nenter the starting node : ");
printf("\n\n");
for(i=0;i<s;i++)
scanf("%d",&st[i]);
printf("\n enter the end node ");
printf("\n\n");
// logic for formation of element node incidence matrix
for (i=0;i<s;i++)
{
for(j=0;j<e;j++)
{
if(j==st[i])
incd[i][j]=+1;
if(j==end[i])
incd[i][j]=-1;
}
}
clrscr();
printf("\n the element node incidence matrix");
cl=5;
for(i=0;i<s;i++)
{
rw=8;
for(j=0;j<e;j++)
{
gotoxy(rw,cl);
printf("%d",incd[i][j]);
rw=rw+5;
}
cl=cl+3;
getch();
printf("\n\n enter the refernce node: ");
scanf("%d",&a);
clrscr();
printf("the bus incidence matrix is: ");
// logic to form the bus incidence matrix
cl=5;
for(i=0;i<s;i++)
{
rw=8;
for(j=0;j<s;j++)
{
if(j==a)
j=j+1;
gotoxy(rw,cl);
printf("%d",incd[i][j]);
rw=rw+5;
}
cl=cl+3;
}
printf("\n\n\n press any key to exit");
getch();
}
getch();
}
OUTPUT:

enter the total number of nodes in the graph: 6


enter the no. of element in the graph: 8

enter the starting nodes


1
1
2
3
4
6
1
enter the end node
2
6
3
4
5
5
5
the element node incidence matrix is
0 1 -1 0 0 0
0 1 0 0 0 0
0 0 1 1 0 0
0 0 0 1 -1 0
0 0 0 0 1 -1
0 0 0 0 0 -1
0 1 0 0 0 -1

ALGORITHM: 5

OBJECTIVE: -
The gauss seidel method is also known as method of successive
displacement use the gauss seidel method to find the solution following equation.

Algorithm:-

(1) equation is the format cz=d.


(2) enter the coefficient of x,y,z and enter d.
(3) enter the first row.
(4) enter the second row.
(5) enter the third row.
(6) enter the initial valve of x,y and z.
(7) for(i=0;i<4;i++)
(8) x0=(d1-b1*y0-c1*z0)/a1
(9) y0=(d2-a2*y0-c2*z0)/b2
(10) z0=(d3-a3*y0-b3*z0)/c3
(11) print the result
(12) exit
PROGRAM NO: 5
/*The GAUSS SEIDEL method is also known as the method of successive
displacement.
Use gauss seidel method to find the solution of the following
equation.*/

#include<stdio.h>
#include<conio.h>
void main ()
{
float a1,b1,c1,d1,a2,b2,c2,d2,a3,b3,c3,d3,x,y,z,x0,y0,z0;
int i;
printf("\ngauss sidel method");
printf("\n\nequation is of the formax by cz=d\n");
printf("enter the cofficient of x,y,z and enter d");
printf("\nenter the first row:\n");
scanf("%f%f%f%f",&a1,&b1,&c1,&d1);
printf("\nenter the second row:\n");
scanf("%f%f%f%f",&a2,&b2,&c2,&d2);
printf("\nenter the third row:\n");
scanf("%f%f%f%f",&a3,&b3,&c3,&d3);
printf("enter the initial value of x");
scanf("%f",&x0);
printf("enter the initial value of y");
scanf("%f",&y0);
printf("enter the initial value of z");
scanf("%f",&z0);
for(i=0;i<4;i++)
{
x0=(d1-b1*y0-c1*z0)/a1;
y0=(d2-a2*y0-c2*z0)/b2;
z0=(d3-a3*y0-b3*z0)/a3;
printf("\nx=%f\ty=%f\tz=%f",x0,y0,z0);
}
getch();
}

OUTPUT:

GAUSS SEIDEL METHOD


enter is of the form ax+by+cz=d;
enter the coefficient of x,y,z& enter d
enter the first row
1
4
-1
-5
enter the second row

1
1
-6
-12
enter the third row

3
-1
-1
4
enter the intial value of x:0
enter the intial valve of y:0
enter the intial valve of z:0

x=-5.000000 y=-7.000000 z=-12000000


x=-3000000 y=-81.000000z=68000000
x=225.000000y=171.000000z=500.000000
x=153.000000y=2835.000000z=-2380.000004

PROGRAM NO: 6
0BJECTIVE:-
The demand estimation for planning the future electrical power
supply. The consistency of demand growth over the year has led to
numerous attempts to fit mathematical curve of this trend. One of the
simplest curve is P=p.exp(a*(t-t)).where a is the average growth rate ,b is
demand in year t in GW the given demand at year t.a=3.4%.Develop a
table to compute the system demand from 1990 t0 2008 on yearly basis.
Also calculate average yearly demand over this period.

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int b,i,s,t,j=0;
float a,c,d,sum=0;
clrscr();
printf("enter the initial demand in GW:");
scanf("%d",&b);
printf("\nenter the average growth rate:");
scanf("%f",&a);
printf("\nenter the starting year:");
scanf("%d",&s);
printf("enter the final year:");
scanf("%d",&t);
/*logic to find out yearly demand*/
for(i=s;i<=t;i++)
{
a=b*(exp(a*j));
printf("\n\n the demand for year %d in gw is %f",i,c);
sum=sum+c;
j=j+1;
}
/*logic to calculate average demand*/
d=sum/j;
printf("\n\n the average yearly in gw is %f",d);
printf("\n\n press any key to exit!!");
getch();
}

OUTPUT:-

Enter the final year in GW: 10000


Enter the average GW rate: .034
Enter the starting year: 1990
Enter the final year: 2008

enter the demand for the year 1990 in gw is 10000.000000


enter the demand for the year 1991 in gw is 10345.845703
enter the demand for the year 1992 in gw is 10703.653320
enter the demand for the year 1993 in gw is 11073.834961
enter the demand for the year 1994 in gw is 11456.819336
enter the demand for the year 1995 in gw is 11853.048828
enter the demand for the year 1996 in gw is 12262.981445
enter the demand for the year 1997 in gw is 12687.091797
enter the demand for the year 1998 in gw is 13125.870117
enter the demand for the year 1999 in gw is 13459.894576
enter the demand for the year 2000 in gw is 13579.823242
enter the demand for the year 2001 in gw is 14049.476562
enter the demand for the year 2003 in gw is 14535.372070
enter the demand for the year 2004 in gw is 15038.072266
enter the demand for the year 2005 in gw is 15558.158203
enter the demand for the year 2006 in gw is 16096.230496
enter the demand for the year 2007 in gw is 16652.012109
enter the demand for the year 2008 in gw is 17228.847656

THE AVERAGE YEARLY DEMAND IN GW IS 12761.501815

You might also like