@@ -1208,16 +1208,16 @@ def limit(ex, *args, dir=None, taylor=False, algorithm='maxima', **kwargs):
1208
1208
sage: f = (1 + 1/x)^x
1209
1209
sage: limit(f, x=oo)
1210
1210
e
1211
- sage: limit(f, x, oo)
1211
+ sage: limit(f, x, oo)
1212
1212
e
1213
1213
sage: f.limit(x=5)
1214
1214
7776/3125
1215
1215
sage: f.limit(x, 5)
1216
1216
7776/3125
1217
1217
1218
- The positional ``limit(expr, v, a)`` syntax is particularly useful
1219
- when the limit variable ``v`` is an indexed variable or another
1220
- expression that cannot be used as a keyword argument
1218
+ The positional ``limit(expr, v, a)`` syntax is particularly useful
1219
+ when the limit variable ``v`` is an indexed variable or another
1220
+ expression that cannot be used as a keyword argument
1221
1221
(fixes :issue:`38761`)::
1222
1222
1223
1223
sage: y = var('y', n=3)
@@ -1280,7 +1280,7 @@ def limit(ex, *args, dir=None, taylor=False, algorithm='maxima', **kwargs):
1280
1280
1281
1281
sage: maxima_calculus.eval("domain:real")
1282
1282
...
1283
- sage: f = (1 + 1/x)^x
1283
+ sage: f = (1 + 1/x)^x
1284
1284
sage: f.limit(x=1.2).n()
1285
1285
2.06961575467...
1286
1286
sage: maxima_calculus.eval("domain:complex");
@@ -1550,19 +1550,19 @@ def limit(ex, *args, dir=None, taylor=False, algorithm='maxima', **kwargs):
1550
1550
v = args [0 ]
1551
1551
a = args [1 ]
1552
1552
elif len (args ) == 1 :
1553
- if kwargs :
1554
- raise ValueError ("cannot mix positional specification of limit variable and point with keyword variable arguments" )
1553
+ if kwargs :
1554
+ raise ValueError ("cannot mix positional specification of limit variable and point with keyword variable arguments" )
1555
1555
else :
1556
- raise ValueError ("three positional arguments (expr, v, a) or one positional and one keyword argument (expr, v=a) required" )
1557
- elif len (args ) == 0 : # Potential syntax: limit(ex, v=a, ...) or limit(ex)
1558
- if len (kwargs ) == 1 :
1556
+ raise ValueError ("three positional arguments (expr, v, a) or one positional and one keyword argument (expr, v=a) required" )
1557
+ elif len (args ) == 0 : # Potential syntax: limit(ex, v=a, ...) or limit(ex)
1558
+ if len (kwargs ) == 1 :
1559
1559
k , = kwargs .keys ()
1560
1560
v = var (k )
1561
1561
a = kwargs [k ]
1562
- elif len (kwargs ) == 0 : # For No variable specified at all
1563
- raise ValueError ("invalid limit specification" )
1564
- else : # For Multiple keyword arguments like x=1, y=2
1565
- raise ValueError ("multiple keyword arguments specified" )
1562
+ elif len (kwargs ) == 0 : # For No variable specified at all
1563
+ raise ValueError ("invalid limit specification" )
1564
+ else : # For Multiple keyword arguments like x=1, y=2
1565
+ raise ValueError ("multiple keyword arguments specified" )
1566
1566
1567
1567
# Ensuring v is a symbolic expression and a valid limit variable
1568
1568
if not isinstance (v , Expression ):
@@ -1586,7 +1586,7 @@ def limit(ex, *args, dir=None, taylor=False, algorithm='maxima', **kwargs):
1586
1586
raise ValueError ("dir must be one of " + ", " .join (map (repr , dir_both )))
1587
1587
1588
1588
# Calling the appropriate backend based on effective_algorithm
1589
- l = None
1589
+ l = None
1590
1590
if effective_algorithm == 'maxima' :
1591
1591
if dir is None :
1592
1592
l = maxima .sr_limit (ex , v , a )
@@ -1603,7 +1603,7 @@ def limit(ex, *args, dir=None, taylor=False, algorithm='maxima', **kwargs):
1603
1603
l = maxima .sr_tlimit (ex , v , a , 'minus' )
1604
1604
elif effective_algorithm == 'sympy' :
1605
1605
import sympy
1606
- sympy_dir = '+-'
1606
+ sympy_dir = '+-'
1607
1607
if dir in dir_plus :
1608
1608
sympy_dir = '+'
1609
1609
elif dir in dir_minus :
@@ -1620,25 +1620,25 @@ def limit(ex, *args, dir=None, taylor=False, algorithm='maxima', **kwargs):
1620
1620
fricas_dir_arg = '"left"'
1621
1621
1622
1622
if fricas_dir_arg :
1623
- l = fricas .limit (f , eq , fricas_dir_arg ).sage ()
1623
+ l = fricas .limit (f , eq , fricas_dir_arg ).sage ()
1624
1624
else :
1625
- l_raw = fricas .limit (f , eq ).sage ()
1626
- if isinstance (l_raw , dict ):
1627
- l = SR ('und' )
1628
- else :
1629
- l = l_raw
1625
+ l_raw = fricas .limit (f , eq ).sage ()
1626
+ if isinstance (l_raw , dict ):
1627
+ l = SR ('und' )
1628
+ else :
1629
+ l = l_raw
1630
1630
elif effective_algorithm == 'giac' :
1631
1631
from sage .libs .giac .giac import libgiac
1632
1632
giac_v = v ._giac_init_ ()
1633
1633
giac_a = a ._giac_init_ ()
1634
- giac_dir_arg = 0 # Default for two-sided
1634
+ giac_dir_arg = 0 # Default for two-sided
1635
1635
if dir in dir_plus :
1636
1636
giac_dir_arg = 1
1637
1637
elif dir in dir_minus :
1638
1638
giac_dir_arg = - 1
1639
1639
l = libgiac .limit (ex , giac_v , giac_a , giac_dir_arg ).sage ()
1640
1640
elif effective_algorithm == 'mathematica_free' :
1641
- # Ensuring mma_free_limit exists
1641
+ # Ensuring mma_free_limit exists
1642
1642
l = mma_free_limit (ex , v , a , dir )
1643
1643
else :
1644
1644
raise ValueError ("Unknown algorithm: %s" % effective_algorithm )
@@ -1647,6 +1647,7 @@ def limit(ex, *args, dir=None, taylor=False, algorithm='maxima', **kwargs):
1647
1647
1648
1648
return original_parent (l )
1649
1649
1650
+
1650
1651
# lim is alias for limit
1651
1652
lim = limit
1652
1653
0 commit comments