Irrational Numbers p/q !!!

Let's talk about algorithms!

Moderator: Board moderators

Post Reply
Moni
Experienced poster
Posts: 202
Joined: Fri Mar 22, 2002 2:00 am
Location: Chittagong. CSE - CUET
Contact:

Irrational Numbers p/q !!!

Post by Moni »

Is there any algorithm that can find digits after decimal point upto any desired numbers for any irrational numbers ?!?!?! :roll: :roll: :roll:
ImageWe are all in a circular way, no advances, only moving and moving!
bery olivier
Learning poster
Posts: 90
Joined: Sat Feb 15, 2003 1:39 am
Location: Paris, France
Contact:

about rational numbers

Post by bery olivier »

Moni wrote:Irrational Numbers p/q
If a number is a fraction p/q (p,q integers) then it's a rational number, isn't it ?

Here is the algorithm I usually use:

Code: Select all

print or store             p/q
print or store       ( (10*p/q)%q )/q
print or store ( (10*( (10*p/q)%q )/q)%q )/q
etc...
My code is as follow :
[c]/* number of decimals required */
#define MAX 80000

short decimal[MAX];

int decimals(long p,long q)
{
long i;
printf("%ld,",p/q);
decimal[0]=(p/q);
p=10*(p%q);
for(i=1;i<MAX;i++)
{
printf("%ld",p/q);
decimal=(p/q);
p=10*(p%q);
}
return 0;
}[/c]
That's the first code I wrote to find digits after the decimal point. So it may not be optimal.

If you want an algorithm to find the digits of an irrational number like PI or sqrt(2), so I have no clue of how to proceed :wink: .
Not AC yet Image AC at last Image
makbet
New poster
Posts: 44
Joined: Tue Nov 26, 2002 11:01 pm
Location: Wejherowo

Post by makbet »

there is a handy formula which you can use to calculate pi:
pi/4=(1/1)-(1/3)+(1/5)-(1/7)...
the more time your program runs, the more accurate it gets :wink:
bery olivier
Learning poster
Posts: 90
Joined: Sat Feb 15, 2003 1:39 am
Location: Paris, France
Contact:

Post by bery olivier »

makbet wrote:there is a handy formula which you can use to calculate pi:
pi/4=(1/1)-(1/3)+(1/5)-(1/7)...
the more time your program runs, the more accurate it gets :wink:
Cool, I lost this formula thanks a lot. I'll have a lot of good time with it.
Thanks a lot !
:D
Not AC yet Image AC at last Image
Moni
Experienced poster
Posts: 202
Joined: Fri Mar 22, 2002 2:00 am
Location: Chittagong. CSE - CUET
Contact:

Post by Moni »

I think you all have heard about POWER SERIES. That also can be useful.

Can you convert any function to "power series" ???
ImageWe are all in a circular way, no advances, only moving and moving!
Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

I think yes ....
every function might be write as power series ....
like Maclaurin series ...

try this link
http://mathworld.wolfram.com/PowerSeries.html

Dominik
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Moni
Experienced poster
Posts: 202
Joined: Fri Mar 22, 2002 2:00 am
Location: Chittagong. CSE - CUET
Contact:

Post by Moni »

Yes! But the value must be convergent to any certain real number.
But how will you know: they converges or not ??? :roll:
ImageWe are all in a circular way, no advances, only moving and moving!
Shahab
New poster
Posts: 24
Joined: Sun Nov 10, 2002 2:17 pm

Post by Shahab »

power series r 2 week for such works
at first, u must know that we can not show all the functions with powe series like Maclaurin series, they have their limitation
for ex, consider the following function. there is no power series to show such function

f(x)= 1 if we have two integers p,q such that x=p/q
0 otherwise

and u know, we also can't have formules for all irrational numbers( of course, we have some formules for some of them like pi,e,sqrt(2),...
but we can prove that we can't have formules for all of them( because of that the cardinal number of N is less than the cardinal number of R)

so, if u r going to deal with rational numbers, be cool. u can know the nth digit after the point using some easy algorithms. but if u r dealing with irrational numbers, u must have a group of interesting numbers and develop your own algorithms for them, u can't do the same work for all irrational numbers

Best regards,
Shahab Tasharrofi
anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:

Post by anupam »

moni bhai,

i have facing problems not only using irrational but also rational number for a huge range...
in incresing or decreasing order...
would u all bosses discuss something about this matter...
thanks...
anupam

(your familier...
neural contest arranger and jud...
should not use it...)
perhaps recognized.... :oops: :oops: :oops:
"Everything should be made simple, but not always simpler"
Moni
Experienced poster
Posts: 202
Joined: Fri Mar 22, 2002 2:00 am
Location: Chittagong. CSE - CUET
Contact:

Post by Moni »

Hello! Anupam! :D :D :D

How are you? When will you come to Chittagong? Must meet me.

I think in your "Numerical Methods for Engineers" course you have found Bisection method and many other methods. I have many of them in C++ codes. I have taken many help from "Numerical Analysis". 8) You will also find it useful. :)

Would you clear in what situation you are facing that? That might be a new knowledge for me. :)

What about our CAAT ??? A contest from chittagong people :wink:
Congrates Dominik the champion! 8)

And yes A great helper and sufferer :wink: :wink: :wink:
ImageWe are all in a circular way, no advances, only moving and moving!
Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

Nice to hear it ;-))

Dominik

BTW. I think that something wrong was with CAAT :( because I send to more problems and I don't get answer for it :((
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
anupam
A great helper
Posts: 405
Joined: Wed Aug 28, 2002 6:45 pm
Contact:

Post by anupam »

hello moni bhai and dominik,

the same problem for me in the latest contest...
i have sent at least 6 submission...
but i found only two...
one ac and the other tle..
and replies comes and showed in the ranklist and status at least after 30 min...
very annoying...bogus..
contest (online) always becomes busy with a lot of submission but if the method or system be not proper then it will be very annoying...

dominik and cyfra was the first two..
then the other two is me(abrbuet@yahoo.com & ishwar)...

ok all about today.. and abt the contest...

i am trying to arrange a contest in uva(online & public)...
will u alll(including dominik(perdon me) and mpni bhai..) help me...
please respond quickly....


----
anupam :oops: :oops: :oops: :oops:
"Everything should be made simple, but not always simpler"
Post Reply

Return to “Algorithms”