Repository: sympy/sympy

Issue:
Strange output from common limit used in elementary calculus
I notice that the following limit expression returns output that appears to be wrong:

```python
x, h = symbols("x h")
n = symbols('n', integer=True)
limit(((x+h)**n-x**n)/h, h, 0)
```

![image](https://cloud.githubusercontent.com/assets/6608130/20554698/802d49ce-b155-11e6-9825-38a259065aa2.png)

Here's [Wolfram's result](https://goo.gl/0EiVO0)

Discussion:

Patch:
diff --git a/sympy/series/gruntz.py b/sympy/series/gruntz.py
index a851b81735..ab0f1e1435 100644
--- a/sympy/series/gruntz.py
+++ b/sympy/series/gruntz.py
@@ -121,7 +121,7 @@
 from sympy.core import Basic, S, oo, Symbol, I, Dummy, Wild, Mul
 from sympy.functions import log, exp
 from sympy.series.order import Order
-from sympy.simplify.powsimp import powsimp
+from sympy.simplify.powsimp import powsimp, powdenest
 from sympy import cacheit
 
 from sympy.core.compatibility import reduce
@@ -464,6 +464,9 @@ def calculate_series(e, x, logx=None):
     for t in e.lseries(x, logx=logx):
         t = cancel(t)
 
+        if t.has(exp) and t.has(log):
+            t = powdenest(t)
+
         if t.simplify():
             break
 


Test patch:
diff --git a/sympy/series/tests/test_limits.py b/sympy/series/tests/test_limits.py
index 157440fd10..9978f2817c 100644
--- a/sympy/series/tests/test_limits.py
+++ b/sympy/series/tests/test_limits.py
@@ -477,6 +477,8 @@ def test_limit_seq():
     assert (limit(Sum(y**2 * Sum(2**z/z, (z, 1, y)), (y, 1, x)) /
                   (2**x*x), x, oo) == 4)
 
+def test_issue_11879():
+    assert simplify(limit(((x+y)**n-x**n)/y, y, 0)) == n*x**(n-1)
 
 def test_limit_with_Float():
     k = symbols("k")