# Gradient of an Interpolating Function

Posted 9 years ago
8318 Views
|
2 Replies
|
0 Total Likes
|
 Hello,I have an Interpolating Function that came from a 2D solution of the Laplace Equation (NDSolve[]). I then did a z=v /.First[y] where y is the InterpolatingFunciton and I can get numbers from, say, z[2,3]. So, I want to do a Vector Plot of the Gradient of z. When I do a Grad[z,{x,y}], I get a boat load of cryptic gibberish. It says something about unable to determine coordinates. This Interpolating Function stuff is always confusing. The concept is easy but using them is always a struggle. Anyone have any idea on how to get what I want from this?Thanks.
2 Replies
Sort By:
Posted 9 years ago
 With an interpolating function, you can approximate derivatives (and thus gradients) using the primitive definitionpartial z[x,y]/partial x = z[x+delta,y]/deltawith delta chosen so that the derivatives are reasonably smooth.
Posted 9 years ago
 Thanks for your help. I was able to use the Derivative[n, m][z] function to find the gradient of the InterpolatingFunction. Your answer did tip me off that the Grad would not work and that I have to form the gradient from derivatives. However I didn't have to go as near a scratch method as you were suggesting.Working with these Interpolating Functions is confusing. First one has to take a part of the returned rule(s) ([[1]]) to do anything. One then gets the Interpolating Function which is a very complex list hierarchy. Then to take the derivative of the Interpolating Function, it is not clear if one has to include arguments next to the head ([x,y]) to which the derivative Interpolating Function is being assigned or next to the Derivative function containing the original Interpolating Function List or both or neither. Then to top it off it is not clear if one has to include arguments next to the head in the derivative plot function call. I tried all the variations and discovered that to get a plot of the gradient I had to not include arguments when forming the derivative but I had to include them when doing the plotting. Further, when I formed negative derivatives (put a minus sign in front of the Derivative Function or in the Derivative Function function argument, I never was able to get numbers or a plot with the result. I still don't know why. Like so many areas of Mathematica, the documentation just doesn't cover all the contingencies and things become a trial and error guessing game. This is a key reason why Mathematica sits on my desktop as a high powered calculator instead of a serious programing and modeling tool. I just don't have the time to constantly discover what should have been clearly documented in the first place.