[BangPypers] Exponential : warning overflow

Anand Reddy Pandikunta anand21nanda at gmail.com
Wed Mar 30 04:19:48 EDT 2016


You need to install bigfloat module first.
See here for instructions
<http://bigfloat.readthedocs.org/en/latest/#installation>.

Once it is done, use bigfloat.exp instead of numpy.exp.

In [31]: v = numpy.linspace(0, 100, 10)

In [32]: from bigfloat import precision, exp

In [33]: with precision(100000):
   ....:         j = [exp(i/1.3806488e-23) for i in v]


Cheers,
Anand Reddy Pandikunta (@ChillarAnand)
www.avilpage.com


On Wed, Mar 30, 2016 at 12:46 PM, Santosh Chiniwar <santosh.chini at gmail.com>
wrote:

> Thanks for kind reply. I am new to this python coding. Could you please
> tell me how use bigfloat to fix this overflow problem
>
> I am getting overflow for following values
>
>      v = numpy.linspace(0, 100, 10)
>      j= numpy.exp(v/1.3806488e-23)
>
>
>
> I have tried to use   In [30]: from bigfloat import *
>
> ---------------------------------------------------------------------------
>
> ImportError                               Traceback (most recent call last)
>
> <ipython-input-30-45ecbac7174b> in <module>()
>
> ----> 1 from bigfloat import *
>
>
> ImportError: No module named 'bigfloat'
>
>
>
>
>
>
> *Santosh P. Chiniwar*
>
> *----------------------------------Research Scholar, Thin Film Measurement
> Lab *
> *Department of Electronics Engineering*
> *Chang Gung University, Taiwan (ROC)*
> *259 Wenhua 1st Rd., Guishan Dist., Taoyuan, *
> *33302, **Taiwan (ROC), **Tel.: +886-3211-8800*
> *-ext.535 **Mob: +886-905667324*
>
> The first principle is that you must not fool yourself-and you are the
> easiest person to fool..... Richard Feynman
>
>
>
> On 29 March 2016 at 21:34, Gora Mohanty <gora at mimirtech.com> wrote:
>
> > On 29 March 2016 at 17:14, Santosh Chiniwar <santosh.chini at gmail.com>
> > wrote:
> > > Dear BangPypers,
> > >   Please find my code and I get Overflow warning. I am unable to
> continue
> > > further. Any support or help is appreciated.
> >
> > Somewhere you are getting too large a number for the range of type in
> > the array that you are using: probably because you are dividing by the
> > very small Boltzmann constant.
> >
> > You either need to use a type with a bigger range, say bigfloat for
> > arbitrary precision floating-point arithmetic, or if the errors only
> > occur for values that can be ignored, see
> > http://docs.scipy.org/doc/numpy/reference/generated/numpy.seterr.html
> > for how to ignore errors.
> >
> > Incidentally, all this information is available from an easy Google
> search.
> >
> > Regards,
> > Gora
> > _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > https://mail.python.org/mailman/listinfo/bangpypers
> >
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> https://mail.python.org/mailman/listinfo/bangpypers
>


More information about the BangPypers mailing list