Ask Your Question
0

Compare elements of a recursive defined sequence

asked 11 years ago

KurtM gravatar image

updated 11 years ago

tmonteil gravatar image

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

Preview: (hide)

Comments

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))

KurtM gravatar imageKurtM ( 11 years ago )

3 Answers

Sort by » oldest newest most voted
1

answered 11 years ago

tmonteil gravatar image

updated 11 years ago

The simple reason is that your conjecture is False. Try with:

A = 1
b = 2
c = 1/2

All those numbers are strictly positive, but you will get:

sage: Sequence_rec(3) - Sequence_rec(2)
-20/3

Note also that the denominator can vanish along the loop when i=c+2, which may be another cause of trouble (you will have a lot of poles). By the way, even if the sequence was indeed increasing, Sage will not be able to give an answer for all n together (it does not understands loops symbolically). Moreover, you could even imagine to encode undecidable problems in the iteration of such formulas.

Preview: (hide)
link
0

answered 11 years ago

tmonteil gravatar image

More generally, if you ask for a boolean, you should know that Sage is not able to answer Unknown, hence it will usually answer False when it is not able to prove that answer is True, which is not what mathematicians usually expect.

Actually, there exists an Unknown truth value in Sage but then python will not be able to deal correctly with boolean operations, see

sage: Unknown?

and PEP 335 for more information about this, which was unfortunately rejected, preventing Sage to deal with "proved True", "proved False", "Unable to prove".

Preview: (hide)
link

Comments

Actually, I would prefer an even better alternative for trueness of an expression: either True, or False here is a counterexample or Unknown.

vdelecroix gravatar imagevdelecroix ( 11 years ago )
0

answered 11 years ago

vdelecroix gravatar image

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
Preview: (hide)
link

Comments

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".

KurtM gravatar imageKurtM ( 11 years ago )

There is no general algorithm to answer the question "f(x) > 0 ?". In your particular case, everything is polynomial so you can do something but not with symbolic expressions.

vdelecroix gravatar imagevdelecroix ( 11 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 11 years ago

Seen: 912 times

Last updated: May 31 '13