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:
exceeding realmax or realmin values

Subject: exceeding realmax or realmin values

From: Maarten

Date: 26 Nov, 2010 15:05:04

Message: 1 of 4

Hi,

Is it in any way possible to temporarily exceed the realmax or realmin value during calculations? For example if I want to find the value for A=Log(exp(1000)). Exp(1000) exceeds the realmax value, so it is infinite. This makes a also infinte. Is there a way to get the correct value for A, in this case 1000?

Thanks

Subject: exceeding realmax or realmin values

From: Bruno Luong

Date: 26 Nov, 2010 15:18:04

Message: 2 of 4

"Maarten " <m.vandewaal@student.tudelft.nl> wrote in message <icoib0$jvp$1@fred.mathworks.com>...
> Hi,
>
> Is it in any way possible to temporarily exceed the realmax or realmin value during calculations?

No. You just have to organize the calculation differently.

Bruno

Subject: exceeding realmax or realmin values

From: Walter Roberson

Date: 26 Nov, 2010 16:31:33

Message: 3 of 4

On 26/11/10 9:05 AM, Maarten wrote:

> Is it in any way possible to temporarily exceed the realmax or realmin
> value during calculations? For example if I want to find the value for
> A=Log(exp(1000)). Exp(1000) exceeds the realmax value, so it is
> infinite. This makes a also infinte. Is there a way to get the correct
> value for A, in this case 1000?

You can _extend_ the range over which you can do the calculation if you
use the symbolic toolbox to do the calculation. However, the symbolic
toolbox has its own limits (I think it might be at 100,000 decimal
digits in the number), so eventually you would run into problems anyhow,
somewhere around exp(300000).

You would be better off rewriting your code so that this situation does
not occur at all.

Subject: exceeding realmax or realmin values

From: Roger Stafford

Date: 26 Nov, 2010 17:32:04

Message: 4 of 4

"Maarten " <m.vandewaal@student.tudelft.nl> wrote in message <icoib0$jvp$1@fred.mathworks.com>...
> Hi,
>
> Is it in any way possible to temporarily exceed the realmax or realmin value during calculations? For example if I want to find the value for A=Log(exp(1000)). Exp(1000) exceeds the realmax value, so it is infinite. This makes a also infinte. Is there a way to get the correct value for A, in this case 1000?
>
> Thanks
- - - - - - - - -
  When you would exceed 'realmax' it is as Bruno says a situation where you must modify your procedure. In the example you give of log(exp(1000)) you could take advantage of rescaling the 1000 by using the identity

 log(exp(x*k)) = log(exp(x)^k) = k*log(exp(x))

If k were equal to ten and x were a hundred, these quantities on the right would fall well within the double floating point format's acceptable range of numbers.

  The designers of the 754 IEEE floating point standard for double precision provided 11 bits out of 64 for a two's exponent, 52 bits for the "significand" and 1 bit as sign. The 'realmax' value has the exponent and significand values at their respective maximum possible values which gives a value of 2^1046*(2-2^-52) which is certainly a very large number, larger than the famous "google" and also larger by a very great margin than the total number of atoms in the known universe.

  You should be aware that a somewhat different situation prevails with very small numbers. The value 'realmin' = 2^-1022 is the smallest floating point value that retains the full 53 bit accuracy in its significand. However floating point numbers can be used in calculations that are as small as 2^-1074 without becoming zero. The exponent becomes locked at 2^-1022 but the signficand can descend to as low as 2^-52 but with gradually reducing accuracy. This has been called a "gradual underflow" as opposed to the sudden "flush to zero" that many previous floating point systems used. To retain full accuracy however the numbers should not descend below 'realmin'.

  This system was planned to take best advantage of the information that could be crammed into only 64 bits, in the opinion of its designers. A user of the system must always take into account the limitations of the number representations in that system and adjust their algorithm accordingly.

Roger Stafford

Tags for this Thread

No tags are associated with 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