I am ready to start development on a new math program but I am stuck as to what I should create. I have already made a FOIL program and a program that tells distance, midpoint, slope and equation from two points. Any feedback would be great!

EDIT 1: Started quadratic formula program. gonna need help simplifying the radical in the program
Sounds like a plan. What does your code look like so far? What are you using as a TI-BASIC guide? What's the algorithm you're planning to use for radical simplification?

Code:
:sqrt(B²-4AC)->D
:-B+D->E
:-B-D->F
:E/2A->G
:F/2A->H
Then there is the usual outputs.
That is the business end of my code.
I am not sure what alg to use...
Well, the simplest version is to pull out factors from the number until you can't pull out any more, but it can be slow. It goes something like this (in pseudocode):


Code:
done = 0
outside = 1;
inside = N; //<- this is the original number
while done == 0:
    done = 1
    for i,1,sqrt(N):
        if N/i^2 = int(N/i^2):
        then
            N=N/i^2
            outside = outside*i
            done = 0
        end
    end
end


See how that works?
So in ti-basic, it looks like
Code:

:B²-4AC->D
:0->K
:1->O
:While K=0
:For i,1,sqrt(D)
:If D/i^2=int(D/i^2
:Then
:D=D/i^2
:O=Oi
:K=0
:End
:End
:End
That looks just about right to me! Three caveats:
- I wouldn't recommend using K for the "done" variable, as K is most often used as the key code returned from getKey. That's personal style, though.
- Don't use lowercase "i", as that has a fixed value, sqrt(-1). Use uppercase I or some other of the 27 uppercase real variables.
- Make sure you save one byte per squared symbol by using the superscript 2 instead of [^][2].
and to make it deal with nonreals, would this work? is there a better way?
probably.

Code:

:B²-4AC->D
:If
:D<0
:Then
:-1D->D
:0->Z
:1->O
:While Z=0
:For I,1,sqrt(D)
:If D/I^2=int(D/I^2
:Then
:D=D/I^2
:O=OI
:Z=0
:End
:End
:End // then output Zi*sqrt(O
:End
:Else
:0->Z
:1->O
:While Z=0
:For I,1,sqrt(D)
:If D/I^2=int(D/I^2
:Then
:D=D/O^2
:O=OI
:Z=0
:End
:End
:End //output Zsqrt(O

then take Z and divide it by 2A
Or add "a+bi" at the top of your program (found in the MODE menu).
souvik1997 wrote:
Or add "a+bi" at the top of your program (found in the MODE menu).
I'd go with what Souvik suggested. Also, I found a few small fixes in your program, all stemming from the fact that the equal sign (=) only checks equality. Unlike other programming languages, to store a value to a variable, you use [value]→[variable], where → is the [STO>] key. So for example,
Code:
:D=D/I^2
:O=OI
:Z=0
should be
Code:
D/I²→D
:OI→O
:0→Z
You can even optimize another byte away by using the Delvar command (Delvar Z) instead of setting Z to 0; they do the same thing.
It isn't working. It doesn't do anything to D. Say I have sqrt(8 And I run it through the program. It says the answer is 8sqrt(1
The correct answer is 2sqrt(2
bump
lanmonster wrote:
It isn't working. It doesn't do anything to D. Say I have sqrt(8 And I run it through the program. It says the answer is 8sqrt(1
The correct answer is 2sqrt(2
Whoops, totally missed this post. Smile Would you mind posting your current code?

Code:

:B²-4AC→D
:0→Z
:1→O
:While Z=0
:For(I,1,√D
:If D/I²=int(D/I²
:Then
:D/I²→D
:OI→O
:0→Z
:End
:End
:End
\\output(D√O
For starters, I see that the done=1 line in my pseudocode (which should become 1->Z here) never got carried over. For another, that inner loop should start from 2, not 1, because D/1^2 will always equal int(D/1^2. With my fixes, O sqrt (D) seems to be correct:
BASIC Code wrote:
:"B²-4AC→D
:128→D
:0→Z
:1→O
:While Z=0
:1→Z
:For(I,2,√(D
:If D/I²=int(D/I²
:Then
:D/I²→D
:OI→O
:0→Z
:End
:End
:End
:Disp {O,D}
Generated by SourceCoder, © 2005-2012 Cemetech
Why not replace :While Z=0 with :Repeat Z ?
I'm on my phone now, so I can't really think of any other suggestions at the moment.
  
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