Ask Your Question

7sDream's profile - activity

2021-02-20 16:02:12 +0200 received badge  Scholar (source)
2021-02-20 12:35:38 +0200 received badge  Supporter (source)
2021-02-20 04:09:44 +0200 received badge  Student (source)
2021-02-19 14:49:44 +0200 asked a question A simple sum causes division by zero exception

I'm very new to SageMath and did some small experiments yesterday. This is my Code:

x, n, r, i = var('x, n, r, i')
f(x, n, r) = x * sum((1 + r) ^ i, i, 1, n)
f(1, 30, 0.0)

It works well if r != 0, but will raise a exception of "division by zero" if equal.

My ipynb file: nbviewer.jupyter.org/gist/7sDream/5db3cfd153269fd1a1cacaf0b60f69bb

It seems some optimizations of sum did not consider the range of variable r. But there is also no change if I added assume(r >= 0)before define f.

So how can I disable this sum optimizations? Or what is wrong with the way I use it?