Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Logo > Re: [LogoForum]...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 1527 of 1588
Post > Topic >>

Re: [LogoForum] Graphing Utility

by "John St. Clair" <john.stclair@[EMAIL PROTECTED] > Jan 19, 2008 at 05:57 AM

The message below is being cross-posted from the LogoForum.  Please 
reply here at comp.lang.logo and it will be cross-posted back to the 
LogoForum.  The original author of this message is 
mjsandy@[EMAIL PROTECTED]
 people have responded to this e-mail
but no one has given a method for solving
the equation.
(Pavel does say:
Some equations have nice and easy 
solutions, others can be solved only approximately. )
A major problem with plotting the graph of a
function such as y=x*x is scaling the axes.
If the x axis has a range -200 to 200(screen coordinates)
then  -14<x<14 is the limit of the plot ( y=196)
difficult to view!
If the scale factor is k then
 y=(x/k)^2 is plotted, the x-axis then covers the range
-200/k to 200/k (e.g. k=10 -20 to 20)
For the general equation
  y = a*x^2 + b*x + c
 y=(a*(x/k)^2 + b*(x/k) + c) is plotted against x 
 where x and y are usual screen coordinates
 e.g. x runs from -200 to 200
The solutions are the values of x when y takes
a particular value e.g.
a*(x/k)^2 + b*x/k + c = 0
 
The aUCBLOGO program below gives the REAL approx.
solution(s) for y=0, where they exist.
If no solns are generated where they should be,
increase the scale factor.
 
plot list# m  sx r
 
list# is a list of the parameters [a b c]
m gives the range of the axes e.g. -m to m
sx is the scaling factor for x
r (r =< 1) is the increment in x for the plot
 for[x -m m r][...]
I'm sure Pavel could easily translate the
program to Elica.
-------------------------------------------
to eqn_plot
 setpc 0
 cs  
 plot [1 0 1-10] 200  10 0.01
 updategraph
end
 
to plot list# m  sx r
 ;y=ax^2+bx+c
 ; list# is [a b c]
 ; m sets the limits for the axes
 ; sx the scaling factor for x, a number > 0 
 ; r the plotting increment for x
 ; the smaller r the more accurate the 
 ; the result but the slower the plot
 setupdategraph "false 
 cs
 h_axes m 
 local [a b c f]
 a=list#.1  b=list#.2  c=list#.3
 h_plot 
end
 
to h_plot  [k 0]
; k is needed to stop multiple
; results for each axis intersection
 setprintprecision 4 
 local [y x1 ans]
 ans=[] 
 for[x -m m r]
     [x1=x/sx 
      y=a*x1*x1+b*x1+c
    if (abs y) >r[k=0]
      if (abs y)<m [setxy x y pd]
  if and k==0  (abs y)< r
     [ans=fput x/sx ans 
    k=1
   ]
     ]
 pu setpos [-10 -300] seth 90
 pd label reverse ans pu
end
 
to h_axes m
 ht pu 
 setpos list m 0 
 seth 0 fd 10 rt 90 pd label m/sx pu
 rt 90 fd 10 pd 
 setpos list -m 0 pu
 seth 0 fd 10 rt 90 pd label -m/sx
 pu setpos list 0 m 
 seth 0 fd 10 rt 90 pd label m/sx
 setpos list 0 -m  pu
 seth 0 bk 10 rt 90 pd label -m/sx 
 home pu
end
 
Mike
 
 
 
 
 
 
 
 
----- Original Message -----
From: jbhnj1975
To: LogoForum@[EMAIL PROTECTED]
 Saturday, January 05, 2008 7:08 PM
Subject: [LogoForum] Graphing Utility



I would like to start with something simple like an xy plane graphing a 
parabola as y=(+/-)x^2

Can I create a program (in Elica/Logo) that can solve and graph 
equations?

I assume I would need to label the variables and put in limits.. 

Any ideas?

Thanks,
Jennifer


__._,_.___
LogoForum messages are archived at: 
http://groups.yahoo.com/group/LogoForum




 3 Posts in Topic:
Re: [LogoForum] Graphing Utility
"John St. Clair"  2008-01-19 05:57:10 
Re: [LogoForum] Graphing Utility
"John St. Clair"  2008-01-19 06:00:48 
Re: [LogoForum] Graphing Utility
"John St. Clair"  2008-01-19 06:05:02 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu May 15 1:08:47 CDT 2008.