Exemple #1
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
Exemple #2
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
Exemple #3
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 attempt == sympy.diff(function, x) else False
Exemple #4
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
Exemple #5
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
Exemple #6
0
    def mark(self):
        """Splits up input into point location and MinMax Value"""
        gradient = 0
        attempt = self.parser.parse()
        attemptPoints = attempt[0]
        attemptMinMax = attempt[1]
        function = equationMaker(self.qvariables)
    
        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(attemptPoints)):
            attemptPoints[i] = sympy.nsimplify(attemptPoints[i])
        
        """Differentiates a second time, works out if the point is positive, negative
        or 0 and then sets the list accordingly. Minimum point is -1, Max is 1."""
        diff2 = sympy.diff(diff, x)
        minOrMax = []
        for i in range(len(results)):
            j = diff2.subs(x, results[i])
            if j > 0:
                minOrMax.append(-1)
            elif j < 0:
                minOrMax.append(1)
            else:
                minOrMax.append(0)

        """Redundant code for if we split marks up, if so it gives value for each part
        correctly answered:

        half = 1 if (set(minOrMax) == set(attemptMinMax)) else 0
        half += 1 if (set(attemptPoints) == set(results)) else 0
        """
        
        return True if (set(minOrMax) == set(attemptMinMax)) and (set(attemptPoints) == set(results)) else False
Exemple #7
0
import sympy
from functions import equationMaker
x, y = sympy.symbols("x y")

attempt = 2*x**1 + 2
function = equationMaker([1,2,3])
print(True if attempt == sympy.diff(function, x) else False)