+ All Categories
Home > Documents > hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3...

hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3...

Date post: 22-Sep-2020
Category:
Upload: others
View: 9 times
Download: 0 times
Share this document with a friend
109
1 Physics Practical DSE-1 : Advanced Mathematical Physics-1 Lab Name- Aakash Yadav Course- B.sc. (H) Physics V Semester Exam Roll no.- 17035567002 College Roll no.- 6317
Transcript
Page 1: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

1

Physics Practical DSE-1 :

Advanced Mathematical Physics-1 Lab

Name- Aakash YadavCourse- B.sc. (H) Physics

V SemesterExam Roll no.- 17035567002

College Roll no.- 6317

EXPERIMENT 1(a)

Page 2: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

2

AIM- Write a scilab code for the multiplication of two 3x3 matrices

A=[2 5 11 7 39 6 4] B=[0 3 1

1 5 73 6 1]

EDITOR-clc()

//Defining the MatricesA=[2 5 1;1 7 3;9 6 4]B=[0 3 1;1 5 7;3 6 1]mprintf("The given matrices are-\nA=\n")mprintf("%d %d %d\n",A)

Page 3: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

3

mprintf("\nB=\n")mprintf("%d %d %d\n",B)

[m,n]=size(A)[k,p]=size(B)C=zeros(3,3)

//Checking dimensions of matrix for multiplicationif n~=k then disp ('Dimensions of given matrix are not compatible')else // Multiplying matrices by LOOPfor i=1:m for j=1:p //s= 0; for r=1:n C(i,j) = C(i,j) + A(i,r) * B(r,j); end //C(i,j) = s endendendmprintf('\nThe multipication of matrices by loop multiplication is\n')mprintf('%4.0f %4.0f %4.0f\n',C)

//Multiplying Matrices directlyC=A*Bmprintf('\nThe multipication of matrices by direct multiplication is\n')

mprintf('%4.0f %4.0f %4.0f\n',C)

Page 4: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

4

CONSOLE-The given matrices are-A=2 5 11 7 39 6 4

B=0 3 11 5 73 6 1

The multipication of matrices by loop multiplication is 8 37 38 16 56 53

Page 5: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

5

18 81 55

The multipication of matrices by direct multiplication is 8 37 38 16 56 53 18 81 55

Page 6: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

6

EXPERIMENT 1(b)

AIM- Write a scilab code for the multiplication of two 3x3 matrices

A=[1 6 94 7 2i8 i 0 ] B=[1+2i 3 4 i

0 8i 68 2i 1+i ]

EDITOR-clc()

//Defining the MatricesA=[1 6 9;4 7 2*%i;8 %i 0]B=[1+2*%i 3 4*%i;0 8*%i 6;8 2*%i 1+%i]

Page 7: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

7

mprintf("The given matrices are-\nA=\n")disp(A)mprintf("\nB=\n")disp(B)

[m,n]=size(A)[k,p]=size(B)

//Checking dimensions of matrix for multiplicationif n~=k disp ('Dimensions of given matrix are not compatible')end // Multiplying matrices by for LOOPfor i=1:m for j=1:p s= 0; for r=1:n s = s + A(i,r) * B(r,j); end C(i,j) = s endend

//Multiplying Matrices directlymprintf('The multipication of matrices is\n')disp(C)

C=A*Bmprintf('\nThe multipication of matrices by direct multiplication is\n')disp(C)

Page 8: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

8

CONSOLE-The given matrices are-

A=

1. 6. 9.

4. 7. 2.i

8. i 0

B=

1. + 2.i 3. 4.i

0 8.i 6.

8. 2.i 1. + i

The multipication of matrices is

73. + 2.i 3. + 66.i 45. + 13.i

Page 9: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

9

4. + 24.i 8. + 56.i 40. + 18.i

8. + 16.i 16. 38.i

The multipication of matrices by direct multiplication is

73. + 2.i 3. + 66.i 45. + 13.i

4. + 24.i 8. + 56.i 40. + 18.i

8. + 16.i 16. 38.i

Page 10: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

10

EXPERIMENT 2

AIM- To find transpose of the given matrix and to verify if it is orthogonal i.e. AA’=I

A= 13 *[2 −2 11 2 22 1 −2]

EDITOR-clc()

//Defining the MatrixA=[2 -2 1;1 2 2;2 1 -2]

Page 11: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

11

A=A/3mprintf('The given matrix is A=\n')mprintf('%1.3f %1.3f %1.3f\n',A)B=zeros(3,3)

//Calculculating Transpose of matrix by for loopfor i=1:3 for j=1:3 B(i,j)=A(j,i) endend

mprintf('\nThe transpose of matrix by loop is A_trans=\n')mprintf('%1.3f %1.3f %1.3f\n',B)

//Calculculating Transpose of matrix directlymprintf('\nThe transpose of matrix calculated directly is A_trans=\n')mprintf('%1.3f %1.3f %1.3f\n',A')

mprintf("\nA x A_trans= =\n")mprintf('%1.3f %1.3f %1.3f\n',A*B)

//Verifying Orthogonality of Matrixif A*B==eye(3,3) thenmprintf('\n Hence Given matrix is an orthogonal matrix')end

Page 12: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

12

CONSOLE-The given matrix is A=0.667 -0.667 0.3330.333 0.667 0.6670.667 0.333 -0.667

The transpose of matrix by loop is A_trans=0.667 0.333 0.667-0.667 0.667 0.3330.333 0.667 -0.667

The transpose of matrix calculated directly is A_trans=0.667 0.333 0.667

Page 13: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

13

-0.667 0.667 0.3330.333 0.667 -0.667

A x A_trans= =1.000 0.000 0.0000.000 1.000 0.0000.000 0.000 1.000

Hence Given matrix is an orthogonal matrix

Page 14: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

14

EXPERIMENT 3

AIM- To verify that the given matrix is a unitary matrix i.e. BB+=I

B= 1√3 *[ 1 1+i1−i −1 ]

EDITOR- clc()B=(1/sqrt(3))*([1 1+%i;1-%i -1])mprintf('\nyour matrix B is\n')

Page 15: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

15

disp(B)C=B'mprintf('\nyour matrix C=conjugate-transpose of B is\n')disp(C)D=C*Bmprintf('\nthe marix D=C*B')disp(D)mprintf('\nthe given matrix is the the unitary matrix')

CONSOLE-your matrix B is 0.5773503 0.5773503 + 0.5773503i 0.5773503 - 0.5773503i - 0.5773503

your matrix C=conjugate-transpose of B is

Page 16: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

16

0.5773503 0.5773503 + 0.5773503i 0.5773503 - 0.5773503i - 0.5773503

the marix D=C*B 1. 0 0 1.

the given matrix is the the unitary matrix

Page 17: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

17

EXPERIMENT 4

AIM- To verify CC-1=I for any randomly chosen matrix C if |C|≠0

C=[1 3 44 2 51 4 6 ]

EDITOR-clc()a=[1 3 4;4 2 5;1 4 6]mprintf("mattrix a is")disp(a)

Page 18: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

18

d=det(a)mprintf("Determinant of A\n|A|= ")mprintf("%d \n not equal to 0",d)if d==0 then mprintf("the inverse of given matrix is not possible")else b=inv(a) mprintf('\n\nInverse of A=') disp(b) c=a*b disp('A*inv(A)=') mprintf('%4.0f %4.0f %4.0f\n',c) mprintf("Hence verified") end

Page 19: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

19

CONSOLE-Matrix A is 1. 3. 4. 4. 2. 5. 1. 4. 6. Determinant of A|A|= -8 not equal to 0

Inverse of A= 0.8888889 0.2222222 - 0.7777778 2.1111111 - 0.2222222 - 1.2222222 - 1.5555556 0.1111111 1.1111111 A*inv(A)= 1 0 -0 0 1 0 0 0 1Hence verified

Page 20: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

20

EXPERIMENT 5

AIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field. Use matrix operations to find the total amount of N,P,K in each field N P K

A=F110% 50% 5%F225% 5% 5%F30% 10% 20%

f1 f2 f3

B=F15 2 4F22 1 1F33 1 3

F-Fertilizer f-Field

EDITOR- clc()mprintf("Given Data :-\n\n")

Page 21: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

21

//Matrix AA=[10 10 5;25 5 5;0 10 20]mprintf(" \t\tN\tP\tK\n")mprintf("Fertiliser1\t%d\t%d\t%d\n",A(1,:))mprintf("Fertiliser2\t%d\t%d\t%d\n",A(2,:))mprintf("Fertiliser3\t%d\t%d\t%d\n",A(3,:))

//Matrix BB=[5 2 4;2 1 1;3 1 3]mprintf("\n\n \t\tfield1\tfield2\tfield3\n")mprintf("Fertiliser1\t%d\t%d\t%d\n",B(1,:))mprintf("Fertiliser2\t%d\t%d\t%d\n",B(2,:))mprintf("Fertiliser3\t%d\t%d\t%d\n",B(3,:))//fieldA=A/100C=A'*B

//Total amount

mprintf("\n\nTOTAL AMOUNT OF N,P,K in respective fields:-")

mprintf("\n\n \tN\tP\tK\n")mprintf("field1\t%1.2f\t%1.2f\t%1.2f\n",C(1,:))mprintf("field2\t%1.2f\t%1.2f\t%1.2f\n",C(2,:))mprintf("field3\t%1.2f\t%1.2f\t%1.2f\n",C(3,:))

Page 22: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

22

CONSOLE-Given Data :-

N P KFertiliser110 10 5Fertiliser225 5 5Fertiliser30 10 20

field1 field2 field3Fertiliser15 2 4Fertiliser22 1 1Fertiliser33 1 3

Page 23: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

23

TOTAL AMOUNT OF N,P,K in respective fields:-

N P Kfield1 1.00 0.45 0.65field2 0.90 0.35 0.75field3 0.95 0.35 0.85

Page 24: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

24

EXPERIMENT 6(a)

AIM- To determine whether the given matrices are commutative

A=[1 0 00 1 01 0 2 ] B=[ 2 4 0

3 1 0−1 −4 1]

EDITOR- clc

a = [1 0 0;0 1 0;1 0 2]b = [2 4 0;3 1 0;-1 -4 1]

Page 25: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

25

mprintf("The given matrices are:-\n")disp(a,"A=")disp(b,"B=")c = a*bc1 = b*amprintf("\nNow we have\nA*B :- \n")disp(c)mprintf("\n")mprintf("B*A :- \n")disp(c1)if c == c1 then mprintf("\nHence,The two matrices are commutative in nature \n")

else mprintf("The two matrices are not commutative in nature \n")end

CONSOLE-The given matrices are:- A= 1. 0. 0. 0. 1. 0.

Page 26: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

26

1. 0. 2. B= 2. 4. 0. 3. 1. 0. - 1. - 4. 1.

Now we haveA*B :- 2. 4. 0. 3. 1. 0. 0. - 4. 2.

B*A :- 2. 4. 0. 3. 1. 0. 0. - 4. 2.

Hence,The two matrices are commutative in nature

Page 27: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

27

Page 28: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

28

EXPERIMENT 6(b)

AIM- To determine whether the given matrices are commutative

A=[1 23 4] B=[5 6

7 8]

EDITOR- clca = [1 2; 3 4]b = [5 6; 7 8]

mprintf("The given matrices are:-\n")

Page 29: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

29

disp(a,"A=")disp(b,"B=")c = a*bc1 = b*amprintf("\nNow we have\nA*B :- \n")disp(c)mprintf("\n")mprintf("B*A :- \n")disp(c1)if c == c1 then mprintf("\nHence,The two matrices are commutative in nature \n")

else mprintf("The two matrices are not commutative in nature \n")end

CONSOLE-The given matrices are:- A= 1. 2. 3. 4. B=

Page 30: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

30

5. 6. 7. 8.

Now we haveA*B :- 19. 22. 43. 50.

B*A :- 23. 34. 31. 46. The two matrices are not commutative in nature

Page 31: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

31

EXPERIMENT 6(c)

AIM- Write a scilab code to show that all the diagonal matrix commute to all other diagonal matrix. Use diag(rand(1,3)) to generate A and B and prove that AB=BA

Page 32: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

32

EDITOR- a = diag(rand(1,3))//disp(a)mprintf(" Given Diagonal Matrix A :- \n")disp(a)b = diag(rand(1,3))mprintf(" \n\nGiven Diagonal Matrix B :- \n")disp(b)mprintf("\n")//disp(b)c = a*bc1 = b*a

mprintf("A*B :- \n")disp(c)

mprintf("B*A :- \n")disp(c1)

if c == c1 then mprintf("\n\nThe two diagonal matrices are commutative in nature \n")else mprintf("The two diagonal matrices are not commutative in nature")endCONSOLE-Given Diagonal Matrix A :-

Page 33: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

33

0.7783129 0. 0. 0. 0.2119030 0. 0. 0. 0.1121355

Given Diagonal Matrix B :-

0.6856896 0. 0. 0. 0.1531217 0. 0. 0. 0.6970851

A*B :-

0.5336810 0. 0. 0. 0.0324469 0. 0. 0. 0.0781680

B*A :-

0.5336810 0. 0. 0. 0.0324469 0. 0. 0. 0.0781680

Page 34: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

34

The two diagonal matrices are commutative in nature

Page 35: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

35

EXPERIMENT 7

AIM- Write a scilab code to show that if two symmetric matrices are commutative then their product is also symmetrici.e. if AB=BA then (AB)’=AB

EDITOR- clcA=[1 2;2 3]B=[4 5;5 6]disp(A,"Given matrix A")

Page 36: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

36

disp(B,"Given matrix B")P=(A*B)'Q=B*AC=P-Q

if C==0 then mprintf('\nAB=BA\ngiven symmtric matrix is commutative\n')else mprintf('given matrix is not commutative\n')end

mprintf('\nA*B=')disp(P)mprintf('\ntranspose(AB)=')disp(Q)

W=A*Bif P == Q then mprintf('\nproduct of matrix is symmertic\n')else mprintf('prod is not symm.')end

Page 37: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

37

CONSOLE-Given matrix A 1. 2. 2. 3. Given matrix B 4. 5. 5. 6.

AB=BAgiven symmtric matrix is commutative

Page 38: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

38

A*B= 14. 23. 17. 28.

transpose(AB)= 14. 23. 17. 28.

product of matrix is symmetric

Page 39: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

39

EXPERIMENT 8(a)

AIM- Write a scilab code to determine whether the given matrices are diagonalizable or not, and if diagonalizable then show thatP-1AP=D

A=[1 1 01 1 00 0 2 ]

EDITOR- clcA=[1 1 0;1 1 0;0 0 2][P,D]=spec(A)

Page 40: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

40

mprintf('Coloumn of P are eigen vector of matrix A \n')mprintf(' and \n P=\n')

disp(P) //pmprintf('\ndigonlisable matrix D is\n D=')disp(D)d=det(P)mprintf('\ndeterminant of P is =%1.2f\n\n',d)

if d==2.961e-17 thenmprintf('since determinant of C is zero therefore its inverse does not exist \nhence given matrix is not digonlisable\n')

elseQ=inv(P) // inverse pB=Q*A*P //diogonal matrix

mprintf('P^-1*A*P=\n')disp(B)if B==D then mprintf('given matrix is diagonlisable\n')else mprintf('given matrix is not digonlisable')endend

Page 41: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

41

CONSOLE-Coloumn of P are eigen vector of matrix A and P= - 0.7071068 0.7071068 0. 0.7071068 0.7071068 0. 0. 0. 1.

digonlisable matrix D is D= 0. 0. 0. 0. 2. 0. 0. 0. 2.

Page 42: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

42

determinant of P is =-1.00

P^-1*A*P= 0. 0. 0. 0. 2. 0. 0. 0. 2. given matrix is diagonlisable

Page 43: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

43

EXPERIMENT 8(b)

AIM- Write a scilab code to determine whether the given matrices are diagonalizable or not, and if diagonalizable then show thatP-1AP=D

A=[1 0 11 2 00 0 3 ]

EDITOR- clcA= [1 0 1;1 2 0;0 0 3]

[P,D]=spec(A)

Page 44: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

44

mprintf('Coloumn of P are eigen vector of matrix A \n')mprintf(' and \n P=\n')

disp(P) //pmprintf('\ndigonlisable matrix D is\n D=')disp(D)d=det(P)mprintf('\ndeterminant of P is =%1.2f\n\n',d)

if d==2.961e-17 thenmprintf('since determinant of C is zero therefore its inverse does not exist \nhence given matrix is not digonlisable\n')

elseQ=inv(P) // inverse pB=Q*A*P //diogonal matrix

mprintf('P^-1*A*P=\n')disp(B)if B==D then mprintf('given matrix is diagonalizable\n')else mprintf('given matrix is not diagonalizable')endend

Page 45: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

45

CONSOLE-Coloumn of P are eigen vector of matrix A and P= 0 0.7071068 0.4082483 1. - 0.7071068 0.4082483 0 0 0.8164966

digonlisable matrix D is D= 2. 0 0 0 1. 0 0 0 3.

Page 46: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

46

determinant of P is =-0.58

P^-1*A*P= 2. 0 0 0 1. 0. 0 0 3. given matrix is diagonalizable

Page 47: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

47

EXPERIMENT 8(c)

AIM- Write a scilab code to determine whether the given matrices are diagonalizable or not, and if diagonalizable then show thatP-1AP=D

A=[1 2 30 2 30 0 2]

EDITOR- clcA= [1 2 3;0 2 3;0 0 2]

Page 48: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

48

[P,D]=spec(A)mprintf('Coloumn of P are eigen vector of matrix A \n')mprintf(' and \n P=\n')

disp(P) //pmprintf('\ndigonlisable matrix D is\n D=')disp(D)d=det(P)mprintf('\ndeterminant of P is =%1.2f\n\n',d)

if d==2.961e-17 thenmprintf('since determinant of C is zero therefore its inverse does not exist \nhence given matrix is not digonlisable\n')

elseQ=inv(P) // inverse pB=Q*A*P //diogonal matrix

mprintf('P^-1*A*P=\n')disp(B)if B==D then mprintf('given matrix is diagonalizable\n')else mprintf('given matrix is not diagonalizable')endend

Page 49: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

49

CONSOLE-Coloumn of P are eigen vector of matrix A and P= 1. 0.8944272 - 0.8944272 0 0.4472136 - 0.4472136 0 0 6.620D-17

digonlisable matrix D is D= 1. 0 0 0 2. 0

Page 50: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

50

0 0 2.

determinant of P is =0.00

P^-1*A*P= 1. 0 0. 0 2. 0. 0 0 2. given matrix is diagonalizable

Page 51: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

51

EXPERIMENT 8(d)

AIM- Write a scilab code to determine whether the given matrices are diagonalizable or not, and if diagonalizable then show thatP-1AP=D

A=[2 1 00 2 10 0 2 ]

EDITOR- clcA=[2 1 0;0 2 1;0 0 2]

[P,D]=spec(A)

Page 52: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

52

mprintf('Coloumn of P are eigen vector of matrix A \n')mprintf(' and \n P=\n')

disp(P) //pmprintf('\ndigonlisable matrix D is\n D=')disp(D)d=det(P)mprintf('\ndeterminant of P is =%1.2f\n\n',d)

if d==2.961e-17 thenmprintf('since determinant of C is zero therefore its inverse does not exist \nhence given matrix is not digonlisable\n')

elseQ=inv(P) // inverse pB=Q*A*P //diogonal matrix

mprintf('P^-1*A*P=\n')disp(B)if B==D then mprintf('given matrix is diagonalizable\n')else mprintf('given matrix is not diagonalizable')endend

Page 53: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

53

CONSOLE-Coloumn of P are eigen vector of matrix A and P= 1. - 1. 1. 0 4.441D-16 - 4.441D-16 0 0 1.972D-31

digonlisable matrix D is D= 2. 0 0 0 2. 0 0 0 2.

Page 54: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

54

determinant of P is =0.00

P^-1*A*P= 2. 0 0 0 2. 0 0 0 2. given matrix is diagonalizable

Page 55: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

55

EXPERIMENT 9(a)

AIM- Write a scilab code to determine whether the given operator is hermitian i.e. orthogonal or not

p=−iħ ∂∂x

EDITOR- clca=1P=[]//Finding hermitian matrixfor i=1:2

Page 56: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

56

for j=1:2 if i==j then P(i,j)=0 elseif i==j+1 | j==i+1 P(i,j)=%i/2 else P(i,j)=0 end endendP(2,:)=-P(2,:)mprintf("\nThe matrix P is\n")disp(P)dx=1A=(1/dx)*[0 %i/2;-%i/2 0][ef,ev]=spec(A) ef1=ef'//dagger of eigen vector matrixX1=ef(:,1)//separating the eigen vectors X2=ef(:,2)XD2=X2' //calculating dagger X2E=XD2*X1 mprintf("\nX1*X2+ = %4.2f\n",E)

K=ef*ef1 //PxDagger(P)

//Checking Hermitianmprintf("\nThe product of eigen vector matrix and its hermitian is--\n")mprintf("%1.0f %1.0f\n",K)if abs(E)<0.001 & abs(det(K)-1)<0.001 then mprintf("The operator is orthogonal")else mprintf("The operator is not orthogonal")end

Page 57: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

57

CONSOLE-The matrix P is 0 0.5i - 0.5i 0

X1*X2+ = 0.00

The product of eigen vector matrix and its hermitian is--1 00 1

Page 58: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

58

The operator is orthogonal

Page 59: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

59

EXPERIMENT 9(b)

AIM- Write a scilab code to determine whether the given operator is hermitian i.e. orthogonal or not

A= ∂2

∂x2

EDITOR-

clca=1L=[]

Page 60: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

60

for i=1:3 for j=1:3 if i==j then L(i,j)=-2 elseif i==j+1 | j==i+1 L(i,j)=1 else L(i,j)=0 end endendmprintf("\nThe matrix L is\n")mprintf("%d %d %d\n",L)A=(1/a^2)*[-2 1 0;1 -2 1;0 1 -2][P,D]=spec(A) P1=P'//dagger of eigen vector matrixX1=P(:,1)//separating the eigen vectors X2=P(:,2)X3=P(:,3)XD2=X2' //calculating dagger X2XD3=X3' //calculating dagger X3E=XD2*X1 mprintf("\nX1*X2+ = %4.2f\n",E)F=XD3*X1mprintf("X1*X3+ = %4.2f\n",F)G=XD3*X2

mprintf("X2*X3+ = %4.2f\n",G)K=P*P1 //PxDagger(P)

//Checking Hermitianmprintf("\nThe product of eigen vector matrix and its hermitian is--\n")mprintf("%1.0f %1.0f %1.0f\n",K)

Page 61: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

61

if abs(G)<0.001 & abs(F)<0.001 & abs(E)<0.001 & abs(det(K)-1)<0.001 then mprintf("The operator is orthogonal")else mprintf("The operator is not orthogonal")end

CONSOLE-

The matrix L is-2 1 01 -2 10 1 -2

X1*X2+ = -0.00X1*X3+ = -0.00X2*X3+ = 0.00

The product of eigen vector matrix and its hermitian is--

Page 62: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

62

1 0 00 1 00 0 1The operator is orthogonal

Page 63: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

63

EXPERIMENT 10AIM- To determine the principal moments and principal axis of moment of inertia of a dumbbell through diagonalisation

ω m L α l Ѳ lcosѲ l lsinѲ m

EDITOR- clc()

A Dumbbell is rotating

Page 64: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

64

m=1//input("mass of dumble= ")l=1//input("length of dumble= ")for x=[0,%pi/6,%pi/4]M=2*m*l^2*[1 0 0;0 cos(x)^2 -sin(x)*cos(x);0 -sin(x)*cos(x) sin(x)^2][f,d]=spec(M)mprintf("@angle= %f \n",x) //check inverse exist or notif det(f)==0 then mprintf("inverse of v does not exist \n")else mprintf("inverse of v exist and det(f)= %f\n",det(f))end //check matrix is diagonalizabel or notD=f^-1*M*fif abs(D-d)<=0.0001 then mprintf("matrix can be diagonalizable \n")else mprintf("matrix can NOT be diagonalizable \n")end //find out principle momentum disp("principal momentum=")mprintf("L1= %f\n",d(1,1))mprintf("L2= %f \n",d(2,2))mprintf("L3= %f \n",d(3,3)) //find out princlipal axisdisp("first principal axies (X1)=")mprintf("%f \n",f(:,1))disp("Second principal axies (X2)=")mprintf("%f \n",f(:,2))disp("third principal axies (X3)=")mprintf("%f \n",f(:,3))mprintf("\n")end

Page 65: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

65

CONSOLE-@angle= 0.000000 inverse of v exist and det(f)= -1.000000matrix can be diagonalizable principal momentum= L1= 0.000000L2= 2.000000 L3= 2.000000 first principal axies (X1)=

Page 66: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

66

0.000000 0.000000 1.000000 Second principal axies (X2)= -0.000000 1.000000 0.000000 third principal axies (X3)= 1.000000 0.000000 0.000000

@angle= 0.523599 inverse of v exist and det(f)= -1.000000matrix can be diagonalizable principal momentum= L1= 0.000000L2= 2.000000 L3= 2.000000

Page 67: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

67

first principal axies (X1)= 0.000000 -0.500000 -0.866025 Second principal axies (X2)= 0.000000 -0.866025 0.500000 third principal axies (X3)= 1.000000 0.000000 0.000000

@angle= 0.785398 inverse of v exist and det(f)= -1.000000matrix can be diagonalizable principal momentum= L1= 0.000000L2= 2.000000 L3= 2.000000

Page 68: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

68

first principal axies (X1)= 0.000000 -0.707107 -0.707107 Second principal axies (X2)= 0.000000 -0.707107 0.707107 third principal axies (X3)= 1.000000 0.000000 0.000000

Page 69: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

69

EXPERIMENT 11AIM- To determine the principal moments and principal axis of moment of inertia of a square plate through diagonalisation z

y

x

EDITOR- clc()M=[1/3 -1/4 0;-1/4 1/3 0;0 0 2/3][f,d]=spec(M)

Page 70: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

70

//check inverse exist or notif det(f)==0 then mprintf("inverse of f does not exist \n")else mprintf("inverse of f exist and det(f)= %f\n",det(f))end //check matrix is diagonalizabel or notD=f^-1*M*fif abs(D-d)<=0.0001 then mprintf("matrix can be diagonalizable \n")else mprintf("matrix can NOT be diagonalizable \n")end //find out principle momentum disp("principal momentum=")mprintf("L1= %f\n",d(1,1))mprintf("L2= %f \n",d(2,2))mprintf("L3= %f \n",d(3,3)) //find out princlipal axis disp("first principal axies (X1)=")mprintf("%f \n",f(:,1))disp("Second principal axies (X2)=")mprintf("%f \n",f(:,2))disp("third principal axies (X3)=")mprintf("%f \n",f(:,3))mprintf("\n")

Page 71: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

71

CONSOLE-inverse of f exist and det(f)= -1.000000matrix can be diagonalizable principal momentum= L1= 0.083333L2= 0.583333 L3= 0.666667 first principal axies (X1)= -0.707107 -0.707107

Page 72: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

72

-0.000000 Second principal axies (X2)= -0.707107 0.707107 0.000000 third principal axies (X3)= 0.000000 0.000000 1.000000

Page 73: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

73

EXPERIMENT 12AIM- To determine the principal moments and principal axis of moment of inertia of a cube through diagonalisation z

y

x

EDITOR- clc()n=3

Page 74: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

74

M=((diag(ones(n-1,1),1))+(diag(ones(n-1,1),-1)))*(-1/4)+2/3*eye(n,n)//M=[2/3 -1/4 -1/4;-1/4 2/3 -1/4;-1/4 -1/4 2/3][f,d]=spec(M) //check inverse exist or notif det(f)==0 then mprintf("inverse of v does not exist \n")else mprintf("inverse of v exist and det(f)= %f\n",det(f))end //check matrix is diagonalizabel or notD=f^-1*M*fif abs(D-d)<=0.0001 then mprintf("matrix can be diagonalizable \n")else mprintf("matrix can NOT be diagonalizable \n")end //find out principle momentum disp("principal momentum=")mprintf("L1= %f\n",d(1,1))mprintf("L2= %f \n",d(2,2))mprintf("L3= %f \n",d(3,3)) //find out princlipal axis disp("first principal axies (X1)=")mprintf("%f \n",f(:,1))disp("Second principal axies (X2)=")mprintf("%f \n",f(:,2))disp("third principal axies (X3)=")mprintf("%f \n",f(:,3))mprintf("\n")

Page 75: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

75

CONSOLE-inverse of v exist and det(f)= -1.000000matrix can be diagonalizable principal momentum= L1= 0.313113L2= 0.666667 L3= 1.020220 first principal axies (X1)= 0.500000

Page 76: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

76

0.707107 0.500000 Second principal axies (X2)= -0.707107 -0.000000 0.707107 third principal axies (X3)= -0.500000 0.707107 -0.500000

Page 77: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

77

EXPERIMENT 13(a)AIM- Write a scilab code to perform the given transformation using the appropriate transformation matrices

Scaling

EDITOR- clcclfx=[0:0.1:2*%pi]

Page 78: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

78

y=sin(x)A=[x;y]a=1b=2//Scaling matrixS=[a 0;0 b]B=S*AX=B(1,:)Y=B(2,:)

//Plottinga=get("default_axes"); // get the handle of the model axes // setting its' propertiesf.background=4;f.auto_resize="off";a.x_location="origin";a.y_location="origin";

plot2d(x,y,3,leg='original')plot2d(X,Y,5,leg='Scaled by a factor of 2')xtitle('Scaled function')

GRAPHIC WINDOW-

Page 79: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

79

Page 80: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

80

EXPERIMENT 13(b)AIM- Write a scilab code to perform the given transformation using the appropriate transformation matrices

2-D Reflection

EDITOR- clcclfx=[0:0.1:2*%pi]y=cos(x)

Page 81: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

81

A=[x;y]

//Reflection About Y-axisR=[-1 0;0 1]B=R*AX=B(1,:)Y=B(2,:)subplot(2,2,1)plot2d(x,y,3,leg='original')plot2d(X,Y,5,leg='reflected')xtitle('Reflection About Y-axis')

//Reflection About X-axisR=[1 0;0 -1]B=R*AX=B(1,:)Y=B(2,:)subplot(2,2,2)plot2d(x,y,3,leg='original')plot2d(X,Y,5,leg='reflected')xtitle('Reflection About X-axis')

//Reflection About Y=XR=[0 1;1 0]B=R*AX=B(1,:)Y=B(2,:)subplot(2,2,3)plot2d(x,y,3,leg='original')plot2d(X,Y,5,leg='reflected')xtitle('Reflection About Y=X')

//Reflection About Y=-XR=[0 -1;-1 0]B=R*AX=B(1,:)Y=B(2,:)subplot(2,2,4)plot2d(x,y,3,leg='original')

Page 82: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

82

plot2d(X,Y,5,leg='reflected')xtitle('Reflection About Y=-X')

GRAPHIC WINDOW-

Page 83: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

83

Page 84: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

84

EXPERIMENT 13(c)AIM- Write a scilab code to perform the given transformation using the appropriate transformation matrices

Rotation

EDITOR- clcclfx=[0:2]y=x

Page 85: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

85

A=[x;y] // rotation for angle 30 degreesubplot(1,2,1)t=-%pi/6R=[cos(t) sin(t);-sin(t) cos(t)]b=R*Aplot2d(x,y,3,leg='original')plot2d(b(1,:),b(2,:),5,leg='Rotated')xtitle('Rotation by 30 degree')a=get("current_axes")//get the handle of the newly created axesa.axes_visible="on"; // makes the axes visiblea.font_size=3; //set the tics label font sizea.x_location="origin"; //set the x axis positiona.y_location="origin"; //set the x axis position // rotation for angle 45 degreesubplot(1,2,2)t=-%pi/4R=[cos(t) sin(t);-sin(t) cos(t)]b=R*Aplot2d(x,y,3,leg='original')plot2d(b(1,:),b(2,:),5,leg='Rotated')xtitle('Rotation by 45 degree')a=get("current_axes")//get the handle of the newly created axesa.axes_visible="on"; // makes the axes visiblea.font_size=3; //set the tics label font sizea.x_location="origin"; //set the x axis positiona.y_location="origin"; //set the x axis position

Page 86: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

86

GRAPHIC WINDOW-

Page 87: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

87

Page 88: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

88

EXPERIMENT 13(d)AIM- Write a scilab code to perform the given transformation using the appropriate transformation matrices

Translation

EDITOR-

Page 89: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

89

clcclfx=[0:2]a=0b=2y=xq=[x;y;1 1 1]t=[1 0 a;0 1 b;0 0 1] c=t*qplot2d(x,y,3,leg='original')plot2d(c(1,:),c(2,:),5,leg='Translated')xtitle('translation of axis by a and b')

GRAPHIC WINDOW-

Page 90: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

90

Page 91: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

91

EXPERIMENT 14AIM- Wrie a scilab code to determine the principal strain and principal strain axis of given strain matrix

A=[ 54 34

34

54 ]

EDITOR- clcclfS=(1/4)*[5 3;3 5]//The two eigenvalues are the principal strain

Page 92: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

92

//The corres eigenvector are principal strain axis which are X1and X2[P,D]=spec(S)mprintf("The two eigenvalues are the principal strain which are \nL1=%1.2f\nL2=%1.2f",D(1,1),D(2,2))mprintf("\n\nThe corresponding eigenvector are principal strain axis which are X1and X2")disp(P(:,1),'X1=')disp(P(:,2),'X2=')x=[-1:0.01:1]

y1=sqrt(1-x^2)y2=-sqrt(1-x^2)

plot2d(x,y1,5)plot2d(x,y2,5)plot2d(P(1,1),P(2,1),-2)plot2d(P(1,2),P(2,2),-2)a=get("default_axes"); // get the handle of the model axes // setting its' propertiesf.background=4;f.auto_resize="off";a.x_location="origin";a.y_location="origin";

B=S*[x;y1]C=S*[x;y2]

plot2d(B(1,:),B(2,:),2,leg='On Applying Strain')plot2d(C(1,:),C(2,:),2)p=D*Pplot2d(p(1,1),p(1,2),-3)plot2d(p(2,1),p(2,2),-3)

Page 93: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

93

if S*P(:,1)-D(1,1)*P(:,1)<=0.1 then mprintf('\n\nS*X1=L1*X1\nVerified')end

if S*P(:,1)-D(1,1)*P(:,1)<=0.1 then mprintf('\n\nS*X2=L2*X2\nVerified')end

mprintf("\n\nSince by operating onn the EIgenvectors X1and X2\nThey are scaled by factors of L1 and L2 respectively")

CONSOLE-The two eigenvalues are the principal strain which are L1=0.50L2=2.00

The corresponding eigenvector are principal strain axis which are X1and X2 X1= - 0.7071068 0.7071068

Page 94: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

94

X2= 0.7071068 0.7071068

S*X1=L1*X1Verified

S*X2=L2*X2Verified

Since by operating onn the EIgenvectors X1and X2They are scaled by factors of L1 and L2 respectively

Page 95: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

95

GRAPHIC WINDOW-

Page 96: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

96

EXPERIMENT 15

AIM- Write a scilab code to show the refraction effect of light beam from rarer to denser medium using transformation matrix and to verify Snell’s law.

EDITOR- clc()clf()i=%pi/15mprintf("\nIncident angle is=%1.2f\n",i)x=[-5:0]

Page 97: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

97

y=tan(i)*xplot(x,y,'r')u1=1u2=1.5r=[1 0;0 u1/u2]x=[0:5]p=r*[x;tan(i)*x]

plot(p(1,:),p(2,:))slope=(p(2,2)-p(2,1))/(p(1,2)-p(1,1))r=atan(slope)mprintf("\nRefraction angle by slope of refracted line=%1.2f\n",r)plot([-5:5:5],[0 0 0],'k--')plot([0 0 0],[-1:1],'k')

hl=legend(['Incident light';'Reflected light';'Normal';'Separation between two medium'],2);

if u2/u1-sin(i)/sin(r)<=0.1 then mprintf("\nSnells Law is verified\nas u2/u1 =~ sin i/sin r\n")end

r=asin((u1/u2)*sin(i))mprintf("\nRefraction angle by snell law is=%1.2f\n",r)

Page 98: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

98

CONSOLE-Incident angle is=0.21

Refraction angle by slope of refracted line=0.14

Snells Law is verifiedas u2/u1 =~ sin i/sin r

Refraction angle by snell law is=0.14

Page 99: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

99

Page 100: hiscilab.files.wordpress.com  · Web viewAIM- Matrix A gives the percentage of N,P,K in 3 fertilizers. Matrix B is amount of each type of fertilizer spread on 3 different field.

100

GRAPHIC WINDOW-


Recommended