Repository: sympy/sympy

Issue:
Sympy giving the wrong solution 
Hello, 

While doing an example with 
```
f(x) =( 2^(1/x) -2^(-1/x))/( 2^(1/x) +2^(-1/x))
```
Where you want to see the left end-behavior and the right end-behavior for f(1/x). Now left end-behavior is -1 and right end-behavior is 1 but according to SymPy its results is equal to 1. 

```
julia> using PythonCall
 
julia> sympy = pyimport("sympy")
Python module: <module 'sympy' from '/Users/verzani/.julia/environments/v1.7/.CondaPkg/env/lib/python3.10/site-packages/sympy/__init__.py'>
 
julia> sympy.limit((2^x - 2^(-x))/(2^x + 2^(-x)), x, -sympy.oo)^C
 
julia> x = sympy.symbols("x")
Python Symbol: x
 
julia> sympy.limit((2^x - 2^(-x))/(2^x + 2^(-x)), x, -sympy.oo)
Python One: 1
 
julia> sympy.__version__
Python str: '1.10'
```

Any reason behind this error? 

Discussion:

Patch:
diff --git a/.mailmap b/.mailmap
index 481ef03e92..a9761aa1b9 100644
--- a/.mailmap
+++ b/.mailmap
@@ -665,7 +665,6 @@ Lucas Jones <lucas@lucasjones.co.uk>
 Lucas Wiman <lucas.wiman@gmail.com>
 Lucy Mountain <lucymountain1@icloud.com> LucyMountain <lucymountain1@icloud.com>
 Luis Garcia <ppn.online@me.com>
-Luis Talavera <luisfertalavera15@gmail.com> Luis F. Talavera R <47088091+LuisFerTR@users.noreply.github.com>
 Lukas Zorich <lukas.zorich@gmail.com>
 Luke Peterson <hazelnusse@gmail.com>
 Luv Agarwal <agarwal.iiit@gmail.com>
diff --git a/sympy/core/function.py b/sympy/core/function.py
index d08b678faf..b5392026a0 100644
--- a/sympy/core/function.py
+++ b/sympy/core/function.py
@@ -47,7 +47,7 @@
 from .parameters import global_parameters
 from .rules import Transform
 from .singleton import S
-from .sympify import sympify
+from .sympify import sympify, _sympify
 
 from .sorting import default_sort_key, ordered
 from sympy.utilities.exceptions import (sympy_deprecation_warning,
@@ -1304,7 +1304,7 @@ def __new__(cls, expr, *variables, **kwargs):
                 variable_count.append(Tuple(v, count))
                 continue
 
-            v = sympify(v)
+            v = _sympify(v)
             if isinstance(v, Integer):
                 if i == 0:
                     raise ValueError("First variable cannot be a number: %i" % v)
diff --git a/sympy/core/power.py b/sympy/core/power.py
index c85a1fcee2..8be33df01a 100644
--- a/sympy/core/power.py
+++ b/sympy/core/power.py
@@ -1793,11 +1793,7 @@ def _eval_as_leading_term(self, x, logx=None, cdir=0):
             raise PoleError("Cannot expand %s around 0" % (self))
         elif e.has(x):
             lt = exp(e * log(b))
-            try:
-                lt = lt.as_leading_term(x, logx=logx, cdir=cdir)
-            except PoleError:
-                pass
-            return lt
+            return lt.as_leading_term(x, logx=logx, cdir=cdir)
         else:
             from sympy.functions.elementary.complexes import im
             f = b.as_leading_term(x, logx=logx, cdir=cdir)
diff --git a/sympy/parsing/c/c_parser.py b/sympy/parsing/c/c_parser.py
index 706d4a903f..fb6d494a9b 100644
--- a/sympy/parsing/c/c_parser.py
+++ b/sympy/parsing/c/c_parser.py
@@ -19,7 +19,7 @@
 
 - Variable Declarations (integers and reals)
 - Assignment (using integer & floating literal and function calls)
-- Function Definitions and Declaration
+- Function Definitions nad Declaration
 - Function Calls
 - Compound statements, Return statements
 
@@ -433,7 +433,7 @@ def transform_parm_decl(self, node):
             =======
 
             param : Codegen AST Node
-                Variable node with the value and type of the variable
+                Variable node with the value nad type of the variable
 
             Raises
             ======
diff --git a/sympy/printing/pretty/pretty.py b/sympy/printing/pretty/pretty.py
index 3917fdd71f..66461181d0 100644
--- a/sympy/printing/pretty/pretty.py
+++ b/sympy/printing/pretty/pretty.py
@@ -1144,24 +1144,22 @@ def _print_BasisDependent(self, expr):
             if '\n' in partstr:
                 tempstr = partstr
                 tempstr = tempstr.replace(vectstrs[i], '')
-                if '\N{RIGHT PARENTHESIS EXTENSION}' in tempstr:   # If scalar is a fraction
+                if '\N{right parenthesis extension}' in tempstr:   # If scalar is a fraction
                     for paren in range(len(tempstr)):
                         flag[i] = 1
-                        if tempstr[paren] == '\N{RIGHT PARENTHESIS EXTENSION}' and tempstr[paren + 1] == '\n':
-                            # We want to place the vector string after all the right parentheses, because
-                            # otherwise, the vector will be in the middle of the string
-                            tempstr = tempstr[:paren] + '\N{RIGHT PARENTHESIS EXTENSION}'\
+                        if tempstr[paren] == '\N{right parenthesis extension}':
+                            tempstr = tempstr[:paren] + '\N{right parenthesis extension}'\
                                          + ' '  + vectstrs[i] + tempstr[paren + 1:]
                             break
                 elif '\N{RIGHT PARENTHESIS LOWER HOOK}' in tempstr:
-                    # We want to place the vector string after all the right parentheses, because
-                    # otherwise, the vector will be in the middle of the string. For this reason,
-                    # we insert the vector string at the rightmost index.
-                    index = tempstr.rfind('\N{RIGHT PARENTHESIS LOWER HOOK}')
-                    if index != -1: # then this character was found in this string
-                        flag[i] = 1
-                        tempstr = tempstr[:index] + '\N{RIGHT PARENTHESIS LOWER HOOK}'\
-                                     + ' '  + vectstrs[i] + tempstr[index + 1:]
+                    flag[i] = 1
+                    tempstr = tempstr.replace('\N{RIGHT PARENTHESIS LOWER HOOK}',
+                                        '\N{RIGHT PARENTHESIS LOWER HOOK}'
+                                        + ' ' + vectstrs[i])
+                else:
+                    tempstr = tempstr.replace('\N{RIGHT PARENTHESIS UPPER HOOK}',
+                                        '\N{RIGHT PARENTHESIS UPPER HOOK}'
+                                        + ' ' + vectstrs[i])
                 o1[i] = tempstr
 
         o1 = [x.split('\n') for x in o1]
diff --git a/sympy/series/order.py b/sympy/series/order.py
index 46afcc95c8..29cf19df6d 100644
--- a/sympy/series/order.py
+++ b/sympy/series/order.py
@@ -3,6 +3,7 @@
 from sympy.core.containers import Tuple
 from sympy.core.function import Function, PoleError, expand_power_base, expand_log
 from sympy.core.sorting import default_sort_key
+from sympy.functions.elementary.exponential import exp, log
 from sympy.sets.sets import Complement
 from sympy.utilities.iterables import uniq, is_sequence
 
@@ -255,7 +256,9 @@ def __new__(cls, expr, *args, **kwargs):
                             elif expr.is_Mul:
                                 expr = Mul(*[a.expr for a in orders])
                             elif expr.is_Pow:
-                                expr = orders[0].expr**orders[1].expr
+                                e = expr.exp
+                                b = expr.base
+                                expr = exp(e * log(b))
                     expr = expr.as_independent(*args, as_Add=False)[1]
 
                     expr = expand_power_base(expr)


Test patch:
diff --git a/sympy/core/tests/test_function.py b/sympy/core/tests/test_function.py
index cde6fc6b3d..1c22e22b60 100644
--- a/sympy/core/tests/test_function.py
+++ b/sympy/core/tests/test_function.py
@@ -131,8 +131,6 @@ def test_diff_symbols():
     raises(TypeError, lambda: cos(x).diff((x, y)).variables)
     assert cos(x).diff((x, y))._wrt_variables == [x]
 
-    # issue 23222
-    assert sympify("a*x+b").diff("x") == sympify("a")
 
 def test_Function():
     class myfunc(Function):
diff --git a/sympy/series/tests/test_limits.py b/sympy/series/tests/test_limits.py
index d3d0ee0e10..6f7de1e357 100644
--- a/sympy/series/tests/test_limits.py
+++ b/sympy/series/tests/test_limits.py
@@ -1102,3 +1102,8 @@ def test_issue_21785():
 
 def test_issue_22181():
     assert limit((-1)**x * 2**(-x), x, oo) == 0
+
+
+def test_issue_23231():
+    f = (2**x - 2**(-x))/(2**x + 2**(-x))
+    assert limit(f, x, -oo) == -1
diff --git a/sympy/series/tests/test_order.py b/sympy/series/tests/test_order.py
index 18e7bd1adf..c3a695f813 100644
--- a/sympy/series/tests/test_order.py
+++ b/sympy/series/tests/test_order.py
@@ -382,7 +382,7 @@ def test_order_at_infinity():
 
     # issue 7207
     assert Order(exp(x), (x, oo)).expr == Order(2*exp(x), (x, oo)).expr == exp(x)
-    assert Order(y**x, (x, oo)).expr == Order(2*y**x, (x, oo)).expr == exp(log(y)*x)
+    assert Order(y**x, (x, oo)).expr == Order(2*y**x, (x, oo)).expr == exp(x*log(y))
 
     # issue 19545
     assert Order(1/x - 3/(3*x + 2), (x, oo)).expr == x**(-2)
@@ -460,5 +460,14 @@ def test_issue_22165():
     assert O(log(x)).contains(2)
 
 
+def test_issue_23231():
+    # This test checks Order for expressions having
+    # arguments containing variables in exponents/powers.
+    assert O(x**x + 2**x, (x, oo)) == O(exp(x*log(x)), (x, oo))
+    assert O(x**x + x**2, (x, oo)) == O(exp(x*log(x)), (x, oo))
+    assert O(x**x + 1/x**2, (x, oo)) == O(exp(x*log(x)), (x, oo))
+    assert O(2**x + 3**x , (x, oo)) == O(exp(x*log(3)), (x, oo))
+
+
 def test_issue_9917():
     assert O(x*sin(x) + 1, (x, oo)) == O(x, (x, oo))
diff --git a/sympy/vector/tests/test_printing.py b/sympy/vector/tests/test_printing.py
index ae76905e96..0f569b7b3e 100644
--- a/sympy/vector/tests/test_printing.py
+++ b/sympy/vector/tests/test_printing.py
@@ -3,7 +3,7 @@
 from sympy.integrals.integrals import Integral
 from sympy.printing.latex import latex
 from sympy.printing.pretty import pretty as xpretty
-from sympy.vector import CoordSys3D, Del, Vector, express
+from sympy.vector import CoordSys3D, Vector, express
 from sympy.abc import a, b, c
 from sympy.testing.pytest import XFAIL
 
@@ -160,55 +160,6 @@ def test_latex_printing():
                             '\\mathbf{\\hat{k}_{N}}{\\middle|}\\mathbf{' +
                             '\\hat{k}_{N}}\\right)')
 
-def test_issue_23058():
-    from sympy import symbols, sin, cos, pi, UnevaluatedExpr
-
-    delop = Del()
-    CC_   = CoordSys3D("C")
-    y     = CC_.y
-    xhat  = CC_.i
-
-    t = symbols("t")
-    ten = symbols("10", positive=True)
-    eps, mu = 4*pi*ten**(-11), ten**(-5)
-
-    Bx = 2 * ten**(-4) * cos(ten**5 * t) * sin(ten**(-3) * y)
-    vecB = Bx * xhat
-    vecE = (1/eps) * Integral(delop.cross(vecB/mu).doit(), t)
-    vecE = vecE.doit()
-
-    vecB_str = """\
-⎛     ⎛y_C⎞    ⎛  5  ⎞⎞    \n\
-⎜2⋅sin⎜───⎟⋅cos⎝10 ⋅t⎠⎟ i_C\n\
-⎜     ⎜  3⎟           ⎟    \n\
-⎜     ⎝10 ⎠           ⎟    \n\
-⎜─────────────────────⎟    \n\
-⎜           4         ⎟    \n\
-⎝         10          ⎠    \
-"""
-    vecE_str = """\
-⎛   4    ⎛  5  ⎞    ⎛y_C⎞ ⎞    \n\
-⎜-10 ⋅sin⎝10 ⋅t⎠⋅cos⎜───⎟ ⎟ k_C\n\
-⎜                   ⎜  3⎟ ⎟    \n\
-⎜                   ⎝10 ⎠ ⎟    \n\
-⎜─────────────────────────⎟    \n\
-⎝           2⋅π           ⎠    \
-"""
-
-    assert upretty(vecB) == vecB_str
-    assert upretty(vecE) == vecE_str
-
-    ten = UnevaluatedExpr(10)
-    eps, mu = 4*pi*ten**(-11), ten**(-5)
-
-    Bx = 2 * ten**(-4) * cos(ten**5 * t) * sin(ten**(-3) * y)
-    vecB = Bx * xhat
-
-    vecB_str = """\
-⎛    -4    ⎛    5⎞    ⎛      -3⎞⎞     \n\
-⎝2⋅10  ⋅cos⎝t⋅10 ⎠⋅sin⎝y_C⋅10  ⎠⎠ i_C \
-"""
-    assert upretty(vecB) == vecB_str
 
 def test_custom_names():
     A = CoordSys3D('A', vector_names=['x', 'y', 'z'],