MathGroup Archive 2013

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

Search the Archive

Re: what is wrong with this code?

An interesting plot! It appears that Mathematica does not evaluate 'f' at a
sufficient number of points. In the documentation, i could not find a way
to control that; perhaps others will. This code shows the problem:

Clear[f, g, z];
z = {};
f[x_] := If[EvenQ[IntegerPart[x]], 0.4, 0.8];
g[x_] := (z = {z, x}; f[x]);
Plot[g[x], {x, 1, 101}]
z // Flatten // IntegerPart // DeleteDuplicates // Sort

On Tue, Apr 2, 2013 at 12:24 AM, <dougwangsaif at> wrote:

> f[x_] := If[EvenQ[IntegerPart[x]], 0.4, 0.8];
> Plot[f[x], {x, 1, 101}]

  • Prev by Date: Re: Issues with Rendering of Graphics[]
  • Next by Date: Re: Packages with data sets
  • Previous by thread: what is wrong with this code?
  • Next by thread: Re: what is wrong with this code?