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
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
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
def find_points_with_gradient(function, gradient, answer): function = convert_equation(function) diff = sympy.diff(function, x) # Sympy can only solve for 0, so must take gradient from function diff -= gradient results = sympy.solve(diff, x) # Simplify results and answer to avoid issue with fractions for i in range(len(results)): results[i] = sympy.nsimplify(results[i]) for i in range(len(answer)): answer[i] = sympy.nsimplify(answer[i]) return True if (set(results) == set(answer)) else False
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
def Factorisation(function, answer): function = convert_equation(function) answer = convert_equation(answer) return True if (f_equals(answer, sympy.factor(function))) else False
def Simplification(function, answer): function = convert_equation(function) answer = convert_equation(answer) return True if (f_equals(answer, sympy.simplify(function))) else False
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
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
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
def parse(self): answer = convert_equation(str(self.attempt)) return answer