Ask Your Question
1

Limit with variables from array

asked 2024-10-03 05:24:51 +0100

Max Alekseyev gravatar image

updated 2024-10-03 17:20:22 +0100

The following code:

x = [var(f'x{i}') for i in range(3)]
f = sum(x)
f.limit(x[1]=1)

gives an error:

SyntaxError: expression cannot contain assignment, perhaps you meant "=="?

If I replace x[1]=1 with x[1]==1, I get

ValueError: call the limit function like this, e.g. limit(expr, x=2).

and we go in circles. How to proceed?

ADDED. This issue has been reported at https://github.com/sagemath/sage/issu...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2024-10-03 06:54:45 +0100

Emmanuel Charpentier gravatar image

This is indeed a misdesign of the limit wrapper method/function. Feel free to propose an enhancement.

Workarounds :

sage: X=var("x", n=3)
sage: f=sum(X) ; f
x0 + x1 + x2
sage: f.maxima_methods().limit(X[0], 1)
x1 + x2 + 1
sage: maxima_calculus.limit(f, X[0], 1)._sage_()
x1 + x2 + 1
sage: from sympy import sympify
sage: f._sympy_().limit(*map(sympify, (X[0], 1)))._sage_()
x1 + x2 + 1

HTH,

edit flag offensive delete link more

Comments

Thanks! Another workaround: f.limit(**{str(x[1]):1})

Anyway, I've submitted the issue: https://github.com/sagemath/sage/issu...

Max Alekseyev gravatar imageMax Alekseyev ( 2024-10-03 17:19:35 +0100 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-10-03 05:24:51 +0100

Seen: 147 times

Last updated: Oct 03