MathGroup Archive 2010

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

Search the Archive

Re: Pi vs its decimal approximation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113170] Re: Pi vs its decimal approximation
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sat, 16 Oct 2010 13:12:02 -0400 (EDT)

On 10/15/10 at 1:51 PM, accardi at accardi.com (John Accardi) wrote:

>In my notebook below, why doesn't cosine2 graph? When I replace the
>symbol for Pi with the decimal approx in the definition of cosine3,
>it graphs correctly. .  Why does Mathematica not interpret Pi
>correctly in the first definition of cosine2?

>In[29]:= cosine2:= 2/3 Cos[2\[Pi]x - \[Pi]/2 ] +1

You are missing a space. 2\[Pi]x should be 2\[Pi] x. Without the
space, Mathematica sees this as a new variable named \[Pi]x
which never gets defined. Consequently, there is nothing to plot
from Mathematica's perspective.

Also, there is no reason to use SetDelayed (:=) here. When you
use SetDelayed here, the portion on the right hand side is
re-evaluated every time a new x is generated. Since this is a
very simple expression, the performance penalty will be too
small to be noticed. But defining cosine2 as

cosine2= 2/3 Cos[2\[Pi] x - \[Pi]/2 ] +1;

is more efficient.

>In[30]:= yline:=1

>In[31]:= Plot[Tooltip[{cosine2, yline}], {x, 0, 1.5},
>Ticks -> {{0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1.0, 1.1, 1.2,
>1.3, 1.4,
>1.5}, Automatic}]

>The plot that appears here only shows the y=1 line, not the cosine2.

>But now I replace the symbol Pi with a decimal approximation in the
>definition of cosine3 .. and it graphs correctly.

>In[20]:= cosine3:=  2/3 Cos[2(3.141592653589793`)x- \[Pi]/2 ] +1

This works not because you have provided a numeric value for Pi,
but because you have it clear there is a multiply. Try

cosine3=  2/3 Cos[2(\[Pi])x- \[Pi]/2 ] +1;

or adding the space suggested above and you will get what you
were expecting.



  • Prev by Date: Re: symbolic division of series
  • Next by Date: Re: referencing auto-numbered cell
  • Previous by thread: Re: Pi vs its decimal approximation
  • Next by thread: Re: referencing auto-numbered cell