Got Questions? Get Answers.
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:
exp function

Subject: exp function

From: Nilesh Goel

Date: 20 Jun, 2011 19:48:05

Message: 1 of 8

i s there a limit of exp(x) for which it will only give zero as answer.

In one of my equation exp(-921) is multiplied by a large constant but the answer is zero. I observe exp(-921) returns zero so even multiply it with large no. will return zero.

Is this a limitation of Matlab or there is any alternative to get the small values also.

Thanks
Nilesh Goel

Subject: exp function

From: Matt J

Date: 20 Jun, 2011 19:53:02

Message: 2 of 8

"Nilesh Goel" wrote in message <ito85l$fgm$1@newscl01ah.mathworks.com>...
> i s there a limit of exp(x) for which it will only give zero as answer.
>
> In one of my equation exp(-921) is multiplied by a large constant but the answer is zero. I observe exp(-921) returns zero so even multiply it with large no. will return zero.
>
> Is this a limitation of Matlab or there is any alternative to get the small values also.


Instead of implementing as N*exp(-921), perhaps implement as

exp( log(N)-921 )

Subject: exp function

From: Nilesh Goel

Date: 20 Jun, 2011 20:44:05

Message: 3 of 8

Hello Matt,

The problem is still there as now value of (log(N) - 921) is very less again so exponent of this gives zero o/p. :(

"Matt J" wrote in message <ito8eu$ge4$1@newscl01ah.mathworks.com>...
> "Nilesh Goel" wrote in message <ito85l$fgm$1@newscl01ah.mathworks.com>...
> > i s there a limit of exp(x) for which it will only give zero as answer.
> >
> > In one of my equation exp(-921) is multiplied by a large constant but the answer is zero. I observe exp(-921) returns zero so even multiply it with large no. will return zero.
> >
> > Is this a limitation of Matlab or there is any alternative to get the small values also.
>
>
> Instead of implementing as N*exp(-921), perhaps implement as
>
> exp( log(N)-921 )

Subject: exp function

From: Matt J

Date: 20 Jun, 2011 20:56:04

Message: 4 of 8

"Nilesh Goel" wrote in message <itobel$pbd$1@newscl01ah.mathworks.com>...
> Hello Matt,
>
> The problem is still there as now value of (log(N) - 921) is very less again so exponent of this gives zero o/p. :(
==================

Then you need to reformulate your calculations so that they can be accomplished within the precision capabilities of normal computers. Show a bigger chunk of what you are trying to do and maybe the community will have suggestions.

Subject: exp function

From: Roger Stafford

Date: 20 Jun, 2011 21:02:04

Message: 5 of 8

"Nilesh Goel" wrote in message <itobel$pbd$1@newscl01ah.mathworks.com>...
> The problem is still there as now value of (log(N) - 921) is very less again so exponent of this gives zero o/p. :(
>
> > > In one of my equation exp(-921) is multiplied by a large constant but the answer is zero. I observe exp(-921) returns zero so even multiply it with large no. will return zero.
- - - - - - - -
  You should remember that the very smallest positive number possible in 'double' format is 2^(-1075). Your number exp(-921) is far below that and is forced to round to zero. There is no avoiding that. You should adjust your proceedings accordingly.

Roger Stafford

Subject: exp function

From: Greg Heath

Date: 21 Jun, 2011 01:05:38

Message: 6 of 8

On Jun 20, 5:02 pm, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> "Nilesh Goel" wrote in message <itobel$pb...@newscl01ah.mathworks.com>...
> > The problem is still there  as now value of (log(N) - 921)  is very less again so exponent of this gives zero o/p. :(
>
> > > > In one of my equation exp(-921) is multiplied by a large constant but the answer is zero. I observe exp(-921) returns zero so even multiply it with large no. will return zero.
>
> - - - - - - - -
>   You should remember that the very smallest positive number possible in 'double' format is 2^(-1075).  Your number exp(-921) is far below that and is forced to round to zero.  There is no avoiding that.  You should adjust your proceedings accordingly.
>
> Roger Stafford

For integer arguments I'm getting

2^(-1074) <= 2^(n) <= 2^(1023)

and

exp(-745) <= exp(m) <= exp(709)

Hope this helps.

Greg

Subject: exp function

From: Roger Stafford

Date: 21 Jun, 2011 02:38:05

Message: 7 of 8

Greg Heath <heath@alumni.brown.edu> wrote in message <43d85ca6-5b2e-4af4-ad1b-f0b1411c220d@y30g2000yqb.googlegroups.com>...
> For integer arguments I'm getting
> 2^(-1074) <= 2^(n) <= 2^(1023)
- - - - - - - - -
  Yes you are right, Greg. The smallest positive double is the denormalized number 2^(-1074), making a nonzero exp(-921) even more impossible.

Roger Stafford

Subject: exp function

From: Rune Allnor

Date: 21 Jun, 2011 10:06:43

Message: 8 of 8

On Jun 20, 9:48 pm, "Nilesh Goel" <nilesh.g...@gmail.com> wrote:
> i s there a limit of exp(x) for which it will only give zero as answer.
>
> In one of my equation exp(-921) is multiplied by a large constant but the answer is zero. I observe exp(-921) returns zero so even multiply it with large no. will return zero.
>
> Is this a limitation of Matlab

No. It's a limitation of finite wordlength aritmetics.

> or there is any alternative to get the small values also.

There might be. But if you routinely mess with numbers of
that kind of magnitudes, you might want to review the
scope of your work.

Rune

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