TOPIC 1Write a program in Matlab or Python or any software to decode a secret message, namely, your program allows user input the following information: The encoded message, the matrix k
Trang 1ĐẠI HỌC QUỐC GIA TRƯỜNG ĐẠI HỌC BÁCH KHOA TP.HCM
REPORT LINEAR ALGEBRA
INSTRUCTURE: HOÀNG HẢI HÀ
Trang 2TOPIC 1 3-6 Solution 3 Python’s code 3-5 Python’s result 5-6
TOPIC 2 7-10 Solution 7-9 Result 10
TOPIC 3 11-18 Solution 11-13 Matlab code 14-15 Matlab’s result 16-18
TOPIC 4 19-25 Solution 15-24 Result 25
Trang 3TOPIC 1
Write a program in Matlab or Python (or any software) to decode a secret message, namely, your program allows user input the following information: The encoded message, the matrix key and then your output is the meaningful message
1 SOLUTION:
To decode the message, we take the string of encoded message in numbers andmultiply it by the inverse of the matrix that was used to encode the message to getthe original string of numbers
Finally, by associating the numbers with their corresponding letters, we obtain theoriginal message
In this topic, user input the encoded messasge and the matrix key
the inverse of the matrix to get the original string of numbers
Finally, by associating the numbers with their corresponding letters, we obtain theoriginal message
2 PYTHON CODE:
Use PYTHON determine the decode message with the encoded message and thematrix key entered by user
import numpy as np
Trang 4from matrix import Matrix
from encoder import Encoder
from decoder import Decoder
# For user input
encoded_message = str(input("Input the encoded message in integer format :"))encoded_message = "[" + encoded_message + "]"
print("Encoded message in integer format : " + encoded_message)
print("Input the matrix key :")
R = int(input("Enter the number of rows:"))
C = int(input("Enter the number of columns:"))
# For printing the matrix
print("The matrix key is:")
Trang 6Using PYTHON determine the decode message with the encoded messageand the matrix key entered by user :
Trang 7TOPIC 2
Problem: “A mouse trap is placed in room 1 of the house with the pictured floor
plan Each time the mouse comes into room 1, he is trapped with probability p =0.1 If he is not trapped, he leaves each room by one of its exits, chosen atrandom.”
Find the matrix transition describing the path of the mouse through thehouse
A vector q is called steady vector of Markov model if P q = q where P ismatrix transition, find q
Suppose that the mouse starts in Room 4, what is the probability that themouse in Room 1 after 3 steps?
Suppose that the mouse starts in Room 5, find the number of expected stepsthat the mouse in Room 4 for the first time
Trang 8in the room.
When the mouse comes to Room 1, there are 2 possible possibilities: the mousecontinues to travel to other rooms with the probability of 0.9 or being trapped withthe probability of 0.1
The transition matrix is the transition probability data we can generate using theinformation provided
The table below present the transition probability of the mouse in the house
Trang 9Thus, we have the transition matrix from the table above:
Trang 10q q
By looking at the powers of the matrix P, we may examine the evolution of theMarkov chain through time (successive transitions) The k-step transition matrix,
Trang 11So that, we get the transition matrix or the probability for the mouse to reach any
TOPIC 3
Consider an open production model having n industries with n > 1 In order to produce $1 of its own output, the j th industry must spend $(1/n) for the output of the i th industry (for all i 6= j ), but the j th industry (for all j = 1, 2, 3, , n ) spends nothing for its own output Write a program with n is input by a user to do the following
• Construct the input-output matrix C n
• The matrix input-output C is called productive if (I − C) exists and (I − C) ≥ −1 −1
0 Show that C is productive n
• Find the vector output-values of this system.
1 SOLUTION:
By using the given data of the consumption matrix , we can constructed as:
The sum’s entries of each row or each column of is:
We can conclude from here that the consumption matrix is productive By usingMATLAB command inv-inverse, we can determine the inverse of for For weuse command inv( eye(2) ) and this gives us:
Using the same idea for , , we have:
- inv( eye(4) ):
- inv( eye(5) ):
Trang 12Taking from respectively, we can obtain that the matrix term is in form where the diagonal entries are 2 and all other entries are 1 Therefore, from this astructure if the matrices we gave the following conjecture
The general form of is:
Proving this conjecture, we show that
We have:
Proving our conjecture:
Proof:
Farther detail:
Trang 13
Find the vector output-values of this system:
According to the theory, we have vector output-values equals
is the demand vector
: is the vector output-values
Trang 14end
outside demand',i);
Trang 15Using MATLAB to construct the input-output matrix and show that isproductive:
Trang 16TOPIC 4:
According to the table, we have three possible genotypes AA, Aa, and aa We can now from request that the farmer dersires to undertake a breeding program in which each plant is always fertilized with a plant of genotype AA
SOLUTION:
First of all, we will demonstrate our old knowledge which not related to Linear Algebra which is biology we studied at high school
Case 1 and 2
Trang 17Case 3 and 4
Case 5 and 6
Trang 18Result from these equation:
Trang 19By using the statics in the table 1 and information in the Howard Anton, Chris
Rorres – Linear Algebra 11 edition, th we have:
x(n) = Mx(n−1) From here, we can conclude that:
a = a + b1 0 0 b1 = c + b0 0 c = 01
Thirdly, to derive an expression for the distribution of the three possible genotypes
in the population after n generations in terms of the fractions present after n – 1 by
Trang 20Continue, we using the same idea in the text book to find eigenvectors
Trang 21 THE END
- HOPE YOU FEEL GOOD ABOUT THIS REPORT AND WE WISH YOU HAVE A NICE DAY AND A GOOD ENERGY ALWAYS TO TEACHING MANY MORE EXCELLENT STUDENTS MS HA -