uwhpsc-2016 / homework1

Homework #1
1 stars 1 forks source link

error for "'Numerical result out of range'" #61

Open junzhang3366 opened 8 years ago

junzhang3366 commented 8 years ago

When I run my code for gradient_descent, i get this error "OverflowError: (34, @'Numerical result out of range')“

 My code :
    #f=x^4−4x^3−2x^2+5x+9
    df = lambda x: 4*x**3-12*x**2-4*x+5
    x0=0.537818 #initial guess
    epsilon = 1e-8
    sigma=0.5
    print gradient_descent(f, df, x, sigma, epsilon)

My function f has one local maximum, and two local minimum. f has local maximum at x=0.537818. No matter what value x is,I will get "Numerical result out of range" My I know why does this happen? How do I solve this situation ?