Re: Confusing results with N[expr]?
- To: mathgroup at smc.vnet.net
- Subject: [mg62364] Re: Confusing results with N[expr]?
- From: Peter Pein <petsie at dordos.net>
- Date: Tue, 22 Nov 2005 04:42:05 -0500 (EST)
- References: <dlp320$1bs$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Thomas Bohl schrieb:
> 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.
>
>
Hi,
I think, I've got a workaround, which does not need changes in every
occurance of N[f[a]]:
In[1]:= a /: N[a, pa_] := N[2, pa]
In[2]:= N [{x^a, x^(Pi*a),E^(x + a*Pi)},3]
Out[2]= {x^2.00, x^6.28, 2.72^(6.28 + x)}
In[3]:= N[x^a, 32]
Out[3]= x^2.`32.
In[4]:= (#1[Last[%]] & ) /@ {Accuracy, Precision}
Out[4]= {31.69897000433602, 32.}
In[5]:= Solve[N[x^a == 1], x]
Out[5]= {{x -> -1.}, {x -> 1.}}
Most likely some of you finds issues, which have been overlooked by me :-\
Peter