Author Topic: what is going on?  (Read 6434 times)

0 Members and 2 Guests are viewing this topic.

Offline dinhotheone

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 410
  • Rating: +2/-1
    • View Profile
what is going on?
« 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

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
what is going on?
« Reply #1 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
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Offline dinhotheone

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 410
  • Rating: +2/-1
    • View Profile
what is going on?
« Reply #2 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.

Offline Speler

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 857
  • Rating: +6/-2
    • View Profile
what is going on?
« Reply #3 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.

Offline dinhotheone

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 410
  • Rating: +2/-1
    • View Profile
what is going on?
« Reply #4 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

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
what is going on?
« Reply #5 on: January 29, 2007, 01:06:00 pm »
well all i know is my idea worked =)
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

graywolf

  • Guest
what is going on?
« Reply #6 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?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
what is going on?
« Reply #7 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

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
what is going on?
« Reply #8 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.
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Delnar_Ersike

  • Guest
what is going on?
« Reply #9 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

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
what is going on?
« Reply #10 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

Offline Speler

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 857
  • Rating: +6/-2
    • View Profile
what is going on?
« Reply #11 on: January 30, 2007, 09:39:00 am »
Yes, that is an almost completely accurate statement.

Offline dinhotheone

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 410
  • Rating: +2/-1
    • View Profile
what is going on?
« Reply #12 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.