simplegraph.frink

View or download simplegraph.frink in plain text format


// This is a simple but rather interesting program that graphs equations.
// You enter equations in terms of x and y, something like one of the
// following:
//
//  y = sin[x]
//
//  x^2 + y^2 = 81
// 
while func = input["Enter equation: "]
{
   func =~ %s/=/ PEQ /            // Replace = with possibly equals

   xsteps = 78
   xmin = -10
   xmax = 10
   xstep = (xmax-xmin) / xsteps

   ysteps = 39
   ymin = -10
   ymax = 10
   ystep = (ymax-ymin) / ysteps

   for yy=ymax to ymin step -ystep
   {
      y = new interval[yy, yy+ystep]
      for xx=xmin to xmax step xstep
      {
         x = new interval[xx, xx+xstep]

         if eval[func]
            print["X"]
         else
            print["."]
      }
      println[]
   }
}


View or download simplegraph.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 17591 days, 17 hours, 39 minutes ago.