14 | PARTIAL DERIVATIVES
14 | PARTIAL DERIVATIVES
This chapter of Single Variable Calculus by Dr JH Klopper is licensed under an Attribution-NonCommercial-NoDerivatives 4.0 International Licence available at http://creativecommons.org/licenses/by-nc-nd/4.0/?ref=chooser-v1 .
14.1 Introduction
14.1 Introduction
In this chapter we start to explore functions with more than a single variable. For functions in two variables we have to consider rates of change in more than a single variable. Here we start to consider techniques of partial derivatives.
14.2 Function of two variables
14.2 Function of two variables
The function is a map from ->. Figure 14.2.1 shows a graph of the function .
zf(x,y)
2
f(x,y)+
2
x
2
y
In[]:=
Plot3D[+,{x,-2,2},{y,-2,2},PlotLabel->"Figure 14.2.1",AxesLabel->{"x","y","z"},ImageSize->Large]
2
x
2
y
Out[]=
It no longer makes sense to consider the rate of change in the function with respect to a change in a single variable using the techniques of single variable calculus. Instead, we consider the partial derivative.
x
14.3 Partial derivatives
14.3 Partial derivatives
Note that from the function we can treat one of the variables, say , as a constant. Irrespective of the value of , we will get the same first derivative of with respect to . This is the partial derivative, shown in (), where we use the partial derivative symbol ∂ instead of .
f(x,y)+
2
x
2
y
y
y
f(x,y)+
2
x
2
y
x
d
∂
∂x
2
x
2
y
(
1
)The Wolfram language confirms the results using the D function.
D[+,x](*Derivativewithrespecttox*)
2
x
2
y
Out[]=
2x
We can also consider the partial derivative of with respect to and treat as a constant. This is shown in (2).
f
y
x
∂
∂y
2
x
2
y
(
2
)The Wolfram language confirms the results.
D[+,y](*Derivativewithrespecttoy*)
2
x
2
y
Out[]=
2y
Problem 14.3.1 Calculate the partial derivative in (3).
∂
∂x
2
x
(
3
)We treat as any constant and calculate the partial derivative in (4).
y
∂
∂x
2
x
(
4
)The Wolfram Language confirms our solution.
In[]:=
D[y+2x+3y,x]
2
x
Out[]=
2+2xy
Unlike our explanatory example where the rate of change in was independent of , we have that the rate of change in is dependent on the value of in this problem. Figure 14.3.2 visualizes the problem.
x
y
x
y
In[]:=
Plot3D[y+2x+3y,{x,-3,3},{y,-3,3},PlotLabel->"Figure 14.3.2",AxesLabel->{"x","y","z"},ImageSize->Large]
2
x
Out[]=
14.4 Application of the partial derivative
14.4 Application of the partial derivative
In[]:=
age={56.,58.,61.,63.,67.}
Out[]=
{56.,58.,61.,63.,67.}
In[]:=
SeedRandom[1];bp=2age+RandomChoice[Range[-5,5,1],5]
Out[]=
{108.,115.,117.,128.,129.}
Figure 14.4.1 visualizes the data as a scatter plot.
In[]:=
ListPlot[Transpose[{age,bp}],PlotLabel->"Figure 14.4.1",AxesLabel->{"Age","Blood pressure"},GridLines->Automatic,ImageSize->Large]
Out[]=
In[]:=
ones={1,1,1,1,1};X=Transpose[{ones,age}]
Out[]=
{{1,56.},{1,58.},{1,61.},{1,63.},{1,67.}}
In[]:=
model=LinearModelFit[{X,bp}]
Out[]=
FittedModel
y
(
5
)ℒ
i
y
i
y
i
y
i
mx
i
(
6
)=++++
2
(108-m(56)-b)
2
(115-m(58)-b)
2
(117-m(61)-b)
2
(128-m(63)-b)
2
(129-m(67)-b)
(
7
)In[]:=
cost=++++
2
(108-56m-b)
2
(115-58m-b)
2
(117-61m-b)
2
(128-63m-b)
2
(129-67m-b)
Out[]=
2
(129-b-67m)
2
(128-b-63m)
2
(117-b-61m)
2
(115-b-58m)
2
(108-b-56m)
In[]:=
cost[-0.127,1.959]
Out[]=
37.0823
In[]:=
ListPointPlot3D[{{-0.127,1.969,37}}]
Out[]=