Author Topic: TI-BASIC: Loops?  (Read 8425 times)

0 Members and 1 Guest are viewing this topic.

Offline Joe

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 10319
  • In Soviet Russia, text read you!
    • View Profile
    • Github
TI-BASIC: Loops?
« on: April 22, 2006, 03:29:46 pm »
Yeah. Inspired by this, I tried to figure it out in TI-BASIC. So far I've got..

PROGRAM:CIRCLE
:0 [STO] A
:Lbl B
:Pt-On(sin(A)*7+8,cos(A)*7+8)
:A+1 [STO] A
:
:Goto B


On the blank line, I'm looking to check if A = 100 (and to quit if it is). How would I do this?
I'd personally do as Joe suggests

You might be right about that, Joe.


Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: TI-BASIC: Loops?
« Reply #1 on: April 22, 2006, 04:27:43 pm »
You know, on TI graphing calculators, to draw a circle, it's just two graphed equations:
y1=sqrt(r2 - x2)
y2=-sqrt(r2 - x2)
where r is the radius of the circle you would like drawn.  This is derived from the definition equation of a circle, x2 + y2 = r2.

I'm pretty sure in the past, for me, something like If A < 100 Then Goto B worked.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Nate

  • Full Member
  • ***
  • Posts: 425
  • You all suck
    • View Profile
Re: TI-BASIC: Loops?
« Reply #2 on: April 23, 2006, 05:47:36 pm »
Its actually possible to graph a circle on a Ti-86 using only one equation but i forget how.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: TI-BASIC: Loops?
« Reply #3 on: April 23, 2006, 07:35:55 pm »
IIRC, In radians mode, set the function theta1 = radius.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Ender

  • x86
  • Hero Member
  • *****
  • Posts: 2390
    • View Profile
Re: TI-BASIC: Loops?
« Reply #4 on: April 23, 2006, 09:24:01 pm »
I believe that will be a spiral, not a circle. The quickest way is to put the calculator in polar mode and enter the equation r = c, where r is the radius and c is some constant.

Offline Nate

  • Full Member
  • ***
  • Posts: 425
  • You all suck
    • View Profile
Re: TI-BASIC: Loops?
« Reply #5 on: April 23, 2006, 09:25:30 pm »
Code: [Select]
PROGRAM:CIRCLE
:0 [STO] A
:For(A,0,360,0.1)
:Pt-On(7sin(A)+8,7cos(A)+8)
:End
« Last Edit: April 23, 2006, 09:30:06 pm by Nate »

Offline Ender

  • x86
  • Hero Member
  • *****
  • Posts: 2390
    • View Profile
Re: TI-BASIC: Loops?
« Reply #6 on: April 23, 2006, 09:33:13 pm »
Eh, I believe that either won't work or is inefficient, depending on what mode your calculator is in. If your program is in degrees, then that shouldn't complete the circle, as the period of sine and cosine are 360° or 2∏ radians. If you're in radians then your program will draw the circle nearly 16 times, wasting your calculator's resources.

Edit: Now it should work.

« Last Edit: April 23, 2006, 09:40:49 pm by Ender »

Offline Nate

  • Full Member
  • ***
  • Posts: 425
  • You all suck
    • View Profile
Re: TI-BASIC: Loops?
« Reply #7 on: April 23, 2006, 09:35:02 pm »
i don't know how to change from degrees to radians in a program on TI-86.

Offline Ender

  • x86
  • Hero Member
  • *****
  • Posts: 2390
    • View Profile
Re: TI-BASIC: Loops?
« Reply #8 on: April 23, 2006, 09:37:21 pm »
I have a TI-83, not a TI-86, but on mine you can choose radians or degrees by hitting the mode button.

Edit: Or you can just type in Radian.

Edit2: You can hit the mode button inside the calculator's program edit menu, pick radians, and it will insert the Radian command.
« Last Edit: April 23, 2006, 09:50:21 pm by Ender »

Offline Nate

  • Full Member
  • ***
  • Posts: 425
  • You all suck
    • View Profile
Re: TI-BASIC: Loops?
« Reply #9 on: April 23, 2006, 09:42:14 pm »
I meant TI-83.  But there should be a function built in to change it inside a program.

Edit: I found the function in the catalog
Code: [Select]
PROGRAM:CIRCLE
:0 [STO] A
:Radian
:For(A,0,2∏,2∏/360)
:Pt-On(7sin(A)+8,7cos(A)+8)
:End
« Last Edit: April 23, 2006, 09:48:44 pm by Nate »

Offline d&q

  • Hero Member
  • *****
  • Posts: 1427
  • I'm here.
    • View Profile
    • Site
Re: TI-BASIC: Loops?
« Reply #10 on: April 24, 2006, 06:56:08 pm »
You know, on TI graphing calculators, to draw a circle, it's just two graphed equations:
y1=sqrt(r2 - x2)
y2=-sqrt(r2 - x2)
where r is the radius of the circle you would like drawn.  This is derived from the definition equation of a circle, x2 + y2 = r2.

I'm pretty sure in the past, for me, something like If A < 100 Then Goto B worked.

I believe that will draw only a partial circle, as seperating the equation into two restricts the domain.
The writ of the founders must endure.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: TI-BASIC: Loops?
« Reply #11 on: April 24, 2006, 07:01:18 pm »
You know, on TI graphing calculators, to draw a circle, it's just two graphed equations:
y1=sqrt(r2 - x2)
y2=-sqrt(r2 - x2)
where r is the radius of the circle you would like drawn.  This is derived from the definition equation of a circle, x2 + y2 = r2.

I'm pretty sure in the past, for me, something like If A < 100 Then Goto B worked.

I believe that will draw only a partial circle, as seperating the equation into two restricts the domain.

You need to split the equations into two equations, because calculators only return positive results of sqrt() where they should return both +/-.

Think of the equations as ORed together.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline d&q

  • Hero Member
  • *****
  • Posts: 1427
  • I'm here.
    • View Profile
    • Site
Re: TI-BASIC: Loops?
« Reply #12 on: April 25, 2006, 10:53:07 pm »
No I mean, the circle will only look like this:



Try graphing it on a graphing calculator.

Quote
y1=sqrt(r2 - x2)
y2=-sqrt(r2 - x2)
Quote

When rooting it, you are still restricting it to a positive number underneath the radical, regardless if you are later going to 'negatify' it.
The writ of the founders must endure.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: TI-BASIC: Loops?
« Reply #13 on: April 25, 2006, 11:02:46 pm »
No I mean, the circle will only look like this:



Try graphing it on a graphing calculator.

Quote
y1=sqrt(r2 - x2)
y2=-sqrt(r2 - x2)

When rooting it, you are still restricting it to a positive number underneath the radical, regardless if you are later going to 'negatify' it.
Rooting *should* restrict the number under the radical such that expr >= 0.  Note that this means:
expr ∈ √(expr) : [0, ∞)
That means your graphing calculator is broken.  :P

By which I mean to say, the calculator simply does not know how to graph it at that granularity.  If you eval your function at x = r, it will tell you 0 for both y1 and y2.  That's how real-life math works, not graphing calculators.  ;)
« Last Edit: April 25, 2006, 11:07:25 pm by MyndFyre[x86] »
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Nate

  • Full Member
  • ***
  • Posts: 425
  • You all suck
    • View Profile
Re: TI-BASIC: Loops?
« Reply #14 on: April 26, 2006, 08:08:30 pm »
Mine works...