Re: Better Set or Set Delayed ?
- To: mathgroup at smc.vnet.net
- Subject: [mg45178] Re: Better Set or Set Delayed ?
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Fri, 19 Dec 2003 06:57:54 -0500 (EST)
- Organization: The University of Western Australia
- References: <brs4pd$ihn$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <brs4pd$ihn$1 at smc.vnet.net>, "Jean.Pellegri" <Jean.Pellegri at wanadoo.fr> wrote: > phi is the function : phi[u_,v_]=u^4+v^3 > > For calculating the Laplacian at u=3 and v=4 , > > is better : How about Laplacian[f_]:= Laplacian[f]= Function[{x,y}, Evaluate[Derivative[2,0][f][x,y]+Derivative[0,2][f][x,y]]] This computes and stores the Laplacian of phi as a pure function. Then you can compute values a particular points, such as Laplacian[phi][3,4] efficiently. See also the article "Gradient of a Pure Function" by Fabio Cavallini in The Mathematica Journal 7:2 (1998): 113-117. Cheers, Paul > > this ?? > > Laplacien2[f_][x_,y_]:= > Module[{expr,p,q,Dpp,Dqq,subs}, > expr = f[p,q]; (* Set *) > Dpp=D[expr,{p,2}]; > Dqq=D[expr,{q,2}]; > subs={p->x,q->y}; > Dpp+Dqq/.subs] > > Laplacien2[phi][3,4] > > or this ??? > > Laplacien3[f_][x_,y_]:= > Module[{g,p,q,Dpp,Dqq,subs}, > g[p_,q_] = f[p,q]; (* Set *) > Dpp=D[g[p,q],{p,2}]; > Dqq=D[g[p,q],{q,2}]; > subs={p->x,q->y}; > Dpp+Dqq/.subs] > > Laplacien3[phi][3,4] > > or this ???? > > Laplacien4[f_][x_,y_]:= > Module[{g,p,q,Dpp,Dqq,subs}, > g[p_,q_] := f[p,q]; (* Set Delayed *) > Dpp=D[g[p,q],{p,2}]; > Dqq=D[g[p,q],{q,2}]; > subs={p->x,q->y}; > Dpp+Dqq/.subs] > > Laplacien4[phi][3,4] > > Thanks and Ciao -- Paul Abbott Phone: +61 8 9380 2734 School of Physics, M013 Fax: +61 8 9380 1014 The University of Western Australia (CRICOS Provider No 00126G) 35 Stirling Highway Crawley WA 6009 mailto:paul at physics.uwa.edu.au AUSTRALIA http://physics.uwa.edu.au/~paul