Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Legendre transform

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64312] Legendre transform
  • From: Tobin Fricke <fricke at ocf.berkeley.edu>
  • Date: Fri, 10 Feb 2006 03:30:08 -0500 (EST)
  • Organization: University of California, Berkeley
  • Sender: owner-wri-mathgroup at wolfram.com

As an exercise in learning Mathematica, and also as a computational and 
pedagogical tool for myself, I'm attempting to implement a function to 
compute the Legedre transform[1] of an expression.

The procedure is, given a function f(x):

   1. compute y(x) = f'(x) and solve for x(y)
   2. the legendre transform is g(y) = -f(x(y)) + x(y) y

Here's my first attempt:

   legendreTransform[f_, x_, y_] := Block[{},
       solutions = Solve[y == D[f, x], x];
       x[k_] := x /. First[solutions];
       -(f /. x -> x[y]) + x[y] y]

For instance, it correctly gives the transform of xLog[x]-x as e^x:

   Simplify[legendreTransform[x Log[x] - x, x, y],
            Assumptions -> {Element[y, Reals]}]

This seems to work, though (1) things go horribly wrong if x==y, and (2) 
errors aren't handled at all--for instance, it should detect whether the 
Solve[] fails, etc.

Another attempt is written in a such a way as to operate on *functions* 
rather than expressions.  To me this seems like the preferred way, but 
maybe it isn't:

   legendreTransform[f_] = Block[{x, y},
       x[y_] = x /. First[Solve[y == f'[x], x]];
       Function[y, -f[x[y]] + x[y] y]]

Any hints/critiques/etc appreciated.  I'd like to end up with a version 
that will let me take the legendreTransform with respect to an arbitrary 
argument of a function with arbitrarily many arguments.

thanks,
Tobin

[1] http://en.wikipedia.org/wiki/Legendre_transform#Legendre_transformation_in_one_dimension


  • Prev by Date: Re: Re: Strange Syntax problem
  • Next by Date: eps color export
  • Previous by thread: text bounding box size
  • Next by thread: Re: Legendre transform