# Pattern matching with subscript

**URL:** <https://community.wolfram.com/t/pattern-matching-with-subscript/22561>\
**Category:** Questions\
**Tags:** algebra\
**Created:** [July 30, 2023, 2:50am UTC](https://community.wolfram.com/t/pattern-matching-with-subscript/22561 "2023-07-30T02:50:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![1592295809](https://avatars.discourse-cdn.com/v4/letter/1/53a042/32.png) [@1592295809](https://community.wolfram.com/u/1592295809)\
**Post date:** [July 30, 2023, 2:50am UTC](https://community.wolfram.com/t/pattern-matching-with-subscript/22561/1 "2023-07-30T02:50:43Z")

</div>

![2.png](https://global.discourse-cdn.com/wolfram/original/2X/7/74c05aab4982e6a99fa3a08f0228e6ec90359413.png)

Hi! I get confused about using phase matching with the case of subscript. In the picture, I want to make

```
Subscript[H,any expr]

```

multiple

```
Subscript[H,any expr]==0

```

However,it doesn’t work. Thanks for your help!

---

<div class="post-metadata">

**Author:** ![dontdont9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dontdont9](https://community.wolfram.com/u/dontdont9)\
**Post date:** [July 30, 2023, 4:12am UTC](https://community.wolfram.com/t/pattern-matching-with-subscript/22561/2 "2023-07-30T04:12:48Z")

</div>

Try

```
Simplify[Subscript[H,SS]*Subscript[H,KK],Subscript[H,x_]*Subscript[H,y_]==0]

```

which returns

```
0

```

because x\_ matches something named x while y\_ matches something different named y

---

<div class="post-metadata">

**Author:** ![1592295809](https://avatars.discourse-cdn.com/v4/letter/1/53a042/32.png) [@1592295809](https://community.wolfram.com/u/1592295809)\
**Post date:** [July 30, 2023, 5:52am UTC](https://community.wolfram.com/t/pattern-matching-with-subscript/22561/3 "2023-07-30T05:52:13Z")

</div>

Thank you very much!

To be further, the expr in the picture in math is to be zero. However ,in mathematica it seems not. So how can I solve this problem? Thanks again!

 ![3.png](https://global.discourse-cdn.com/wolfram/original/2X/c/c99b00933234bc90a553f50876b083ac08104a12.png)

---

<div class="post-metadata">

**Author:** ![dontdont9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dontdont9](https://community.wolfram.com/u/dontdont9)\
**Post date:** [July 30, 2023, 7:12am UTC](https://community.wolfram.com/t/pattern-matching-with-subscript/22561/4 "2023-07-30T07:12:04Z")

</div>

Mathematica automatically simplifies b\*c\*b\*a to a\*b^2\*c but you did not tell Simplify that b^2==0 or that the product of a subscripted variable times the square of a subscripted variable equals zero.

Add one more rule for squares

```
Simplify[Subscript[A,sn]*Subscript[A,sp]*Subscript[A,sn]*Subscript[d,11], 
   {Subscript[A,x_]*Subscript[A,y_]==0,Subscript[A,z_]^2==0}]

```

returns

```
0

```

Now think if there is a\*b\*a\*c\*a == a^3\*b\*c

```
Simplify[Subscript[A,sn]*Subscript[A,sp]*Subscript[A,sn]*Subscript[A,sq]*Subscript[A,sn], 
   {Subscript[A,x_]*Subscript[A,y_]==0,Subscript[A,z_]^2==0}]

```

returns

```
Subscript[A,sn]^3*Subscript[A,sp]*Subscript[A,sq]

```

because there is no rule for simplifying cube powers.

Perhaps you could study the documentation and think how to write a rule that says any positive power of a subscripted variable will equal zero. Look up Condition in the documentation and see if you can think how to use that to say that any positive power of a Subscript will equal zero.

Please test that carefully to see that it works as you expect.
