From ab960534f9de120c21282eb657aa47a97052e291 Mon Sep 17 00:00:00 2001 From: midhun varman Date: Mon, 19 Oct 2020 13:04:44 +0530 Subject: [PATCH] added vector dot product --- mathgenerator/funcs/__init__.py | 1 + mathgenerator/funcs/vectorDotFunc.py | 13 +++++++++++++ mathgenerator/mathgen.py | 1 + 3 files changed, 15 insertions(+) create mode 100644 mathgenerator/funcs/vectorDotFunc.py diff --git a/mathgenerator/funcs/__init__.py b/mathgenerator/funcs/__init__.py index efb1ce7..99ab6b4 100644 --- a/mathgenerator/funcs/__init__.py +++ b/mathgenerator/funcs/__init__.py @@ -71,3 +71,4 @@ from .multiplyComplexNumbersFunc import * from .geomProgrFunc import * from .geometricMeanFunc import * from .harmonicMeanFunc import * +from .vectorDotFunc import * diff --git a/mathgenerator/funcs/vectorDotFunc.py b/mathgenerator/funcs/vectorDotFunc.py new file mode 100644 index 0000000..a15cd75 --- /dev/null +++ b/mathgenerator/funcs/vectorDotFunc.py @@ -0,0 +1,13 @@ +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 diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 0e813a6..35c657f 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -156,3 +156,4 @@ complexNumMultiply = Generator("Multiplication of 2 complex numbers", 64, "(x + geometricprogression=Generator("Geometric Progression", 65, "Initial value,Common Ratio,nth Term,Sum till nth term =", "a,r,ar^n-1,sum(ar^n-1", geomProgrFunc) geometricMean=Generator("Geometric Mean of N Numbers",66,"Geometric mean of n numbers A1 , A2 , ... , An = ","(A1*A2*...An)^(1/n) = ans",geometricMeanFunc) harmonicMean=Generator("Harmonic Mean of N Numbers",67,"Harmonic mean of n numbers A1 , A2 , ... , An = "," n/((1/A1) + (1/A2) + ... + (1/An)) = ans",harmonicMeanFunc) +vectorDot = Generator("Dot Product of 2 Vectors",68, "a . b = ", "c", vectorDotFunc)