Ask Your Question

KurtM's profile - activity

2021-03-27 05:18:07 +0200 received badge  Famous Question (source)
2018-02-12 17:39:01 +0200 received badge  Famous Question (source)
2017-03-10 09:22:02 +0200 received badge  Notable Question (source)
2017-03-10 09:22:02 +0200 received badge  Popular Question (source)
2015-10-28 07:46:17 +0200 received badge  Notable Question (source)
2014-11-05 13:48:07 +0200 received badge  Popular Question (source)
2013-06-03 11:51:40 +0200 asked a question Compare symbolic expressions

Following is the problem I am trying to solve:

I have multiple complex symbolic expressions f1(x1,x2,...,xn),f2(x1,x2,...,xn),...,fn(x1,x2,...,xn) which are functions of symbolic variables x1,x2,...,xn. I also have some constraints for the symbolic variables, e.g. 0 is smaller than x1, 2 is smaller than x2, x2 is integer, etc. How can I find out for two selected symbolic expressions which one is larger for given constraints?

I've tried something like:

assume(0<x1,2<x2)< p="">

assume(x2,'integer')

bool(f1>f2)

It seems to work for more simple symbolic expressions. For more complex symbolic expressions (where a solution definitely exists) SAGE seems not to be able to compare the expressions. Is there a way to overcome this?

2013-06-03 11:43:43 +0200 asked a question Compare symbolic expressions

Following is the problem I am trying to solve:

I have multiple complex symbolic expressions f1(x1,x2,...,xn),f2(x1,x2,...,xn),...,fn(x1,x2,...,xn) which are functions of symbolic variables x1,x2,...,xn. I also have some constraints for the symbolic variables, e.g. 0<x1, 2<x2,="" x2="" is="" integer,="" etc.="" how="" can="" i="" find="" out="" for="" two="" selected="" symbolic="" expressions="" which="" one="" is="" larger="" for="" given="" constraints?<="" p="">

I've tried something like:

assume(0<x1,2<x2)< p="">

assume(x2,'integer')

bool(f1>f2) code

It seems to work for more simple symbolic expressions. For more complex symbolic expressions (where a solution definitely exists) SAGE seems not to be able to compare the expressions. Is there a way to overcome this?

2013-06-03 11:16:16 +0200 marked best answer Compare elements of a recursive defined sequence

If you expect an answer you should tell Sage what are your assumptions (ie in the case you mention assume(c > 2)). Nevertheless, assuming your intution is correct, you can not rely on the output of bool(my_expression) as

sage: assume(c > 3)
sage: bool(Sequence_rec(4) > Sequence_rec(3))
False
sage: bool(Sequence_rec(4) < Sequence_rec(3))
False
sage: bool(Sequence_rec(4) == Sequence_rec(3))
False
2013-06-03 11:16:16 +0200 received badge  Scholar (source)
2013-05-31 05:04:28 +0200 commented answer Compare elements of a recursive defined sequence

Thank you. As far as I know, the command bool(my_expression) evaluates the relation of the symbolic expressions. In this case I do not understand why it is not evaluated according to my "intuition".

2013-05-31 04:19:01 +0200 received badge  Supporter (source)
2013-05-31 04:18:39 +0200 received badge  Editor (source)
2013-05-31 04:12:39 +0200 commented question Compare elements of a recursive defined sequence

Thanks for your reply. I forgot to mention that c and k are defined as integers and k<=c. In this case it must be Sequence_rec(n+1) > Sequence_rec(n). I use the elements of the sequence for further calculations. What is the reason Sage is not able to compare symbolic expressions: bool(Sequence_rec(3) > Sequence_rec(2))? It works for: bool(Sequence_rec(2) > Sequence_rec(1))

2013-05-29 11:02:26 +0200 asked a question Compare elements of a recursive defined sequence

I define the recursive sequence as:

A, b, c = var('A, b, c')
def Sequence_rec(k):
     x = 0
     for i in range(1,k+1):
         x = x + (A - x)/((c-i+2)^b)
     return x

For the parameters the assumptions are:

assume(A>0,c>0,b>0)
assume(c, 'integer')

I'm interested in the elements of Sequence_rec(k) with k<=c. The following relation has to be true for the defined sequence considering the given assumptions:

assume(c>2)
bool(Sequence_rec(4) > Sequence_rec(3))

But Sage computes it is false! The following plot shows the difference is positive:

plot((Sequence_rec(4) - Sequence_rec(3))(A=1,c=3),b,(0,100))

How can I force Sage to compare the elements of the sequence bool(Sequence_rec(n+1) > Sequence_rec(n)) = true for any positive integer n correctly? Thank you for your advice!

Kurt