Skip to content

Instantly share code, notes, and snippets.

@Pascal-0x90
Created August 19, 2020 07:07
Show Gist options
  • Save Pascal-0x90/04df48542c35e541a5b00a9ff43322b0 to your computer and use it in GitHub Desktop.
Save Pascal-0x90/04df48542c35e541a5b00a9ff43322b0 to your computer and use it in GitHub Desktop.
Calculates the volume of fundamental domain using basis vectors
#!/usr/bin/env python3
import numpy as np
'''
Our volume is found by taking the determinte
of the vectors given. #LinearAlgebraBoii
v1 = [6, 2, -3]
v2 = [5, 1, 4]
v3 = [2, 7, 1]
Then make it look like:
6, 2, -3
5, 1, 4
2, 7, 1
Then the determinite algorithm is:
6(1*1-7*4) - 2(5*1 - 2*4) + (-3)(5*7 - 2*1) = -255
Then our volume is: |-255| = 255
'''
v1 = [6, 2, -3]
v2 = [5, 1, 4]
v3 = [2, 7, 1]
numpy_array = np.array([v1,v2,v3])
det = np.linalg.det(numpy_array)
print(f"Volume: {abs(det)}") # Can round up if need be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment