This function can be converted into symbolic expressions.
'''
- #if(is_DDFunction(input)):
- # return Sin(x)(input);
+ if(is_DDFunction(input)):
+ return Sin(x)(input);
f,dR = __decide_parent(input, ddR);
evaluate = lambda p : dR.getSequenceElement(p,_sage_const_0 );
This function can be converted into symbolic expressions.
'''
- #if(is_DDFunction(input)):
- # return Cos(x)(input);
+ if(is_DDFunction(input)):
+ return Cos(x)(input);
f,dR = __decide_parent(input, ddR);
evaluate = lambda p : dR.getSequenceElement(p,_sage_const_0 );
This function can be converted into symbolic expressions.
'''
- #if(is_DDFunction(input)):
- # return Tan(x)(input);
+ if(is_DDFunction(input)):
+ return Tan(x)(input);
if(input == x):
return DDFinite.element([-_sage_const_2,0,Cos(x)**2],[0,1]);
g, dR = __decide_parent(input, ddR,_sage_const_2 );
This function can be converted into symbolic expressions.
'''
- #if(is_DDFunction(input)):
- # return Sinh(x)(input);
+ if(is_DDFunction(input)):
+ return Sinh(x)(input);
f,dR = __decide_parent(input, ddR);
evaluate = lambda p : dR.getSequenceElement(p,_sage_const_0 );
This function can be converted into symbolic expressions.
'''
- #if(is_DDFunction(input)):
- # return Cosh(x)(input);
+ if(is_DDFunction(input)):
+ return Cosh(x)(input);
f,dR = __decide_parent(input, ddR);
evaluate = lambda p : dR.getSequenceElement(p,_sage_const_0 );
This function can be converted into symbolic expressions.
'''
- #if(is_DDFunction(input)):
- # return Log(x+_sage_const_1 )(input-1);
+ if(is_DDFunction(input)):
+ return Log(x+_sage_const_1 )(input-1);
f,dR = __decide_parent(input, ddR);
evaluate = lambda p : dR.getSequenceElement(p,_sage_const_0 );
This function can be converted into symbolic expressions.
'''
- #if(is_DDFunction(input)):
- # return Log1(x)(input);
+ if(is_DDFunction(input)):
+ return Log1(x)(input);
f,dR = __decide_parent(input, ddR);
evaluate = lambda p : dR.getSequenceElement(p,_sage_const_0 );
This function can be converted into symbolic expressions.
'''
- #if(is_DDFunction(input)):
- # return Exp(x)(input);
+ if(is_DDFunction(input)):
+ return Exp(x)(input);
f,dR = __decide_parent(input, ddR);
evaluate = lambda p : dR.getSequenceElement(p,_sage_const_0 );
if(is_DDRing(R)):
return R(self).to_simpler();
elif(is_PolynomialRing(R)):
- if(self.getOrder() == 1):
- degree = abs(self[0].lc());
- if(self.derivative(times=degree+1).is_null):
- x = self.parent().variables()[0];
- return sum(self.getSequenceElement(i)*x**i for i in range(degree+1));
- except:
- pass;
+ degs = [self[i].degree() - i for i in range(self.getOrder()+1)];
+ m = max(degs);
+ maxs = [i for i in range(len(degs)) if degs[i] == m];
+
+ if(len(maxs) <= 1):
+ raise ValueError("1:Function %s is not a polynomial" %repr(self));
+
+ x = R.gens()[0];
+ pol = sum(falling_factorial(x,i)*self[i].lc() for i in maxs);
+
+ root = max(root[0] for root in pol.roots() if (root[0] in ZZ and root[0] > 0));
+ pol = sum(x**i*self.getSequenceElement(i) for i in range(root+1));
+
+ if(pol == self):
+ return pol;
+ raise ValueError("2:Function %s is not a polynomial" %repr(self));
+ except Exception as e:
+ print e;
return self;
def quick_equals(self,other): ### TO REVIEW
- Matrices or vectors with polynomials rocignized by the Conversion system
- Elements in `self.base()`
'''
+ from sage.structure.element import is_Matrix;
+ from sage.structure.element import is_Vector;
+
if(element in self.poly_ring()):
try:
return self.poly_ring()(element).reduce(self._relations());
return set([self.simplify(el) for el in element]);
elif(isinstance(element, tuple)):
return tuple([self.simplify(el) for el in element]);
- elif(isinstance(element, sage.matrix.matrix.Matrix)):
+ elif(is_Matrix(element)):
R = self.poly_ring();
if(element.parent().base().is_field()):
R = self.poly_field();
return Matrix(R, [[self.simplify(el) for el in row] for row in element]);
- elif(isinstance(element, sage.modules.free_module_element.FreeModuleElement)):
+ elif(is_Vector(element)):
R = self.poly_ring();
if(element.parent().base().is_field()):
R = self.poly_field();