Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
I am new to graphic calculators and am working my way through the TI-83 plus manual. I got to the Sierpinski triangle example on page 17-7. It worked as expected but I thought I would investigate what is happening with some of the calculations. Instead of a random numbers for X, Y, and N, I put in a starting value of 1 for X and Y and a constant of 0.2 for N. I also shortened the loop to only a dozen of iterations or so. With the N less than 1/3, the X and Y values should be halved for each iteration. This is true for X, but Y goes to zero after the first go around. This makes no sense to me. I tried a bunch of different changes to see why. Curiously, when I use another variable letter throughout the program rather than Y, it works just as expected showing a halved value for both X and the second variable.

While the program works as presented in the text with random numbers, I sure would like to know what is happening when one uses the variable Y so I can be confident in my results for future programming applications. There must be something I am missing. Thanks in advance for any insight. Code is below for both the original and modified program.

ORIGINAL PROGRAM

Code:
PROGRAM:SIERPINS
:FnOff :ClrDraw
:PlotsOff
:AxesOff
:0→Xmin:1→Xmax
:0→Ymin:1→Ymax
:rand→X:rand→Y
:For(K,1,3000)
:rand→N
:If N≤1/3
:Then
:0.5(0.5+X)→X
:0.5(0.5+Y)→Y
:End
:If 1/3<N and N≤2/3
:Then
:0.5(0.5+X)→X
:0.5(1+Y)→Y
:End
:If 2/3<N
:Then
:0.5(1+X)→X
:0.5Y→Y
:End
Pt-On(X,Y)
:End
:StorePic 6


MODIFIED PROGRAM

Code:
PROGRAM:SIERPINS
:FnOff :ClrDraw
:PlotsOff
:AxesOff
:0→Xmin:1→Xmax
:0→Ymin:1→Ymax
:1→X:1→Y
:For(K,1,12)
:.2→N
:If N≤1/3
:Then
:0.5(0.5+X)→X
:0.5(0.5+Y)→Y
:End
:If 1/3<N and N≤2/3
:Then
:0.5(0.5+X)→X
:0.5(1+Y)→Y
:End
:If 2/3<N
:Then
:0.5(1+X)→X
:0.5Y→Y
:End
Pt-On(X,Y)
:End
:StorePic 6
Many of the drawing commands will reset Y (and sometimes X!) when they are used. It's rather silly. That's why it is best practice to avoid using these variables in your programs. Also welcome to Cemetech Smile
Wow!!! Thanks for the fast and helpful reply! That is easy enough to deal with. I am glad that I at least understand what is happening.

The graphing calculators came out after I got through school but always was somewhat curious about them. I did have a Sharp EL-5500II that ran basic but just had a two line character display. I am looking forward to doing more with my TI-83 plus.

Thanks for the warm welcome!!!!
Try using the BBcode function "[ code ]" in future posts.

Example:

Code:

:FnOff :ClrDraw
:PlotsOff
:AxesOff
:0→Xmin:1→Xmax
:0→Ymin:1→Ymax
:rand→X:rand→Y
:For(K,1,3000)
:rand→N
:If N≤1/3
:Then
:0.5(0.5+X)→X
:0.5(0.5+Y)→Y
:End
:If 1/3<N and N≤2/3
:Then
:0.5(0.5+X)→X
:0.5(1+Y)→Y
:End
:If 2/3<N
:Then
:0.5(1+X)→X
:0.5Y→Y
:End
Pt-On(X,Y)
:End
:StorePic 6
Thanks. I didn't know what the BBcode function was.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement