Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: what is wrong with this code?
Replies: 2   Last Post: Apr 3, 2013 4:07 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
James Stein

Posts: 130
Registered: 5/8/10
Re: what is wrong with this code?
Posted: Apr 3, 2013 4:07 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


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@gmail.com> wrote:

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





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.