Skip to main content
Added example that does not work as expected.
Source Link
Hedgehog
  • 624
  • 3
  • 15

How do you decorate or annotate a variable in a replacement rule?

For example

{(e[(-X + Y)^2 || f])} //. {e[(-a_ + b_)^2 || f] -> (-a + b)^2}

Would ideally return:

(-lagXdt + lagYdt)^2

Update: The following does not return lagXdt and lagYdt but rather lagadt and lagbdt:

{(e[(-X + Y)^2 || f])} //. {e[(-a_ + b_)^2 || 
     f] -> (-Symbol["lag" <> ToString@a <> "dt"] + 
      Symbol["lag" <> ToString@b <> "dt"])^2}

How do you decorate or annotate a variable in a replacement rule?

For example

{(e[(-X + Y)^2 || f])} //. {e[(-a_ + b_)^2 || f] -> (-a + b)^2}

Would ideally return:

(-lagXdt + lagYdt)^2

How do you decorate or annotate a variable in a replacement rule?

For example

{(e[(-X + Y)^2 || f])} //. {e[(-a_ + b_)^2 || f] -> (-a + b)^2}

Would ideally return:

(-lagXdt + lagYdt)^2

Update: The following does not return lagXdt and lagYdt but rather lagadt and lagbdt:

{(e[(-X + Y)^2 || f])} //. {e[(-a_ + b_)^2 || 
     f] -> (-Symbol["lag" <> ToString@a <> "dt"] + 
      Symbol["lag" <> ToString@b <> "dt"])^2}
Fixed syntax errors.
Source Link
Hedgehog
  • 624
  • 3
  • 15

How do you decorate or annotate a variable in a replacement rule?

For example

{({e[(-X + Y)^2 || f])} // /. {e[(-a_ + b_)^2 || f] -> (-a + b)^2}

Would ideally return:

(-lagXdt + lagYdt)^2

How do you decorate or annotate a variable in a replacement rule?

For example

{({e[(-X + Y)^2 || f])} // /. {e[(-a_ + b_)^2 || f] -> (-a + b)^2}

Would ideally return:

(-lagXdt + lagYdt)^2

How do you decorate or annotate a variable in a replacement rule?

For example

{(e[(-X + Y)^2 || f])} //. {e[(-a_ + b_)^2 || f] -> (-a + b)^2}

Would ideally return:

(-lagXdt + lagYdt)^2

Source Link
Hedgehog
  • 624
  • 3
  • 15

Annotating variables in replacement rules

How do you decorate or annotate a variable in a replacement rule?

For example

{({e[(-X + Y)^2 || f])} // /. {e[(-a_ + b_)^2 || f] -> (-a + b)^2}

Would ideally return:

(-lagXdt + lagYdt)^2