Re: Plot this?

*To*: mathgroup at smc.vnet.net*Subject*: [mg109548] Re: Plot this?*From*: "David Park" <djmpark at comcast.net>*Date*: Wed, 5 May 2010 06:04:02 -0400 (EDT)

There are many ways to plot it. I'll show just a few and discuss some basic plotting techniques. You may want to look up many of the commands in help. The straightforward method is to move 49 to the other side of the equation (which would actually use == instead of = in Mathematica) and then use Plot3D to plot the lhs. But what xy domain do you want to use? You didn't say so I'll just pick one. Plot3D[8 x - x^2 + 14 y - y^2 - 49, {x, -20, 20}, {y, -20, 20}] That might or might not be satisfactory for your needs. It doesn't give a very good indication that the surface is an off-center paraboloid. We could get a better indication of this by completing the square in x and then in y to get a more symmetrical form. You could do this by hand, but the Presentations package has a built-in CompleteTheSquare routine, so I'm going to make a temporary excursion there and then define the function as f[x,y]. Needs["Presentations`Master`"] 8 x - x^2 + 14 y - y^2 - 49; CompleteTheSquare[%, x]; f[x_, y_] = CompleteTheSquare[%, y] 16 - (-4 + x)^2 - (-7 + y)^2 The paraboloid is centered at {x0,y0}={4,7}. That was the basic information we wanted. You could define f with the new expression or with the original expression. We make a better centered plot. Plot3D[f[x,y],{x,4-10,4+10},{y,7-10,7+10}] It is a little awkward to enter and adjust the x,y iterators for the plot domain. We could write this in a more convenient form by putting the Plot3D inside a With statement where we can easily set the center and plot range. With[{x0 = 4, y0 = 7, range = 10}, Plot3D[f[x, y], {x, x0 - range, x0 + range}, {y, y0 - range, y0 + range}] ] We can make much better plots by utilizing the plot options. These come in the form of rules that are added at the end of the Plot statements. There are two types, those that affect the objects that are drawn, and those that affect the overall look of the plot. WRI doesn't distinguish between them very well. Here are the options for Plot3D. (I omit the output because it is rather long, but you can evaluate.) Options[Plot3D] // Column Here we use some of the options to alter the appearance of the surface and the overall look of the plot. With[{x0 = 4, y0 = 7, range = 10}, Plot3D[f[x, y], {x, x0 - range, x0 + range}, {y, y0 - range, y0 + range}, PlotStyle -> Opacity[.85, Brown], Mesh -> None, Lighting -> "Neutral", AxesLabel -> {"x", "y", "f"}, BoxRatios -> {1, 1, 1}, ImageSize -> 400] PlotStyle and Mesh changed the appearance of the surface by giving it a color and turning off the mesh lines. Lighting, AxesLabel, BoxRatios and ImageSize affected the overall look of the plot. Another method for specifying a surface in 3D space is through a parametric representation {x, y, f[x,y]} and then using ParametricPlot3D. With[{x0 = 4, y0 = 7, range = 10}, ParametricPlot3D[{x, y, f[x, y]}, {x, x0 - range, x0 + range}, {y, y0 - range, y0 + range}, PlotStyle -> Opacity[.85, Brown], Mesh -> None, Lighting -> "Neutral", AxesLabel -> {"x", "y", "f"}, BoxRatios -> {1, 1, 1}, ImageSize -> 400] ] But this kind of surface, that has rotational symmetry about a vertical axis would look much better with a circular domain. We can do that by using polar coordinates. Let r be the distance from the center in the xy-plane and theta the angle with the x axis. Then we can write rules to convert from x,y to polar coordinates and generate a new polar parametrization. CartesianToPolarRules = {x -> 4 + r Cos[\[Theta]], y -> 7 + r Sin[\[Theta]]}; g[r_, \[Theta]_] = {x, y, 8 x - x^2 + 14 y - y^2 - 49} /. CartesianToPolarRules // Simplify {4 + r Cos[\[Theta]], 7 + r Sin[\[Theta]], 16 - r^2} Now we obtain a better representation of the surface. ParametricPlot3D[g[r, \[Theta]], {r, 0, 10}, {\[Theta], 0, 2 \[Pi]}, PlotStyle -> Opacity[.85, Brown], Mesh -> None, Lighting -> "Neutral", SphericalRegion -> True, RotationAction -> "Clip", AxesLabel -> {"x", "y", "f"}, BoxRatios -> {1, 1, 1}, ImageSize -> 400] You can use the mouse to rotate the image, zoom in and out (hold down Ctrl) or shift the image (hold down Shift). Just using rotation, the image often jumps when you let go of the mouse. The options SphericalRegion and RotationAction stop this. (You can also stop the jumping by doing a little zooming first.) Finally, you might want to show the surface without the axes, box and labeling. You can do that with: ParametricPlot3D[g[r, \[Theta]], {r, 0, 10}, {\[Theta], 0, 2 \[Pi]}, PlotStyle -> Opacity[.85, Brown], Mesh -> None, Lighting -> "Neutral", SphericalRegion -> True, RotationAction -> "Clip", Axes -> False, BoxRatios -> {1, 1, 1}, Boxed -> False, ImageSize -> 400] Sometimes you can make a quick plot with Mathematica and it will be sufficient for the purpose. Other times, especially if you are making a graphics to present to others, you may have to slowly develop the plot, using a certain amount of trial and error to obtain the most effective presentation. David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: Trevor Rabey [mailto:trevorATperfectproject.com.au at giganews.com] I am new to Mathematica and going at snail's pace. I would like to plot: 8x - x^2 + 14y - y^2 = 49 Anyone? -- Trevor Rabey

**Optimization problem for dice game (repost)**

**NDSolve backward in time**

**Re: Plot this?**

**Re: Plot this?**