MathGroup Archive 2007

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

Search the Archive

Re: Replace in Modules

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81226] Re: [mg81187] Replace in Modules
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 16 Sep 2007 04:08:32 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

Works this way

Clear[f];

f[x_] := Module[{a, y}, y = x; a /. FindRoot[y == a^2, {a, 1}]];

f[2]

1.41421

Clear[f];

f[x_] := Module[{a}, a /. FindRoot[x == a^2, {a, 1}]];

f[2]

1.41421


Bob Hanlon

---- Joerg Schaber <schaber at molgen.mpg.de> wrote: 
> Hi,
> 
> why doesn't the following give me the square root?
> 
> f[x_] := Module[{a, y},y = x;Return[FindRoot[y == a^2, {a, 1}]]]
> 
> f[z] /. {z -> 2}
> 
> where as
> 
> f[x_] := Module[{a},Return[FindRoot[x == a^2, {a, 1}]]]
> 
> f[z] /. {z -> 2}
> 
> works fine?
> 
> best,
> 
> joerg
> 



  • Prev by Date: Re: Help: Font problem
  • Next by Date: Re: problem with Dynamic?
  • Previous by thread: Replace in Modules
  • Next by thread: Re: Replace in Modules