[Date Index]
[Thread Index]
[Author Index]
Re: Re: Confusing results with N[expr]?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg62373] Re: [mg62327] Re: Confusing results with N[expr]?
*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>
*Date*: Tue, 22 Nov 2005 04:42:20 -0500 (EST)
*References*: <dlp320$1bs$1@smc.vnet.net> <200511210854.DAA22039@smc.vnet.net> <7EF1243C-78FD-4926-8E96-72AF496B0E91@mimuw.edu.pl> <E0F8D2A1-44F0-43D6-B55B-671647375C19@mimuw.edu.pl>
*Sender*: owner-wri-mathgroup at wolfram.com
On 21 Nov 2005, at 21:46, Andrzej Kozlowski wrote:
>
> On 21 Nov 2005, at 21:09, Andrzej Kozlowski wrote:
>
>>
>> On 21 Nov 2005, at 17:54, Peter Pein wrote:
>>
>>> 2.)
>>> Unprotect[Power];
>>> Power /: N[(x_)^(y_)] := Pow$[N[x], N[y]];
>>> Protect[Power];
>>> $Post = #1 /. Pow$ -> Power & ;
>>>
>>
>> Well, I would not recommend it. As often happens if you change one
>> of the basic arithmetic functions, there is be a price to pay if
>> you do this. Here is an example:
>>
>> In[1]:=
>> Unprotect[Power];
>> Power /: N[(x_)^(y_)] := Pow$[N[x], N[y]];
>> Protect[Power];
>> $Post = #1 /. Pow$ -> Power & ;
>>
>> In[5]:=
>> Solve[N[x^2 - 1 == 0], x]
>>
>> "Inverse functions are
>> being used
>> by so some solutions may not be \
>> found; use Reduce for complete solution information.
>>
>> Out[5]=
>> {}
>>
>> Solving polynomial equations has suddenly become harder
>> (although, of course, if you do not use N things will still work
>> fine).
>>
>> Andrzej Kozlowski
>
>
> Actually, there is more. Try this:
>
>
> Unprotect[Power];
> Power /: N[(x_)^(y_)] := Pow$[N[x], N[y]];
> Protect[Power];
> $Post = #1 /. Pow$ -> Power & ;
>
>
> Plot[1,{x,0,1}]
>
> or for that matter any other Plot. It's a nice puzzle to try work
> out how this comes about ;-)
>
> Andrzej Kozlowski
Actually, I think Peter's solution above was quite instructive. One
often hears the advice "do not modify the basic functions like Plus,
Times, Power...", but quite often even experienced users are tempted
to do this (I have done so more than once myself) and it is not easy
to think of convincing examples showing the unexpected things that
can happen.
Now, I am inclined to think that the functions Plus,Times and Power
(at least) should be given the attribute "Locked" in addition to the
attribute "Protected".
Andrzej Kozlowski
Prev by Date:
**Boolean Integral**
Next by Date:
**Re: statistics questions**
Previous by thread:
**Re: Re: Confusing results with N[expr]?**
Next by thread:
** Re: Confusing results with N[expr]?**
| |