[Date Index] [Thread Index] [Author Index]
Re: Confusing results with N[expr]?
There may be a clue in the following, equally distressing nonsense... In:= $Version Out= 5.1 for Microsoft Windows (October 25, 2004) (* Map[f, expr] or f /@ expr applies f to each element on the first level in expr. *) In:= Map[f, a^b] Out= f[b] f[a] In:= f /@ a^b Out= b a (* MapAll[f, expr] or f //@ expr applies f to every subexpression in expr. *) In:= MapAll[f, a^b] Out= f[b] f[f[a] ] In:= f //@ a^b Out= b f[a] Thomas Bohl wrote: > 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. > >