# Why won't this graph? [closed]

I'm trying to sketch level curve for z=k for the specified values of k={-2,-1,2} of z= 4x^2 - 4x + y^2 + 2y

So I changed this(by hand) to ellipse of the form 4(x - (1/2))^2 + (y + 1)^2 = k + 2 then I put in the following code

ContourPlot[z + 2 == 4 (x - (1/2))^2 + (y + 1)^2 , {z = -1.99999}, {z = -1}, {z =
1}, {x, -5, 5}, {y, -5, 5}, ContourStyle -> Black]


but when I try to evaluate cell I get

ContourPlot::nonopt: Options expected (instead of {y,-5,5}) beyond position 3 in ContourPlot[z+2==4 (x-Times[<<2>>])^2+(y+1)^2,{z=-1.99999},{z=-1},{z=1},{x,-5,5},{y,-5,5},ContourStyle->Black]. An option must be a rule or a list of rules. >>
ContourPlot[z + 2 == 4 (x - 1/2)^2 + (y + 1)^2, {z = -1.99999}, {z = -1}, {z =  1}, {x, -5, 5}, {y, -5, 5}, ContourStyle -> Black]


Anyone can tell me what wrong with this code? Also when its says "beyond position 3" do I count 1 for each comma ? How can I get it to sketch this ellipse for the 3 different values of k? thought maybe its the -2 so changed it to -1.999 . I'm sorry if this is really obvious but it's only my 2nd time using Mathematica. Any help is much appreciated.

## closed as off-topic by Daniel Lichtblau, bbgodfrey, Karsten 7., Mr.Wizard♦Feb 5 '15 at 7:00

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, bbgodfrey, Karsten 7., Mr.Wizard
If this question can be reworded to fit the rules in the help center, please edit the question.

• Wrong syntax for ContourPlot. You'll want the Contours option. Also you don't actually need to recast in that form (it shouldn't hurt or help, that is). – Daniel Lichtblau Feb 4 '15 at 20:29
• Contours[3 == 4 (-(1/2) + x)^2 + (1 + y)^2, {-1.99999}, {-1}, {1}, {x, -5, 5}, {y, -5, 5}, ContourStyle -> GrayLevel[0]] is what it returns when I use Contours – user24907 Feb 4 '15 at 20:30
• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – bbgodfrey Feb 4 '15 at 20:39
• Somebody please improve my answer, utter neophyte when it comes to putting MMA images in answer – Manuel --Moe-- G Feb 4 '15 at 20:48
• See Help > Documentation Center, enter ContourPlot, then navigate to Options > Contours and look at example "Use specific contours:". – Daniel Lichtblau Feb 4 '15 at 21:56

Evaluate inside of ContourPlot is how I would do it...

kVals = {-1.95, -1.9, -1.5, -1, 0, 1, 2};

levelCurve = (4 x^2 - 4 x + y^2 + 2 y)


-4 x + 4 x^2 + 2 y + y^2

 levelCurve2 = (4 (x - 1/2)^2 + (y + 1)^2 - 2)


-2 + 4 (-(1/2) + x)^2 + (1 + y)^2

Simplify[levelCurve2 == levelCurve]


True

ContourPlot[
Evaluate[Table[levelCurve2 == k, {k, kVals}]], {x, -1, 2}, {y, -4, 2}]


• Thank you, but if I only want k= -2, -1, 2 this is all I should need to change in your code? – user24907 Feb 4 '15 at 20:51
• what do you expect to see from k=-2? -- I doubt ContourPlot will give you a single point – Manuel --Moe-- G Feb 4 '15 at 20:54
• Yes k=-2 was part of question not my choice but I just put in -1.9999 and it has given what looks like a point. – user24907 Feb 4 '15 at 20:59
• Try -1.999 and PlotPoints -> 200 to get inner point (almost). – bbgodfrey Feb 4 '15 at 21:00
• {z = -1.99999} etc, is not a legal argument for ContourPlot, which is why it failed. Note also that you need to delete z from your equation inside ContourPlot, because it is an undefined (and unnecessary) variable. Contours is an option inside ContourPlot. For instance, you could have used Contours->{-1.9999,-1,1}. See the Details and Options section of the ContourPlot documentation for more information. – bbgodfrey Feb 4 '15 at 21:21

To make clear the explanation in my Comments, your curves can be plotted with

ContourPlot[4 (x - (1/2))^2 + (y + 1)^2 - 2, {x, -5, 5}, {y, -5, 5},  ContourStyle -> Black,
Contours -> {-1.999, -1, 1}, PlotPoints -> 200, ColorFunction -> (White &)]


It differs from your original expression as follows:

• The equation involving z is replaced by an expression that defines z
• Input parameters {z = -1.99999}, etc not recognized by ContourPlot are eliminated. These are what caused the error message.
• Contours -> {-1.999, -1, 1} specifies the contours desired. This undoubtedly is what Daniel Lichtblau had in mind.
• ColorFunction -> (White &) specifies that the space between contours is white.
• PlotPoints -> 200 tells ContourPlot to begin looking for contours at 200 locations. With fewer points it is unable to find the innermost contour. Warning: too large a number of points can slow your code greatly!
• Thanks, sorry for late reply I left computers in college. Will try again with this new knowledge you and Manuel have given me in the morning. Your help and time are much appreciated. – user24907 Feb 4 '15 at 23:04