Ejemplo n.º 1
0
def Prob(PVar1, PVar2, PVar3, PVar4, PVar5, PVar6, PVar7, PVarP, answerE, answerV):

	ExpectedV = ((PVar1 * PVarP) + (PVar2 * PVarP) + (PVar3 * PVarP) + (PVar4 * PVarP) + (PVar5 * PVarP) + (PVar6 * PVarP) + (PVar7 * PVarP))
	ExpectedVsq = (((PVar1)**2 * PVarP) + ((PVar2)**2 * PVarP) + ((PVar3)**2 * PVarP) + ((PVar4)**2 * PVarP) + ((PVar5)**2 * PVarP) + ((PVar6)**2 * PVarP) + ((PVar7)**2 * PVarP))
	
	#This is the equation for working out the Variance. Var(x) = E(x**2) - (E(x)**2)
	VarianceV = ExpectedVsq - (ExpectedV**2)

	return True if (f_equals(answerE, ExpectedV)) and (f_equals(answerV, VarianceV)) else False
Ejemplo n.º 2
0
 def mark(self):
     """
     This function deterimines if the input gets a mark or not
     """
     attempt = self.parser.parse()
     function = equationMaker(self.qvariables)
     return True if (f_equals(attempt, sympy.integrate(function, x))) else False
Ejemplo n.º 3
0
def VectorDot(VectorA, VectorB, answer):

	VectorA = convert_Vector(VectorA)
	VectorB = convert_Vector(VectorB)

	Dotproduct = (VectorA0 * VectorB0) + (VectorA1 * VectorB1) + (VectorA2 * VectorB2)

	return True if (f_equals(answer, Matrix.T)) else False
Ejemplo n.º 4
0
    def mark(self):
        """Takes the first variable which is x coordinate of point and the rest makes
        equation"""

        attempt = self.parser.parse()
        point = (self.qvariables[:1])[0]
        function = equationMaker(self.qvariables[1:])
        return True if (f_equals(attempt, sympy.diff(function, x).subs(x, point))) else False
Ejemplo n.º 5
0
def Remainder(function, functionvalue, answer):

	#Need someone just to double check this, but you will need the value of f(x) = "to something" seperate than the function 
	function = convert_equation(function)
	functionvalue = convert_equation(functionvalue)
	answer = convert_equation(answer)
	remainderf = solve(Eq(function, x).subs(x, functionvalue))

	return True if (f_equals(answer, remainderf)) else False
Ejemplo n.º 6
0
 def mark(self):
     """
     This solves for the product rule, takes the values 'u' and 'v' and differentiate them
     """
     attempt = self.parser.parse()
     u = equationMaker(self.qvariables[0]) 
     v = equationMaker(self.qvariables[1])
     function = "(" + str(u) + ")*(" + str(v) + ")"
     return True if f_equals(attempt, sympy.diff(function, x)) else False
Ejemplo n.º 7
0
 def mark(self):
     """
     This solves the quoitent rule, by differeniating u over v
     """
     attempt = self.parser.parse()
     u = equationMaker(self.qvariables[0]) 
     v = equationMaker(self.qvariables[1])
     function = "(" + str(u) + ")/(" + str(v) + ")"
     return True if f_equals(attempt, sympy.diff(function, x)) else False
Ejemplo n.º 8
0
def MatrixMultiply(MatrixM, MatrixN, answer):

	MatrixM = convert_Matrix(MatrixM)
	MatrixN = convert_Matrix(MatrixN)
	answer = convert_Matrix(answer)

	Multi = MatrixM * MatrixN

	return True if (f_equals(answer, Multi)) else False
Ejemplo n.º 9
0
def VectorCross(VectorA, VectorB, answer):

	VectorA = convert_Vector(VectorA)
	VectorB = convert_Vector(VectorB)

	Crossproducti = (VectorA1 * VectorB2) - (VectorA2 * VectorB1)
	Crossproductj = (VectorA0 * VectorB2) - (VectorA2 * VectorB0)
	Crossproductk = (VectorA0 * VectorB1) - (VectorA1 * VectorB0)
	Cross = (Crossproducti * i) - (Crossproductj * j) + (Crossproductk * k)

	return True if (f_equals(answer, Cross)) else False
Ejemplo n.º 10
0
def find_equation_of_normal(function, point, answer):
	x0 = point[0]
	y0 = point[1]

	function = convert_equation(function)
	answer = convert_equation(answer)

	n =  - (1 / (sympy.diff(function, x).subs(x, x0)))

	normal = n*x + y0 - n*x0

	return True if f_equals(answer, normal) else False
Ejemplo n.º 11
0
def find_equation_of_tangent(function, point, answer):
	x0 = point[0]
	y0 = point[1]

	function = convert_equation(function)
	answer = convert_equation(answer)

	m = sympy.diff(function, x).subs(x, x0)

	tangent = m*x + y0 - m*x0

	return True if f_equals(answer, tangent) else False
Ejemplo n.º 12
0
def MatrixCofactor(Matrix, answer):

	Matrix = convert_Matrix(Matrix)

	def cofactorMatrix(Matrix, method="berkowitz"):
	#Return a matrix containing the cofactor of each element.
		out = Matrix._new(Matrix.rows, Matrix.cols, lambda i,j:
			Matrix.cofactor(i, j, method))
		return out

	answer = convert_Matrix(answer)

	return True if (f_equals(answer, cofactorMatrix(Matrix))) else False
Ejemplo n.º 13
0
def Choose(VarO, Var1, Var2, Var3, answer):

	answer = convert_equation(answer)

	#This creates a needed value that is the opposite to the required variable
	Ne = VarO - Var3
	
	#This creates the value that allows the maximum number of chooses and still gets the required number of objects 
	Bc = Ne - Var2

	#The creates the value that allows the total maximum number of chooses before the goal cannot be reached
	Be = VarO - Var2

	#This is the total number of combinations that could be made to take out the required numbers irregradless of what is taken out
	Ch1 = (math.factorial(VarO)) / (math.factorial(Ne) * math.factorial(VarO - Ne))

	#This is the total number of combinations that could be made to take out the required number with notice to what is taken out
	Ch2 = (math.factorial(Be)) / (math.factorial(Bc) * math.factorial(Be - Bc))

	#This determines the actuall probability of the question
	ans = Ch2 / Ch1

	return True if (f_equals(answer, ans)) else False
Ejemplo n.º 14
0
def MatrixTranspose(Matrix, answer):

	Matrix = convert_Matrix(Matrix)
	answer = convert_Matrix(answer)

	return True if (f_equals(answer, Matrix.T)) else False
Ejemplo n.º 15
0
def Factorisation(function, answer):

	function = convert_equation(function)
	answer = convert_equation(answer)

	return True if (f_equals(answer, sympy.factor(function))) else False
Ejemplo n.º 16
0
def Simplification(function, answer):

	function = convert_equation(function)
	answer = convert_equation(answer)

	return True if (f_equals(answer, sympy.simplify(function))) else False
Ejemplo n.º 17
0
def Intergrate_this(function, answer):

	function = convert_equation(function)
	answer = convert_equation(answer)

	return True if (f_equals(answer, sympy.integrate(function, x))) else False
Ejemplo n.º 18
0
def find_gradient_at(function, point, answer):
	function = convert_equation(function)
	return True if (f_equals(answer, sympy.diff(function, x).subs(x, point))) else False
Ejemplo n.º 19
0
def differentiate_this(function, answer):
	function = convert_equation(function)
	answer = convert_equation(answer)
	return True if (f_equals(answer, sympy.diff(function, x))) else False
Ejemplo n.º 20
0
def MatrixInverse(Matrix, answer):

	Matrix = convert_Matrix(Matrix)
	answer = convert_Matrix(answer)

	return True if (f_equals(answer, sympy.Matrix.inv("LU"))) else False
Ejemplo n.º 21
0
def MatrixDet(Matrix, answer):

	Matrix = convert_Matrix(Matrix)
	answer = convert_Matrix(answer)

	return True if (f_equals(answer, sympy.Matrix.det())) else False