4

My equations contain different cases which differ only by some signs. So in order to work with all cases simultaneously, I introduce a placeholder for a sign:

s[x]

where x labels which sign that is. Now when I perform manipulations of my terms, I encounter higher powers of the same sign, like s[1]^2. Of course the square of a sign should be just s[1]^2=1, so I try to define a rule:

s[x_]^2:=1

SetDelayed::write: Tag Power in s[x_]^2 is Protected.

As you can see, there is an error message and the rule does not get set. How should I be going about defining a rule that sets the square of any s[x] to 1?

Kagaratsch
  • 11,955
  • 4
  • 25
  • 72

1 Answers1

8

You can use TagSetDelayed i.e.:

s /: s[x_]^2 := 1

This will create a substitution rule (UpValue) for symbol s, which is only applied, when s is inside Power[s[_], 2].

Ray Shadow
  • 7,816
  • 1
  • 16
  • 44