[Note that, in thisexample, the mesh sizes in x and y are identical (h); strictlyspeaking, this need not be true. In some applications, we may needmore resolution along the x- or y-axis; we could then use separatemesh sizes hx and hy.]
By definition, thepartial derivative of a function f ( x , y ) with respect to xis
∂ f ∂ x = L i m h ⟶ 0f ( x i + h , y j ) − f ( x i , y j ) h
and the partialderivative with respect to y is
∂ f /∂ y = L i m h ⟶ 0f ( x i , y j + h ) − f ( x i , y j )/ h
If we applied theseformulas to our grid values, we would get the finitedifference expressions
∂ f /d x ( x i , y j )≅ f ( x i + 1 , y j ) − f ( x i , y j )/ h
Note:To avoid round-off error, retain at least six decimalplaces in all of your calculations.
- Assume the function f is defined as f(x, y) = 3 tan x cosy
- Use differentiation rules to find the exact partial derivatives∂ f /∂ x and ∂ f /∂ y , and evaluate those exact partialderivatives at (1.56, -2.1). Â
- Use the finite difference formulas to estimate ∂ f /∂ x and ∂f/ ∂ y at (1.56, -2.1) for three different values of the mesh size
- h = 0.01
- h = 0.001
- h = 0.0001
- Use your calculated values to fill in this table:
Estimated partialderivatives using finite difference formulas: |
h | finitedifference approx. to ∂ f/ ∂x | exact ∂f/ ∂ x | finitedifference approx. to ∂ f/ ∂y | exact ∂f/ ∂ y |
0.01 | | | | |
0.001 | | | | |
0.0001 | | | | |
Answer the followingquestions:
- For which partial derivative is the finite differenceapproximation more accurate?
- Why is the finite difference approximation for the otherpartial derivative less accurate?  Under what real-worldconditions might we see such poor approximations?