# How to do make Plot automatically figure out a domain interval?

When you tell Wolfram|Alpha to plot something, it automatically figures out a reasonable domain to plot it over. When I try something like

Plot x^2 + y^2 = 1000


it automatically translates that to

ContourPlot[x^2 + y^2 == 1000, {x, -40, 40}, {y, -40, 40}]


and gives me back a nice circle.

Now this isn't even a function, but I'd be pretty happy even if this could be done just for functions, or even only relatively simple ones at that.

I'm pretty new to Mathematica, and for the life of me, I can't figure out how to do this with Mathematica. I just want it to plot the function and figure out the range itself! It drives me nuts to have to say

Plot[f[x], {x, -8, 8}]


when I have no idea what f will look like.

How can I have Mathematica figure out a reasonable domain by itself? I don't need it to be perfect, just something that isn't totally unreasonable (e.g. a blank plot). It can't be that hard for a system that can symbolically solve differential equations.

• An interesting question but could you provide additional examples? How are more complicated functions handled? – Mr.Wizard Jul 7 '15 at 6:40
• @Mr.Wizard: I'm not sure if I should be reading between the lines of your comment or if I'm understanding what you're asking me. If you literally just want me to run more examples, I'd be happy to, just tell me what function you want to see the plot for because I have no idea what you're looking for. But if this is just a subtle way of suggesting that it's unreasonable to expect such a feature to exist because it can't handle arbitrarily complex functions... well yes, I realize nothing in the world can handle arbitrarily complex tasks, but so what? – user541686 Jul 7 '15 at 6:56
• No reading between the lines needed. I merely would like to see how MATLAB is handling some nontrivial examples as a reference for attempting to emulate its behavior. Also I would like to know what should be done for functions that cannot be symbolically analyzed. Should we evaluate an arbitrary range of x values and then attempt narrow the plot to an "interesting" part of the result? – Mr.Wizard Jul 7 '15 at 7:03
• For the updated question: consider building a function around RegionPlot of an ImplicitRegion form of your equation. At least for simple cases, RegionPlot is capable of reasoning the bounds of a geometric region (v10 functionality). An example: RegionPlot[ImplicitRegion[x^2 + y^2 == 1000, {x, y}]] – kirma Jul 7 '15 at 7:41
• @kirma: Cool! Feel free to post it as an answer. – user541686 Jul 7 '15 at 7:48

ezplot(fun) plots the expression fun(x) over the default domain -2π < x < 2π, where fun(x) is an explicit function of only x.

(... and pretty much the same for other variations.) That wasn't actually at all as fancy as I expected!

Thus the simplest case:

ClearAll[ezplot];

ezplot[expr_, rest___] := Plot[expr, {x, -2 Pi, 2 Pi}, rest];
SetAttributes[ezplot, HoldAll]; (* just to act like Plot *)


EDIT: Now my answer looks strange... why? Because OP extensively edited the question while I was answering it.

Starting point for the edited question:

ClearAll[ezregion];

ezregion[expr_, rest___] := RegionPlot[ImplicitRegion[expr, {x, y}], rest];
SetAttributes[ezregion, HoldAll];


Now you can perform automatic 2D region plot for expressions involving x and y:

ezregion[x^2 + y^2 == 1000]


Try typing the equal sign first (=), and then, in words, "plot x^2".

EDIT: