MPOUT

advertisement
MPOUT
This set of files is used to test multi-precision input and output. Multi-precision
numbers are defined by
IT 1
X  IB IX (1)  IB  J IX  j  1 (1)
J 1
The first test number is PI from ../../brent/example.for.
3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170680
The sign has been dropped, but otherwise the value is unchanged from the IT=30 that it
was generated with. This means that the IB values go from 0 to 16383. This will be
changed by
SUBROUTINE MPNORM(IX,N,IT,ITT) MPBOB.FOR
From ..\..\brent\tmpmulb.for
BD=B
BDP=BD**(XTEMP3(2)-1)
TEMP3=BDP*XTEMP3(3)
DO I=4,18
WRITE(1,*)I,XTEMP3(I)
BDP=BDP/16384
TEMP3=TEMP3+BDP*XTEMP3(I)
ENDDO
TEMP3=TEMP3*XTEMP3(1)
Bounds
B=16384D0
After a call to MPNORB.for, IX(j)<16384. Thus each term in the sum in(1) is
less than or equal to B. Thus
M
X   B IX  2 j IX  j  2  
j 1
16

B IX  21 j
(2)
j  M 1
The second sum in the second term is
SS 
16

B IX  21 j  B IX  21 M 1
j  M 1
16 M 1

B  j (3)
j 0
Extend the sum to infinity and utilize

1
  z j to find
1  z j 0
16  M 1

j 0
B j 
1
1
1  1/ B
So that
SS  BIX  2M and
M
M

B IX  2  B  j IX  j  2   X  B IX  2   B  j IX  j  2   B  M 
j 1
 j 1

-16
The error in double precision is 10 . That is B-M/ B-1<10-16. This implies
(1-M)log(B)=-16 or (1-M)=-16/log(B) or M=1+16/log(16384) = 4.8 5
The code dpmp.for –(tested in ..\dpmp.zip ..\..\brent\dpmp.zip) will also be used
to convert final inverse to double precision.
Code for finding JE
M
AL10=LOG10(|X|)=IX(2)*log10(B)+log10(
B
j
IX  j  2  )
j 1
PRINT*,' AL10 = ',AL10
IF(AL10.GT.0)THEN
NP10=AL10+1
ELSE
NP10=AL10
ENDIF
PRINT*,' POWER OF 10 ',NP10
Log10(|X|)
Log10(16384)~ 4.2144199392957367329923445261429
M
LOG10(|X|)=IX(2)*log10(B)+log10(
B
j
IX  j  2  )
j 1
Code for finding C
R2=10**(NP10-1)
PRINT*,' O OF M ',R2
DO I=1,JC
IT1=R1/R2
R3=R1-R2*IT1
PRINT*,' IT1 = ',IT1
R1=R3
R2=R2*1D-1
ENDDO
Making an “exact” decimal number
Pi1/2=1.7724538509055160272981674833411 according to the calculator.
A normalized term has internal digits  231=2147483648 so that pi can be set as
IPI(1)=0
IPI(2)=1772453850
This can then be divided by 1000000000, and then normalized to give a number
that is “exact” to 10 digits. – In practice internal multiplications limit this to 105, but it
can be done twice.
If the first 16 digits are input as real*8, the binary representation leaves numerous
digits beyond 16
Download