[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

1877.0. "drawing f(x,y)=2xy ????" by SNLV01::GONZALEZF () Mon May 30 1994 00:28

    Please can some one out there help me please or show me 
    how to draw f(x,y) = 2xy
               
    By drawing a number of level curves f(x,y) = k  +- k.
    Draw some traces or sections of the graph on selectecd planes.
    
    
    Many thanks.
    
    Fernando.
    
    
T.RTitleUserPersonal
Name
DateLines
1877.1A picture, a picture, my kingdom for a pictureAUSSIE::GARSONachtentachtig kacheltjesMon May 30 1994 04:2315
    re .0
    
    f(x,y) = 2xy really requires three dimensions to "graph". One way to
    represent it in two dimensions is in perspective. Another way
    (mathematically simpler) is using level curves, like the contours on a
    topographical map (in an atlas) or even like the isobars on a weather
    map. Level curves are just the intersections of a number of planes
    parallel to the xy plane with the three dimensional object being
    represented, with those intersections projected onto the xy plane.
    
    What you are supposed to do is draw on the one set of axes the graph of
    k = 2xy for a range of values of k (labelling each graph with the
    appropriate value of k).

    You should get a set of right hyperbolae.
1877.2R3 R3 R3 R3 R3 ????? SNLV01::GONZALEZFTue May 31 1994 00:297
    Thanks for the help but I still having trouble picturing the R3 
    image from the level curvers. An what about traces how could I deal
    with them.
    
    Again thanks.
    
    Fernando.
1877.3curve tracingWRKSYS::ROTHGeometry is the real life!Tue May 31 1994 10:3995
>    Please can some one out there help me please or show me 
>    how to draw f(x,y) = 2xy

>    By drawing a number of level curves f(x,y) = k  +- k.
>    Draw some traces or sections of the graph on selectecd planes.

   I assume x and y are real.

   You probably want to draw the curve of the implicit function
   g(x,y) = f(x,y) - xy = 0.  This is by analogy with the
   circle, where g = x^2 + y^2 - 1 = 0

   In general, this can be a difficult problem to do with rigor since
   even algebraic curves (where g is a polynomial or ratio of polynomials
   in x and y) can have bad behaviour like cusps, kinks, and multiple
   branches in the real xy plane.  (in complex variables, the set of
   points satsfying an algebraic function is connected however.)

   There are some adhoc ways to approach the problem that may work.

   One is to search around the XY plane for two points where the sign of
   g differs - then a line drawn from one point to the other will
   cross the curve, and you can find the point as a root finding
   problem in one dimension.

   Then you can trace the curve.  Make a small step, ds, at right angles
   to the gradient of g(x,y).

   Let

        ux = gx/sqrt(gx^2 + gy^2) [unit vector in direction of grad g]
        uy = gy/sqrt(gx^2 + gy^2)

	x = x +/- uy*ds		[ move left or right, at right
	y = y -/+ ux*ds	          angle to the gradient ]

   Since this moves off the curve where g = 0, you should correct
   this; one way is to use Newton iteration...  near a point
   g will have a power series expansion

	g(x0+dx, y0+dy) = g0 + dx*gx0 + dy*gy0 + high order terms.

   You want to find the step, ds, in the direction along the gradient
   that cancels out error, g0.

   Again let

	ux = gx0/sqrt(gx0^2 + gy0^2) [unit vector in direction of grad g]
	uy = gy0/sqrt(gx0^2 + gy0^2)

	dx = ds*ux
	dy = ds*uy

   solve for ds

	0 = g0 + (gx0*ux + gy0*uy)*ds   

	ds = -g0/(gx0*ux + gy0*uy)

   correct x and y
   
	x = x0 + dx
	y = y0 + dy

   This could be repeated, but in all likelyhood it will be accurate
   enough to take another step along the curve.

   Other things that help are to try identifying points on the curve
   where its gradient is tangent to the x or y axes.  This is
   where g and one of the gradient components simultaneously vanish -
   a root finding problem in two variables.  But if you can find these
   points it will help your curve tracing since you only need to follow
   the curve till the gradient has changed by 90 degrees.

   Another way not involving tracing the curve (which may be more
   robust) is to try tessellating a region of the XY plane into small
   triangles.  Then any triangle whose vertices have g with different
   signs crosses the curve, and you can solve for the intersections
   of the sides that cross the curve - a very safe way is to use
   interval halving along the sides till a certain tolerance is reached.
   Then join the points on the two sides with a line.  This is actually
   quite reliable, but is slower than curve tracing - and can miss
   small local maxima or minima of g which might fit inside one of your
   triangles.  Those points could be searched for by finding where
   the gradient vanishes, but then this is another multivariate
   root finding problem...

   I emphasise that this is a *difficult* problem in general, but it
   has been much studied in the field of solid modelers for mechanical
   CAD where it is eqivalent to finding the intersection curve between
   two free form parametric surfaces.

   Have fun!

   - Jim
1877.4for actual drawings in no time, ...BIGQ::DCLARKCollective SoulTue May 31 1994 14:392
    if you have access to math/stat packages like RS/1 or SAS you
    can draw 3D pictures of functions like this in a couple minutes.
1877.5Visual pictureEMASS::ROOSWed Jun 01 1994 00:074
    The best way of describing this surface is to take a piece of paper and
    with one set of opposite corners have them going upwards and with the
    other set of opposite corners have them go downwards.  Try that a it
    should give you a prety good picture.
1877.6take a look at formula f in XSurfaceOINOH::KOSTASHe is great who confers the most benefits.Wed Jun 01 1994 12:4115
        re. .0
    
        I have included the function f(x,y) = 2xy as formula F in XSurface.
        Copy the image from oinoh::dua2:[kostas.userlib]xsurface.exe;
        and run it (I have compiled this on OpenVMS V6.0 and Motif V1.2).
        Select the formula code F and plot the 3d image with the Do option.
        You can change min and max of any one of the three axes, you
        change pixels per unit, hosrizontal gaps, etc.
        Before I forget you could autorotate the formula and then replay it
        back. When you are done with formula F try formula B.
    
        Enjoy,
        Kostas
     End of note
    
1877.7caveatAUSSIE::GARSONachtentachtig kacheltjesWed Jun 01 1994 23:366
    re .6
    
    The program requires rather excessive amounts of virtual memory. I got
    EXQUOTA the first time I ran it and then, on upping my PGFLQUOTA to
    100000, I got VASFUL (which would require a reboot to bypass so I gave
    up at that point).
1877.8re. .-1 reduced memory reqsOINOH::KOSTASHe is great who confers the most benefits.Thu Jun 02 1994 10:536
    re. .-1
    
    I have reduced the memory requirements significantly, and have
    provided .obj files for re-linking.
    
    kostas
1877.9From MathematicaWRKSYS::BRANDENBERGFri Jun 03 1994 01:5810
Alternatively, you can copy the file avalon.mlo:~montyb/2xy.ps.Z,
uncompress it, and print or display the resulting postscript.
In an effort to justify my annual Mathematica service fee  :-)
I cranked out a few plots including the not-very-interesting
partials by X and Y.  With a little more work, I probably could have
come up with an audio representation of the function... Now, time
to get a life...

monty
1877.10AUSSIE::GARSONachtentachtig kacheltjesFri Jun 03 1994 05:235
    re .8
    
    I get undefined symbol "XMSTRINGCREATELTOR". I assume this is because I
    am using VMS V5.5/Motif V1.1 (the latter being the more relevant). Even
    my V6.1 system only has Motif V1.1. Maybe later...
1877.11WLW::KIERMy grandchildren are the NRA!Sat Jun 04 1994 14:574
    Re: .-1

    Add SYS$SHARE:DECW$XMSHRLIB to the options list in the XSURFACE.COM file
    provided is his directory.
1877.12AUSSIE::GARSONachtentachtig kacheltjesSat Jun 04 1994 22:577
    re .11
    
    Right. It works now.
    
    re .6
    
    Nice program. I must play with it some more.
1877.13i know about the problems with the hidden line algorithmOINOH::KOSTASHe is great who confers the most benefits.Mon Jun 06 1994 10:088
    re. .all
    
    just in case, I know about the hiden line algorithm problems (I just
    did not have the time to refine it). If there is an expert out there
    who could help please send me mail. The code is made up from Pascal and
    Xlib calls (you can tell by the primative interface).
    
    Kostas