Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: dinhotheone on January 29, 2007, 11:28:00 am

Title: what is going on?
Post by: dinhotheone on January 29, 2007, 11:28:00 am
i was making a math program for calculus, you basically input an equation for the derivative and the calc will spit out a slope plot (lots of lines aproximating a function with an unknown constant)
anyway the problem is that i set the calc to do 2 for loops so it will hit a bunch of points in a square. but for the inside loop's first iterations before it returns back to the outer loop, the loop starts at zero. then later once it goes in again after it hops out, it executes properly. Another odd thing is that the varialbe starts at the correct value up untill it hits an "expr(str1)" then seems to change to zero when it should start at Ymin (Ymin = -3). The only thing that changes the varialbe is the for loop so im confused as to how this could be happening. I've tried having the loop count up and down but no matter what it starts at zero.
Ex.
c1-->
CODE
ec1
For (X,Xmin,Xmax,LLen(1)*6
For (Y,Ymin,Ymax,LLen(2)*6
:here Y = -3 (Ymin = -3)
expr(Str1)
:here Y = 0...wtf?
line(X+LLen(1),Y+LLen(2)Ans,X-LLen(1),Y-LLen(2)Ans
End
End
c2
ec2
I am 100% sure that the comments are correct because tested it using a pause and then i broke and checked what Y was.
 So who can tell me whats wrong, and it really is aas simple a code as this, im not leaving anything out between the for's and the ends
Title: what is going on?
Post by: trevmeister66 on January 29, 2007, 11:30:00 am
try using "For(Z..." instead of "For(Y..."

EDIT: i think the "expr(" command deletes the Y variable... I think... <_<dry.gif
Title: what is going on?
Post by: dinhotheone on January 29, 2007, 11:37:00 am
...WTH why did that work, i changed for y to for z like you said and then at the top of the for i put Z-> Y (because they have to enter the equation with x's and y's) and it worked...cool

about expr( deleting the variable, i would say it seems so but then the rest of the program executed flawlessly... so i dont think so otherwise the for would never make any pprogress.
Title: what is going on?
Post by: Speler on January 29, 2007, 11:55:00 am
expr( was not what caused the problem, TI-OS uses variables X and Y to preform graphscreen calculations, which is why these variables should be avoided.
Title: what is going on?
Post by: dinhotheone on January 29, 2007, 12:05:00 pm
hmmm...i see, i was trying to make my code easier to be understood because i usually distribute em around the school. But i guess adding a comment in there would do well in a pinch :)smile.gif
Title: what is going on?
Post by: trevmeister66 on January 29, 2007, 01:06:00 pm
well all i know is my idea worked =)
Title: what is going on?
Post by: graywolf on January 29, 2007, 04:05:00 pm
Yah, it sucks that there are no system variables that you can't mess with (like on a TI89). Anwayz, congratz on figuring it out. What does the prgm do anywayz, display secant lines?
Title: what is going on?
Post by: DJ Omnimaga on January 30, 2007, 03:22:00 am
yeah it sucks that this happens. X-Y always go back to 0 when using graph screen, and i got massive trouble figuring out code problems before because of this
Title: what is going on?
Post by: trevmeister66 on January 30, 2007, 03:38:00 am
X does too? hmm... <.< i've never had that happen to me, and i use the X var all the time. Maybe i'm just lucky.
Title: what is going on?
Post by: Delnar_Ersike on January 30, 2007, 05:57:00 am
I never had a chance to find out: I have never used the variables X and Y in my programs before :angel:ange.gif , but it is a good thing to know
Title: what is going on?
Post by: DJ Omnimaga on January 30, 2007, 06:56:00 am
having this happen with X is rare, but it can happens. I believe its the same for all variables that cannot be archived (ERR:VARIABLE) in the mem menu if you set the calc in Par/Pol/Seq
Title: what is going on?
Post by: Speler on January 30, 2007, 09:39:00 am
Yes, that is an almost completely accurate statement.
Title: what is going on?
Post by: dinhotheone on January 30, 2007, 10:10:00 am
The program graphs a slop field, basically an approximation of the graph of the antiderivative of the function times any constant (i think)

anyway i ran into a different problem, since the user has to enter the function with x's and y's i created 2 loops that check for x's and y's and change them to z and theta and i changed the for loops and the code inside of them. I brought that to school after testing on basic inputs but when i gave it to the only other decent programmer in the school to show it too he entered 100 and 101 for xmin and 200 and 202 for y min, when he does this the calc only shows an empty graph and then exits the program. the only reason i sould see this happening is that somewhere the graph screen variables change so that max is less than min then it doesnt enter the for loop. and then it resets them to what i want them to be. I'd give you my full code if i knew an easier way to post it but basically....

ask for xmin xmax y min and ymax
loops around if either max is too big
ask for "Resolution of field" not graphscreen res.