# [Scipy-tickets] [SciPy] #1873: scipy.misc.derivative yields wrong answer.

SciPy Trac scipy-tickets@scipy....
Sun Mar 24 13:11:27 CDT 2013

```#1873: scipy.misc.derivative yields wrong answer.
------------------------+---------------------------------------------------
Reporter:  kaufman     |       Owner:  rgommers
Type:  defect      |      Status:  new
Priority:  normal      |   Milestone:  Unscheduled
Component:  scipy.misc  |     Version:  0.11.0
Keywords:              |
------------------------+---------------------------------------------------
The result from derivative() differs from the analytical result.
The derivative of 2x**3 - 3x**2 + 0.5 should be zero at 0 and 1

{{{
from scipy.misc import derivative as der

def f(x):
return 2*x**3 - 3*x**2 + 0.5

def dfdx(x):
return 6*x*x - 6*x

dx = 0.01
print "f(0)+/-dx:", f(0-dx), f(0), f(0+dx)
print "f(1)+/-dx:", f(1-dx), f(1), f(1+dx)
print "dfdx(0,1):", dfdx(0),dfdx(1)
print "derf(0,1):", der(f,0),der(f,1)

clf()
x = arange(-1,2,0.02)
plot(x,f(x))
plot(x,dfdx(x))
plot(x,der(f,x))
grid()
draw()

f(0)+/-dx: 0.499698 0.5 0.499702
f(1)+/-dx: -0.499702 -0.5 -0.499698
dfdx(0,1): 0 0
derf(0,1): 2.0 2.0
}}}

--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1873>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
```