# how do you graph a function?

I know techniques from calculus to more or less know the behavior of a function. But I still don't know how to graph functions people expect me to graph, for example, in Fulton's curve book there are curves like $F=(X^2+Y^2)^3-4x^2y^2$ and there's a picture but if someone asked me to draw such function I've had no idea where to start. In summary I'm asking what do you do when you want to do the graph of a function (of one or several real variables), please don't skip anything, I think I lack of some things that are obvious for others but not for me. Regards.

-
Are you asking how to draw 3D height fields, e.g. $z=x^2+y^2-4x^2y^2$? Or 2D level sets, e.g. $C=x^2+y^2-4x^2y^2$? – user7530 Feb 15 '13 at 0:21
the curve $F = (x^2+y^2)^3 -4x^2y^2$ in the plane, but more generally I am asking for techniques to graph functions – Cybuster Feb 15 '13 at 0:38
Yes, but "graphing functions" can refer to many, very different techniques, depending on the dimensions involved and the form of the function (e.g. parametric vs implicit). – user7530 Feb 15 '13 at 0:40
To be honest, most mathematicians I know (which being a beginning grad student is relatively small, so take this with a grain of salt) wouldn't be able to graph such a curve without just plotting lots of points. Instead, we'd all just plug the equation into Mathematica or Maple (or even Wolfram|Alpha). – Avi Steiner Feb 15 '13 at 0:47
Well obviously Fulton and his contemporaries had ways to do this that didn't depend on computers, but there were probably never very many people who knew those methods, and even fewer now that we do have computers. Are there people (living ones, I mean) who expect you to be able to graph $(x^2+y^2)^3-4x^2y^2=F$? If so, you could try going to polar co-ordinates, $r^6-r^4\sin^22\theta=F$. – Gerry Myerson Feb 15 '13 at 2:05

First, how to most efficiently approximate a function using as little information as possible is a deep topic of considerable academic interest, as it has applications to numerical quadrature, simulation, etc. I'm assuming here you're interested in more elementary "back of the envelope" graphing by hand.

I'll also assume you want to plot implicit 2D functions $f(x,y) = 0$, since graphs $y=f(x)$ and parametric curves $(x,y) = f(t)$ are relatively easy to graph by sampling them.

For implicit functions, there are some special cases to be aware of; if $f$ is linear in either variable, obviously you can solve for it. If $f$ is a degree-2 polynomial, it is a conic section, and can be brought into standard form by a change of coordinates and then easily plotted. Trying polar coordinates can also pay off.

Otherwise, a general technique is "ray tracing": plug into $f$ any curve $\gamma(t)$. Solutions to $f(\gamma(t)) = 0$ are clearly points of $f(x,y)=0$, and moreover $f\circ \gamma$ is a function of only one variable. The trick is to find $\gamma$ which on the one hand sample the $f$ well, and on the the other hand yield equations whose roots are easy to find. (In the worst case, the roots can always be approximated using Newton's method). Some good families to try are horizontal and vertical lines $(a,t)$ and $(t,a)$, and rays through the origin $(at,bt)$.

For instance, for your equation, we have $$f(at,bt) = (a^2+b^2)^3t^6 - 4a^2b^2t^4 = 0,$$ which is a quadratic equation in $t$. Plotting these intersection points for a few different ray slopes $\frac{b}{a}$ will give a good picture of what the function looks like.

-
can you give me a reference (book preferably) for ray tracing? – Cybuster Feb 15 '13 at 7:53
See for instance graphics.ethz.ch/Downloads/Publications/Dissertations/Sig06.pdf, section 2.5.1. The more sophisticated ideas are intended for computer graphics and are too laborious to do by hand, but the basic idea is the same. – user7530 Feb 15 '13 at 9:04
– user7530 Feb 15 '13 at 9:09

When plotting a function or any set of points that satisfy some equations, first thing to do is observing some properties, like symmetry or antisymmetry, because it might shorten your efforts. As for the parametrization, the whole point of it is to make function or equation easier to interpret and eventually plot. Beside that, parameters are completely arbitrary. Let's consider your example.

First, I'd observer that equation is completely symmetric for $x \rightarrow -x$ and $y \rightarrow -y$ transformations, which means all you have to is plot it in $x \geq 0; \ y \geq 0$ quadrant and translate it symmetrically to other three. Furthermore, equation is symmetric with respect to $x \rightarrow y$ transformation, which means it's symmetric with respect to $y = x$ line.

Next, since there are $x^2+y^2$ I'd go to polar coordinates $$x = r \cos \phi \\ y = r \sin \phi$$ Taking into account symmetry, you can consider $0 \leq \phi \leq \frac \pi 4$

Also, let's consider zero level set $F = 0$: $$(r^2\cos^2 \phi + r^2 \sin^2 \phi)^3=4r^4\cos^2\phi\sin^2\phi \\ r^6 = 4r^4\cos^2\sin^2\phi \\ r^2 = \sin^2 2\phi \\ r = \sin 2\phi$$ So eventually $$x = \sin 2\phi \cos \phi \\ y = \sin 2\phi \sin \phi$$ And finally, take several values for $\phi$ like $0:\pi/20:\pi/4$ (6 points) and you can sketch your figure, more or less.

So, first, pick some values for $\phi$ and plot it

Next translate it above $y = x$ line symmetrically

Then translate whatever you got to $x \geq 0,\ y \leq 0$ quadrant

And finally translate it to $y \leq 0$ halfplane

I know, this only for $F = 0$ level set, but symmetry properties are valid for all level sets, only parametrization needs to be chosen differently.

-

The following freely available books are good references for this sort of thing, if you are interested in pursuing the topic in spite of what others have said.

R. Howard Duncan, Practical Curve Tracing with Chapters on Differentiation and Integration (1910)

Percival Frost, An Elementary Treatise on Curve Tracing (1918)

William Woolsey Johnson, Curve Tracing in Cartesian Coordinates (1884)

-
Great! +1 - I was curious about this sort of thing. – Voyska Mar 8 '13 at 17:21