mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Merge branch 'master' into master
This commit is contained in:
@@ -71,4 +71,8 @@ from .multiplyComplexNumbersFunc import *
|
||||
from .geomProgrFunc import *
|
||||
from .geometricMeanFunc import *
|
||||
from .harmonicMeanFunc import *
|
||||
from .binary2sComplement import *
|
||||
from .euclidianNormFunc import *
|
||||
from .angleBtwVectorsFunc import *
|
||||
from .absoluteDifferenceFunc import *
|
||||
from .vectorDotFunc import *
|
||||
from .binary2sComplement import *
|
||||
|
||||
10
mathgenerator/funcs/absoluteDifferenceFunc.py
Normal file
10
mathgenerator/funcs/absoluteDifferenceFunc.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from .__init__ import *
|
||||
|
||||
def absoluteDifferenceFunc (maxA = 100, maxB = 100):
|
||||
a = random.randint(-1*maxA, maxA)
|
||||
b = random.randint(-1*maxB, maxB)
|
||||
absDiff = abs(a-b)
|
||||
|
||||
problem = "Absolute difference between numbers " + str(a) + " and " + str(b) + " = "
|
||||
solution = absDiff
|
||||
return problem, solution
|
||||
16
mathgenerator/funcs/angleBtwVectorsFunc.py
Normal file
16
mathgenerator/funcs/angleBtwVectorsFunc.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from .euclidianNormFunc import euclidianNormFunc
|
||||
import math
|
||||
from .__init__ import *
|
||||
|
||||
|
||||
def angleBtwVectorsFunc(v1: list, v2: list):
|
||||
sum = 0
|
||||
for i in v1:
|
||||
for j in v2:
|
||||
sum += i * j
|
||||
|
||||
mags = euclidianNormFunc(v1) * euclidianNormFunc(v2)
|
||||
problem = f"angle between the vectors {v1} and {v2} is:"
|
||||
solution = math.acos(sum / mags)
|
||||
# would return the answer in radians
|
||||
return problem, solution
|
||||
7
mathgenerator/funcs/euclidianNormFunc.py
Normal file
7
mathgenerator/funcs/euclidianNormFunc.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from .__init__ import *
|
||||
|
||||
|
||||
def euclidianNormFunc(v1: list):
|
||||
problem = f"Euclidian norm or L2 norm of the vector{v1} is:"
|
||||
solution = sqrt(sum([i**2 for i in v1]))
|
||||
return problem, solution
|
||||
11
mathgenerator/funcs/vectorDotFunc.py
Normal file
11
mathgenerator/funcs/vectorDotFunc.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from .__init__ import *
|
||||
|
||||
|
||||
def vectorDotFunc(minVal=-20, maxVal=20):
|
||||
a = [random.randint(minVal, maxVal) for i in range(3)]
|
||||
b = [random.randint(minVal, maxVal) for i in range(3)]
|
||||
c = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
|
||||
|
||||
problem = str(a) + " . " + str(b) + " = "
|
||||
solution = str(c)
|
||||
return problem, solution
|
||||
Reference in New Issue
Block a user