randon numbers...

Programming, for all ages and all languages.
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post by bluecode »

As pcmattman more or less said: A polynomial is a function like f(x) = a_n * x^n + a_(n-1) * x^(n-1) + ... + a_1 * x^1 + a_0 (Write it down on a paper and this might actually look prettier :-) ). You can insert a value in this function and get a value in return. Now you are searching the x's (this is not only one x, there are more in this case) for which the return value is 0. They are seeking the smallest x for which f(x) is 0.
The "real" means "real number" in contrast to e.g. complex number (which would make the question just more anoying :lol: , but then the number of x for which f(x) is 0 would be more predictable *g*).
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post by Zacariaz »

k, i still dont understand the polymonatunvndf... whatever, but i do now understand the solution to the problem and thats what matters i guess, thanks.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

http://en.wikipedia.org/wiki/Polynomial

Alternative definition: A numerate parrot :) (shamelessly copied from the 'Polygon' joke)
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

For random numbers, you can use LFSR's. Linear feedback shift registers can be implemented in hardware or software. Essentially you start out with your 'seed', which is x bits long. every iteration you shift the seed one bit, take the bit that just fell off the end, XOR it with some of the other bit positions (this is statically defined, there are set patterns to get true pseudorandomness), and feed that back in as the MSB. This has been proven to be pseudorandom in the average case, and is dead easy to implement.

I implemented it in hardware and interfaced it to a Z80 system no problems. I had it clocking at 2MHz, more than enough to get some decent random numbers.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

A function is a polynomial 'in x' if it can be written as a sum, each term of which is of the form:

Code: Select all

    n
a x 
Where a, n are constants.

So, for example:

Code: Select all

f(x) = 3 + x^2 + 3x^3 + 83x^4
Is a polynomial.

JamesM
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

Oh the horror, these complicated mathematical equations would meet me too in OSdev? :cry:
If you want to get random 16-bit number, you can use this:

Code: Select all

mov al,0
out 43h,al
in al,40h
mov ah,al
in al,40h
;) Untested, but should work. :P

Regards
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
User avatar
binutils
Member
Member
Posts: 214
Joined: Thu Apr 05, 2007 6:07 am

Post by binutils »

User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Oh the horror, these complicated mathematical equations would meet me too in OSdev? Crying or Very sad
Errrr, I studied polynomials when I was 14 (at school)...

And no, they probably won't.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

inflater wrote:If you want to get random 16-bit number, you can use this:

Code: Select all

mov al,0
out 43h,al
in al,40h
mov ah,al
in al,40h
It wouldn't be random. If you asked for a series of random numbers you get a linearly ascending function, which is quite predictable. :shock:

In other words, a timer isn't a source of entropy, thus it can not be used as a source for truly random numbers.

The timer can however be used for converting entropy from another source - keyboard and mouse interrupts are unpredictable because they are generated by a human source, with minor variances. by looking up the pit counter each interrupt and taking the bottom bits you can change the temporal entropy generated by the computer user into a binary one.
binutils wrote:noise -> computer
Good one for everybody who has an AM receiver in their computers. Not standard issue though :(
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

Reincarnation, I've missed this one:
JamesM wrote:Errrr, I studied polynomials when I was 14 (at school)...
Of course I did too :) But when I see some big equations I always say "that must be hard"... even if it isn't :)

Regards
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

inflater wrote:
JamesM wrote:Errrr, I studied polynomials when I was 14 (at school)...
Of course I did too :) But when I see some big equations I always say "that must be hard"... even if it isn't :)
I really like the mathematical\theoretical side of computer science. I'm currently looking into boolean algebra a bit, along with some linear algebra.
C8H10N4O2 | #446691 | Trust the nodes.
Post Reply