Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7604787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:59:59+00:00 2026-05-30T23:59:59+00:00

Using numpy, I have this definition of a function: def powellBadlyScaled(X): f1 = 10**4

  • 0

Using numpy, I have this definition of a function:

def powellBadlyScaled(X):
    f1 = 10**4 * X[0] * X[1] - 1
    f2 = numpy.exp(-numpy.float(X[0])) + numpy.exp(-numpy.float(X[1])) - 1.0001
    return f1 + f2

This function is evaluated a huge number of times on an optimization routine. It often raises exception:

RuntimeWarning: overflow encountered in exp

I understand that operand cannot be stored in allocated space for a float. But how can I overcome the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:00:00+00:00Added an answer on May 31, 2026 at 12:00 am

    You can use the bigfloat package. It supports arbitrary precision floating point operations.

    http://packages.python.org/bigfloat/

    import bigfloat
    bigfloat.exp(5000,bigfloat.precision(100))
    # -> BigFloat.exact('2.9676283840236670689662968052896e+2171', precision=100)
    

    Are you using a function optimization framework? They usually implement value boundaries (using penalty terms). Try that. Are the relevant values really that extreme? In optimization it’s not uncommon to minimize log(f). (approximate log likelihood etc etc). Are you sure you want to optimize on that exp value and not log(exp(f)) == f. ?

    Have a look at my answer to this question: logit and inverse logit functions for extreme values

    Btw, if all you do is minimize powellBadlyScaled(x,y) then the minimum is at x -> + inf and y -> + inf, so no need for numerics.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using scipy's gmean() function to determine the geometric mean of a numpy
I have a very large matrix(10x55678) in numpy matrix format. the rows of this
I have a numpy script that -- according to top -- is using about
I am using Python and Numpy to do some data analysis. I have a
I have many 100x100 grids, is there an efficient way using numpy to calculate
I cant get the insert to work in this code. I have other numpy
I have an array like this numpy array dd= [[foo 0.567 0.611] [bar 0.469
Say I have an array in NumPy containing evaluations of a continuous differentiable function,
Using NumPy , a matrix A has n rows and m columns, and I
I believe I am having a memory issue using numpy arrays. The following code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.