# Thread: Numerical Differentiation - 2 variables

1. ## Numerical Differentiation - 2 variables

Hi,
I have an example where I have a function of 2 variables and I want to calculate the following second derrivative. I can do this example by hand (I think) and evaluate it a point say (2,1).

$\displaystyle f(x,y)=2x^2y+3xy^3$

$\displaystyle \frac{{{\partial }^{2}}f(x,y)}{\partial x\partial y}=4x+9{{y}^{2}}$

So at the point(2,1),

$\displaystyle \frac{{{\partial }^{2}}f(2,1)}{\partial x\partial y}=17$

My question is, how do I do the same thing numerically so I can apply it to a more complex function. I have used the methods for a single variable before such as Numerical differentiation - Wikipedia, the free encyclopedia but am confused on how to solve this example numerically?

Regards Elbarto

2. I have found the derivatives wrt to x and y using the central difference formula below:
Code:
f=@(x,y)2*x^2*y+3*x*y^3;%function_handle
h = 1e-10;%step size

xi = 2;%Point to evaluate function
yi = 1;

% Estimate derrivatives by central difference method
dfdx = (f(xi+h,yi)-f(xi-h,yi))/(2*h)
dfdy = (f(xi,yi+h)-f(xi,yi-h))/(2*h)
Result from after running (MATLAB command prompt)
Code:
dfdx =

11.0000

dfdy =

26.0000

EDU>>
Can I use these values to find the value of $\displaystyle \frac{{{\partial }^{2}}f(x,y)}{\partial x\partial y}$ at this point?

Regards Elbarto