1 | initial version |
Defining a variable inside the function lets us control what variable we use for the limit.
For example, define t
and substitute it for the variable provided by the user.
Applying this idea, we can define myfunction
as follows:
def mylimit(f, x, a):
r"""
Return the limit of the expression `f` when `x` tends to `a`.
"""
t = SR.var('t')
return f.subs({x: t}).limit(t=a)
With that definition:
sage: mylimit(1/y, y, 2)
1/2
2 | No.2 Revision |
Defining a variable inside the function lets us control what variable function, we can use it for the limit.
For example, define t
and substitute it for the variable provided by the user.
Applying this idea, we can define myfunction
as follows:
def mylimit(f, x, a):
r"""
Return the limit of the expression `f` when `x` tends to `a`.
"""
t = SR.var('t')
return f.subs({x: t}).limit(t=a)
With that definition:
sage: mylimit(1/y, y, 2)
1/2