Weird behavior of a divergent sum when using the assume() command

29 views
Skip to first unread message

saad khalid

unread,
Jan 15, 2018, 9:23:16 PM1/15/18
to sage-support
Hello everyone:

So, I was just messing around with the assume command, and did:

var('i')
assume
(abs(x) < 1)
f
(x) = sum(x^i, i, 0, oo )

This is just 1/(1-x). I wanted to see what would happen when I tried using x > 1, and it still evaluates properly, even though the sum should be divergent for x > 1. How does this happen behind the scenes exactly? Is Sage/Maxima substituting 1/(1-x) for my sum? Further, I took the integral from 0 to 2:

integrate(f(x),x,0,2)

which returned -I*pi. How does this work? What exactly is it doing here? I'm assuming it's using an analytic continuation somehow, but how does it find it and where is it substituted in exactly? What I mean is, what exactly is the function f(x) equal to if it can be integrated like that?

Thank you!

Ralf Stephan

unread,
Jan 17, 2018, 2:40:35 AM1/17/18
to sage-support
On Tuesday, January 16, 2018 at 3:23:16 AM UTC+1, saad khalid wrote:
Hello everyone:

So, I was just messing around with the assume command, and did:

var('i')
assume
(abs(x) < 1)
f
(x) = sum(x^i, i, 0, oo )

This is just 1/(1-x). I wanted to see what would happen when I tried using x > 1, and it still evaluates properly

I cannot confirm that, I get:
sage: forget()
sage
: assume(x-1>0)
sage
: f(x) = sum(x^i, i, 0, oo )
...
ValueError: Sum is divergent.
 
, even though the sum should be divergent for x > 1. How does this happen behind the scenes exactly? Is Sage/Maxima substituting 1/(1-x) for my sum? Further, I took the integral from 0 to 2:

integrate(f(x),x,0,2)

which returned -I*pi. 

I cannot confirm that either for f(x) = 1/(1-x) because I get
sage: integrate(1/(1-x),x,0,2)
...
ValueError: Integral is divergent.
regardless of assumptions.

My guess is you have done operations with f(x) in the meantime that change what you think you are doing.

Regards,

saad khalid

unread,
Jan 17, 2018, 4:54:10 PM1/17/18
to sage-support


On Wednesday, January 17, 2018 at 1:40:35 AM UTC-6, Ralf Stephan wrote:
On Tuesday, January 16, 2018 at 3:23:16 AM UTC+1, saad khalid wrote:
Hello everyone:

So, I was just messing around with the assume command, and did:

var('i')
assume
(abs(x) < 1)
f
(x) = sum(x^i, i, 0, oo )

This is just 1/(1-x). I wanted to see what would happen when I tried using x > 1, and it still evaluates properly

I cannot confirm that, I get:
sage: forget()
sage
: assume(x-1>0)
sage
: f(x) = sum(x^i, i, 0, oo )
...
ValueError: Sum is divergent.
 



Sorry, what I meant was, when I use the assume(abs(x) < 1), but still plug in a value for x that is greater than 1 into the function.  For example, f(1.5) runs fine, even when I have assume(abs(x) < 1).

Here is a cocalc sheet with the code:


I cannot confirm that either for f(x) = 1/(1-x) because I get
sage: integrate(1/(1-x),x,0,2)
...
ValueError: Integral is divergent.
regardless of assumptions.

Yes, exactly! This is what was confusing me. So, when i run my original code with assume( abs(x) < 1), and then define my function, it seems to automatically define my function as f(x) = -1/(x-1). Originally, I was just curious about how it knew to do this substitution (though I assumed it was just some built in substitution/simplification). But, I didn't understand why it let me plug in values for x that were greater than 1, when I had defined the function to take inputs less than 1. I don't think this is a bad thing, I just thought it was interesting and was curious about it. But then, I tried integrating over the divergence at 1, doing the integral from 0 to 2, and i expected it to tell me it was a divergent integral, but the result was -I*pi. I was even more intrigued by this, because I assume it is substituting in some sort of analytic continuation, but I wasn't sure how it was doing that exactly, since the function I originally defined as an infinite sum had obviously been replaced by f(x) = -1/(x-1), which clearly has a divergent integral over these limits. Why is it that when I integrate over 1/(1-x), it is divergent with these limits, but when I integrate over the function I defined originally, it is not? Why does the substitution happen in the second case and not the first, and how is this substitution happening?

Thanks!

Ralf Stephan

unread,
Jan 18, 2018, 2:27:42 AM1/18/18
to sage-support
On Wednesday, January 17, 2018 at 10:54:10 PM UTC+1, saad khalid wrote:
what I meant was, when I use the assume(abs(x) < 1), but still plug in a value for x that is greater than 1 into the function.  For example, f(1.5) runs fine, even when I have assume(abs(x) < 1).

The right side of "f(x)=sum..." is evaluated at the time where the assumption holds. If you change assumptions after that the f(x) is already set. If you want to have different behaviour use a Python function:

sage: def f(x): return sum(x^i, i, 0, oo)
sage
: assume(abs(x)<1)

sage
: f(x)
-1/(x - 1)
sage
: forget()
sage
: assume(abs(x)>1)
sage
: f(x)

...
ValueError: Sum is divergent.

As to the integral I take back what I said because I get (both on a fresh Sage):
sage: assume(abs(x)>1)

sage
: integrate(1/(1-x),x,0,2)
...
ValueError: Integral is divergent.

and

sage: var('i')
i
sage
: assume(abs(x)<1)

sage
: f(x) = sum(x^i, i, 0, oo)

sage
: integrate(f(x),x,0,2)
-I*pi
sage
: forget()
sage
: assume(abs(x)>1)
sage
: integrate(f(x),x,0,2)

Ralf Stephan

unread,
Jan 18, 2018, 2:44:09 AM1/18/18
to sage-support
Looking back to earlier posts in this thread I think the confusion was because of assuming x<1 not abs(x)<1.

Finally in your cocalc worksheet the assumption abs(x)<1 holds at the time the integral is done so you get the value.
Reply all
Reply to author
Forward
0 new messages