views:

374

answers:

3

Hello.

What is the usual method or algorithm used to plot implicit equations of 2 variables?

I am talking about equations such as,

sin(x*y)*y = 20

x*x - y*y = 1

Etc.

Does anyone know how Maple or Matlab do this? My target language is C#.

Many thanks!

+3  A: 

One way to do this is to sample the function on a regular, 2D grid. Then you can run an algorithm like marching squares on the resulting 2D grid to draw iso-contours.

In a related question, someone also linked to the gnuplot source code. It's fairly complex, but might be worth going through. You can find it here: http://www.gnuplot.info/

Eric
Thank you for providing the right keywords to search for.This search (http://www.google.com.sg/search?q=Marching+squares+contours) especially threw up some interesting links.
ARV
+2  A: 

Iterate the value of x across the range you want to plot. For each fixed value of x, solve the equation numerically using a method such as interval bisection or the Newton-Raphson method (for which you can calculate the derivative using implicit differentiation, or perhaps differentiate numerically). This will give you the corresponding value of y for a given x. In most cases, you won't need too many iterations to get a very precise result, and it's very efficient anyway.

Note that you will need to transform the equation into the form f(x) = 0, though this is always trivial. The nice thing about this method is that it works just as well the other way round (i.e. taking a fixed range of y and computing x per value).

Noldorin
A: 

i think,

in matlab you give array as input for x.

then for every x, it calculates y.

then draws line from x0,y0 to x1, y1

then draws line from x1,y1 to x2, y2

...

...

ufukgun