Re: How to pass a function to a function?
- To: mathgroup at smc.vnet.net
- Subject: [mg93657] Re: How to pass a function to a function?
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 21 Nov 2008 05:30:57 -0500 (EST)
- References: <gg3c9m$k5b$1@smc.vnet.net>
Hi, << VectorAnalysis` and Laplacian[f] or Laplacian[f,coordsys] as th help say. And your code would never get the function > f[x_, y_] := x^4 +y^4 > g = Laplacian[f]; will do nothing, because the Laplacian does not know what variables should be used for the computation of the derivative. But what is with f[x_, y_] := x^4 + y^4 myLaplace[f_Symbol] := Module[{down, vars}, down = DownValues[f] ; vars = Cases[down, _Pattern, Infinity] /. Verbatim[Pattern][a_, Blank[]] :> a; Plus @@@ Outer[D[#1, {#2, 2}] &, Last /@ down, vars] /. {a_} :> a ] and myLaplace[f] gives 12 x^2 + 12 y^2 Regards Jens Aaron Fude wrote: > Hi, > > How does one write a call a function that represents an operator? In > other words, it takes a function and returns another function. > > For example, if you think of the Laplacian I want to do something like > this (pseudo code): > > f[x_, y_] := x^4 +y^4 > g = Laplacian[f]; > > N[g[1, 1], 50] > > How would one write "Laplacian"? > > Many thanks in advance, > > Aaron >