Message Boards Message Boards

0
|
2191 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Use replacement rule for this named pattern?

Posted 6 years ago

Suppose I have two systems of coordinates:{x1,x2} and {y1,y2}. I want to transform an expression containing $\frac{\partial yi}{\partial xj}$'s to those in terms of $\frac{\partial xj}{\partial yi}$'s. I wrote the following code:

expr = D[y2[x1, x2], {x1, 2}, {x2, 0}] + D[y1[x1, x2], {x1, 0}, {x2, 2}];
expr /. Derivative[n_, m_][y : y1 | y2][x1, x2] -> Nest[(1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\(x2[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\((#)\)\) + 1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\(x2[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\((#)\)\)) &, Nest[(1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\(x1[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\((#)\)\) + 1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\(x1[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\((#)\)\)) &, 1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y\)]\(x1[y1, y2]\)\), n], m]

Why is this not working? It seems n,m and y are not recognized in the RHS of my replacement rule.

2 Replies

Thanks. This fix works!

Is it this what you want ( :> instead of -> in your rule) ?

expr /. Derivative[n_, m_][y : y1 | y2][x1, x2] :> Nest[(1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\(x2[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\((#)\)\) + 1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\(x2[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\((#)\)\)) &, Nest[(1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\(x1[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y1\)]\((#)\)\) + 1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\(x1[y1, y2]\)\) \!\(
\*SubscriptBox[\(\[PartialD]\), \(y2\)]\((#)\)\)) &, 1/\!\(
\*SubscriptBox[\(\[PartialD]\), \(y\)]\(x1[y1, y2]\)\), n], m]
POSTED BY: Hans Dolhaine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract