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 );
- init: a TUPLE with the initial values for the function. Each element can be a string to create a variable, any rational number or any polynomial expression which variables will be considered as parameters (so 'x' is not allowed).
'''
if(is_DDFunction(q)):
- destiny_ring = DDRing(q.parent());
+ destiny_ring = q.parent().to_depth(q.parent().depth());
parent, new_all = __check_list([a] + list(init), [str(el) for el in DFinite.variables()]);
if(not (parent is QQ)):
elif(len(input) == 0 ):
return element;
- raise NotImplementedError("Not implemented evaluation of an element of this ring (%s) with the parameters %s and %s" %(self,rx,input));
+ raise NotImplementedError("Not implemented evaluation of an element of this ring (%s) with the parameters %s and %s" %(self,repr(rx),input));
def get_recurrence(self, *args, **kwds):
if(self.__get_recurrence is None):
#####################################
### Differential methods
#####################################
- def derivative(self, *args):
+ def derivative(self, *args, **kwds):
'''
Method to get a DDFunction `g` that satisfies `D(self) = g`.
INPUT:
- ``args``: ignored input
- '''
+ - ''kwds'': if times is included, we compute the times-th derivative
+ '''
+ if('times' in kwds):
+ if(kwds['times'] in ZZ):
+ times = kwds['times'];
+ if(times < 0):
+ raise ValueError("Negative derivatives can not be computed");
+ elif(times == 0):
+ return self;
+ elif(times > 1):
+ return self.derivative(times=times-1).derivative();
+
if(self.__derivative is None):
if(self.is_constant):
### Special case: is a constant
to_mult *= value;
return float(res),float(abs(to_sum));
+ @cached_method
def to_symbolic(self):
evaluation = sage_eval(str(self.__name).replace("'", ".derivative()").replace("^", "**"), locals=globals());
if(isinstance(evaluation, sage.symbolic.expression.Expression)):
evaluation = evaluation.simplify_full();
return evaluation;
+
+ @cached_method
+ def to_simpler(self):
+ try:
+ R = self.parent().base();
+ 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;
+ return self;
def quick_equals(self,other): ### TO REVIEW
'''