Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: Munchor on October 31, 2010, 04:16:08 pm
-
Ok, I was programming a few little things in BASIC to learn I got this problem:
:ClrHome
:Prompt A,B,C
:(BB-(4AC))->X
:If X<0
:Then
:Disp "NO REAL ANSWER"
:Else
:(-B+sqrt(X))/(2A)->Y
:(-B-sqrt(X))/(2A)->X
:Output(6,2,"RESULTS:
:Output(7,2,X
:Output(8,2,Y
It gives me error in:
(BB-(4AC))->X
It's probably a stupid and easy mistake.
Any help?
Thanks :)
-
BB? Try B^2. Also, what error? syntax? what does it highlight on the goto?
-
Tried B^2 and BB, none works.
Syntax Error, it highlights in B, of B^2-(4AC)->X.
-
Lowercase B will not work, although I doubt you are doing that. Try 2.
-
B2 should fix the problem... also, this could be optimized into Ti Basic Dev's quadratic formula. or if you like your way:
ClrHome
Prompt A,B,C
B^2-4AC->X
If Ans<0:Then
Disp "NO REAL ANSWER
Else
Output(6,2,"RESULTS:
Output(7,2,-B+sqrt(X)/(2A)
Output(8,2,-B-sqrt(X)/(2A)
End
-
I tried that, B2 (two as an exponent)...
-
are you typing "->" or are you using the [STO] key in the lower lefthand corner?
-
Ok, sorry if this isn't the problem, but we can't over look this.
You are using the STO button to get the arrow right? Not minus greater than.
Edit:
Ninja'd
-
Please post the program.
-
Ok, sorry if this isn't the problem, but we can't over look this.
You are using the STO button to get the arrow right? Not minus greater than.
Edit:
Ninja'd
OF COURSE NOT...
-
so... any other ideas?
-
so... any other ideas?
Made it working:
:ClrHome
:Prompt A,B,C
:B^2-4AC→X
:If Ans<0:Then
:Disp "NO REAL ANSWER
:Else
:Output(6,2,"RESULTS:
:Output(7,2,-B+sqrt(X)/(2A)
:Output(8,2,{-}B-sqrt(X)/(2A)
:End
Thanks
-
Or better yet...
:ClrHome
:a+bi (Found in the [MODE] menu, allows imaginary numbers)
:2->dim(L₁
:Disp "AX²+BX+C=0
:Prompt A,B,C
:(-B+√(B²-4AC))/(2A->L₁(1
:(-B-√(B²-4AC))/(2A->L₁(2
:Pause L₁
Allows imaginary numbers! (Scroll for answer, don't keep anything important in L1)
Edited: Thanks, Qwerty.55
-
The Superscript and subscript tags don't work in a code block. Try alt codes:
:ClrHome
:a+bi (Found in the [MODE] menu, allows imaginary numbers)
:2->dim(L₁
:Disp "AX²+BX+C=0
:Prompt A,B,C
:(-B+√(B²-4AC))/(2A->L₁(1
:(-B-√(B²-4AC))/(2A->L₁(2
:Pause L₁
EDIT: Sorry if this shows up a few hours late. I think I'm using the bandwidth for the whole building right now.
-
So what was the error?
-
Yeah, I knew that it allowed imaginary numbers, but I haven't learn them at school yet =P
-
Oh. If this isn't too intrusive, may I ask what math level you're currently taking?
-
Oh. If this isn't too intrusive, may I ask what math level you're currently taking?
10th grade in portugal
-
Out of how many grades? I don't know the Portugal schooling system.
Also, could you post the original program you had instead of nemo's one that fixed the issue. I think we're all still curious about what was originally going on with the error and that would help figure it out.
-
(sorry, but I had to optimize a little ;D)
:ClrHome
:a+bi (Found in the [MODE] menu, allows imaginary numbers)
:Disp "AX²+BX+C=0
:Prompt A,B,C
:√(B²/4-AC
:Pause -B/(2A)+{Ans,-Ans
This won't use L₁, either. If you do want to store it to L₁, then just do Ans→L₁ after running the program because Ans will contain the results.
-
(sorry, but I had to optimize a little ;D)
And I has to optimize it more. :P Also, your code doesn't work; it would have to be √(B²/4-AC)/A :(
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:Pause -(B+{1,-1}√(B²+4i²AC))/(2A
Doesn't even change the mode settings ;D
-
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:Pause -(B+{1,-1}√(B²+4i²AC))/(2A
Doesn't even change the mode settings ;D
O.o
That's hyper-optimized! If you remove the ClrHome and the Disp, you can get it to be under 50 bytes!
Does using i allow for an imaginary output even if you don't mess with the mode settings?
-
Indeed :) A number that's already "imaginary" (even if that imaginary part is 0) will not give an error when you try to take its square root.
-
(sorry, but I had to optimize a little ;D)
And I has to optimize it more. :P Also, your code doesn't work; it would have to be √(B²/4-AC)/A :(
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:Pause -(B+{1,-1}√(B²+4i²AC))/(2A
Doesn't even change the mode settings ;D
Two can play the optimization game. :P
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:-B+{1,-1}√(B²+4i²AC
:Pause Ans/(2A
-
Congratulations, you win. :D
* calcdude, admitting defeat, bows to Runer in acknowledgement of his victory.
-
(sorry, but I had to optimize a little ;D)
And I has to optimize it more. :P Also, your code doesn't work; it would have to be √(B²/4-AC)/A :(
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:Pause -(B+{1,-1}√(B²+4i²AC))/(2A
Doesn't even change the mode settings ;D
Two can play the optimization game. :P
But only one may win...
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:B+{1,-1}√(B²+4i²AC
:Pause -2C/Ans
-
(sorry, but I had to optimize a little ;D)
And I has to optimize it more. :P Also, your code doesn't work; it would have to be √(B²/4-AC)/A :(
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:Pause -(B+{1,-1}√(B²+4i²AC))/(2A
Doesn't even change the mode settings ;D
Two can play the optimization game. :P
But only one may win...
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:B+{1,-1}√(B²+4i²AC
:Pause -2C/Ans
:o that works? In which case...
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:Pause -2C/(B+{1,-1}√(B²+4i²AC
-
oops. how'd i miss that.
but yeah, alternate form of the quadratic formula.
-
But only one may win...
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:B+{1,-1}√(B²+4i²AC
:Pause -2C/Ans
:o that works? In which case...
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:Pause -2C/(B+{1,-1}√(B²+4i²AC
And the winner is...
:ClrHome
:Pause "GOOGLE IT
;)
Only 11 bytes!
-
But only one may win...
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:B+{1,-1}√(B²+4i²AC
:Pause -2C/Ans
:o that works? In which case...
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:Pause -2C/(B+{1,-1}√(B²+4i²AC
And the winner is...
:ClrHome
:Pause "GOOGLE IT
;)
Only 11 bytes!
Oh really?
:ClrHome
:Pause "JFGI"
-
You left an extra parenthesis :P
:ClrHome
:Pause "JFGI
Meh, let the user clear the screen:
:Pause "JFGI
-
why pause it anyway?
"JFGI
-
And the official winner is...Runer112 with 54 bytes :P
Xeda had the first hyper optimization and then calcdude84se optimized it again. Runer112 then did an optimization that, in turn, actually wasn't since they resulted in the exact same size (since the new line accounts for the taking off two parentheses). Nemo then optimized it again and then Runer112 optimized again by taking out that last line.
If you want a winner the the latest one I would go with me with:
"GI
Who really needs the "Just F******" part? ;)
-
Taken from Cemetech:
:Prompt A,B,C
:(-B+sqrt(B^2-4AC))/(2A
:Disp Ans, -B/A-Ans
-
As long as we are keeping the list output (as a pause) and the
:ClrHome
:Disp "AX²+BX+C=0
Then here is a smaller version (by 1 byte):
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:√(B²+4i²AC
:Pause .5A-1(-B+{Ans,-Ans
(The code box didn't allow the -1)
-
As long as we are keeping the list output (as a pause) and the
:ClrHome
:Disp "AX²+BX+C=0
Then here is a smaller version (by 1 byte):
:ClrHome
:Disp "AX²+BX+C=0
:Prompt A,B,C
:√(B²+4i²AC
:Pause .5A-1(-B+{Ans,-Ans
(The code box didn't allow the -1)
It's smaller than who's by one byte?
-
couldn't you use -4AC instead of i^2? or am i missing something?
-
Having i2 forces the calculator to evaluate the expression as complex numbers, so the square root function won't throw an error and you can find imaginary roots.
-
couln't you set the mode to a+bi at the beginning?
-
Having i2 forces the calculator to evaluate the expression as complex numbers, so the square root function won't throw an error and you can find imaginary roots.
Plus it's two bytes smaller :P
-
couln't you set the mode to a+bi at the beginning?
this changes the mode setting, and adds just as many bytes as i2 anyway.
-
kk, cool, you learn something new everyday. ;)
-
Sorry, in my program above, on my calculator I forgot the :ClrHome part. hehe...