MathGroup Archive 1997

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

Search the Archive

Re: Procedure to Function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8180] Re: Procedure to Function
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Mon, 18 Aug 1997 03:07:04 -0400
  • Organization: University of Western Australia
  • Sender: owner-wri-mathgroup at wolfram.com

Robert Pratt wrote:

> I am having difficulty rewriting a short procedure as a single function.
> Can anyone explain why I get the wrong answer using the function instead
> of the procedure?  Given a harmonic function u[x,y], I'm trying to find
> its harmonic conjugate v[x,y] (so that the Cauchy-Riemann equations hold).
> 
> PROCEDURE
> 
> Clear[u, v, x, y, g]
> u = x^3 - 3 x y^2 + y;
> v[x_, y_] := Integrate[D[u,x],y] + g[x];
> g[x_] := Evaluate[g[x] /.DSolve[D[v[x, y],x] == D[u,y], g[x], x][[1]]];
> v[x, y]
> 
> -x + 3 x^2 y - y^3 + C[1]

How about the following?

  In[1]:= HarmonicConjugate[u_, x_, y_] := Module[{v,g},
	v = Integrate[D[u,x], y]+g[x];
     v /. First[DSolve[D[v, x] == D[u, y], g[x], x]]]

  In[2]:= HarmonicConjugate[x^3 - 3 x y^2 + y, x, y]
  Out[2]= -y^3 - 3 x^2 y + x + C[1]

This way v and g are local to the Module and u, x, and y are passed as
input.

Cheers,
	Paul 

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia           
Nedlands WA  6907                     mailto:paul at physics.uwa.edu.au 
AUSTRALIA                              http://www.pd.uwa.edu.au/Paul

            God IS a weakly left-handed dice player
____________________________________________________________________


  • Prev by Date: Re: ListPlot with little plus signs instead?
  • Next by Date: Re: Can Mathematica Do This?
  • Previous by thread: Re: Procedure to Function
  • Next by thread: Re: Procedure to Function