Numerical Recipes Forum  

Go Back   Numerical Recipes Forum > Obsolete Editions Forum > Fortran 90 Programming with NR

Reply
 
Thread Tools Display Modes
  #1  
Old 08-13-2009, 05:03 AM
TheIsingGuy TheIsingGuy is offline
Registered User
 
Join Date: Jul 2009
Posts: 8
small numbers..

how do I define and use small numbers for computations? on the scale of 10^-30?

e.g.
Program A
implicit none
double precision a,b,c,d
c = (a*b)/(a+b)
d = etc...

End program

The above has an overflow error when I give a,b the values 3.345 * 10^-27

Can anyone help?

Thanks

Ising
Reply With Quote
  #2  
Old 08-14-2009, 10:27 AM
davekw7x davekw7x is offline
Registered User
 
Join Date: Jan 2008
Posts: 453
Quote:
Originally Posted by TheIsingGuy View Post
how do I define and use small numbers for computations? on the scale of 10^-30?
Same advice as with very large numbers: Find an arbitrary precision package.

With mpfun I calculated 500 factorial (1135 decimal digits). I also printed its inverse to 1200 digits:

Code:
 N=         500  N!=
10 ^      1134 x  1.2201368259911100687012387854230469262535743428031928421924
135883858453731538819976054964475022032818630136164771482035841633787220781772
004807852051593292854779075719393306037729608590862704291745478824249127263443
056701732707694610628023104526442188787894657547771498634943677810376442740338
273653974713864778784954384895955375379904232410612713269843277457155463099772
027810145610811883737095310163563244329870295638966289116589747695720879269288
712817800702651745077684107196243903943225364226052349458501299185715012487069
615681416253590566934238130088562492468915641267756544818865065938479517753608
940057452389403357984763639449053130623237490664450488246650759467358620746379
251842004593696929810222639719525971909452178233317569345815085523328207628200
234026269078983424517120062077146409794561161276291459512372299133401695523638
509428855920187274337951730145863575708283557801587354327688886801203998823847
021514676054454076635359841744304801289383138968816394874696588175045069263653
3817505547812864,

 N=         500  1.0/N!=
10 ^     -1135 x  8.1958021321723963095047614624954847353031039731345424185533
377291083165764574549623440899229975032223999847135401000229774507564909766192
093055666364093145535276240409452511189019003431204869738423954422643123093567
208155564368697833913935068673189430036359547580501228575047617204104149255170
361033077415082936395630744710260955212659304330507147285587514891373603240624
523090271942525114248440422827342200654520187704884364455758790754150079392136
303453258156482056506072156354503044161656890264060566028236938485928091064842
923773074779241444108836556889415035033318887877302805815040186160648847523749
963401166692391431955267755897972670683021944553319913446130373748642677763239
251174555474236974923386217961285067674705006833287822315178723296193749892684
318745303256642706022489446074339228282277055732812488109899142168181690843214
354402963062600627358805296638582161867045203582675163862010380704002809401964
709997969050483832447624298365397847780681544461468746227270711828992567523683
451922684324014873908292561279393101740219848985934135105366389074318295911259
027975571257836904658867633413910232154303917608883065014477772847442874592985
03138819165999141989186488169863319146674522324733,
Note that the integer value of the factorial is exact, but mpfun represents and prints it in floating point format so the output doesn't show the 125 trailing zeros.

Regards,

Dave
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:49 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.