Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
regarding increasing precision value

Subject: regarding increasing precision value

From: aralimaradsir@gmail.com

Date: 27 Jan, 2009 05:20:10

Message: 1 of 3

Hello friends, i have written a program below which can generate 64
bit double precision hex value but i require a value of more than 128
bits can anyone of you help me in this matter thank you
clc;
clear all;
format long

N=1000;
x=[.197];
Y=0;
y1=0;
for n=1:1:N
   Y=4.*x.*(1-x);
   y1=y1+Y;
   x=y1;
   y1=0;

  end
disp (Y)
key=num2hex(Y)

Subject: regarding increasing precision value

From: Roger Stafford

Date: 27 Jan, 2009 10:04:02

Message: 2 of 3

aralimaradsir@gmail.com wrote in message <18642ed7-fb80-4875-a7db-a79a15a12c4a@r37g2000prr.googlegroups.com>...
> Hello friends, i have written a program below which can generate 64
> bit double precision hex value but i require a value of more than 128
> bits can anyone of you help me in this matter thank you
> clc;
> clear all;
> format long
>
> N=1000;
> x=[.197];
> Y=0;
> y1=0;
> for n=1:1:N
> Y=4.*x.*(1-x);
> y1=y1+Y;
> x=y1;
> y1=0;
>
> end
> disp (Y)
> key=num2hex(Y)

  There are only 53 bits of precision in matlab's double format significand, the other 11 bits being used for exponent and sign. If you really need 128 bits you might consider the Symbolic Toolbox with decimal number precision set to some very high level in an endeavor to achieve 128 bits accuracy. However you must realize that decimal precision is not precisely equivalent to binary accuracy. You might make a single bit error in the 128th bit even though decimal accuracy is set far above 128*log(10)/log(2) = 38 decimal place accuracy. You should also realize that even if you had a machine using binary floating point numbers with 128 bit precision, your algorithm would still be making rounding errors down at that 128-th place in its multiplications. Why do you feel the need of just 128 bit precision in particular, as opposed to some other value, higher or lower?
  
  Your code is puzzling. The quantity y1 is always equal to zero when you do y1=y1+Y, so you are just copying Y into y1 and then on into the next x. Why are you doing things in this round-about way, as opposed to just

 x = 4*x*(1-x);

at each step?

  The iteration is interesting. If you plot the x values as a function of the number of steps, it makes an almost random distribution of values which seem to fill up the screen area in a rectangle in a nearly uniform manner except of course in the vicinity of x = 0.75 where one would expect an anomaly, since an exact x = 0.75 would stay constant. Where did you encounter this peculiar iteration? It looks like a good example of the fractals in chaos theory.

Roger Stafford

Subject: regarding increasing precision value

From: aralimaradsir@gmail.com

Date: 30 Jan, 2009 05:01:35

Message: 3 of 3

On Jan 27, 3:04=A0pm, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> aralimarad...@gmail.com wrote in message <18642ed7-fb80-4875-a7db-a79a15a=
12...@r37g2000prr.googlegroups.com>...
> > Hello friends, i have written a program below which can generate 64
> > bit double precision hex value but i require a value of more than 128
> > bits can anyone of you help me in this matter thank you
> > clc;
> > clear all;
> > format long
>
> > N=3D1000;
> > x=3D[.197];
> > Y=3D0;
> > y1=3D0;
> > for n=3D1:1:N
> > =A0 =A0Y=3D4.*x.*(1-x);
> > =A0 =A0y1=3Dy1+Y;
> > =A0 =A0x=3Dy1;
> > =A0 =A0y1=3D0;
>
> > =A0 end
> > disp (Y)
> > key=3Dnum2hex(Y)
>
> =A0 There are only 53 bits of precision in matlab's double format signifi=
cand, the other 11 bits being used for exponent and sign. =A0If you really =
need 128 bits you might consider the Symbolic Toolbox with decimal number p=
recision set to some very high level in an endeavor to achieve 128 bits acc=
uracy. =A0However you must realize that decimal precision is not precisely =
equivalent to binary accuracy. =A0You might make a single bit error in the =
128th bit even though decimal accuracy is set far above 128*log(10)/log(2) =
=3D 38 decimal place accuracy. =A0You should also realize that even if you =
had a machine using binary floating point numbers with 128 bit precision, y=
our algorithm would still be making rounding errors down at that 128-th pla=
ce in its multiplications. =A0Why do you feel the need of just 128 bit prec=
ision in particular, as opposed to some other value, higher or lower?
>
> =A0 Your code is puzzling. =A0The quantity y1 is always equal to zero whe=
n you do y1=3Dy1+Y, so you are just copying Y into y1 and then on into the =
next x. =A0Why are you doing things in this round-about way, as opposed to =
just
>
> =A0x =3D 4*x*(1-x);
>
> at each step?
>
> =A0 The iteration is interesting. =A0If you plot the x values as a functi=
on of the number of steps, it makes an almost random distribution of values=
 which seem to fill up the screen area in a rectangle in a nearly uniform m=
anner except of course in the vicinity of x =3D 0.75 where one would expect=
 an anomaly, since an exact x =3D 0.75 would stay constant. =A0Where did yo=
u encounter this peculiar iteration? =A0It looks like a good example of the=
 fractals in chaos theory.
>
> Roger Stafford- Hide quoted text -
>
> - Show quoted text -
sir,actually i am working on Advanced encryption standard algoritham
where it uses fixed key for encryption so by using logistic map
equation i want to generate that key.key size varies from 128bits,....
so on sir.wheather it is possibleto get that key length from my
progrmme what i have written sir ?.of course if i write like this
x=3D4*x*(1-x) then also it genrates the value.but i need the required
size of bits sir.can you please help in this matter sir ? thanking you

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us