Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

RE: Plotting a function -

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71667] RE: [mg71642] Plotting a function -
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sun, 26 Nov 2006 03:48:51 -0500 (EST)

I don't see why you are using Boole. Also you can't have Sum[f,...] or
Plot[g,...]. You would need f[x] and g[x]. It always helps to evaluate and
test your definitions before you throw them all together in a plot.

Here are some routine that will work better. digits3 gives the number of 3's
in the number. The values are 'remembered' so we won't have to keep
computing them.  fractable gives the fraction of 3's for each number.
List plots should be much faster than regular plots here.

Needs["Graphics`Graphics`"]

digits3[n_] := digits3[n] = DigitCount[n, 10, 3]

fractable[
    x_] := (Drop[FoldList[Plus, 0, Table[digits3[n], {n, 1, x}]], 1] // N)/
    Range[x]

ListPlot[fractable[32000],
    Frame -> True,
    FrameLabel -> {x, f},
    PlotRange -> All,
    ImageSize -> 450];

LogLinearListPlot[{Range[32000], fractable[32000]} // Transpose,
    Frame -> True,
    FrameLabel -> {x, f},
    PlotRange -> All,
    ImageSize -> 450];

Other may give you more efficient code.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

From: Craig Reed [mailto:tharkun860 at publicspam.com]

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?"



  • Prev by Date: Re: Function Name from Inside the function
  • Next by Date: Re: Plotting a function -
  • Previous by thread: Re: Plotting a function -
  • Next by thread: Re: Plotting a function -