MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

"Simplifying" expressions to not expand user-defined functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109974] "Simplifying" expressions to not expand user-defined functions
  • From: Ostap <ostap at mailinator.com>
  • Date: Thu, 27 May 2010 06:43:32 -0400 (EDT)

Hello,

First off, I'm a new user, so I apologize for any confusing or non-
standard lingo...

I have a question about user-defined functions. Suppose I define the
following function for the magnitude of the gradient:

mg[x_, y_] := Sqrt[x^2 + y^2]
mgg[f_] := mg[D[f, x], D[f, y]]

If I now use mgg in some lengthy sequence of differentiations, for
example in finding a variational derivative, my output may include the
magnitude of the gradient, but its expanded form: Sqrt[f^(0,1)
(x,y)^2+f^(1,0)(x,y)^2].

Is there a way to convert such an answer to a form which uses mgg[f],
i.e. have Mathematica "simplify" the output to account for user-
defined functions that were used in the first place?

Example:
Input:
mg[x_, y_] := Sqrt[x^2 + y^2]
mgg[f_] := mg[D[f, x], D[f, y]]
Factor[VariationalD[mgg[p[x, y]], p[x, y], {x, y}]]

What I get:
( p^(2,0)(x,y) p^(0,1)(x,y)^2 - 2 p^(1,0)(x,y) p^(1,1)(x,y) p^(0,1)
(x,y) + p^(0,2)(x,y) p^(1,0)(x,y)^2 ) / ( p^(0,1)(x,y)^2+p^(1,0)
(x,y)^2 )^(3/2)

What I want:
( p^(2,0)(x,y) p^(0,1)(x,y)^2 - 2 p^(1,0)(x,y) p^(1,1)(x,y) p^(0,1)
(x,y) + p^(0,2)(x,y) p^(1,0)(x,y)^2 ) / ( mgg(p(x,y)) )^3

Any help would be greatly appreciated.


-O


  • Prev by Date: Corruption of formulas after cut-and-paste
  • Next by Date: the Operate[] function
  • Previous by thread: Re: Corruption of formulas after cut-and-paste
  • Next by thread: the Operate[] function