def derivative_factory(name):
    """Create derivative function for some ufuncs."""

    if name == 'sin':
        def derivative(self, point):
            """Return the derivative operator."""
            return MultiplyOperator(cos(self.domain)(point))
    elif name == 'cos':
        def derivative(self, point):
            """Return the derivative operator."""
            point = self.domain.element(point)
            return MultiplyOperator(-sin(self.domain)(point))
    elif name == 'tan':
        def derivative(self, point):
            """Return the derivative operator."""
            return MultiplyOperator(1 + self(point) ** 2)
    elif name == 'sqrt':
        def derivative(self, point):
            """Return the derivative operator."""
            return MultiplyOperator(0.5 / self(point))
    elif name == 'square':
        def derivative(self, point):
            """Return the derivative operator."""
            point = self.domain.element(point)
            return MultiplyOperator(2.0 * point)
    elif name == 'log':
        def derivative(self, point):
            """Return the derivative operator."""
            point = self.domain.element(point)
            return MultiplyOperator(1.0 / point)
    elif name == 'exp':
        def derivative(self, point):
            """Return the derivative operator."""
            return MultiplyOperator(self(point))
    elif name == 'reciprocal':
        def derivative(self, point):
            """Return the derivative operator."""
            point = self.domain.element(point)
            return MultiplyOperator(-self(point) ** 2)
    elif name == 'sinh':
        def derivative(self, point):
            """Return the derivative operator."""
            point = self.domain.element(point)
            return MultiplyOperator(cosh(self.domain)(point))
    elif name == 'cosh':
        def derivative(self, point):
            """Return the derivative operator."""
            return MultiplyOperator(sinh(self.domain)(point))
    else:
        # Fallback to default
        derivative = Operator.derivative

    return derivative
def derivative_factory ( name ) : if name == 'sin' : def derivative ( self , point ) : return MultiplyOperator ( cos ( self . domain ) ( point ) ) elif name == 'cos' : def derivative ( self , point ) : point = self . domain . element ( point ) return MultiplyOperator ( - sin ( self . domain ) ( point ) ) elif name == 'tan' : def derivative ( self , point ) : return MultiplyOperator ( 1 + self ( point ) ** 2 ) elif name == 'sqrt' : def derivative ( self , point ) : return MultiplyOperator ( 0.5 / self ( point ) ) elif name == 'square' : def derivative ( self , point ) : point = self . domain . element ( point ) return MultiplyOperator ( 2.0 * point ) elif name == 'log' : def derivative ( self , point ) : point = self . domain . element ( point ) return MultiplyOperator ( 1.0 / point ) elif name == 'exp' : def derivative ( self , point ) : return MultiplyOperator ( self ( point ) ) elif name == 'reciprocal' : def derivative ( self , point ) : point = self . domain . element ( point ) return MultiplyOperator ( - self ( point ) ** 2 ) elif name == 'sinh' : def derivative ( self , point ) : point = self . domain . element ( point ) return MultiplyOperator ( cosh ( self . domain ) ( point ) ) elif name == 'cosh' : def derivative ( self , point ) : return MultiplyOperator ( sinh ( self . domain ) ( point ) ) else : derivative = Operator . derivative return derivative
Create derivative function for some ufuncs.