[comp.sys.handhelds] plotting relations

NELSON%VWSCYG@vmsd.oac.uci.edu (Matthew A. Nelson) (12/12/90)

>
>Long ago, I had a wonderful program that plotted relations, i.e.
>if you gave it X^2+Y^2-1, it drew the unit circle. I would love to
>see a program like this for my 48, but I'm not much of a programmer.
>In order to plot f(x,y)=0, one would have to begin with the pixel
>in the upper left hand corner, and check the 3 adjacent pixels and
>compare the sign of f(x,y) evaluated at those points. If a sign change
>occured, it indicates a solution of f(x,y)=0, and that pixel should
>be turned on. Am I making sense? Can someone give me a hand implementing
>this?
>
>Mitch

Read the manual.  Store 'SQ(x)+SQ(y)=1' as EQ (via STEQ in PLOT menu), then
go into the PLOT PTYPE menu and hit CONIC.  Now, when you go into the PLOTR
and do an ERASE DRAW, you'll get your unit circle.  The 48 does a variety of
fancy plots; read the manual.

-matt

akcs.mitchell@hpcvbbs.UUCP (Mitchell Dickerman) (12/12/90)

I have read the manuals, thank you. I simply used X^2+Y^2=1 as a 
simple example. You'll notice I defined a relation as f(x,y)=0. Can 
the 48 plot Y^X=X^Y? No, and that's the program I'm looking for.

Mitch

jurjen@cwi.nl (Jurjen NE Bos) (12/13/90)

akcs.mitchell@hpcvbbs.UUCP (Mitchell Dickerman) writes:

>Can the 48 plot Y^X=X^Y? No, and that's the program I'm looking for.

This is quite hard; plotting relations is hard in general.  How about
plotting F(x,y)>0 using TRUTH plot? (It takes forever, but it works)
For example, plotting 'RE(X^Y)>RE(Y^X)' gives you a very interesting plot
indeed (using default PPAR).

akcs.mitchell@hpcvbbs.UUCP (Mitchell Dickerman) (12/13/90)

When I initially tried the TRUTH plot, it didn't due much, as not many
pixels satisfied 'Y^X=X^Y'. Then I tried 'Y^X-X^Y<.1', which worked,
but not very well. I gave up after that, but just last night I realized
that if I plot 'Y^X-X^Y<=0', the outline of the shaded in areas is
the plot I'm looking for! I.e. those pixels are the nearest ones to
the solution. Now, how do I turn on just those pixels bordering the
shaded in areas and then turn off the shaded areas?

Mitch

mike@DRD.Com (Mike Rovak) (12/14/90)

jurjen@cwi.nl (Jurjen NE Bos) wrote:
} akcs.mitchell@hpcvbbs.UUCP (Mitchell Dickerman) writes:
} 
} >Can the 48 plot Y^X=X^Y? No, and that's the program I'm looking for.
} 
} This is quite hard; plotting relations is hard in general.  How about
} plotting F(x,y)>0 using TRUTH plot? (It takes forever, but it works)
} For example, plotting 'RE(X^Y)>RE(Y^X)' gives you a very interesting plot
} indeed (using default PPAR).

I plotted 'ABS(Y^X-X^Y)<.001' as a TRUTH plot, with X independent and
Y dependent.  I did it this way so that floating point roundoff would
not kill me.  Takes a relatively long time as you say, the power
function does not help speed things up.

I get the expected result, a pixel at (-4,-2), a pixel at (+4,+2),
and all the points along the line X=Y in the default display range.  Is
this not what was requested?

-- Mike

------------------------------------------------------------------------
Disclaimer: My opinions do not necessarily reflect those of my employer.
========================================================================
------------------------------------------------------------------------
     mike@DRD.Com  
     uunet!apctrc!drd!mike
========================================================================

akcs.ciarn@hpcvbbs.UUCP (Dan Ciarniello) (12/14/90)

Try the following:
Instead of giving the plotter an equation to plot, give it a program.
The program should test whether there is a sign change from the current
pixel to the next one.  If there is, put a 1 on the stack alse put a 
0 on the stack.  (note read else for alse in previous line).  The plotter
takes care of the rest.
(The manual gives details on how to use programs for plotting.)
Hope this helps, Dan.

mcgrant@elaine3.stanford.edu (Michael Grant) (12/15/90)

In article <27678177:1419.3comp.sys.handhelds;1@hpcvbbs.UUCP> akcs.mitchell@hpcvbbs.UUCP (Mitchell Dickerman) writes:
>When I initially tried the TRUTH plot, it didn't due much, as not many
>pixels satisfied 'Y^X=X^Y'. Then I tried 'Y^X-X^Y<.1', which worked,
>but not very well. I gave up after that, but just last night I realized
>that if I plot 'Y^X-X^Y<=0', the outline of the shaded in areas is
>the plot I'm looking for! I.e. those pixels are the nearest ones to
>the solution. Now, how do I turn on just those pixels bordering the
>shaded in areas and then turn off the shaded areas?

Well, you could try ABS(Y^X-X^Y)<EPSILON, where epsilon is some small
number that you sorta grabeed out of the air.

If you pick epsilon too small, it will in some places be less than
1/2 a pixel, so some points won't plot; if you make it too thick,
then there will be a thick band defining the function.

Mike

akcs.mitchell@hpcvbbs.UUCP (Mitchell Dickerman) (12/17/90)

This weekend I've been busy working on the relation-plotting problem.
Allow me to update you. I did in fact write a program to take a
plot like X^Y-Y^X<=0 and turn it into just the outline of the shaded
areas. Unfortunately, it took around 35 minutes, which on top of the
intial 15 minutes for the first plot, was unacceptable. Then I worked on
a program which, when plotted, returned the graph of where a sign change
occurs. I revised it a couple of times, and here it is:
%%HP: T(3)A(R)F(.);
\<< 'Y^X-X^Y' \->NUM
SIGN DUP X Y R\->C
C\->PX OBJ\-> DROP SWAP
DROP
  IF # 0h ==
  THEN
    IF 0 ==
    THEN 1
    ELSE 0
    END
  ELSE
    IF 0 ==
    THEN 1
    ELSE
      IF DUP ROT
ROT * -1 ==
      THEN 1
      ELSE 0
      END
    END
  END
\>>
(Note: replace 'Y^X-X^Y' with whatever relation you want to plot.)
This takes about 41 minutes to plot, which is still terribly long. About
a third of the time is that initial check to see if we're at the top of
the screen. All it's doing is getting the Y pixel coordinate. Does anyone
know of a SYSEVAL that returns it? That would speed things up
dramatically. Elaborating more on the program, it simply gets the sign at
the current point, then checks to see if we're at the top of the screen,
in which case we only check to see if the sign is 0. After that, we leave
the sign on the stack for the next point to compare against. If we're not
at the top, it checks to see if the sign is 0. If it's not, it checks to
see if the current sign times the previous one is -1, which would
indicate a sign change. Either way, it leaves the last sign on the stack
for future checks. The reason for checking for the top of the screen is
that I don't want it comparing the top sign of one column to the bottom
sign from the previous one, it wouldn't make sense. 
     To use this, simply store the program as the equation to be plotted
and choose the TRUTH plot. If someone can speed this up, it would be
greatly appreciated.
 
Mitch

TNAN0@CCVAX.IASTATE.EDU (12/20/90)

To Mitch (The guy who wanted to plot f(x,y)=0)...

  You've read the manuals?  Look on page 333...  You will see a section on
TRUTH plots...   Aren't these exactly what you are looking for?  It evaluates
an expression at each point on the screen, and if it is true, it sets that
point.  So, enter X^Y-Y^X>0 as your 'eq' and plot using a TRUTH plot.  Your
f(x,y)=0 will be the border between white and black on the screen... 
In general, this means that you can plot f(x,y)=0 as f(x,y)>0 and simply use
the border as your level curve at 0.

  I attempted the example that you gave (the x^y=y^x one) and found that the
calculator would bomb when it tried to execute > on a complex number...
Easily solved...  Just try using ABS(X^Y) > ABS(Y^X) instead...  I warn you:
this is extremely slow...


---Xeno