MathGroup Archive 2006

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

Search the Archive

Re: Plotting a function -

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71666] Re: Plotting a function -
  • From: Bill Rowe <readnewsciv at sbcglobal.net>
  • Date: Sun, 26 Nov 2006 03:48:49 -0500 (EST)

On 11/25/06 at 5:37 AM, tharkun860 at publicspam.com (Craig Reed) wrote:

>Hi -
>
>I'm trying to get Mathematica 5.2 to graph a function which is the
>ratio of integers which have a '3' in them. Done in Exce3l, the
>graph of the first 32,000 data points has a fractal look to it,
>especially when done with a log scale.

>What I've tried is the following

>f[x_] := Boole[DigitCount[x, 10, 3]]
>g[x_] := Sum[f, {i, x}]/x
>Plot[g, {x, 1, 100}]

>I get 3 errors of "g is not a michine-size real number at" followed
>by 3 real numbers: 1.000004125 5.016125..... 9.39607.....

>What am I doing wrong?  or perhaps what I should ask is, "Is there a
>better way?"

You have a variety of errors in your code that are causing the 
problem. You have defined the functions f and g to have an 
argument. Yet when you call the function you don't supply an 
argument. That is g needs to be defined as follows:

g[x_]:=Sum[f[i],{i,x}]/x

Similarly when you plot g the syntax is

Plot[g[x],{x,1,100}]

But you also have a problem with your definition of f. The 
argument to Boole needs to be an expression not an integer that 
will be returned by DigitCount. That is you need something like

f[x_]:=Boole[DigitCount[x,10,3]>0]
--
To reply via email subtract one hundred and four


  • Prev by Date: RE: Nonlinear Regression
  • Next by Date: Re: Limit of Infinitely Nested Expression (4.0 succeeds, 5.2 fails...)
  • Previous by thread: Re: Plotting a function -
  • Next by thread: RE: Plotting a function -