Post Reply 
[hp50g] how enter the rand function for graphing?
10-13-2022, 12:21 PM
Post: #15
RE: [hp50g] how enter the rand function for graphing?
(10-13-2022 07:06 AM)Gil Wrote:  By the way, how would you increase the number of graphed points with your "trick" «RAND » STEQ?

When plotting a function, the graphing engine of the 50g looks at all of the given parameters (mostly residing in the PPAR object for this scenario), then repeatedly sets the value of the independent variable (X in this case) to what it has determined as the current value to plot. After setting X, it calls the program stored in EQ. Whatever the result is from that program becomes the Y value for the given iteration. In this case, we don't really care what X is, so it doesn't need to show up in the EQ program.

Getting more points plotted becomes a matter of changing the environment so that the \<< RAND \>> program gets called more times. The previous program used a "canvas" with the default dimensions (131x80). Let's say that we want to increase the size of that canvas to 500x500, with plotted points covering that entire image. Increasing the size of the canvas will inherently spread out the results, so I'll apply multiple plots to provide more points in the final graph:
Code:
\<<
  @ PURGE the graphics environment variables
  { PICT X Y EQ PPAR ZPAR } PURGE

  @ we're going to create a FUNCTION plot
  FUNCTION

  @ set the PICT size that we want
  #500d DUP PDIM

  @ store the "equation"
  \<< RAND \>> STEQ

  @ set the X/Y ranges
  1 500 XRNG
  0 1 YRNG

  @ we want points in each column
  1 RES

  @ no axes wanted, don't connect points
  { -29 -31 } SF

  @ set the RAND seed so that the exact results can be duplicated
  987654321 RDZ

  @ ERASE (not really needed here due to PICT being purged above, but good habit)
  ERASE

  @ 20 separate passes
  1 20 START
    DRAW
  NEXT

  @ recall the final plot to the stack so that it can be saved
  PICT RCL
\>>

Here's the final output that the above program generates:
[Image: RAND20-500x500.png]
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [hp50g] how enter the rand function for graphing? - DavidM - 10-13-2022 12:21 PM



User(s) browsing this thread: 1 Guest(s)