First time here? Check out the FAQ!

Ask Your Question
1

Limit with variables from array

asked 0 years ago

Max Alekseyev gravatar image

updated 0 years ago

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

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 0 years ago

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,

Preview: (hide)
link

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 ( 0 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

1 follower

Stats

Asked: 0 years ago

Seen: 189 times

Last updated: Oct 03 '24