Repository: sympy/sympy

Issue:
simplify not working on Array (but working on sympy expressions)
As far as I remember, simplify could operate on Arrays previously. Kindly see the snippet below :
```
>>> from sympy.abc import x
>>> from sympy import sin, cos, simplify, Array
>>> import sympy
>>> sympy.__version__
'1.5'
>>> A = Array([sin(2*x) - 2*sin(x)*cos(x), 0])
>>> simplify(A)
[-2*sin(x)*cos(x) + sin(2*x), 0]
>>> simplify(sin(2*x) - 2*sin(x)*cos(x))
0

```

Now it is not working on Array, but working on same expressions when each element on Array is simplified individually.

Discussion:

Patch:
diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md
index ea1ea035ad..4daea807c2 100644
--- a/PULL_REQUEST_TEMPLATE.md
+++ b/PULL_REQUEST_TEMPLATE.md
@@ -3,8 +3,8 @@ was changed. Do not include the issue number in the title. -->
 
 #### References to other Issues or PRs
 <!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
-format, e.g. "Fixes #1234" (see
-https://tinyurl.com/auto-closing for more information). Also, please
+format, e.g. "Fixes #1234". See
+https://github.com/blog/1506-closing-issues-via-pull-requests . Please also
 write a comment on that issue linking back to this pull request once it is
 open. -->
 
@@ -24,4 +24,4 @@ automatically to see if they are formatted correctly. -->
 
 <!-- BEGIN RELEASE NOTES -->
 
-<!-- END RELEASE NOTES -->
\ No newline at end of file
+<!-- END RELEASE NOTES -->
diff --git a/sympy/tensor/array/dense_ndim_array.py b/sympy/tensor/array/dense_ndim_array.py
index c962bb870c..874a029933 100644
--- a/sympy/tensor/array/dense_ndim_array.py
+++ b/sympy/tensor/array/dense_ndim_array.py
@@ -5,7 +5,7 @@
 from sympy.core.sympify import _sympify
 from sympy.tensor.array.mutable_ndim_array import MutableNDimArray
 from sympy.tensor.array.ndim_array import NDimArray, ImmutableNDimArray
-
+from sympy.simplify import simplify
 
 
 class DenseNDimArray(NDimArray):
@@ -150,6 +150,8 @@ def __setitem__(self, index, value):
     def as_mutable(self):
         return MutableDenseNDimArray(self)
 
+    def _eval_simplify(self, **kwargs):
+        return self.applyfunc(simplify)
 
 class MutableDenseNDimArray(DenseNDimArray, MutableNDimArray):
 


Test patch:
diff --git a/sympy/tensor/array/tests/test_ndim_array.py b/sympy/tensor/array/tests/test_ndim_array.py
index 261f2f87d9..9a097a3fb8 100644
--- a/sympy/tensor/array/tests/test_ndim_array.py
+++ b/sympy/tensor/array/tests/test_ndim_array.py
@@ -1,8 +1,10 @@
 from sympy.testing.pytest import raises
 from sympy import (
     Array, ImmutableDenseNDimArray, ImmutableSparseNDimArray,
-    MutableDenseNDimArray, MutableSparseNDimArray
+    MutableDenseNDimArray, MutableSparseNDimArray, sin, cos,
+    simplify
 )
+from sympy.abc import x, y
 
 
 array_types = [
@@ -31,3 +33,12 @@ def test_array_negative_indices():
         raises(ValueError, lambda: test_array[-3, :])
 
         assert test_array[-1, -1] == 10
+
+
+def test_issue_18361():
+    A = Array([sin(2 * x) - 2 * sin(x) * cos(x)])
+    B = Array([sin(x)**2 + cos(x)**2, 0])
+    C = Array([(x + x**2)/(x*sin(y)**2 + x*cos(y)**2), 2*sin(x)*cos(x)])
+    assert simplify(A) == Array([0])
+    assert simplify(B) == Array([1, 0])
+    assert simplify(C) == Array([x + 1, sin(2*x)])