# Differentiate and Integrate Interpolated Data with Quantities

Perform three-dimensional interpolation on a list of quantity data.

 In[1]:= Xdata = N@Flatten[ Outer[Quantity[Sin[#1 + #2^2], "Pounds"] &, Range[10], Range[10]], 1]; grid = Flatten[ Outer[List, Quantity[Range[10], "Seconds"], Quantity[Range[10], "Feet"]], 1]; data = Join[grid, Transpose[{data}], 2] /. {x_, y_, z_} :> {{x, y}, z};
 In[2]:= Xif = Interpolation[data]
 Out[2]=

Plot the solution.

 Out[3]=

The input and output quantities associated with the interpolated function can be extracted using property "QuantityUnits".

 In[4]:= Xif["QuantityUnits"]
 Out[4]=

Differentiate the interpolated function.

 In[5]:= XDerivative[#, 0][if][Quantity[3, "Seconds"], Quantity[1, "Meters"]] & /@ Range[3]
 Out[5]=
 In[6]:= XDerivative[#, #][if][Quantity[3, "Seconds"], Quantity[1, "Meters"]] & /@ Range[3]
 Out[6]=

Integrate the interpolated function.

 In[7]:= XIntegrate[ if[x, y], {x, Quantity[1, "Seconds"], Quantity[10, "Seconds"]}, {y, Quantity[1, "Feet"], Quantity[10, "Feet"]}]
 Out[7]=

## Mathematica + Mathematica Online

Questions? Comments? Contact a Wolfram expert »