I am proceeding with the understanding while implementing it in python to deepen my understanding of mathematics. For the time being, I will do linear algebra. I didn't like math so much, but I may have come to like it lately. The table of contents of the series is here. Feel free to comment if you have any mistakes or better ways.
The determinant is defined by the following formula. Reference source Suddenly, I didn't have enough knowledge to implement the determinant, so I'll try to replace it first. The replacement is defined as follows: Reference source (1, 2, 3) and (3, 1, 2) are examples of replacements. There are a total of n! Ways to replace n characters. This time I will implement the product of permutations. The product of permutations is expressed as: Reference source Here article says that the correspondence between two permutations ("A → B" and "B → C") is put together in a three-stage rationale ("A → C"). It seems to be a feeling. If you take a closer look, I'm likely to get stuck in a swamp, so I'll keep this image. This time I will implement the product of this permutation.
I couldn't find a python library that can be replaced, so I'm worried if my implementation is correct. Please let me know if you have a library. I implemented it like below. I simply tried it as defined.
def permutation(list1, list2):
list_len = len(list2[1])
final_list = []
first_list = []
ans_list = []
for i in range(list_len):
a = list2[1][i]
ans = list1[1][a - 1]
if list1[0][i] != ans:
first_list.append(list1[0][i])
ans_list.append(ans)
final_list.append(first_list)
final_list.append(ans_list)
return final_list
def main():
print("~~permutation_test~~")
pm1 = [[1, 2, 3], [2, 3, 1]]
pm2 = [[1, 2, 3], [3, 2, 1]]
print("my_answer:", permutation(pm1, pm2))
#Output result
# ~~permutation_test~~
# my_answer: [[2, 3], [3, 2]]
There seems to be a lot of room for improvement, but for the time being, I tried it this time.
A good theory with a video of a university math class and a preliminary glue.
Recommended Posts