MathGroup Archive 2001

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

Search the Archive

Re: Peculiar behavior of DiscreteDelta

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28772] Re: [mg28731] Peculiar behavior of DiscreteDelta
  • From: BobHanlon at aol.com
  • Date: Sat, 12 May 2001 01:36:40 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

1. To maintain maximum precision, Sin will not evaluate if its argument 
is an exact number for which it does not have a specific definition.  
For example,

{Sin[3], Sin[Pi/2], Sin[Pi/7], Sin[1/2(1-Sqrt[5])+1/2(-1+Sqrt[5])]}

{Sin[3], 1, Sin[Pi/7], 
  Sin[(1/2)*(1 - Sqrt[5]) + 
    (1/2)*(-1 + Sqrt[5])]}

Mathematica generally does not Simplify unless directed

%//Simplify

{Sin[3], 1, Sin[Pi/7], 0}

Applying Simplify after-the-fact worked or you can Simplify first

Sin[Simplify[1/2(1-Sqrt[5])+1/2(-1+Sqrt[5])]]

0

2.  JackDelta

DiscreteDelta[1/2(1-Sqrt[5])+1/2(-1+Sqrt[5])]

\!\(\*FormBox[
  RowBox[{\($MaxExtraPrecision::"meprec"\), 
    ":", "\<\"In increasing internal precision while attempting to evaluate \
\\!\\(TraditionalForm\\`\\(\\(\\(1\\/2\\\\ \\(\\((1 - \\@5)\\)\\)\\)\\) + \\(\
\\(1\\/2\\\\ \\(\\((\\(\\(-1\\)\\) + \\@5)\\)\\)\\)\\)\\)\\), the limit \
$MaxExtraPrecision = \\!\\(TraditionalForm\\`50.`\\) was reached. Increasing \
the value of $MaxExtraPrecision may help resolve the uncertainty.\"\>"}], \
TraditionalForm]\)

DiscreteDelta[(1/2)*(1 - Sqrt[5]) + 
   (1/2)*(-1 + Sqrt[5])]

The warning arises in trying to determine if the argument is zero

1/2(1-Sqrt[5])+1/2(-1+Sqrt[5]) == 0

\!\(\*FormBox[
  RowBox[{\($MaxExtraPrecision::"meprec"\), \(\(:\)\(\ \)\), "\<\"In \
increasing internal precision while attempting to evaluate \
\\!\\(TraditionalForm\\`\\(\\(\\(1\\/2\\\\ \\(\\((1 - \\@5)\\)\\)\\)\\) + \\(\
\\(1\\/2\\\\ \\(\\((\\(\\(-1\\)\\) + \\@5)\\)\\)\\)\\)\\)\\), the limit \
$MaxExtraPrecision = \\!\\(TraditionalForm\\`50.`\\) was reached. Increasing \
the value of $MaxExtraPrecision may help resolve the uncertainty.\"\>"}], \
TraditionalForm]\)

(1/2)*(1 - Sqrt[5]) + 
   (1/2)*(-1 + Sqrt[5]) == 0

However, JackDelta does not test for zero.  Its first definition just 
responds to an argument which is identically zero

Clear[JackDelta];
JackDelta[0]  = 1;
JackDelta[x_?NumericQ] = 0;

JackDelta[1/2(1-Sqrt[5])+1/2(-1+Sqrt[5])]

0

Since it did not see an argument which is identically zero, it moved on to 
the question of whether the argument is numeric

NumericQ[1/2(1-Sqrt[5])+1/2(-1+Sqrt[5])]

True

Since all of its components are numeric Mathematica can determine that it is 
numeric without actually evaluating it.

This occurs again because it is not evaluated.  Consequently, you need to 
force evaluation before JackDelta looks at its arguments, that is, 

JackDelta[Simplify[1/2(1-Sqrt[5])+1/2(-1+Sqrt[5])]]

1

Alternatively, you can change the definition of JackDelta to take care of this

Clear[JackDelta];
JackDelta[x_ /; N[x] == 0]  = 1;
JackDelta[x_?NumericQ] = 0;

JackDelta[1/2(1-Sqrt[5])+1/2(-1+Sqrt[5])] 

1


Bob Hanlon

In a message dated 2001/5/11 4:03:59 AM, jackgold at math.lsa.umich.edu writes:

>I am using Mathematica, version 4.0 on a Mac OS.9 system and a Unix system.
>On
>both systems I get the following peculiar buglet:
>
>In[1]:= DiscreteDelta[1/2(1-Sqrt[5])+1/2(-1+Sqrt[5])]
>
>results in a message entitled $MaxExtraPrecision::meprecp :  ...
>
>and an output which is identical to the input.  This does not happen if
>DiscreteDelta is replaced by a numeric function such as Sin.  This led
>me
>to note that 
>
>*  DiscreteDelta does not have the Attribute NumericFunction.
>
>Back to the main point:
>
>If the output of In[1] is followed by FullSimplify, then we get 1 which
>is
>expected since the argument of DiscreteDelta is 0.  If Sqrt[5] is replaced
>by other Sqrt[n] where n is not a perfect square, the result is again the
>message and the input is returned unaltered.  However if Sqrt[5] is
>replaced by Sqrt[r] (where r is symbolic) the input is returned unaltered
>with no message.
>
>Since  DiscreteDelta is not an oft used function, my guess is that Wolfram
>will not get around to fixing this for some time.  While I wait, I would
>like to write a "work around".
>
>** I define a pseudo  DiscreteDelta say JackDelta[x] which, like
>DiscreteDelta, gives 0 if the argument is not 0 and 1 otherwise. (That
>is,
>
>   JackDelta[0]  = 1;
>   JackDelta[x_?NumericQ] = 0;
>
>Amazingly,
>
>   JackDelta[1/2(1-Sqrt[5])+1/2(-1+Sqrt[5])]
>
>returns 1. I am delighted but very puzzled.  
>
>Well experts, what's up?
>
>(1) Why doesn't
>
>   Sin[1/2(1-Sqrt[5])+1/2(-1+Sqrt[5])] 
>
>return 0.  (It returns the input unaltered)
>  
>(2) Why does 
>
>   JackDelta[1/2(1-Sqrt[5])+1/2(-1+Sqrt[5])] 
>
>return 0. In view of (1), it should!
>
>(3) Why does
>
>   DiscreteDelta[1/2(1-Sqrt[5])+1/2(-1+Sqrt[5])] 
>
>have an error message associated with it.
>
>(4) Why does Mathematica have a different response for each of these calls?
>


  • Prev by Date: Re: Bug in Integrate?
  • Next by Date: Re: Bug in Integrate?
  • Previous by thread: Re: Peculiar behavior of DiscreteDelta
  • Next by thread: Help optimizing a slow integral