I am attempting to make a program for solving any equation for its roots using the solve( command, but the correct roots won't show up because of the guess. Is there a way to find the roots without inputting the X.

Also, I start making a program for mean, median, and mode. I have this so far:


Code:
ClrHome: Input "# of numbers",A
If A<1
Then: Output(2,1,"Must be greater than 1
Pause:prgrmMMM
Else:A-->dim(L1)
For(B,1,A
Input "N:",N
N-->L1(B)
End:ClrHome
Disp "Range:"
Disp max(L1)-min(L1)
Disp "Median:"
Disp median(L1)
Disp "Mean:"
Disp mean(L1
Disp "mode:"



How can I find the mode of the numbers?
I read that to make a program compatible with MIrageOS and Doors CS you can add this in the beginning of the program:

Code:
:DCS
:0123456789ABCDEF

But MirageOS doest pause the program when I need it to. Why doesn't it work?
You can find the mode with a For() loop.

Also, the hex code for the icon must be in quotes (").
souvik1997 wrote:
You can find the mode with a For() loop.

Also, the hex code for the icon must be in quotes (").



How can I use a For( loop to find the mode? Putting the hex code in quotes works! Thanks!
Loop through all the elements of the list and use a counter variable.
After reading this, it inspired me to come up with this.
Feel free to use it as you please, and please help me optimize it!
I ended up making my own algorithm for listing all the modes of a set.

Going on-topic, there's a fun little algorithm called the Newton-Raphson method. It repeatedly draws lines that are tangent to the function at a given point and finds out where the line crosses the x-axis, which becomes the new point. This should iterate to the nearest root.
RMMM
technomonkey76 has just edited this program. The source code now reads:
BASIC Code wrote:
:ClrHome
:Input "Numbers? ",N
:If N<2
:Then
:Output(2,3,"Must have 2+
:Output(3,5,"numbers!
:Pause ENTER to quit
:Return
:Else
:SetUpEditorRMMM
:N→dim(∟RMMM
:For(B,1,N
:Input A
:A→∟RMMM(B
:End
:ClrHome
:Disp "Range:",max(∟RMMM)-min(∟RMMM
:Disp "Median:",median(∟RMMM
:Disp "Press ENTER for
:Output(6,7,"more
:Pause
:ClrHome
:Disp "Mean:",mean(∟RMMM
:Disp "Mode:"
:SortA ∟RMMM
:DelVar VDelVar WDelVar YDelVar ZFor(C,1,dim(∟RMMM
:∟RMMM(C→X
:Z+(X=Y)1→Z
:If X≠Y
:X→Y
:If Z>W
:Then
:Z→W
:Y→V
:End
:End
:Disp V
:Pause
Generated by SourceCoder, © 2005-2010 Cemetech
This is an automatic post from SourceCoder 2. Report abuse to admin@cemetech.net . You can disable these posts by unchecking the "Post on Update" box in the file's permissions.
Very nice! Just for the sake of posterity, I have a few tiny suggestions:


Code:
:Z+(X=Y)1→Z
:If X≠Y
:X→Y
Why not just this:
Code:
 Z+(X=Y→Z
:X→Y
If X=Y, then :X→Y does nothing; if they're not equal, it will do what it says on the tin. No need to make it conditional. Finally:

Code:
:Disp V
:Pause
can just be Pause V.
Here is some code to find the number of occurrences of a number in L1:

Code:
sum(seq(L1(X)=<number>,X,1,dim(L1
souvik1997 wrote:
Here is some code to find the number of occurrences of a number in L1:

Code:
sum(seq(L1(X)=<number>,X,1,dim(L1
Even smaller and faster:
Code:
sum(L1=<number>
KermMartian wrote:
souvik1997 wrote:
Here is some code to find the number of occurrences of a number in L1:

Code:
sum(seq(L1(X)=<number>,X,1,dim(L1
Even smaller and faster:
Code:
sum(L1=<number>

/me facepalms >.<
Rohi, you will want to use Kerm's code to check the amount of times a number appears in your list starting from min(L1) to max(L1).
Souvik, it's not like you were wrong or anything; your code was just a bit suboptimal. Smile
KermMartian wrote:
Souvik, it's not like you were wrong or anything; your code was just a bit suboptimal. Smile


I know, it was just a really obvious optimization.
souvik1997 wrote:
KermMartian wrote:
Souvik, it's not like you were wrong or anything; your code was just a bit suboptimal. Smile


I know, it was just a really obvious optimization.
I suppose, but it's not like you didn't know that technique, it was just an oversight. Smile Anyway, what else does this topic need? We haven't heard from the OP in a while.
  
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