Code:
:ClrHome
:ClrDraw
:AxesOff
:FnOff
:Float
:ZStandard
:a+bi
:Goto A
:Lbl 1
:0→Y
:ClrHome
:FnOff
:Disp "AX2+BX+C","","VALUE?"
:Input "A= ",A
:If A=0:Goto 1
:Input "B= ",B
:Input "C= ",C
:If A<0:Then
:‾A→A
:‾B→B
:‾C→C
:1→Y
:End
:B2-4AC→S
:(‾B+√(S))/(2A)→E
:(‾B-√(S))/(2A)→F
:S→G
:If G<0:‾G→G
:ClrHome
:Disp "X=",F►Frac,"AND",E►Frac
:If fPart(A)≠0 or fPart(B)≠0 or fPart(C)≠0:Goto KK
:If fPart(√(G))≠0:Then
:ClrHome
:Goto 2
:End
:Lbl AA
:0→D
:Lbl JJ
:D+1→D
:‾C→O
:If O<0:Then
:23→W:O-1→O
:End
:If O>0:Then
:22→W:O+1→O
:End
:If O=0:Then
:A→P:B→O:1→D:0→G
:Goto II
:End
:Lbl LL
:If W=23:O+1→O
:If W=22:O-1→O
:If fPart(A/D)=0:A/D→P
:If O≠0:Then
:If fPart(C/O)=0:C/O→G
:End
:PG+DO→H
:PD→I
:OG→J
:If H=B and I=A and J=C:Goto II
:If D>A:Goto KK
:If O=C:Goto JJ
:Goto LL
:Lbl II
:gcd(abs(P),abs(O))→M
:P/M→P:O/M→O
:int(log(P)+1→J
:If P=1:0→J
:int(log(abs(O))+1→K
:int(log(D)+1→N
:If D=1:0→N
:int(log(abs(G))+1→Q
:If G=0:‾1→Q
:int(log(M)+1→R
:1→R
:If M=1:0→R
:If Y=1:Output(6,1,"‾
:Output(6,1+Y,M
:Output(6,1+R+Y,"(
:Output(6,2+R+Y,P
:Output(6,2+R+J+Y,"X+
:If O<0:Output(6,2+R+J+Y,"X-
:Output(6,4+R+J+Y,abs(O
:Output(6,4+R+J+K+Y,")
:Output(7,1,"(
:Output(7,2,D
:Output(7,2+N,"X+
:If G<0:Output(7,2+N,"X-
:Output(7,4+N,abs(G
:Output(7,4+N+Q,")
:If P=D and O=G:Then
:Output(7,1,"                "
:Output(6,5+R+J+K+Y,"2
:End
:If C=0:Output(7,4,"           "
:Goto BG
:Lbl KK
:Output(6,1,"-NOT FACTORABLE-
:Lbl BG
:Pause
:If Y=1:Then
:‾A→A
:‾B→B
:‾C→C
:End
:Goto 3
:Lbl 2
:iPart(√(abs(S)))→N
:Lbl CC
:If fPart(S/N2)=0:Then
:S/N2→D
:Goto BB
:End
:If N=1:Goto GG
:N-1→N
:Goto CC
:Lbl BB
:‾B→O
:2A→P
:For(I,2,P)
:O/I→J:N/I→K:P/I→θ
:If fPart(J)=0 and fPart(K)=0 and fPart(θ)=0:Then
:J→O
:K→N
:θ→P
:End
:End
:Lbl GG
:ClrDraw
:Text(28,5,"X=")
:If N≠1:Then
:If S>0:Then
:Text(21,15,O,"+-",N,"√(",D,")")
:Else
:Text(21,15,O,"+-",N,"i√(",‾D,")")
:End
:Else
:If S>0:Then
:Text(21,15,O,"+-√(",D,")")
:Else
:Text(21,15,O,"+-i√(",‾D,")")
:End
:End
:If P≠1:Then
:Text(28,14,"----------------"
:Text(33,27,P)
:End
:Pause
:If Y=1:Then
:‾A→A
:‾B→B
:‾C→C
:End
:Goto 3
:Lbl A
:Text(5,5,"THE  COMPLETE  QUADRATIC"
:Text(12,18,"FORMULA  PROGRAM"
:Text(22,42,"v5.5"
:Text(40,18,"BY:  BEN  ILEGBODU"
:Text(57,14,"COPYRIGHT (C) 2001"
:Pause
:Goto 1
:Lbl 3
:Menu("   WHAT NEXT?   ","DECIMAL FORM",8,"FRACTION FORM",9,"SHOW GRAPH",4,"DISCRIMINANT",5,"VERTEX",6,"ANOTHER EQ.",1,"--QUIT--",7)
:Lbl 4
:ClrHome
:ClrDraw
:FnOff
:AxesOn
:"AX2+BX+C"→Y1
:abs(C)+5→Ymax
:abs(C)+5→Xmax
:‾abs(C)-5→Ymin
:‾abs(C)-5→Xmin
:DispGraph
:Pause
:AxesOff
:Goto 3
:Lbl 5
:ClrHome
:Disp "","","DISCRIMINANT","IS:","",S
:Pause
:Goto 3
:Lbl 6
:‾C→G:B/A→J:(J/2)2→I:AI→D:(J/2)→H:D+G→K:‾H→H:‾K→K
:FnOff
:ClrDraw
:Fix 4
:Text(20,1,"VERTEX IS:"
:Text(33,5,"(",H,",",K,")")
:Pause
:Float
:Goto 3
:Lbl 8
:ClrHome
:Disp "","","X=",E,"             AND",F
:Pause
:Goto 3
:Lbl 9
:ClrHome
:Disp "","","X=",E►Frac,"             AND",F►Frac
:Pause
:Goto 3
:Lbl 7
:ClrHome
:AxesOn
:Disp "","","  BEN ILEGBODU","  COPYRIGHT(C)","      2001"
:Pause





Note: I did not create this program[/b]
Don't use so many Gotos - especially since you are jumping all over the place. When the Goto searches for the label, it starts at the top of the program to find the label, so each time you Goto it has to make a new search for the specified label.

To replace the Gotos, you should add Repeat/While/For loops (whatever suits your needs). These allow you to keep repeating stuff (or quickly go back to previous sections of code by exiting a loop or two).

Also, you should add [code] to the beginning of your post and [ /code] (without the space) at the end of your code, so it doesn't post it with smilies (plus it makes it easier for readers to distinguish separate parts of your posts).
1) Please use the phpBB option generated from SourceCoder.
2) Please don't strip out the SourceCoder copyright line.
3) As Beta7 accurately and concisely noted, you're overusing Goto. Use Repeat(), While(), and For() loops to improve both speed and size.
Wait, who did create that program?
_player1537 wrote:
Wait, who did create that program?

Code:
:Text(5,5,"THE  COMPLETE  QUADRATIC"
:Text(12,18,"FORMULA  PROGRAM"
:Text(22,42,"v5.5"
:Text(40,18,"BY:  BEN  ILEGBODU"
:Text(57,14,"COPYRIGHT (C) 2001"
Probably that guy?
Oh... didn't even check the full source. Well, I guess that question is solved >.>
Another point: there are a lot of redundancies like this:
Code:
:abs(C)+5→Ymax
:abs(C)+5→Xmax
:‾abs(C)-5→Ymin
:‾abs(C)-5→Xmin
which could be optimized to
Code:
:abs(C)+5→Ymax
:Ans→Xmax
:‾Ans→Ymin
:Ans→Xmin
Wouldn't the second to last command have to run the abs(C) again, since it adds 5 on the first two and subtracts 5 on the last two?
Beta7 wrote:
Wouldn't the second to last command have to run the abs(C) again, since it adds 5 on the first two and subtracts 5 on the last two?


No. -abs(C)-5 = -(abs(C) +5) due to the distributive property.
Totally did NOT see the negative in front of the abs(). My bad.
I have never used any of the loops before, so can anyone give me a few examples of when they are used.
Let's do some math. (Correct me if I make a mistake)

AX^2+BX+C=(DX+E)(FX+G)

A = DF
B = DG + EF
C = EG

E = N*Root1
G = N*Root2

E/G = Root1/Root2

C*E/G -> EG*E/G ->E^2
so E = +/- sqrt(C*Root1/Root2)
and G = +/- sqrt(C*Root2/Root1)
or rather

:E=sqrt(abs(C*Root1/Root2))
:G=C/(abs(C))sqrt(abs(C*Root2/Root1))


Therefore, we only have two unknowns: D & F.


Code:
:DelVar D (sets D to 0)
:While 1
      :D+1 ->D
      :If fpart(A/D)=0  (if F is an integer)
      :Then
             :F = A/D
             :if B=DG+EF: Return
       :End
:End



So, in TI-Basic code...


Code:
:R = (-B+sqrt(B^2-4AC))/(2A)     //find both roots
:S = (-B-sqrt(B^2-4AC))/(2A) 
:sqrt(abs(C*R/S->E                    //find E and G
:C/(abs(C))sqrt(abs(C*S/R ->G
:DelVar D
:While D<abs(A
      :D+1 ->D
      :If fpart(A/D)=0
      :Then
             :if B=DG+EA/D: Return {D, E, A/D, G}
             :if -B=DG + EA/D: Return {-D, E, -A/D, G}
      :End
:End
:Return "No Result"



Correct me if I made a mistake, as I haven't touched a calculator in a while...
Rohi, regarding your questions about loop:

:: For(): For(X,1,10) \ code \ End runs "code" ten times, first with X=1, then with X=2, then with X=3, ..., finally with X=10. For(X,0,10,2) would run from 0 through 10 inclusive but stepping by 2: X=0, CX=2, X=4, X=6, X=8, X=10. For(X,10,1,-1) would step backwards: X=10, X=9, ... X=0. A simple example to draw a horizontal line (although obviously relatively useless code):


Code:
For(X,0,94
Pxl-On(20,X
End


:: While() Run a loop While a condition is true (equal to logical true or numeric non-zero). For example, While(getKey = 0) \ code \ End will run "code" as long as getKey is 0, and will escape the loop and continue at the End when you press a key.

:: Repeat() Whereas While() runs a loop while the condition is true, Repeat repeats the loop until the condition is true. While runs the loop at least ZERO times (ie, if you start and the condition is false, the loop never executes, and it jumps straight to the End) whereas Repeat runs the loop at least once before checking the condition. While is like while() { } in C/C++/... whereas Repeat is like do { } while (); in that regard.
Does this program only factors second grade equations? If yes, I suppose it only factors real answers?
I built something like that last year when I was at school, I actually was way to lazy to factor them myself so I made this.

Code:
:ClrHome
:Real
:Disp "BEREKENEN","VAN DE","DISCRIMINANT"
:Pause
:ClrHome
:Disp "AX2+BX+C":Input "A:",A
:Input "B:",B
:Input "C:",C:
:ClrHome
:Disp "DISCRIMINANT","D=B2-4AC"
:B2-4AC→D
:If D<0
:Then
:Disp "GEEN OPLOSSING":Pause :ClrHome:Output(1,1,""):Else
:Disp "D IS",D:Pause
:If D=0:Then
:Disp "1 OPLOSSING","X IS",‾B/(2A)►Frac
:Else
:Disp "2 OPLOSSINGEN","X1 IS",(‾B-√(D))/(2A)►Frac,"X2 IS",(‾B+√(D))/(2A)►Frac
:Pause
:ClrHome
:ClrDraw
:FnOff
:AxesOff
:0→Xmin
:94→Xmax
:0→Ymin
:62→Ymax
:Text(‾1,1,31,"Vkv
:Text(2,50,"v1.0
:Text(8,20,"By Ti84Prgmhuuh
:For(A,47,62
:For(B,0,94
:Pt-Change(B,A
:End
:End
:Text(16,12,"This is a math tool not
:Text(22,14,"meant for cheating
:Text(28,9,"I'm not responsible for
:Text(34,27,"any misuse!
:Text(42,11,"CONTACT/BUG REPORT:
:Text(48,10,"mhuuh(a)hotmail.com
:Text(56,25,"(c)2010-2011
:Pause
:Output(1,1,"")


*Parsed with SourceCoder*
I think I finally figured out what you mean by "second-grade" equations: you mean "second-degree". Smile Am I correct?
KermMartian wrote:
I think I finally figured out what you mean by "second-grade" equations: you mean "second-degree". Smile Am I correct?
Yes my bad ^^" lame translation. In dutch it's ''graad'' and that can be translated as grade or degree. Sorry, stupid mistake.

May I add that personally I use much more Repeat loops with getKey in order to trap the program in a loop until the wanted key is pressed, it comes in very handy with graphscreen custom menus like those I like to create.
Definitely, that's the best (and fastest) way to do it. No worries about the translational difficulties. Wink
KermMartian wrote:
Definitely, that's the best (and fastest) way to do it. No worries about the translational difficulties. Wink
I thought so ^^ and I actually do mind the translation error :p I try having my English as perfect as I can ^^
Ti84Prgmhuuh wrote:
Does this program only factors second grade equations? If yes, I suppose it only factors real answers?
I built something like that last year when I was at school, I actually was way to lazy to factor them myself so I made this.

Code:
:ClrHome
:Real
:Disp "BEREKENEN","VAN DE","DISCRIMINANT"
:Pause
:ClrHome
:Disp "AX2+BX+C":Input "A:",A
:Input "B:",B
:Input "C:",C:
:ClrHome
:Disp "DISCRIMINANT","D=B2-4AC"
:B2-4AC→D
:If D<0
:Then
:Disp "GEEN OPLOSSING":Pause :ClrHome:Output(1,1,""):Else
:Disp "D IS",D:Pause
:If D=0:Then
:Disp "1 OPLOSSING","X IS",‾B/(2A)►Frac
:Else
:Disp "2 OPLOSSINGEN","X1 IS",(‾B-√(D))/(2A)►Frac,"X2 IS",(‾B+√(D))/(2A)►Frac
:Pause
:ClrHome
:ClrDraw
:FnOff
:AxesOff
:0→Xmin
:94→Xmax
:0→Ymin
:62→Ymax
:Text(‾1,1,31,"Vkv
:Text(2,50,"v1.0
:Text(8,20,"By Ti84Prgmhuuh
:For(A,47,62
:For(B,0,94
:Pt-Change(B,A
:End
:End
:Text(16,12,"This is a math tool not
:Text(22,14,"meant for cheating
:Text(28,9,"I'm not responsible for
:Text(34,27,"any misuse!
:Text(42,11,"CONTACT/BUG REPORT:
:Text(48,10,"mhuuh(a)hotmail.com
:Text(56,25,"(c)2010-2011
:Pause
:Output(1,1,"")


*Parsed with SourceCoder*


Would you mind to translate some of the code to English, so I can understand it better? thanks
Well those words are only there for the users sake since it was originally written for local students.
You know the factorizing formula for 2nd degree equation?
X1&2 = (-b +/- sqrt(b²-4ac)/(2a) so all you need to do is ask for a,b and c and your good to write a foctorizer of you own. it can be as short as

Code:
PRGM VKV
:Disp "Factorizer"
:Input "A:",A
:Input "B:",B
:Input "C:",C
:If B²-4AC>=0
:Then
:(-B + sqrt(B²-4AC)/(2A)→D
:(-B - sqrt(B²-4AC)/(2A)→E
:Disp "Answers are",D,E
:End
  
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 UTC - 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