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: Cool example with ContourPlot+EvaluationMonitor
Replies: 9   Last Post: Mar 23, 2012 2:35 AM

Advanced Search

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

Posts: 66
Registered: 4/28/07
Re: Cool example with ContourPlot+EvaluationMonitor
Posted: Mar 20, 2012 3:25 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi Ralph,
Well, the thing is that most Mathematica functions are sort of a "black box", ie you supply a set of functions and parameters and it produces a result. In this case you never see the intermediate steps/results, the source code is obviously not available and even if it was, according to the documentation in many cases it's not even human readable (for efficiency reasons).

Therefore, this example illustrates how one of the functions (ContourPlot) operates in real time: first it makes a grid in the 2D space specified by the user, eg {x, -1.5, 1.5} & {y, -1.5, 1.5}, and then it picks values of (x,y) close to the actual contour: my guess is it chooses the ones close to where Abs[x^2+y^2-1]<dr, where dr is a small number say 0.2 (of course this is just a guess). I'm posting some (quick and dirty) code below that illustrates this.

I hope this helps!

Cheers

PS Of course I have to mention that Mathematica also checks the corners of the region etc but that's another story ;)

--- Code ---

(* grab the data from ContourPlot *)
data = {};
ContourPlot[x^2 + y^2 == 1, {x, -1.5, 1.5}, {y, -1.5, 1.5},
EvaluationMonitor :> AppendTo[data, {x, y}]];

(* just take the grid *)
qq = data[[1 ;; 15*15]];

(* evaluate Abs[x^2+y^2-1] and take the ones <0.2, then plot *)
qq1 = Table[{Abs[qq[[i, 1]]^2 + qq[[i, 2]]^2 - 1], qq[[i, 1]],
qq[[i, 2]]}, {i, 1, Length[qq]}] // Sort;
qq1 = qq1[[1 ;; 32]][[All, {2, 3}]];
ListPlot[{qq, qq1}, PlotStyle -> {Blue, Red}, AspectRatio -> 1]




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.