Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Mata computes the second derivative of x^2 as 1.9.

From   Patrick Roland <>
Subject   st: Mata computes the second derivative of x^2 as 1.9.
Date   Sat, 4 Aug 2012 20:22:15 -0700

Perhaps someone might be able to explain this anomaly. The following
code finds the second derivative of x^2 evaluated at 0.5, which should
of course be 2.


void f(p,v){
	v = p^2	
D = deriv_init()
deriv_init_evaluator(D, &f())
deriv_init_params(D, 0.5)


Instead, in both Stata 11.2 and 12.1, the answer is 1.906569171.

I'm trying to compute the Hessian of a complicated nonlinear function
of several hundred arguments. It appears that Mata cannot correctly
find the second derivative of x^2. This does not inspire confidence.

Hopefully I'm overlooking something simple here, in which case I would
greatly appreciate a correction.
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index