MathGroup Archive 2005

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

Search the Archive

Re: Confusing results with N[expr]?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62327] Re: [mg62318] Confusing results with N[expr]?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 20 Nov 2005 04:50:31 -0500 (EST)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

Map N onto the expression or use a replacement rule

N[a]=2.;

k=z*(a*Pi);

{N[k],N/@k,k/.a->2.}

{6.28319 z,6.28319 z,6.28319 z}

k=z^(a*Pi);

{N[k],N/@k,k/.a->2.}

{z^(3.141592653589793*a), z^6.283185307179586, 
  z^6.283185307179586}


Bob Hanlon

> 
> From: "Thomas Bohl" <Thomas.Bohl at cern.ch>
To: mathgroup at smc.vnet.net
> Date: 2005/11/19 Sat PM 11:19:01 EST
> Subject: [mg62327] [mg62318] Confusing results with N[expr]?
> 
> I have the impression that since some time (since Vers. 5.0?) N[expr] does 
> not give anymore the results I expect.
> 
> The following code should illustrate this:
> 
> N[a] = 2.;
> 
> k = z*(a*Pi);
> N[k]
> > 6.28319 z       (* "a" and "Pi" are replaced by their numerical value as 
> > expected *)
> 
> k = z^(a*Pi)
> N[k]
> > z^(3.14159 a)    (* "Pi" is replaced by its numerical value but not "a", 
> > why not? *)
> 
> 
> There are more examples of this behaviour: If the expression is Log[z*a*Pi], 
> the numerical values of "a" and "Pi" are evaluated, if the expression is 
> Exp[z*a*Pi] the numerical value of "a" is not evaluated. Why not?
> 
> The motivation behind my question is that I was used to write expressions 
> symbolically and assign numerical values with N[expr] = num. value. This 
way 
> you could keep those expressions symbolically and just apply //N when 
you 
> needed numerical values. Now it seems that I have lost this possibility.
> 
> Could you please comment my observation and maybe suggest a way out?
> 
> Thank you very much for any idea.
> 
> Kind regards,
> Thomas.
> 
> 
> 


  • Prev by Date: Re: AW: Same scaling for plots/ charts
  • Next by Date: Re: Re: Recursion
  • Previous by thread: Re: Re: Confusing results with N[expr]?
  • Next by thread: Re: Confusing results with N[expr]?