VI Differentiation
Part I Differentiation
Usage Overview
Functions | Brief Usage Descriptions and Examples |
---|---|
dif | The function "dif(f(x),x)" or "dif;f(x);x" returns the first derivative, and "n; keywords; c" in "dif;f(x);x;n;keyword;c" are optional, where keywords include 'rt','ic','dc','cp','ip','df','tn'. For functions with several variables, e.g., "dif;f(x,y,z);x;x;z;y" returns the partial derivatives. Examples dif;x^2-a^2;x || dif;x^(-2/5);x;2 || dif;x^2+x^-2;x;1;rt;1 || dif;x^2-x*y^2+y^2-4;x;y || dif;x^3*y+y^2*x-10;x;2;y || dif;x^3-2*x^2-3*x-5;x;1;cp || dif;x^3-2*x^2-3*x-5;x;1;ic || dif;x^3-2*x^2-3*x-5;x;1;dc || dif;2*x^3-11*x^2+15*x;x;2;ip || dif;2*x^3-11*x^2+15*x;x;2;cu || dif;x^4-3*x^2+1;x;1;tn;1 || dif;1/(x-1)^0.5;x;1;df;10;0.1 ||. |
idf | For the equation F(x,y) = 0 in which y is implicitly defined by x, the function "idf;F(x,y);x;y;n;a,b" returns the implicit derivative of y with respect to x, where "n;a;b" are optional. By default, the order n = 1, and x = a and y = b is used to evaluate the derivative at the point (a, b). Examples idf;x^(2/3)+y^(2/3)+2*x*y-8;x;y || idf;x^2-y^2+8;x;y;2;1;3 || idf;2*x^3-x*y-y^2;x;y;2;1;-2 ||. |
grd | Find gradient vector functions by "vec;grd(f(x,y,z),x,y,z)", and evaluate the gradient at a point (x,y,z) = (a,b,c) by "vec;grd(f(x,y,z),x,a,y,b,z,c)". Examples vec;grd(x^2+y^2-z^2,x,y,z) || vec;grd(x^2+y^2-z^2,x,1,y,1,z,0) || vec;grd(x**2*z/y,x,y) || vec;grd(x*y+y*z-x*z,x,1,y,0,z,2) ||. |
sf3,imf,pc3 cnt |
The function "sf3;f(x,y);a;b;c;d" plots z = f(x,y), where "a;b;c;d" are optional, "[a, b]" is the interval for x, and "[c, d]" for y. The function "imf;F(x,y)" plots an implicit equation F(x,y) = 0, "cnt;f(x,y)" plots contour curves, "pc3;x(t);y(t);z(t)" plots the parametric equations (x(t), y(t), z(t)), and "ps3;x(u,v);y(u,v);z(u,v)" plots 3D surfaces for parametric equations with parameters u and v. Examples sf3;cos(x^2+y^2);-2;2;-2;2 || pc3;2;y;y^2 || pc3;x^2;-1;x^3 || imf;2*x^2-y^2-3 || ps3;cos(u);sin(v);u || imf;2*x-y**3 || imf;3*x-y**2 || cnt;x^2-2*y^2-2 || imf;x**2-y**2 || imf;x**2-y**3 || imf;x**3-y**2 ||. |
hsd | Second derivative test by Hessian determinant. The function "vec;hsd(f(x,y),x,a,y,b)" returns three values "Hessian determinant, fxx, fyy" in the order, where (a, b) is a critical point of f(x,y). Examples vec;hsd(x^2-log(y)+2*x*y-3*y,x,1,y,-1) || vec;hsd(x^2-log(y)+2*x*y-3*y,x,0.5,y,-0.5) ||. |
Table of Contents: Part I
Part II: Differentiation for Several Variables
1 Definition, Differentiation Rules, and Mean Value Theorem
Definition
Definition of derivative The derivative of a function \(f\) at a point \(x=c\) is defined by the limit of a difference quotient \(f'(c)=\lim\limits_{h\to 0}\frac{f(c+h)-f(c)}{h}\), provided the limit exists. We say \(f\) is differentiable at \(c\).
Geometrically speaking, \(f'(c)\) is the slope of the tangent line through the point \((c,f(c)\) to the graph of \(f\).
If \(x\) is an unknown variable, we call \(f'(x)=\lim\limits_{h\to 0}\frac{f(x+h)-f(x)}{h}\) a derivative function, which is also denoted as \(\frac{d}{dx}f(x)\). We usually do not evaluate derivatives by definition.
Examples Use the above definition to verify some derivative formulas.
(1) \((\sin x)'=\lim\limits_{h\to 0}\frac{\sin(x+h)-\sin(x)}{h}\) and \(\frac{\sin(x+h)-\sin(x)}{h}=\frac{\sin x\cos h+\cos x\sin h-\sin x}{h}=\frac{\sin(x)[\cos(h)-1)]}{h}+\frac{\cos x\sin h}{h}\) and thus
\(\lim\limits_{h\to 0}(\frac{\sin(x)[\cos(h)-1)]}{h}+\frac{\cos x\sin h}{h})=\sin x·0+\cos(x)·1=\cos(x)\). Verify the result by
lim;(sin(x+h)-sin(x))/h;h;0 || lim;(sin(x)-sin(0))/x;x;0 || lim;(sin(x)-sin(pi/3))/(x-pi/3);x;pi/3 ||.
(2) lim;(cos(x+h)-cos(x))/h;
h;0 || lim;(1/(x+h)-1/x)/h;h;0 || lim;(1/(x+h)^(1/2)-1/x^(1/2))/h;h;0 || lim;(1/(x+h)^3-1/x^3)/h;h;0 || lim;(1/(x+h)^(2/3)-1/x^(2/3))/h;h;0 ||
lim;(exp(x+h)-exp(x))/h;h;0 || lim;(sin(pi/6+h)-1/2)/h;h;0 || lim;(tan(pi/4+h)-1)/h;h;0 || lim;(tan(x+h)-tan(x))/h;h;0 || lim;(2*(1/3+h)^5-2*(1/3)^5)/h;
h;0 ||.
(3) lim;(cos(x)-cos(pi/2))/(x-pi/2);x;pi/2 || lim;(x^(1/2)-3)/(x-9);x;9 || lim;(f(x)-f(2))/(x-2);x;2 || lim;(g(y)-g(0))/y;y;0 ||.
Derivatives of single-variable functions: [dif; f(x); x; n], [dif(f(x), x, n)]
Use "dif; f(x); x; n" to find the nth derivative of f(x), where 'dif' is the function name, "f(x)" is the expression of a function, "x" the independent variable at which the derivative is with respect to, and "n" is the nth order of derivative.
Attention Also write "dif(f(x), x, n)" to find n-th order derivatives of f(x) with respect to x, and you get same results as "dif; f(x); x; n". In this way, write and solve differential equations by "ode" module. For instance, the expression "dif(g(x),x,2)-2*dif(g(x),x)-3" represents the differential equation g''(x) - 2g'(x) - 3 = 0, and "ode(dif(g(x),x,2)-2*dif(g(x),x)-3)" find the solution for g(x).
Examples
(1) If \(f(x)=\ln x,f'(x)=\frac{1}{x}\) or \(\frac{d}{dx}\ln(x)=\frac{1}{x}\) by dif;log(x);x || dif(log(x),x) ||.
(2) dif;2/x^3;x;2 || or dif(2/x^3,x,2) || shows\(\frac{d^2}{dx^2}2x^{-3} =\frac{24}{x^5}\).
(3) dif;1/(1-x);x;2 || dif;2;x || dif;y^(-2/3);y;2 || dif;2*a;x; || dif;x/(1+x^2);x || dif;(t^4-t+3)/(t+5);t || dif;(a^30+a^5-2)*(a^20+4);a || dif;(b^5-b^2+6)^7;b || dif;c/(c^2+8)^(1/2);c;2 || dif;((h^3-3)/(2*h^2+1))^2;h;2 || dif;(2*x+3)^(1/2);x || dif;cos(t)*exp(t);t || dif;log(x)/x;x || dif;(x+2)^(60);x || dif;L/(1-A*exp(-k*t));t || dif;L/(1-A*exp(-k*t));t;2 ||.
If a function involves several variables, then other variables are treated as constants by the "dif" module.
Examples Check dif;x^2+y^2;x || dif;x/y;y || dif;x*y^2*z^3;z || dif;z/(x*y);x;2 ||.
Hiegher order derivatives We can repeatedly differentiate a function to find higher derivatives. A polynomial of degree \(n\) has at most nth derivative. Some transcendental and rational functions (e.g., \(e^x,\sin x,\cos x,\frac{1}{x}\)) have infinitely many derivatives, and the nth derivative of some functions appear patterns. For example,
\(\frac{d^n}{dx^n}x^n=n!, \frac{d^n}{dx^n}e^x=e^x, \frac{d^n}{dx^n}e^{-x}=(-1)^ne^{-x}, \frac{d^n}{dx^n}a^x=a^x\ln^na, \frac{d^n}{dx^n}a^{-x}=(-1)^na^x\ln^na\),
\(\frac{d^n}{dx^n}e^{bx}=b^ne^{bx}, \frac{d^n}{dx^n}\frac{1}{x}= \frac{(-1)^nn!}{x^{n+1}}, \frac{d^n}{dx^n}\frac{1}{x+b}=\frac{(-1)^nn!}{(x+b)^{n+1}}, \frac{d^n}{dx^n}\frac{1}{b-x}=\frac{n!}{(b-x)^{n+1}}\),
\(\frac{d^n}{dx^n}\sin x=\sin(x+\frac{n\pi}{2}), \frac{d^n}{dx^n}\cos x=\cos(x+\frac{n\pi}{2})\).
The default of "dif" module produces first derivatives. To produce higher order derivatives, you need to add the order "n" (positive integers up to 20) to the end.
Examples Verify these results by dif;x^(15);x;10 || dif;exp(y);y;10 || dif;exp(-z);z;16 || dif;a^x;x;10 || dif;b^(-x);x;13 || dif;3^x;x;8 || dif;5^(-u);u;11 || dif;exp(4*x);x;15 || dif;exp(-3*y);y;18 || dif;1/x;x;19 || dif;1/(y+1);y;14 || dif;1/(1-z);z;11 || dif;cos(u);u;18 || dif;sin(v);v;15 ||.
Examples Use some basic patterns for nth derivatives to find the nth derivatives for other functions.
(1) If \(y=\frac{x-1}{x+2}=1-\frac{3}{x+2}\) and \(y^{(n)}=(-1)^{n+1}n!3(x+2)^{-(n+1)}\) by dif;(x-1)/(x+2);x;6 || dif;(x-1)/(x+2);x;11 ||.
(2) If \(y=\frac{1}{x(3-x)}=\frac{1}{3}(\frac{1}{x}+\frac{1}{3-x})\) and \(y^{(n)}=\frac{1}{3}n![(-1)^nx^{-(n+1)}+(3-x)^{-(n+1)}]\) by dif;1/(3*x-x^2);x;3 || dif;1/(3*x-x^2);x;7 ||.
(3) If \(y=\sqrt{x},y^{(n)}=(-1)^{n+1}\frac{(2n-3)!}{2^n} x^{\frac{1}{2}-n}\) by dif;x^(1/2);x;2 || dif;x^(1/2);x;4 || dif;x^(1/2);x;6 ||.
(4) dif;2*sin(x)+3*cos(x);x;4 || dif;4*exp(-x)-5*log(x);x;6 || dif;x^7-31*x^6;x;7 ||.
Differentiation Rules
We usually use these rules to find derivatives.
Derivative of a constant If \(f(x)=c\), then \(f'(x)=\frac{df}{dx}=\frac{d}{dx}f(x)=\frac{d}{dx}(c)=0\) for all \(x\).
Constant multiple rule If \(f\) is differentiable at \(x\) and \(c\) is a constant, then \([cf(x)]'=cf'(x)\).
Sum rule If \(f\) and \(g\) are differentiable at \(x\), then \([f(x)\pm g(x)]'=f'(x)\pm g'(x)\).
Product rule If \(f,g\) are both differentiable at \(x\), then \([f(x)g(x)]'=f'(x)g(x)+f(x)g'(x)\).
Quotient rule If \(f,g\) are both differentiable at \(x\) and \(g(x)≠0\), then \((\frac{f(x)}{g(x)})'=\frac{f'(x)g(x)-f(x)g'(x)}{g^2(x)}\).
Power rule \(\frac{d}{dx}x^r=nx^{r-1}\) for all real numbers \(r\).
Derivatives of exponential functions \((e^x)'=e^x, (b^x)'=b^x\ln b\).
Derivatives of logarithmic functions \((\ln x)'=\frac{1}{x}, (\log_b x)'=\frac{1}{x\ln b}\).
Chain rule If \(g\) is differentiable at \(x\) and \(f\) is differentiable at \(g(x)\), then \(f[g(x)]\) is differentiable at \(x\) and \([f(g(x))]'=f'(g(x))g'(x)\). Chain rule is not only used to find derivatives of composite functions, but also used to derive rules such as implicit differentiation and inverse functions. We first apply chain rule to extend the power, exponential, and logarithm rules.
General power rule \(\frac{d}{dx}g^n(x)=n(g(x))^{n-1}g'(x)\).
general exponential rule \(\frac{d}{dx}e^{g(x)}=g'(x)e^{g(x)}\) and \((b^{g(x)})'=g'(x)b^{g(x)}\ln b\) for \(b> 0, b\ne 1\).
general logarithm rule \(\frac{d}{dx}\ln|g(x)|=\frac{g'(x)}{g(x)}\) for \(g(x)\ne 0\), and rules for function translation and scaling functions \(\frac{d}{dx}g(ax+b)=ag'(ax+b)\).
Examples
(1) Check these rules by dif;c*f(x);x || dif;f(c*x);x || dif;a*f(x)+b*g(x);x || dif;f(x)*g(x);x || dif;f(x)/g(x);x ||
dif;f(g(x));x || dif;x*f(x)^2;x || dif;f(x)^n;x || dif;a^(f(x));x || dif;exp(g(x));x || dif;f(x)^(g(x));x || dif;log(f(x));x ||.
(2) Check some examples by dif;x^(-5);x || dif;y^(2/3);y || dif;z^(-3/4);z || dif;a*a^(1/2);a || dif;(x+5)^6;x ||
dif;(x+a)^7;x || dif;(b-y)^(-8);y || dif;1/(2*x-3)^6;x || dif;(x-2)/(x+3);x || dif;(3*x-4)^3/(x+2)^5;x || dif;(2*x)^(1/2)-(3*x)^(2/3);x ||
dif;(x-2)^2/(x^2+2*x-5)^(1/2);x ||.
Derivatives of absolute value functions Absolute value functions are not differentiable everywhere. For example, the function y = |x| is not differentiable at x = 0. Note that \(|x|'=\frac{x}{|x|}\) for \(x≠0\) and \(|f(x)|'=f'(x)· \frac{f(x)}{|f(x)|}\) for \(f(x)≠0\), where \(\frac{x}{|x|}\) or \(\frac{f(x)}{|f(x)|}\) is a sign function with a value either 1 or -1. Check dif;(f(x)^2)^(1/2);x ||.
Attention Use this identity \(|x|=\sqrt{x^2}\) to find derivatives of functions involving absolute values based on certain assumptions. Check dif;(x^2)^(1/2);x ||.
Examples
(1) If \(y=|2x + 1| = \sqrt{(2x+1)^2}, y'=\frac{1}{2}[(2x+1)^2]^{-\frac{1}{2}}[2(2x+1)(2)] =2\frac{2x+1}{|2x+1|}\) by the chain rule, where \(\frac{2x+1}{|2x+1|}\) is a sign function. Thus, \(y'=2\) if \(x > -\frac{1}{2},y'=-2\) if \(x<-\frac{1}{2}\), and \(y'\) is undefined if \(x=-\frac{1}{2}\). Verify the result by dif;((2*x+1)^2)^(1/2);x ||.
(2) dif;((x-1)^2)^(1/2);x || dif;((cos(t))^2)^(1/2);t || dif;((4-3*t)^2)^(1/2);t || dif;((x^2-3^x-4)^2)^(1/2);x || dif;((x^2-x-2)^2)^(-1/2);x ||.
In general, if \(y=|f(x)|\) and \(f',f''\) exists, then \(y'=f'(x)\cdot \frac{f(x)}{|f(x)|}\) and \(y''=f''(x)\cdot \frac{f(x)}{|f(x)|}\). If \(f^{(n)}\) exists, then \(y^{(n)}=f^{(n)}(x)\cdot \frac{f(x)}{|f(x)|}\) by chain rule for \(n≥1\). Notice that \(y^{(n)}\) is undefined for values of \(x\) such that \(f(x)=0\).
Examples
(1) \(|x^2-1|''=2\frac{x^2-1}{|x^2-1|}\) and \(|x^2-1|'''=0\) by dif;((x^2-1)^2)^(1/2);x;2 || dif;((x^2-1)^2)^(1/2);x;3 ||.
(2) dif;((x^3-3)^2)^(1/2);x;2 || dif;((x^3-3)^2)^(1/2);x;3 || dif;(x^2)^(-1/2);x;2 || dif;((x^4-3*x^3-4)^2)^(1/2);x;3 || dif;((x^4-3*x^3-4)^2)^(1/2);x;4 ||.
Attention \(|f(x)|\) is different from \(f(|x|)\). If \(y=f(|x|)\) and \(y^{(n)}\) exists for \(n≥1\), then \(y'=f'(|x|)\cdot\frac{x}{|x|}\),\(y''=f''(|x|),y^{(n)}=f^{(n)}(|x|)\) for \(n\) an even number, and \(y^{(n)}=f^{(n)}(|x|)\cdot\frac{x}{|x|}\) for \(n\) an odd number.
Examples
(1) If \(y=|x|^2=x^2\),\(y'=2|x|\frac{x}{|x|}=2x\). If \( y=|x|^3,y'= 3|x|^2\frac{x}{|x|}=3x^2\frac{x}{|x|}=3x|x|,y''=6|x|,
y'''=\frac{6x}{|x|}\). Verify these results by dif;(x^2)^(3/2);x || dif;(x^2)^(3/2);x;2 || dif;(x^2)^(3/2);x;2 ||.
(2) If
\(y=\frac{1}{|x|}⇒y'=\frac{-1}{|x|^2}\frac{x}{|x|}⇒y''=\frac{2}{|x|^3}⇒y'''=\frac{-6}{|x|^4}\frac{x}{|x|}\). Verify the results by
dif;(x^2)^(-1/2);x || dif;(x^2)^(-1/2);x;2 || dif;(x^2)^(-1/2);x;3 ||.
(3) dif;cos((t^2)^(1/2));t || dif;cos((t^2)^(1/2));t;2 || dif;cos((t^2)^(1/2));t;3 || dif;log((t^2)^(1/2));t;4 ||.
Derivatives of exponential and logarithmic functions The basic rules are \((b^x)'=b^x\ln(b),(e^x)'=e^x\) and \((\ln|x|)'=\frac{1}{x},(\log_bx)'=\frac{1}{x\ln b}\) for all \(x≠0,b≠1\) and \(b>0\). Note that \(y=\ln|x|⇒y'=\frac{1}{|x|}\frac{x}{|x|}=\frac{1}{x}\).
Examples dif;2^x;x || dif;(2/3)^y;y || dif;exp(-x);x;5 || dif;2^(x^2);x || dif;(exp(x))^(x^2);x || dif;log(3*x);x || dif;log(x,2);x || dif;log(y,1/2);y || dif;log(2*x,3/4);x || dif;log(z^2,0.21);z || dif;log(u^(1/2),2/3);u || dif;2^x/5^x;x || dif;log(x^5);x || dif;log(3^x);x || dif;log(y^3,3);y ||.
Logarithmic differentiation Use the following to find the derivatives products or quotients. In general, \((\ln|f(x)|)'=\frac{f'(x)}{f(x)},\frac{d}{dx}\ln|fg|=\frac{(fg)'}{fg}=\frac{f'}{f}+\frac{g'}{g}, \frac{d}{dx}\ln|\frac{f}{g}|=(\ln|f|)'-(\ln|g|)' =\frac{f'}{f}-\frac{g'}{g}\). These formulas are useful for differentiating functions with complicated products, quotients, and exponential expressions.
Examples
(1) If \(y=\frac{(x+1)^4\sqrt[3]{x+4}}{\sqrt{x^2+5}}⇒\ln|y|=4\ln|x+1|+\frac{\ln|x+4|}{3}-\frac{x^2+5}{2}⇒
\frac{y'}{y}=\frac{4}{x+1}+\frac{1}{3(x+4)}-\frac{x}{(x^2+5)}\)
\(⇒y'=\frac{(x+1)^4\sqrt[3]{x+4}}{\sqrt{x^2+5}}[\frac{4}{x+1}+\frac{1}{3(x+4)}
-\frac{x}{(x^2+5)}]\). Check dif;(x+1)^4*(x+4)^(1/3)/(x^2+5)^(1/2);x ||.
(2) dif;(x^2-3)^(1/2)*cos(x)/(2*x+3)^4;x || dif;((3*x-2)/(4*x+5))^(2/3);x ||.
If \(y=f(x)^{g(x)}\) is differentiable, then its derivative \((f^g)'=f^gg'\ln|f|+ gf^{g-1}f'\) because \(\ln|y|=g(x)\ln|f(x)|⇒\frac{y'}{y}=g'(x) \ln|f(x)|+\frac{g(x)f'(x)}{f(x)}⇒y'=f(x)^{g(x)}g'(x)\ln|f(x)|\) \(+f(x)^{g(x)-1}g(x)f'(x)\) by general power rule.
Examples
(1) \(y=x^x⇒\ln|y|=x\ln|x|⇒\frac{y'}{y}=\ln|x|+1⇒y'=x^x(\ln|x|+1)\). Or use the identity \(y=e^{x\ln|x|}⇒\)
\(y'=e^{x\ln x}(\ln|x|+1)=x^x(\ln|x|+1)\). Check the result by dif;x^x;x ||.
(2) dif;x^x;x || dif;(x^(1/2))^(log(x));x ||
dif;x^(cos(x));x || dif;sin(y)^(cos(y));y ||.
Trigonometric functions The six basic trigonometric functions are differentiable at every value in their domains. \((\sin x)'=\cos x, (\cos x)'=-\sin x,(\tan x)=\sec^2x, (\cos x)'=-\csc^2x,(\sec x)'=\sec x\tan x\), \((\csc x)'=-\csc x\cot x\). Note that \(x\) is measured by radian, and the derivative \((\sin x°)'=(\sin\frac{\pi x}{180})'=\frac{\pi}{180}\cos x°\).
Examples dif;sin(x);x;7 || dif;cos(x);x;10 || dif;cos(3*x)^2;x || dif;sec(z^(1/2));z || dif;tan(2*u)*sec(3*u^2);u ||.
Hyperbolic functions The six basic hyperbolic functions are differentiable at every value in their respective domains.
\((\sinh x)'=\cosh x, (\cosh x)'=\sinh x,(\tanh x)=\text{sech}^2x, (\coth x)'=-\text{csch}^2x\),
\((\text{sech }x)'=-\text{sech }x\tanh x,(\text{csch }x)'=-\text{csch }x\coth x\).
Derivatives for inverse functions Assume \(f\) is differentiable, one-to-one, and has an inverse \(y=f^{-1}(x)\). Then \(x=f(y)⇒x'=f'(y)·y'\) by chain rule, and the derivative of its inverse \(y'=\frac{1}{f'(y)}=\frac{1}{f'[f^{-1}(x)]}\), or \(\frac{dy}{dx}=\frac{1}{\frac{dx}{dy}}\). By the chain rule, we can find derivatives of inverse functions without solving the formulas for inverse functions.
Examples \((\sin^{-1}x)'=\frac{1}{\sin'[\sin^{-1}(x)]}=\frac{1}{\cos[\sin^{-1}(x)]}=\frac{1}{\sqrt{1-\sin^2[\sin^{-1}(x)]}}= \frac{1}{\sqrt{1-x^2}}\). By a similar method, \((\cos^{-1}x)'=\frac{-1}{\sqrt{1-x^2}}\), \((\tan^{-1}x)' =\frac{1}{1+x^2}, (\cot^{-1}x)'=\frac{-1}{1+x^2}\), \((\sec^{-1}x)'=\frac{1}{|x|\sqrt{x^2-1}},(\sec^{-1}x)'=\frac{-1}{|x|\sqrt{x^2-1}}\). Be aware about the domain of each derivative function.
Examples \((\sinh^{-1}x)'=\frac{1}{\sqrt{x^2+1}},(\sinh^{-1}x)'=\frac{1}{\sqrt{x^2-1}}, (\tanh^{-1}x)'=\frac{1}{1-x^2},(\coth^{-1}x)'=\frac{1}{1-x^2}\),
\((\text{sech}^{-1}x)'=\frac{-1}{x\sqrt{1-x^2}}, (\text{csch}^{-1}x)'=\frac{-1}{|x|\sqrt{x^2+1}}\). Be aware about the domain of each derivative function.
Implicit Differentiation: [idf; f(x, y); x; y; n; x0, y0], [idf(f(x, y), x, y, n, x0, y0)]
Implicit differentiation When \(y\) is implicitly defined as a function of \(x\) in an equation \(F(x,y)=0\), it is sometimes difficult or even impossible to solve for \(y\) as an explicit function of \(x\). In this case, we use implicit differentiation by treating \(y\) as a differentiable function of \(x\), then applying the chain rule, and solving for \(\frac{dy}{dx}\).
In general, \(\frac{dy}{dx}=-\frac{F_x}{F_y}\), where \(F_x\) is the derivative of \(F\) with respect to \(x\), and \(F_y\) the derivative to \(y\). If \(x\) is an implicit function of \(y\), then \(\frac{dx}{dy}=-\frac{F_y}{F_x}\).
To find implicit differentiation by "idf, you need to specify which variable is independent "x", which is dependent "y", and enter the expression "f(x, y)" or the defining equation (without the portion "= 0"). The order n has options from 1 to 4, and the default order is 1. To evaluate derivatives at a given point (x0, y0), add the values of "x0" for "x" and "y0" for "y" to the end. So the code pattern should be "idf; f(x, y); x; y; n; x0, y0" or "idf(f(x, y), x, y, n, x0, y0)".
Attention Use the combination "slv(idf(f(x, y(x)), x), idf(y(x), x))" for implicit differentiation y' if y is implicitly defined. You need to explicitly write the dependent variable y as y(x), a function of the independent variable x. Otherwise, y would be treated as a constant.
Attention If both x, y are functions of t, then x'(t) and y'(t) are called related rates for x and y related in f(x(t), y(t)) = 0, so use "idf;f(x(t), y(t)); t; x" for implicit differentiation x'(t) and "idf;f(x(t), y(t)); t; y" for y'(t). But you need to write x as x(t) and y as y(t), indicating both are functions of t. Otherwise, x and y would be treated as constants.
Examples
(1) If \(y\) is implicitly defined in \(x^2+xy+y^2=1, F(x,y)=x^2+xy+y^2-1, y'=-\frac{2x+y}{2y+x}\). Verify the result by
idf;x^2+x*y+y^2-1;x;y || idf;x^2+x*y+y^2-1;x;y;2 || idf;x^2+x*y+y^2-1;x;y;1;0;1 || idf;x^2+x*y+y^2-1;x;y;2;0;1 ||.
(2) If \(y\) is
implicitly defined in \(e^{x+y}=\cos(xy)+xy^2⇒F(x,y)=e^{x+y}-\cos(xy)-x^2y^2\), and get \(y'\) by idf;exp(x+y)-cos(x*y)-x^2*y^2;x;y || or
dif(exp(x+y)-cos(x*y)-x^2*y^2,x,y) ||.
(3) idf;x^(2/3)+y^(2/3)+2*x*y-8;x;y || idf;y*sin(x+x^2+y);x;y ||
idf;s^2+3*s*t+t^3-9;s;t || idf;u^2*v^2-u*v+5;v;u || idf;b^2*x^2+a^2*y^2-a^2*b^2;x;y || idf;y^2-4*p*x;x;y ||
idf;b^2*x^2+a^2*y^2-a^2*b^2;x;y;2 || idf;x^3+y^2-x*y;x;y;2 || idf;y^2-4*p*x;x;y;2 || idf;x^n+y^n-c;x;y;2 || idf;x^2-y^2+8;x;y;2;1;3 ||.
Examples If y is implicitly defined in 2x² + 3y² = 5, find y' by idf;2*x^2+3*y^2;x;y || or use the combination slv(dif(2*x^2+3*y(x)^2-5,x),dif(y(x),x)) ||.
Examples Suppose x(t) and y(t) are related in the equation x² - 2xy + 3y² = 6. Find x'(t) by idf;x(t)^2-2*x(t)*y(t)+ 3*y(t)^2-6;t;x ||, and y'(t) by idf;x(t)^2-2*x(t)*y(t)+3*y(t)^2-6;t;y ||.
Implicit differentiation involving more than two dependent variables: [idf;f(x, y(x), z(x)); x; y/z; n]
If there are more than two dependent variables that are related in an equation, for instance, y(x) and z(x) are related in x + 2y - 3z = 7, you
can find y'(x) by idf;x+2*y(x)-3*z(x)-7;x;y || and z'(x) by y'(x) by idf;x+2*y(x)-3*z(x)-7;x;z ||. In a similar fashion, find the nth order implicit
differentiation.
Orthogonal Two curves are orthogonal if the tangent lines to their graphs are perpendicular at intersection points.
Examples
(1) Verify that \(xy = a\) and \(y^2 - x^2 = b\) are orthogonal by idf;x*y-a;x;y || idf;y^2-x^2-b;x;y ||. The product
of the slopes is -1.
(2) Verify \(y^2 = b^2 - 2bx\) and \(y^2 = b^2 + 2bx\) are orthogonal by idf;y^2-b^2+2*b*x;x;y || idf;y^2-b^2-2*b*x;x;y
||. The product of slopes is \(-\frac{b^2}{y^2}\) and each point of intersection satisfies \(y^2 = b^2\) for the two curves, so the product is -1.
Examples
(1) To show that the tangent line at any point on the circle \(x^2 + y^2 = r^2\) is perpendicular to the line through the
point \((x, y)\) and center (0, 0), get the slope \(\frac{-x}{y}\) by idf;x^2+y^2-r^2;x;y ||, the slope \(\frac{y}{x}\) of a line joining \((x, y)\)
and (0, 0), and product is -1.
(2) The slope of tangent line to \(y^2 - x = \cos(xy)\) at \(x\) = 0 can be got by idf;y^2-x-cos(x*y);x;y;1;0;1 ||
idf;y^2-x-cos(x*y);x;y;1;0;-1 || dif(y^2-x-cos(x*y),x,y,1,0,1) ||.
(3) To find the equation of tangent line of \(2x^2 - 4xy + 3y^2 = 6\) at \(x\) = 1, substitute \(x\) = 1 in the equation and solve for \(y\) = 2, -2/3 by slv;3*y^2-4*y-4;y ||, get the slope -1/2, 5/6 by idf;2*x^2-4*x*y+3*y^2-6;x;y;1;1;2 || idf;2*x^2-4*x*y+3*y^2-6;x;y;1;1;-2/3 ||, and obtain the equations \(y = \frac{1-x}{2} - 2\) and \(y = \frac{5(x - 1)+4}{6}\).
Evaluate derivatives at a number: [dif; f(x); x; n; rt; x0], [dif(f(x), x, n, rt, x0)]
In many cases, we not only want to find derivative functions, but also want to evaluate them like slopes and rate of changes of f(x) at some particular point x = x0. To do this by "dif" module, add 'rt' (rate) after the derivative order 'n', and specify a value of "x0". So the code pattern is "dif; f(x); x; n; rt; x0" or "dif(f(x), x, n, rt, x0)".
Examples
(1) To find the slope of tangent line to the curve \(y = \sin(x)\) at \(x = \frac{π}{3}\) by dif;sin(x);x;1;rt;pi/3 || dif(sin(x),x,1,rt,pi/3) ||.
(2) The rate of change of the slope of tangent line to \(y^2 = 4x\) at \(x\) = 1 can be got by dif;y^2-4*x;x;y;2;1;2 ||.
(3) dif;cos(2*x);x;1;rt;pi || dif;1/(1+y^2)^0.5;y;2;rt;0 || dif;atan(z);z;2;rt;3 || dif;log(y);y;3;rt;2 || dif;z^4-z^(3/2);z;2;rt;4 || dif;sin(3*t);t;4;rt;pi/2 ||.
Estimating derivatives Since \(f'(a)=\displaystyle\lim_{h\to 0}\frac{f(a+h)-f(a)}{h}\) is a limit, we can estimate \(f'(a)\approx \frac{f(a+h)-f(a)}{h}\) when \(h\) is small, just as we estimate a limit. In general, if \(y=f(x)\) is differentiable at \(x=a,f'(a)=\lim\limits_{\Delta x\to 0}\frac{\Delta y}{\Delta x}\) and \(\Delta y=f(a+\Delta x)-f(a)≈f'(a)\Delta x\), which is the formula linear approximation, and \(f'(a)\) is approximately the ratio of vertical over horizontal change for small change \(\Delta x\) near \(a\). Velocity can be estimated by average velocity when time interval is small.
Mean value theorem
The extreme value theorem, Fermat theorem, Rolle's theorem and the mean value theorem play an essential role in differential calculus. Understand each of these theorems, their implications, and the associated assumptions.
By completeness of real numbers, the extreme value theorem states that there exist both absolute minimum and maximum values of continuous functions on closed intervals.
Fermat theorem states that local extreme values occur at critical points.
The mean value theorem relates instantaneous rates of change to average rates of change for continuous functions on closed intervals.
We do not repeat these theorems here, but finding the particular point(s) is not our focus of attention to Rolle's theorem and the mean value theorem. Our main focus to these theorems is the existence of such a point.
Corollaries The following lists the three important corollaries from the mean value theorem.
(1) If \(g'(x) = 0\) for all \(x ∈ (a, b)\), then \(g(x)\) is a constant on \((a, b)\).
(2) If \(g'(x) > 0\) for all \(x\) in \((a, b)\), then \(g(x)\) is increasing on \((a, b)\); if \(g'(x) < 0\) for all \(x\) in \((a, b)\), then \(g(x)\) is decreasing.
(3) If \(G(x)\) is an antiderivative of \(g(x)\) on \((a, b)\), all other antiderivatives \(F(x)\) of \(g(x)\) on \((a,b)\) can be written as \(F(x) = G(x) + C\) for some constant \(C\).
Examples
(1) The function \(g(x) = 2x^3 - 2x^2 + 1\) on [0, 1] satisfies the assumption of Rolle's theorem \(g(0) = g(1) = 0\). Find the number \(c\) in (0, 1) by dif;2*x^3-2*x^2+1;x || slv;6*x^2-4*x;x || and \(c = \frac{2}{3}\) such that \(g'(\frac{2}{3}) = 0\). Or use slv(dif(2*x^3-2*x^2+1,x),x) ||.
(2) The assumption of the mean value theorem of \(g(x) = |2 - x|\) on [0, 3] does not hold because \(\frac{g(3) - g(0)}{3 - 0} = -\frac{1}{3}\), but \(g'(x) = -1\) for \(x < 2, g'(x) = 1\) for \(x > 2\), and \(g'(2)\) does not exist.
Number of roots to equations Rolle's theorem is often used with the intermediate value theorem to determine the number of (real) roots of the equation \(f(x)=0\) on a closed interval \([a, b]\).
If \(f'(x)≠ 0\) for \(x∈(a,b)\), then \(f(x)=0\) has at most one root in \((a,b)\). If \(f'(x)=0\) has one root in \((a,b)\), then \(f(x)=0\) has at most two roots in \((a,b)\). In general, if \(f'(x)=0\) has (at most) \(n\) roots in \((a,b)\), then \(f(x)=0\) has at most \(n+1\) roots in \((a,b)\).
If \(f\) has the second derivative on \((a,b)\) and \(f''(x)≠ 0\), then \(f'(x)=0\) has at most one root and \(f(x)=0\) has at most two roots in \((a,b)\).
If \(f\) has third derivative and \(f'''(x)≠ 0\), then \(f\) has at most three distinct real roots (e.g., a polynomial of degree 3).
A more general result is if \(f^{(n)}(x)\) exists for all \(x∈(a,b)\) and \(f^{(n)}(x)≠ 0\), then \(f(x)=0\) has at most \(n\) distinct real roots. Furthermore, if \(f^{(n)}\) exists on \((a,b)\) and \(f^{(n)}\) has (at most) one zero, then \(f(x)\) has at most \(n+1\) zeros in \((a,b)\). Conversely, if \(f\) has at least \(n+1\) distinct zeros, then \(f^{(n)}\) has at least one zero in \((a,b)\). Pay attention to the words "at most" and "at least" in each implication.
Based on these facts, we can determine the number of zeros of a function (in particular polynomials) from the number of zeros of its nth derivative. It is obvious if \(f''(x)=a≠0,f\) is a quadratic function and has at most two real roots.
Examples
(1) The function \(f(x)=3x^4-5x+9\) has no more than two zeros because the equation \(f'(x)=12x^3-5=0\) has only one root. || dif;3*x^4-5*x+9;x ||.
(2) The function \(g(x)=5x^5+7x-8\) has exact one zero because \(g\) changes signs and \(g'(x)=25x^4+7>0\). Check dif;5*x^5+7*x-8;x ||.
(3) The function \(h(x)=3x^9-2x-6\) has at most three zeros because \(h'(x)=27x^8-2=0\) has two roots. Check dif;3*x^9-2*x-6;x ||.
(4) The function \(w(x)=\tan x+x^3+x\) has exact one zero in \((-\frac{\pi}{2},\frac{\pi}{2})\) because \(f(0)=0\) and \(f'(x)=\sec^2x+3x^2+1 > 0\) by dif;tan(x)+x^3+x;x ||.
2 Differentials and Linearization
Slopes, Rates of Change, Equations of Tangent Lines: [dif; f(x); x; 1; rt; c], [dif(f(x), x, 1, rt, c)]
Differentials If \(y=f(x)\) is differentiable, \(dy=f'(x)dx\) is called differential. Note that \(dy\) is not \(Δy\). It encodes how the variation of \(y\) is related to the variation of \(x\), and can be used to approximate \(Δy\) by \(Δy≈f'(x)Δx\).
Slopes of tangent lines Use "dif; f(x); x; 1; rt; c" to find the slope of a tangent line to a curve f(x) at a fixed point x = c by "dif" operation. Set the order n = 1 (for first derivative), followed by the keyword "rt" (rate), and the value "c" that the variable "x" takes.
Examples
(1) dif;tan(x)^2;x;1;rt;pi/4 || gives the slope = 4 of the tangent line to \(y = \tan^2(x)\) at \(x = \frac{π}{4}\).
(2) dif;x^(2/3);x;1;tn;27 || dif;a^(1/2);a;1;rt;9 || dif;x^(1/3);x;1;rt;0 || dif;x^2-3;x;1;tn;2 || dif;s/(1+s^2)^(1/2);s;1;tn;-1 || dif;x*exp(x);x;1;tn;-2 ||.
Examples
(1) The angle \(θ\) of the tangent line to \(4x^3 - 5x^2\) at \(x\) = 1 with the x-axis is \(\tan(θ) = 2 ⇒
θ\) = atan(2) because the slope is 2 is by dif;4*x^3-5*x^2;x;1;rt;1 || dif(4*x^3-5*x^2,x,1,rt,1) ||.
(2) To find the angle \(θ\)
of intersection between two lines \(y = ax + b\) and \(y = cx + d\), we have the slopes \(a = \tan(θ_1)\) and \(c = \tan(θ_2)\), where the
angle of inclination \(θ_1\) or \(θ_2\) is the line making with x-axis. So \(θ = θ_2 - θ_1\) and \(\tan(θ) = \tan(θ_2 - θ_1) = \frac{c - a}{1 + ca}\). As a result, \(θ\) = atan\(\frac{c - a}{1 + ca}\). Find the angle between \(y = x - 4\) and \(y = 2 - 0.5x\) by atan[1-(-0.5)/(1-0.5)] = atan(3), which is about 1.107 radian or 63.47°.
Equations of tangent lines: [dif; f(x); x; 1; tn; c], [dif(f(x), x, 1, tn, c)]
To find the equation of a tangent line to a curve f(x) at a given point x = c, you need to evaluate the slope at the point, and express the equation in point-slope form.
Use "dif; f(x); x 1; tn; c" to get the equation directly by setting the order n = 1, keyword "tn" (tangent) a particular number c (tangency point). If the
number is not in the domain of the derivative function f'(x), the output may involve complex numbers.
Examples
(1) Find the tangent line to \(0.2(x - 2)^2(x+3)\) at \(x\) = 0 by dif;(x-2)^2*(x+3)/5;x;1;tn;0 ||. Or obtain the
slope = -1.6 first by dif;(x-2)^2*(x+3)/5;x;1;rt;0 ||, the tangency point (0, 12/5), and point-slope form \(y = -1.6x + 2.4\).
(2) Find the
equation of the tangent line to the curve \(y=\sqrt{2x^2+1}\) at \(x=2\) by dif;(2*x^2+1)^(1/2);x;1;tn;2 || or by dif((2*x^2+1)^(1/2),x,1,tn,2) ||.
Examples Find the point on the graph \(x^5-3x+4\) whose tangent line also passes through a point (1, 1). Let the point be \((a,b)\). Then \(b=a^5-3a+4\) and the slope satisfies \(5a^4-3=\frac{b-1}{a-1}⇒5a^4-3=\frac{a^5-3a+3}{a-1}\). Solve the equation by slv;(5*a^4-3)*(a-1)-(a^5-3*a+3);a || for \(a = 0, a = 5/4\), and \(b = 4, b = 4405/1024\).
Graph tangent lines: [plt; f(x); px + q; pt = (a, b)]
Once the equation of a tangent line y = px + q is available, graph the curve f(x), tangent line and the tangency point (a, b) using the code
pattern "plt; f(x); px + q; pt=(a,b)".
Examples
(1) Plot the tangent line \(y = 4x - 7\) to the curve \(y = x^2 - 3\) at point (2, 1) by plt;x^2-3;4*x-7;pt=(2,1) ||.
(2) Plot the tangent line to the curve \(y=\sqrt{2x^2+1}\) at \(x=2\) by plt;(2*x^2+1)^(1/2);4*x/3+1/3;pt=(2,3) ||.
Differentials and Linear Approximation: [dif; f(x); x; 1; df; c; dx], [dif(f(x), x, 1, df, c, dx)]
Local linearity The curve of a differentiable function is smooth or is locally linear at a point means it looks nearly linear over small intervals of the point. If y = g(x) is locally linear at x = a, its graph looks more and more like a straight line as we zoom in on that point (a, g(a)). The linearization of y = g(x) at x = a results a linear function, which is based on the assumption of local linearity.
Differentials Let y = g(x) be differentiable at x = a and Δx is a small change (or increment) of x near x = a. The change of y is Δy = g(a + Δx) - g(a) ≈ g'(a)Δx, which means the change of y (or Δy) is directly proportional to the (change of x (or Δx) to a small error.
Let the differential dx = Δx. Then the approximation Δy ≈ g'(a)Δx = g'(a)dx = dy. Simply put, Δy ≈ dy implies the change of y can be approximated by the differential dy. Or the differential dy represents the principal part of the change of y with respect to the change of x, and dy = g'(x)dx is a function of both x and dx.
Linearization Let x = a + Δx. Then we have Δy = g(x) - g(a) ≈ g'(a)(x - a) ⇒ g(x) ≈ g(a) + g'(a)(x - a) for Δx very small. Thus, the function y = g(x) can be approximated by a linear function (its tangent line) near the point (a, g(a)) for x very close to x = a. This is called linearization or linear approximation. The further x is apart from x = a, the less accurate is the approximation. In fact, Δy = g'(a)Δx + εΔx, and as Δx → 0, the error εΔx → 0.
The absolute error in linear approximation is E = |Δy - g'(a)Δx|, and the relative error (percentage) is |Δy/y| × 100%. In general, the error bound is E ≤ \(\frac{1}{2}\)KΔx², where K is the maximum value of |g''(x)| for x between a and a + Δx.
Use "dif; f(x); x; 1; df; c; dx" or "dif(f(x), x, 1, df, c, dx)" approximates f(x) at x close to c, where "df" means differential, "c" is an anchor value (tangent point at x = c) that "x" is close to, and "dx" the small change Δx (or increment). Notice that "dif(f(x), x, 1, df, c, dx)" gives approximation of f(c + dx).
Examples
(1) If the radius of a ball is measured with at most 2% errors, then the percentage error of the volume is at most 6% because
V = 4πr³/3, ΔV ≈ 4πr²dr, and ΔV/V ≈ 3dr/r = 3(2%) = 6%.
(2) If the radius r = 9 cm with a possible
error 0.1 cm, the possible error of the volume is 32.4π cm³ by ΔV ≈ 4π²dr by 4*pi*9^2*0.1 || or by
dif;4*pi*r^3/3;r;1;df;9;0.1 || or dif(4*pi*r^3/3,r,1,df,9,0.1) ||.
To estimate an irrational number by linear approximation, you need to specify the function f(x), the number x = c, calculate the increment dx, and then apply the "dif(f(x), x, 1, df, c, dx)" module to get the approximation.
Examples
(1) Estimate \(\sqrt{37}\). Let \(g(x)=\sqrt{x},x=37,a=36,dx=x-a=37-36, g'(x)=\frac{1}{2\sqrt{x}}, g'(36)=\frac{1}{12}\).
Then by linearization, calculate \(\sqrt{37}≈g(36)+g'(36)dx\) by dif;x^(1/2);x;1;df;36;1 || dif(x^(1/2),x,1,df,36,1) ||.
(2) Estimate
sin(1) by dif;sin(x);x;1;df;0;0.1 || dif(sin(x),x,1,df,0,0.1) ||.
(3) Estimate \(\sqrt[3]{25.8^2}\) by dif;x^(2/3);x;1;df;27;-1.2 ||.
(4) Estimate e0.1 by dif;exp(x);x;1;df;0;0.1 ||.
(5) Estimate tan(π/4-0.05) by dif;tan(x);x;1;df;pi/4;-0.05 ||.
(6) Estimate cos(59°) by dif;cos(x);x;1;df;pi/3;-pi/180 ||.
(7) Estimate sin³(π/4 + 0.03) by dif;sin(x)^3;x;1;df;pi/4;0.03 ||.
(8) Estimate sec(58°) by dif;sec(x);x;1;df;pi/3;-pi/90 ||.
Newton's method is an iterative process for finding numerical approximation to roots of functions. Suppose a function \(f\) has a zero \(r\). To find \(r\) by Newton's method, first choose an initial guess \(x_0\) that is close to \(r\), and find the tangent line \( y=f(x_0)+f'(x_0)(x-x_0)\) passing through the point \((x_0, f(x_0))\). Solve the x-intercept of the tangent line for \(x=x_1=x_0-\frac{f(x_0)}{f'(x_0)}\), and treat \(x=x_1\) as the first improved approximation to \(r\).
In the second iteration, find the tangent line \(y=f(x_1)+f'(x_1)(x-x_1)\) passing through the point \((x_1,f(x_1))\), solve the x-intercept of the tangent line for \(x_2=x_1-\frac{f(x_1)}{f'(x_1)}\), and regard \(x=x_2\) as the second approximation to \(r\).
If we continue this process, we will produce a sequence \(x_0, x_1,x_2,\cdots\) of successive approximation until it converges to the root \(r\).
Note that if \(f\) does not have a zero, the sequence \(x_n\) diverges. If \(x_{n+1}=x_n,f(x_n)=0\) and \(x_n\) is a zero of \(f\). Thus, if an initial guess \(x_0\) is chosen such that \(f(x_0)=0\), the iteration process stops at the beginning.
If \(x_n\) is a critical point so that \(f'(x_n)=0\) or \(f'(x_n)\) is undefined, then Newton's method fails. In case \(f\) has multiple zeros, solve each root one at a time and choose an initial value that is close to the corresponding root.
For an explicit function y = f(x), use "slv" to find the zeros of the function. Or use "plt" to graph the function, spot the x-intercepts (if any) and the zeros.
Examples
(1) The two zeros of 2x² - 9.6x + 8.64 from the graph plt;2*x^2-9.6*x+8.64 || are about x = 1.2 and x = 3.6. Check them by slv;2*x^2-9.6*x+8.64;x ||.
(2) The zeros of 2x³ + 5.4x² - 3.78x - 13.23 by plt;2*x^3+5.4*x^2-3.78*x-13.23 || slv;2*x^3+5.4*x^2-3.78*x-13.23;x ||.
Newton's method may be useful for implicit functions of the form F(x, y) = 0, where y is difficult or impossible to be expressed explicitly as a function of x. In this case, use "imf" module to sketch their graphs and view the x-intercepts. Or substitute y = 0 and solve the equation for x by "slv" module.
Examples
(1) Plot (x-1)² + (y - 2)² = 9 by imf;(x-1)^2+(y-2)^2-9 ||. The two x-intercepts are about x = -1.236 and x = 3.236. Or solve (x-1)² = 5 by slv;(x-1)^2-5;x ||.
(2) If y² + 3x = x³ + 1, find roots by imf;x^3-3*x+1-y^2 || slv;x^3-3*x+1;x ||.
(3) If 2x² + 3xy + 2y² = 16, find roots by imf;2*x^2+3*x*y+2*y^2-16 || slv;2*x^2-16;x ||.
3 Monotonicity, Concavity, and Extreme Values
Monotonicity and Concavity: [dif; f(x); x; 1; ic/dc/cp], [dif(f(x), x, 1, ic/dc/cp)]
Increasing and decreasing functions, critical points Let g be differentiable on an open interval \(I\). If g'(x) > 0 for x ∈ \(I\), then g is increasing on \(I\); if g'(x) < 0, then g is decreasing on \(I\). A number c in the domain of g is called a critical number if g'(c) = 0 or g'(c) does not exist.
We can find the interval on which g is increasing, which is decreasing, and find all critical numbers of g by first differentiating g(x), and then solving the inequality g'(x) > 0 or g'(x) < 0, or the equation g'(c) = 0, respectively.
The code pattern "dif; f(x); x; 1; ic/dc/cp" or "dif(f(x), x, 1, ic/dc/cp)" can help find the interval on which a function f(x) is increasing "ic", decreasing "dc", and all possible critical points "cp" by setting the order n = 1, and choosing a corresponding keyword.
Attention Use the combination "slv(dif(f(x), x), x)" for solving critical numbers of f(x), "slv(dif(f(x), x) > 0, x)" for finding the intervals where f(x) is increasing, "slv(dif(f(x), x) < 0, x)" for the intervals where f(x) decreasing. These patterns are similar to "dif; expr; var; 1; cp", "dif; expr; var; 1; ic" and "dif; f(x); x; 1; ic/dc/cp" or "dif(f(x), x, 1, ic/dc/cp)", respectively. The former set is conceptually appealing and easy to use.
Examples
(1) dif;x^2-x-12;x;1;ic || slv(dif(x^2-x-12,x)>0,x) || find the interval on which g(x) = x² - x - 12 is increasing.
(2) dif;x^3-8*x^2;x;1;dc || slv(dif(x^3-8*x^2,x)<0,x) || find the interval on which g(x) = x³ - 8x² is decreasing.
(3)
dif;x*(x-2)^3;x;1;cp || slv(dif(x*(x-2)^3,x),x) || give the set of critical numbers of g(x) = x(x-2)³.
(4)
dif;2*x-3;x;1;ic || dif;4-2*x;x;1;dc || dif;x+1/x;x;1;ic || slv(dif(2*x^3-3*x^2-36*x+6,x),x) ||.
Attention The set of critical numbers from "dif" module does not include the points where g'(c) does not exist.
Examples
(1) g(x) = |x² - 2x - 3| has a critical number x = 1 by dif;((x^2-2*x-3)^2)^(1/2);x;1;cp || because g'(x) =
(2x - 2)sign(x), where sign(x) = -1 for x < -1 and sign(x) = 1 for x > 3, but g'(3) and g'(-1) does not exist. Thus, x = -1 or x = 3 is also a critical
number of g(x) by definition. Or by dif(((x^2-2*x-3)^2)^(1/2),x,1,cp) || slv(dif(((x^2-2*x-3)^2)^(1/2),x),x) ||.
(2) The codes dif;(x-2)^(2/3);x;1;cp || find no critical number for g(x) = (x - 2)2/3, but x = 2 is a critical number since g'(2) is undefined.
Suppose g''(x) exists on an open interval \(I\). If g''(x) > 0 for x ∈ \(I\), then g is concave up on \(I\); if g''(x) < 0, then g is concave down on \(I\). If g''(c) = 0 or g''(c) does not exist for c ∈ \(I\) and g''(x) changes sign at x = c, then x = c is an inflection point.
Inflection points must satisfy the three conditions.
(1) Must be in the domain of g.
(2) g''(c) = 0 or
g''(c) does not exist.
(3) g''(x) changes sign on both sides of x = c.
If any one of the conditions fails, x = c is not an inflection point. The inflection points of g usually occur at the points where g'(x) has a local minimum or maximum.
Just as first derivatives for monotonicity and critical points, the pattern "dif; f(x); x; 2; ip/cu/cd" or "dif(f(x), x, 2, ip/cu/cd)" helps find inflection point(s) ("ip") of a function f(x), the interval(s) on which f(x) is concave up ("cu"), and on which f(x) concave down ("cd") by setting order n = 2, and choosing the correct keyword in the end.
Attention Similar to first derivatives, use the combination "slv(dif(f(x), x, 2), x)" for solving the inflection points of f(x), "slv(dif(f(x), x, 2) > 0, x)" for finding the intervals where f(x) is concave up, "slv(dif(f(x), x, 2) < 0, x)" for the intervals where f(x) concave down. These patterns are similar to "dif; expr; var; 2; ip", "dif; expr; var; 2; cu" and "dif; expr; var; 2; cd", respectively. The former set is conceptually appealing and easy to understand.
Examples
(1) Find the inflection point(s) of the logistic growth curve \(y=\frac{L}{1+Ae^{-kt}}\) for some positive constants
\(A, L, k\) by dif;L/(1+A*exp(-k*t));t;2;ip ||, which is \(t=\frac{\ln A}{k}\) and \(y=\frac{L}{2}\) by L/(1+A*exp(-k*log(A)/k)) ||.
This implies if \(t<\frac{\ln A}{k}\) or before the population reaches a half limit, the growth rate is increasing (concave up), and after a half limit the
growth rate is decreasing (concave down).
(2) dif;x^2-5*x+7;x;2;cu || dif;x-x^3;x;2;cd || dif;u/(1+u^2);u;2;cu ||
dif;cosh(t);t;2;cu || dif;s^2*exp(-s);s;2;ip || dif(cosh(t),t,2,cu) || dif(s^2*exp(-s),s,2,ip) || dif(x-x^3,x,2,cd) ||.
(3) slv(dif(x-x^3,x,2)<0,x) || slv(dif(u/(1+u^2),u,2)>0,u) || slv(dif(cosh(t),t,2)>0,t) ||
slv(dif(s^2*exp(-s),s,2),s) ||.
Extreme Values and Optimization Problems
Minimum and maximum values If g is defined on an interval \(I\), g(c) is an absolute minimum if g(x) ≥ g(c) for all x ∈ \(I\), and g(c) is an absolute maximum if g(x) ≤ g(c) for all x ∈ \(I\).
The value g(c) is a local minimum of g if g(x) ≥ g(c) for all x in some open interval containing c, and g(c) is a local maximum of g if g(x) ≤ g(c) for all x in some open interval containing c.
Fermat's theorem states that local minimum and maximum occur at critical points. So to find extreme values, we need to first locate all critical points, and then determine which one leads to a local minimum, which one leads to a local maximum, or neither, by use of the first or second derivative test.
First derivative test If g'(c) = 0, g(c) is a local minimum if g'(x) changes sign from + to - at the left and right sides of x = c; g(c) is a local maximum if g'(x) changes sign from - to + at the left and right sides of x = c. If g'(x) does not change sign at both sides of x = c, then the first derivative test fails. In this case, we need to use the second derivative test.
Second derivative test If g'(c) = 0 and g''(c) > 0, then g(c) is a local minimum; if g'(c) = 0 and g''(c) < 0, then g(c) is a local maximum; if g''(c) = 0, the second derivative test is inconclusive. Then we need to use the first derivative test.
Absolute minimum and maximum for continuous function on closed intervals If g is continuous on [a, b], g has both absolute minimum and maximum values. To find these values, obtain a list of all critical numbers {c1, c2, ...} of g in [a, b], and calculate g(x) for x in this list as well as the endpoints g(a) and g(b). The largest and smallest values correspond to the absolute maximum and minimum. Be aware that absolute extreme values of continuous functions on closed intervals are guaranteed, and the procedure for finding these values does not involve any derivative test.
Examples
(1) To find the absolute extrema of g(x) = 2x³ + 3x² - 12x on [0, 2], get critical numbers x = {-2, 1} by dif;2*x^3+3*x^2-12*x;x;1;cp ||. Since -2 is not in the interval, we only calculate g(1) = -7, g(0) = 0, and g(2) = 4 for x = {1, 0, 2}. Thus, g(1) = -7 is the absolute minimum and g(2) = 4 is the absolute maximum. Use its graph plt;2*x^3+3*x^2-12*x;itv=(0,2) || to verify it.
(2) To find absolute extrema of y = \(\sqrt{|2x-1|}\) on [0, 1], you get no critical numbers by dif;((2*x-1)^2)^(1/4);x;1;cp ||. Note that y is not differentiable at x = 1/2, so it is the only critical number. Calculate y(0) = 1, y(1/2) = 0, and y(1) = 1, so the absolute maximum is 1 minimum 0.
Extreme values on open and infinite intervals Functions defined on open/infinite intervals may or may not have extreme values, and finding extreme values on open intervals is more complicated than on closed intervals.
Since extreme values are not guaranteed for functions on open/infinite intervals (a, b), we follow standard procedures to first locate all critical points of a function, test and evaluate each of them, and check the limiting behaviors of the function as x approaches a+ and b-. Note that the endpoints a, b can be infinity.
Infinite intervals Suppose g is defined on an infinite interval (-\(\infty, \infty\)). If g(x) → \(\infty\) as x → ±\(\infty\), then g(x) has an absolute minimum; if g(x) → -\(\infty\) as x → ±\(\infty\), then g(x) has an absolute maximum.
Open intervals Let g be defined on an finite open interval (a, b) for a < b. If g(x) → \(\infty\) as x → a+ and x → b-, then g(x) has an absolute minimum; if g(x) → -\(\infty\) as x → a+ and x → b-, then g(x) has an absolute maximum.
Examples
(1) y = x(x + 5)³ has absolute minimum since as x → ±\(\infty\), y → \(\infty\).
(2)
The function y = (3 - 2x)³(x - 5)² has absolute maximum since x → ±\(\infty\), y → -\(\infty\).
(3) y =
(x - 1)/(x + 2) has no absolute maximum and minimum because as x → \(\infty\), y → \(\infty\) and x → -\(\infty\), y → -\(\infty\).
It has horizontal asymptote y = 1.
(4) The function (x² - 4)³ has absolute minimum since x → ±\(\infty\), y → -\(\infty\).
Half open intervals Absolute extrema may exist on a half open interval \([a, b)\) or \((a, b]\). To find them, we need to locate all critical points of \(f\) on the interval and evaluate and test each of them. In addition, if \(f\) is continuous on \([a,b)\), also calculate \(f(a)\) as well as the limit \(\displaystyle \lim_{x\to b^-}f(x)\), and then compare all these values to determine which one is absolute minimum or maximum. If \(f\) is continuous on \((a,b]\), calculate \(f(b)\) and \(\displaystyle \lim_{x\to a^+}f(x)\) and determine which is the absolute minimum or maximum.
Use "dif" module to determine the relative/absolute extreme values of a function y = g(x) by these procedure:
(1) Locate all possible critical numbers by keyword "cp".
(2) Do second derivative test by checking whether a critical number is in an interval on which g(x) is concave up by keyword "cu" or down by keyword "cd". If a critical number x = c is in an interval where g(x) is concave up, then g''(c) > 0 and g(c) is a relative minimum. If x = c falls in an interval where g(x) is concave down, then g''(c) < 0 and g(c) is a relative maximum.
(3) Do the first derivative test to see if a critical number falls in an interval on which g(x) is increasing or decreasing by keywords "ic" and "dc".
(4) If (2) and (3) both fail, do derivative test manually.
(5) Calculate function values at critical numbers and endpoints (if any), and compare them to determine relative and absolute extreme values. Keep in mind that you need to verify if there is any critical number whose derivative is undefined.
Examples
(1) Determine extreme values of g\((x)=\frac{x^2}{x-2}\). Locate critical numbers x= {0, 4} by dif;x^2/(x-2);x;1;cp ||. Note that g'(2) is undefined, but 2 is not in the domain of g. The second derivative test by dif;x^2/(x-2);x;2;cu || dif;x^2/(x-2);x;2;cd || indicates g is concave up on (2, \(\infty\)) and down on (-\(\infty\), 2), which implies g''(4) > 0, g''(0) < 0, so g(4) = 8 is a relative minimum and g(0) = 0 is a local maximum. The first derivative test by dif;x^2/(x-2);x;1;ic || dif;x^2/(x-2);x;1;dc || tells g(x) is increasing on x < 0 and x > 4, which implies g'(0) changes sign from + to - and g'(4) changes sign from - to +. You may confirm these results using the graph of g by plt;x^2/(x-2) ||.
(2) The critical numbers of y = x(x-3)³ are x = {3/4, 3} by dif;x*(x-3)^3;x;1;cp ||. The first derivative test by dif;x*(x-3)^3;x;1;ic || dif;x*(x-3)^3;x;1;dc || or second derivative test by dif;x*(x-3)^3;x;2;cu || dif;x*(x-3)^3;x;2;cd || (3/4)*(3/4-3)^3 || shows (3/4, -2187/256) is a local/global minimum, and (3, 0) is an inflection point. Confirm the results by plt;x*(x-3)^3 ||. Note that x → ±\(\infty\), y → \(\infty\) and y(3/4) is the absolute minimum, which is 3*(3/4-3)^3/4 ||.
(3) dif;cos(x)+x;x;1;cp || dif;cos(x)+x;x;1;ic || plt;cos(x)+x || show y = cos(x) + x has no extreme value, and the critical points are inflection points.
4 Application of Differentiation
Rectilinear Motion
Rectilinear motion A particle moves along a straight line in either direction is said to be in rectilinear motion. We usually choose a coordinate line or s-axis (just as a number line with designated positive direction) as the frame of reference to analyze linear motion. With this reference frame, the coordinate s = s(t), which is a function of time t, represents the position (function) of the particle at time t.
If s(t) > 0, the particle is at the positive side of the s-axis; if s(t) < 0, the particle is at the negative side. If s(t1) is the position at time t1, and s(t2) at time t2, then s(t2) - s(t1) is the displacement of the particle over the time interval [t1, t2], and |s(t2) - s(t1)| is the distance traveled by the particle over this time period. Displacement represents the change in position with respect to change in time.
The first derivative s'(t) = v(t) is the particle's velocity at time t, and the second derivative s''(t) = a(t) = v'(t) is the acceleration at time t. The speed |v(t)| is the magnitude of velocity at t.
If v(t) > 0, the particle moves toward the positive direction; if v(t) < 0, the particle moves toward the negative direction. If v(t) = 0, the particle is momentarily at rest or stops.
If a(t) > 0, the particle accelerates to the positive direction; if a(t) < 0, the particle accelerates to the negative direction. If a(t) = 0, the particle is neither speeding up nor slowing down, and it's instantaneous acceleration is 0.
The particle is speeding up if its velocity and acceleration have the same sign, and is slowing down if they have opposite signs. If v(t) = 0 for t in a time interval, then the particle is at rest during this period of time.
Examples Suppose an object in a linear motion with position s(t) = t³ - t² + 3t.
(1) The velocity is by dif;t^3-t^2+3*t;t ||,
the object moves to the right and never changes direction by slv;3*t^2-2*t+3>0;t ||, and is always at the right side by slv;t^3-t^2+3*t>0;t ||.
(2) Find the position s(2.5) at t = 2.5 by 2.5^3-2.5^2+3*2.5 ||; find the velocity v(3) at t = 3 by dif;t^3-t^2+3*t;t;1;rt;3 ||.
(3) Find the acceleration a(4.5) at t = 4.5 by dif;t^3-t^2+3*t;t;2 ||, and find the distance traveled from t = 2 to 4 by s(6.5)
- s(3.5) by 6.5^3-6.5^2+3*6.5-(3.5^3-3.5^2+3*3.5) ||.
Examples Suppose an object in linear motion has position s(t) = 2t³ - 21t² + 60t - 12.
(1) Its velocity and acceleration are by dif;2*t^3-21*t^2+60*t-12;t || dif;2*t^3-21*t^2+60*t-12;t;2 ||.
(2) Solve v(t) > 0, and you get when the object moves to the right by
slv;6*t^2-42*t+60>0;t || for t < 2 and t > 5. Solve v(t) < 0, and you find when the object moves to the left by slv;6*t^2-42*t+60< 0;t ||
for 2 < t < 5. Thus, the object changes direction at t = 2 from right to left and t = 5 from left to right.
(3) Find when the object speeds up
by solving a(t) > 0 and a(t) < 0 by slv;12*t-42>0;t || slv;12*t-42<0;t || and compare the sign of a(t) and v(t). So the object speeds up
for t > 5 or 2 < t < 3.5, and slows down for t < 2 and 3.5 < t < 5.
(4) Find the displacement s(5) - s(0) = 25 from t = 0 to t =
5 by 2*5^3-21*5^2+60*5-12-(-12) ||. Find the distance traveled by the object |s(5) - s(0)| = s(2) - s(0) - [s(5) - s(2)] = 79.
Examples The position of free fall of an object is s(t) = s0 + v0t - \(\frac{1}{2}\)gt²
where s0 = s(0) is initial position, v0 = v(0) is initial velocity, and g = 9.8 m/s² or 32 ft/s² is the acceleration due to
gravity.
(1) If an object is thrown straight up from the ground with v0 = 49 m/s, then s0 = 0, and s(t) = 49t - 4.9t².
(2) The object first (or second) reaches a height of 78.4. Solve 78.4 = 49t - 4.9t² by
slv;49*t-4.9*t^2-78.4;t || for t.
(3) Find the velocity v(t) = s'(t) by dif;49*t-4.9*t^2;t ||, when the object reach the maximum height
by solving v(t) = 0 or slv;49-9.8*t;t ||, the velocity v(6) at t = 6 by 49-9.8*6 ||, and find the height s(7) at t = 7 by 49*7-4.9*7^2 ||.
(4)
Find when the object hits the ground by solving 49t - 4.9t² = 0 by slv;49*t-4.9*t^2;t ||, and the velocity at the moment object hits the ground
by 49-9.8*10 || or dif;49*t-4.9*t^2;t;1;rt;10 ||.
For free fall motion, in general, if an object is shot straight up with v0, it reaches maximum height s(t) = v0²/2g at t = v0/g, and hits the ground with velocity v(t) = -v0 at t = 2v0/g.
Examples
(1) The initial velocity required for an object shooting straight up from ground to hits ground in 2 seconds is
v0 = g.
(2) The initial velocity required to reach a maximum height of 50 m is by solving v0²/2g = 50 by slv;v^2/(2*9.8)-50;v || or (2*9.8*50)^(1/2) ||.
Related Rates
Related rates: [dif; f(x(t), y(t), z(t)); t; x], [dif; f(x(t), y(t), z(t)); t; y], [dif;f(x(t), y(t), z(t)); t; z]
Suppose two (or more) variables x and y are functions of another variable t (usually time) for x = f(t) and y = g(t), and they are related in an equation h(x, y) = 0. Differentiating this equation implicitly with respect to t, we have the rates of change x'(t) and y'(t), which are called related rates, in the resulting differential equation. To solve related-rates problems is usually to find an unknown rate of change (probably inconvenient to measure) from the known rates of change and other necessary known values and constants.
Use the "dif" module for implicit differentiation to find related rates for two or more functions. For instance, the code pattern "dif; f(x(t), y(t)); t; y" tells how the rate y'(t) is related to x'(t). Be sure to write x as x(t) and y as y(t), because they are functions of t.
General procedure for solving related rates problems
(1) Find the equation(s) that relate variables for unknown
rates of change to known rates of change.
(2) Differentiate both sides of the equation(s) implicitly by chain rule.
(3) Solve for the
unknown rate of change (or derivatives) using known rates and constants Note that Pythagorean theorem and properties of similar triangles are often used for related-rates problems.
Examples Suppose a particle moves along the curve y = x³ - 2x² + 2x - 4.
(1) At a certain time t when x = 2.5, if the x-coordinate is increasing at a rate of 1.5 ft/s, find y'(t). The y-coordinate is change 16.125 ft/s, or y'(t) = 16.125 because y'(t) = (3x² - 4x + 2)x'(t), x'(t) = 1.5, and x = 2.5. Check the related rates by dif;y(t)-x(t)^3+2*x(t)^2-2*x(t)+4;t;y ||.
(2) Find the points where x- and y-coordinates are changing at the same rate. Since x'(t) = 1.5, y'(t) = x'(t) ⇒ 3x² - 4x + 2 = 1, and solve the equation for x = 1, 1/3 by slv;3*x^2-4*x+1;x || (1/3)^3-2*(1/3)^2+2/3-4 ||, you get x = 1, 1/3. Thus, at points (1, -3) and (1/3, -95/27), the x- and y-coordinates of the particle are changing at the same rate.
Examples If the radius of a sphere is increasing at 4 cm/s, how fast is the volume changing when the surface area is 16 cm²? (1) Find the equation V = 4πr³/3 that relates the variables V and r. (2) Differentiate both side V'(t) = 4πr²r'(t). Check dif;V(t)-4*pi*r(t)^3/3;t;V ||. (3) Solve unknown rate V'(t) = 16(4) = 64 cm³/s given r'(t) = 4 cm/s and 4πr².
Examples If a ladder 20 feet long leans against a wall, find the rate the ladder top is moving downward if the ladder bottom is 10 feet away from the wall and sliding along the ground away from the wall at a rate of 3 ft/s. (1) By Pythagorean theorem x² + y² = 20², where x represents the distance from ladder bottom to the base of the wall, y the distance from ladder top to the base of wall. (2) Differentiate 2xx'(t) + 2yy'(t) = 0. Check dif;x(t)^2+y(t)^2-20;t;y ||. (3) Solve for y'(t) = -xx'(t)/y. Given x = 10, y = (20^2-10^2)^(1/2) and x'(t) = 3, so y'(t) = -\(\sqrt{3}\) ft/s.
Marginal Analysis
Maximize profit To maximize profit, differentiate the profit function \(P(x)\), and find all possible critical points. If the equation \(P'(x)=R'(x)-C'(x)=0\) or \(R'(x)=C'(x)\) has a solution, we arrive at a basic principle in economics: The maximum profit must occur at a production level where its marginal revenue is equal to its marginal cost.
Maximize average revenue If \(R''(x)< 0\), then the average revenue \(\bar{R}(x)\) is maximized at the level \(x\) such that \(R'(x)=\bar{R}(x)\). Since \(\bar{R}(x)=\frac{R(x)}{x},\bar{R}'(x)=\frac{xR'(x)-R(x)}{x^2}=0⇒xR'(x)-R(x)=0⇒R'(x)=\bar{R}(x)\). By the second derivative test, if \(R''(x)< 0\), the average revenue is maximized.
Minimize average cost If \(C''(x)>0\), then the average cost \(\bar{C}(x)\) is minimized at the level \(x\) such that \(C'(x)=\bar{C}(x)\). Since \(\bar{C}(x)=\frac{C(x)}{x},\bar{C}'(x)=\frac{xC'(x)-C(x)}{x^2}=0⇒xC'(x)-C(x)=0⇒C'(x)=\bar{C}(x)\). By the second derivative test, if \(C''(x)> 0\), the average cost is minimized.
L'hopital's Rule
Indeterminate form Indeterminate form of \(\frac{0}{0},\frac{\pm\infty}{\pm\infty},0^0,\infty-\infty,0\cdot\infty,\infty^0, 1^{\infty}\) is a type of function form that is difficult to determine its limit by direct substitution. For example, if both numerator and denominator of a rational function approach 0, direct substitution results in a form of \(\frac{0}{0}\), which is difficult to determine whether its limit exists. Note that \(\infty+\infty=\infty,-\infty-\infty=-\infty,\infty\cdot\infty=\infty,-\infty\cdot \infty=-\infty,\infty^{\infty}=\infty\), and these are not indeterminate forms.
L'hopital's rule Let \(f\) and \(g\) be both differentiable functions on an open interval containing \(a\) and \(f(a)=g(a)=0\). Assume \(g'(x)\ne 0\) (except possibly at \(a\)). Then \(\displaystyle\lim_{x\to a}\frac{f(x)}{g(x)}=\lim_{x\to a}\frac{f'(x)}{g'(x)}\) if the limit exists, or is either \(\infty\) or \(-\infty\). L'hopital's rule is a result of Cauchy's mean value theorem, and \(x\to a\) can be replaced by \(x\to a^+, x\to a^-\) or \(x\to \pm\infty\).
L'hopital's rule provides a very useful tool for computing limits of functions with indeterminate forms that are otherwise difficult to evaluate. L'hopital's rule says under certain conditions the ratio of two functions approaches the same limit as the ratio of their corresponding derivatives (rates of change). L'hopital's rule applies to limits at a finite number, limits at infinity, and one-sided limits as well.
Examples \(\displaystyle\lim_{x\to \infty}\frac{x^n}{e^x}\) = 0 after nth derivative by L'hopital's rule and check lim;x^n/exp(x);x;oo ||.
Examples \(\displaystyle\lim_{x\to 0}\frac{\sin6x}{\sin3x}=\lim_{x\to 0}\frac{6\cos6x}{3\cos3x}\) = 2 and lim;sin(6*x)/sin(3*x);x;0 ||.
Examples \(\displaystyle\lim_{x\to 0^+}x\ln x=\lim_{x\to 0^+}\frac{\ln x}{1/x}=\lim_{x\to 0^+}\frac{1/x}{-1/x^2}=-\lim_{x\to 0^+} x=0\) by lim;x*log(x);x;0;p ||.
Examples \(\displaystyle\lim_{x\to 1}\frac{x^7-1}{x^5-1}=\lim_{x\to 1}\frac{7x^6}{5x^4}=\frac{7}{5}\) by lim;(x^7-1)/(x^5-1);x;1 ||.
Examples || lim;(x^5-1)/(x^3-1);x;1 || lim;x^x;x;0;p || lim;x^(1/x);x;oo || lim;(2^x-3^x)/x;x;0 || lim;sin(1/x)^x;x;oo || lim;cos(1/x)^x;x;oo ||.
5 Curve Sketching
Curve sketching Although the "plt" module or other computer programs allow you to graph a function by simply typing its formula, it is important to learn how to graph a function by hand, and understand the basic structures, terms, and geometric features of various function graphs.
Curve types There are four basic curve types. Suppose g is a differentiable function.
increasing and concave up g'(x) > 0 and g''(x) > 0; both g(x) and g'(x) are increasing. Check g(x) = ex by plt;exp(x) ||.
decreasing and concave down g'(x) < 0 and g''(x) < 0; both g(x) and g'(x) are decreasing. Check plt;1/x || for x < 0.
increasing and concave down g'(x) > 0 and g''(x) < 0; g(x) increasing; g'(x) decreasing. || plt;log(x) || plt;x^(1/2) ||.
decreasing and concave up g'(x) < 0 and g''(x) > 0; g(x) decreasing; g'(x) increasing. Check plt;exp(-x) ||.
A function may have one or more than one curve types. Curves changing their types from one to another involve transition (or turning) points. Critical points are turning points for curves changing from increasing type to decreasing or from decreasing to increasing. Inflections points are turning points for curves changing types from concave up to down or from down to up.
Examples
(1) If g(2) = - 3, g'(2) = 0 and g''(x) > 0 for all x, then g(2) = -3 is the absolute minimum and the curve is always concave up, decreasing for x < 2 and increasing for x > 2.
(2) Suppose h(0) = 0 and h''(x) > 0 for all x < 0 and h''(x) < 0 for all x > 0, and h'(x) → \(\infty\) as x → 0. Then (0, 0) is an inflection point since the curve changes concavity and has a vertical tangent line at (0, 0).
(3) Suppose u(2) = 2, u''(x) < 0 for all x ≠ 2, and u'(x) → -\(\infty\) as x → 2- and u'(x) → \(\infty\) as x → 2+. Then the curve has a cusp at the point (2, 2). It is not an inflection point since the curve does not change its concavity.
Examples
(1) The graph of (x + 2)² by plt;(x+2)^2 || is decreasing from left to -2 and then increasing after -2, so x = -2 is a critical number leading to the absolute minimum, and the curve is always concave up.
(2) The curve (x - 4)³ by plt;(x-4)^3 || is increasing, but it changes its concavity at x = 4 from concave down to up. So its inflection point is at x = 4.
(3) The graph of y = |x + 1| by plt;abs(x+1) || is never concave up nor down. It does not bend because it includes two straight lines and y'' = 0. It is decreasing for x < -1 and increasing for x > -1. So x = -1 is a critical number leading to the absolute minimum.
(4) The graph (x - 2)2/3 by imf;(x-2)^2-y^3 || is concave down all the time. It is decreasing for x < 2 and increasing for x > 2. Thus, x = 2 is a critical number leading to the absolute minimum.
Asymptotes Some functions, in particular rational functions, have horizontal, vertical, and slant asymptotes to their curves. Not every function has all these asymptotes. Some functions (polynomials) do not have any asymptote, but some (e.g., tan(x)) have infinitely many asymptotes. In graph sketching, horizontal asymptotes describe a function's end behaviors at infinity, and vertical asymptotes describe possible infinite limits at some finite numbers.
Examples
(1) The line x = 2 is a vertical asymptote to the graph y = 1/(x - 2), since as x → 2+, y → \(\infty\) and as x → 2-, y → -\(\infty\).
(2) The line y = 0 is a horizontal asymptote to the graph as x →±\(\infty\), y → 0.
(3) The graph of y = tan-1(x) has two horizontal lines y = π/2 and y = -π/2 by plt;atan(x) ||.
Summary of curve sketching Basic procedure for plotting g(x) is summarized in the table with an example.
(1)
Check its domain (a, b), possible range, and any symmetry axes the curve may have (x-axis, y-axis, or any other symmetry axes, origin).
(2) Find
the critical numbers x = {c1, c2} and inflection points x = p, for example.
(3) Determine the intervals on which g(x) is
increasing/decreasing and the intervals on which g is concave up/down, and then identify the corresponding curve types on such intervals.
(4) Connect all the curves, the turning points of extreme values, the inflection points, or the x- and y-intercepts.
(5) Check if there is any asymptotes to form the graph.
Examples g(x) = x + 1/(x - 1)
\(\begin{array}{c|ccc}\hline \text{ domain}&(-∞, 1)∪(1, ∞)\\ \text{ symmetry}
& NA\\ \text{ asymptote}&\text{vertical }x=1\\ \text{xy-intercept} &(0, -1)\\ \text{extreme value}&(0,-1)&(2, 3)\\
\hline x\text{ (interval)} &(-∞,0)&0&(0,1)∪(1,2)&2&(2,∞)\\ \hline g' \text{ sign}&+&0&-&0&+\\
\text{ monotonicity} &↗&\text{max}&↘&\text{min}&↗\\ \hline g''\text{ sign}&-& 1& +\\
\text{ concavity}& \text{down} &\text{IP}NA &\text{up}& \\ \hline \end{array}\).
Examples plt;x^3-2*x^2-4*x+5 || plt;x^2+1/x || plt;(x^2+2)/(x^2-4) || plt;x/(x^2-1) || plt;4*x^2/(x^2+3) || plt;x^5-4*x^3+1 || plt;0.5*x^4-2*x^2+2 || plt;2*x/(x^2+1)^(1/2) ||.
Part II Differentiation in Several Variables
Table of Contents: Part II
Back to top Part 1: Differentiation for Single Variable
1 Functions of Several Variables and Their Graphs
Functions of two variables have 3d surfaces. Use the code pattern "sf3; f(x,y)" to graph 3d surfaces for functions of two variables, where "sf3" (surface 3d) is the operation code, and "f(x,y)" is the function expression of two variables. The graphs have default intervals for both x and y.
If you want to plot the surfaces within particular intervals for x and y, add x1 and x2 for x interval and y1 and y2 for y interval to the end, so the code pattern should be "sf3; expr; x1; x2; y1; y2". Keep in mind that the function must be at most two variables. It can be a constant, or a function of one or two variables.
Examples In R³, the graph of a constant (e.g., z = 2) or a linear function of two variables (e.g., z = x - y) is a plane (horizontal or slant). Try these codes sf3;-2 || sf3;2*x || sf3;y-1 || sf3;x+y || sf3;2*x-3*y+1 || sf3;7 || sf3;-3*y || sf3;3*x-2 ||.
Examples Use "ps3" to plot vertical planes such as x = 1, y = 2, x = -3, y = -4, and other 3d surfaces for parametric equations. || ps3;1;y;z || ps3;x;2;z || ps3;-3;y;z || ps3;x;-4;z ||. Click parametric equations for more details on surface parametrizations.
Be aware that "sf3" is difficult to graph the surfaces defined implicitly in equations (e.g., quadratic surfaces). It plots surfaces of explicit functions of the form z = f(x, y). You need to use "ps3" to plot quadratic surfaces as well as other surface parametrization.
Examples Show the surfaces of z = f(x, y). sf3;sin(x^2+y^2);-2;2;-2;2 || sf3;-(cos(x)^2+cos(y)^2)^2;0;6.3;0;6.3 || sf3;log(4-x^2-y^2)+ log(x^2+y^2-1) || sf3;x*y || sf3;x^2+y^2 || sf3;y^2-x || sf3;x-y^2 || sf3;cos((s+t)/2) || sf3;y/(1+x^2) || sf3;x*y/(x^2+y^2) || sf3;cos(y^2)*exp(-0.1*(x^2+y^2)) || sf3;x*y^2/(x^2+y^2) || sf3;x^2*y^2/(x^2+y^2) || sf3;x*y/(x^2+y^4) || sf3;(x^2-y^2)/(x^2+y^2) || sf3;(x^2-y^2)/(x^2+y^4) || sf3;x/(x^2+y^2) || sf3;x^2*y^2/(x^3+y^3) || sf3;x*y/(x^2+y^2)^0.5 || sf3;x*y^2/(x^2+y^2)^0.5 || sf3;x^2*y^2/(x^2+y^2)^0.5 || sf3;exp(x)*log(x*y)/3 || sf3;x*cos(y);-2;2;0;6.3 || sf3;exp(-(x^2+y^2));-2;2;-2;2 || sf3;2*x^2+3*y^2;-2;2;-2;2 || sf3;abs(x)+abs(y) ||.
Vertical traces: [pc3; a; y; f(a,y)], [pc3; x; b; f(x,b)]Vertical and horizontal traces are used to analyze 3d surfaces f(x, y) by freezing one variable and letting the other vary. To generate vertical traces in a vertical plane x = a, set x = a so that the function f(x, y) becomes f(a, y), and the vertical trace consists of the set of points (a, y, f(a, y)). Use "pc3; a; y; f(a,y)" to graph these traces.
Similarly, graph vertical traces in the plane y = b by "pc3; x; b; f(x,b)". Notice that traces are space curves that involve 3-dimensions. That's why you use the module "pc3" (parametric curve 3d) to graph them. Check parametric equations for more details on parametrizations of space curves.
Examples pc3;1;y;1-y^2 || pc3;3;y;3-y^2 || pc3;0;y;-y^2 || pc3;-2;y;-2-y^2 || pc3;x;3;x^2+3 || pc3;x;0;x^2 || pc3;x;-2;x^2-2 || pc3;t;1;sin(t) || pc3;0;t;cos(2*t) || pc3;0;t;abs(sin(t)) ||.
Horizontal traces: [pc3; x(t); y(t); c]Horizontal traces are obtained by setting f(x, y) = c such that the set of points (x, y, c) are in a horizontal plane z = c. Use the code pattern "pc3; x(t); y(t);c" to graph horizontal traces of f(x, y).
Examples
(1) Graph the surface f(x, y) = x² + y by pc3;x;2-x^2;2 || sf3;x^2+y ||.
(2) Graph the horizontal traces f(x, y) = 0 by pc3;x;-x^2;0 ||, and f(x, y) = -3 by pc3;x;-3-x^2;-3 ||.
(3) Graph the horizontal traces for the elliptic paraboloid z = 3x² + 4y² by pc3;3*cos(t);4*sin(t);1 || pc3;3*cos(t);4*sin(t);3 || pc3;3*cos(t);4*sin(t);5 ||.
Use similar methods to graph the horizontal traces for surfaces (ellipsoids, paraboloids, cones, and hyperboloids) that are implicitly defined in equations.
Examples
(1) pc3;3*cos(t);2*sin(t);0 || pc3;3*cos(t);2*sin(t);-3 || pc3;3*cos(t);2*sin(t);-8 || pc3;3*cos(t);2*sin(t);-15 give horizontal traces for the ellipsoid \(\frac{x^2}{9}+\frac{y^2}{4}+z^2=1\).
(2) pc3;2*cos(t);3*sin(t);1 || pc3;4*cos(t);6*sin(t);2 || pc3;6*cos(t);9*sin(t);3 give the horizontal traces for the elliptic cone \(\frac{x^2}{4}+\frac{y^2}{9}=z^2\).
(3) pc3;2*2^0.5*cos(t);2^0.5*sin(t);1 || pc3;2*5^0.5*cos(t);5^0.5*sin(t);2 || pc3;2*10^0.5*cos(t);10^0.5*sin(t);-3 are some horizontal traces for the hyperboloid \(\frac{x^2}{4}+y^2=z^2+1\).
If horizontals traces f(x, y) = c are plotted in the xy-plane, the curves are called level curves. The level curves of a function f(x, y) are the family of curves f(x, y) = c and z = 0. They are the projections of the horizontal traces onto the xy-plane. A contour map shows the level curves f(x, y) = c for equally spaced value of c. Since level curves are 2-dimensional, use the "imf" module to graph level curves.
Examples
(1) z = x² - 2y² by imf;x^2-2*y^2 || imf;x^2-2*y^2-2 || imf;x^2-2*y^2-4 || imf;x^2-2*y^2+3 || imf;x^2-2*y^2+3 ||.
(2) Plot the level curves for 2x² + 3y² = z² - 1 by imf;2*x^2+3*y^2+1 || imf;2*x^2+3*y^2 || imf;2*x^2+3*y^2-3 || imf;2*x^2+3*y^2-5 ||.
Examples Plot the contour curves z = f(x,y) by the "cnt" module. || cnt;x^2-2*y^2-2 ||. Graph the contour curves of 2x² + 3y² = z² - 1 by cnt;(2*x^2+3*y^2+1)^(1/2) ||.
Level surfaces: [ps3; x(u, v), y(u, v), z(u, v)], [sf3; f(x,y)]It is not possible to draw the graph of a function w = f(x, y, z) in R4 of four (or more) variables. But we can graph its level surfaces by setting f(x, y, z) = c using "sf3" and "ps3" modules.
If level surfaces are explicit functions z = f(x, y), use "sf3" module to graph them directly. If a level surface is a quadratic surface, which can parametrized by two parameters and graphed by "ps3" module.
Examples The level surfaces of w = x² + y² - z are x² + y² = z + c, which is a circular paraboloid, and can be obtained by sf3;x^2+y^2 || sf3;x^2+y^2+2 || sf3;x^2+y^2-3 ||.
Examples The level surfaces of \(f(x,y,z)=\frac{1}{x^2+y^2+z^2}\) are sphere of radius \(c>0\), except at the origin. Check ps3;sin(s)*cos(t);sin(s)*sin(t);cos(s) || ps3;2*sin(s)*cos(t);2*sin(s)*sin(t);2*cos(s) || ps3;3*sin(s)*cos(t);3*sin(s)*sin(t);3*cos(s) ||.
Examples The level surfaces of 2z² + 3y² - x are elliptic paraboloids and can be graphed by ps3;2*z^2+3*y^2-1;y;z || ps3;2*z^2+3*y^2-2;y;z || ps3;2*z^2+3*y^2;y;z || ps3;2*z^2+3*y^2+3;y;z ||.
Examples The level surfaces of 2x² + y² - z² are elliptic one for c = 0, hyperboloid (one sheet) for c > 0, and two sheets for c < 0. They can be graphed by ps3;z*cos(t)/2^0.5;z*sin(t);z || ps3;(z^2+1)^0.5*cos(t)/2^0.5;(z^2+1)^0.5*sin(t);z || ps3;2^0.5*(z^2+1)^0.5*cos(t);2*(z^2+1)^0.5*sin(t);2*z || ps3;(z^2-1)^0.5*cos(t)/2^0.5;(z^2-1)^0.5*sin(t);z || ps3;2^0.5*(z^2-1)^0.5*cos(t);2*(z^2-1)^0.5*sin(t);2*z ||.
Examples The level surfaces of 2x² + y² + 2z² are ellipsoids for c > 0 and can be graphed by ps3;sin(s)*cos(t)/2^0.5;sin(s)*sin(t);cos(s)/2^0.5 || ps3;sin(s)*cos(t);sin(s)*sin(t)/2^0.5;cos(s) ||.
2 Partial, Directional, and Implicit Derivatives
Partial Derivatives
Partial derivatives: [dif; f(x, y, z); x; y; x; z; ... ], [ dif(f(x, y, z), x, y, x, z, ...) ]The code pattern "dif; f(x, y, z); x; y; z; x ..." helps find partial derivatives for functions of two or more variables, where "f(x, y, z)" is a function of three variables, and "x; y; z; ..." are the sequence of variables to which the partial derivative is with respect. Ensure that the sequence of variables in the order as you want the partial derivative to be carried out, and write each variable in one letter.
The first partial derivative of f(x, y) is often denoted as fx and fy, and calculate them by dif;f(x,y);x || dif;f(x,y);y ||. The second partial derivatives are denoted by fxx, fyy, fxy, and fyx, and calculated by dif;f(x,y);x;x || dif;f(x,y);y;y || dif;f(x,y);x;y || dif;f(x,y);y;x ||. Continue this process for other higher order partial derivatives.
Attention Also use the code pattern "dif(f(x, y, z), x, x, y, z, ...)" to find partial derivatives of f(x, y, z). For example, dif(exp(x^2*y^3*z),x,z,y) ||, and you will get the same result as dif;exp(x^2*y^3*z);x;z;y ||.
Use the expression dif(f(x,y),x,y)-dif(f(x,y),y,x) to check if the order matters. For instance, f(x, y) = cos(x + y)exy, verify fxy = fyx by dif(cos(x+y)*exp(x*y),x,y)-dif(cos(x+y)*exp(x*y),y,x) ||, which is 0.
In particular, use "dif; f(x,y,z); x; n" to get the results for higher order partial derivatives with respect to the same variable. For instance, dif(exp(x*y),x,x,x) || dif(exp(x*y),x,3) || give the same results.
Use the expression dif(f(x,y),x) to write and solve first-order linear partial differential equations. For example, the expression dif(g(x,y),y)-2*x stands for the partial differential equations gy - 2x = 0, and solve it for g(x, y) by pde(dif(g(x,y),y)-2*x) ||.
Examples
(1) If \(f(x,y)=x\ln(xy), f_{xy}=\frac{\partial}{\partial y\partial x}x\ln(xy)=y^{-1}\) by dif;x*log(x*y);x;y || or dif(x*log(x*y),x,y) ||, \(f_{yx}\) by dif;x*log(x*y);y;x || dif(x*log(x*y),y,x) ||, \(f_{xx}\) by dif;x*log(x*y);x;x ||, and \(f_{yyx}\) by dif;x*log(x*y);y;y;x ||.
(2) Similarly, dif;y^2/x;x;x;y;y || yields an output \(\frac{\partial}{\partial y^2\partial x^2}y^2x^{-1}=4x^{-3}\), and
dif;x*exp(y)*cos(z);x;y;z || dif(x*exp(y)*cos(z),x,y,z) || give \(\frac{\partial}{\partial z\partial y\partial x}xe^y\cos(z)=-e^y\sin(z)\).
(3) dif;y^x;x;y;x || dif;cos(x^2*y^3);y;x;y || dif;u/(u+v);u;u;v || dif;asin(x/y);u;v || dif;cos(3*x)*sin(4*y);y;x || dif;exp(x*y)*cos(x*y);x;y || dif;(x^2*y-x*y^2)/(x^2+y^2);x;y ||.
Examples
(1) To verify the equality of mixed partial derivatives, use dif;x^2*y+y^3*x;x;y || dif;x^2*y+y^3*x;y;x ||, and then
compare their outputs. Or by dif(x^2*y+y^3*x,x,y)-dif(x^2*y+y^3*x,y,x) ||.
(2) In a similar fashion, verify higher order mixed partial derivatives by dif;exp(x*y*z)*sin(x);x;y;z || dif;exp(x*y*z)*sin(x);y;z;x || dif;exp(x*y*z)*sin(x);z;y;x || dif;x^3*sin(y)+y^2*cos(x);x;y || dif;x^3*sin(y)+y^2*cos(x);y;x || dif;sin(x*y*z)+z/y;x;y;z || dif;sin(x*y*z)+z/y;y;x;z || dif;sin(x*y*z)+z/y;x;x;x || dif;sin(x*y*z)+z/y;y;y;y || dif;sin(x*y*z)+z/y;x;x;z ||.
Examples Let f(x, y) = g(x)h(y). Show fxy = fyx by dif(g(x)*h(y),x,y)-dif(g(x)*h(y),y,x) ||. Show fxfy = fxyf by dif(g(x)*h(y),x)*dif(g(x)*h(y),y)-dif(g(x)*h(y),x,y)*g(x)*h(y) ||.
Attention To apply module "dif", we assume f(x, y, z) is an explicit function. If z is implicitly defined by f(x, y, z) = 0, then we need to use implicit differentiation 'idf" for partial derivatives.
Examples
(1) If z is implicitly defined as a function of x and y by x² + 2y² - 3z² = 4, find zx by idf;x^2+2*y^2-3*z^2-4;x;z || and zy by idf;x^2+2*y^2-3*z^2-4;y;z ||.
(2) Let x = eusin(v), y = e2usin(2v). Find ux by idf;x+y-exp(u)*sin(v)-exp(2*u)*cos(2*v);x;u ||, uy by idf;x+y-exp(u)*sin(v)-exp(2*u)*cos(2*v);y;u ||, vx by
idf;x+y-exp(u)*sin(v)-exp(2*u)*cos(2*v);x;v ||, and vy by idf;x+y-exp(u)*sin(v)-exp(2*u)*cos(2*v);y;v ||.
(3) Let z = yex/y.
Show xzx + yzy = z by x*dif(y*exp(x/y),x)+y*dif(y*exp(x/y),y)-y*exp(x/y) ||, which is 0.
(4) Let z = x² - 5xy + z². Prove xzx + yzy = 2z by showing x*dif(x^2-5*x*y+y^2,x)+y*dif(x^2-5*x*y+y^2,y)-2*(x^2-5*x*y+y^2) = 0.
(5) Let z = f(x² + y²). Show xzy - yzz = 0 by dif(f(x^2+y^2),x)*y-x*dif(f(x^2+y^2),y) ||.
Partial derivative definition The partial derivatives \(f_x\) and \(f_y\) of \(f(x,y)\) are rates of change with respect to \(x\) and \(y\), respectively, and \(f_x(a,b)=\displaystyle\lim_{h\to 0}\frac{f(a+h,b)-f(a,b)}{h}, f_y(a,b)=\lim_{h\to 0}\frac{f(a,b+h)-f(a,b)}{h}\). Check lim;(f(a+h,b)-f(a,b))/h;h;0 || lim;(f(a,b+h)-f(a,b))/h;h;0 ||.
Examples Verify fx = 2xy³ and fy = 3x²y² for f(x, y) = x²y³ by lim;((x+h)^2*y^3-x^2*y^3)/h;h;0 || lim;(x^2*(y+h)^3-x^2*y^3)/h;h;0 ||. Or check dif;x^2*y^3;x || dif;x^2*y^3;y ||.
Partial derivatives for functions defined by integrals For functions defined by integrals, use "dif" and "itg" modules to find partial derivatives by the fundamental theorem of calculus.
(1) If \(g(x)=\int_a^bf(x,y)dy\), then \(g'(x)=\int_a^bf_x(x,y)dy\); if \(g(y)=\int_c^df(x,y)dx\), then \(g'(y)=\int_c^df_y(x,y)dx\).
Now you need to evaluate the integrals by itg(dif(f(x,y),x),y,a,b) || itg(dif(f(x,y),x),y,a,b) || to find the partial derivatives.
(2) If \(g(x,y)=\int_x^yf(t)dt\), then \(g_x=-f(x),g_y=f(y),g_{xx}=-f_x,g_{yy}=f_y\). Using "dif(itg(f(t),t,x,y),y,n)" to find nth order derivatives of \(f(x)\) and \(f(y)\). Verify dif(itg(f(t),t,x,y),x) || dif(itg(f(t),t,x,y),y) || dif(itg(f(t),t,x,y),x,2) || dif(itg(f(t),t,x,y),y,2) ||.
(3) If \(g(x, y)=∫_a^bf(x,y,z)dz\), then the expression dif(itg(f(x,y,z),z,a,b),x) || stands for \(g_x\), dif(itg(f(x,y,z),z,a,b),y,2) for \(g_{yy}\), and dif(itg(f(x,y,z),z,a,b),x,y) || for \(g_{xy}\).
Examples
(1) If \(g(x)=\int_0^1\cos(xy)dy\), the partial derivatives \(g_x,g_{xx}\) and \(g_{xy}\) = 0 can be
obtained by itg;-y*sin(x*y);y;0;1 || dif;(x*cos(x)-sin(x))/x^2;x || dif;(x*cos(x)-sin(x))/x^2;y ||. Or g(x) = itg(dif(cos(x*y),x),y,0,1) ||.
(2) If \(g(y)=∫_1^2\frac{1}{x}e^{\frac{y}{x}}dx, g'(y)\) by itg(dif(exp(y/x)/x,y),x,1,2) ||, and \(g_{yy}\) by dif;(exp(y)-exp(y/2))/y;y ||.
Examples If \(g(x,y)=\int_x^ye^{\cos t}dt,g_x=-e^{\cos x},g_y=e^{\cos y}\). Now use dif;-exp(cos(x));x || to find \(g_{xx}=e^{\cos x}\sin x\), and dif;exp(cos(y));y || to find \(g_{yy}=-e^{\cos y}\sin y\). Higher order derivatives are given by dif(itg(exp(cos(t)),t,x,y),x,3) || dif(itg(exp(cos(t)),t,x,y),y,3) ||.
Examples Let \(g(x,y)=∫_0^1\sin(2x-3y+z)dz\). Then find \(g_x, g_y\) by dif(itg(sin(2*x-3*y+z),z,0,1),x) || dif(itg(sin(2*x-3*y+z),z,0,1),y) ||. Find \(g_{xx}, g_{yy}\) by dif(itg(sin(2*x-3*y+z),z,0,1),x,2) || dif(itg(sin(2*x-3*y+z),z,0,1),y,2) ||. Find \(g_{xy}\) by dif(itg(sin(2*x-3*y+z),z,0,1),x,y) ||.
Chain rule for composite of scalar and vector functionsIf \(w=f(x,y,z), x=x(u,v),y=y(u,v),z=z(u,v)\), then by the chain rule the partial derivatives \(\frac{∂w}{∂u}\) and \(\frac{∂w}{∂v}\) can be calculated by \(\frac{∂w}{∂u}=\frac{∂w}{∂x}\frac{∂x}{∂u}+\frac{∂w}{∂y}\frac{∂y}{∂u}+\frac{∂w}{∂z}\frac{∂z}{∂u},\frac{∂w}{∂v}=\frac{∂w}{∂x}\frac{∂x}{∂v}+\frac{∂w}{∂y}\frac{∂y}{∂v}+\frac{∂w}{∂z}\frac{∂z}{∂v}\). In this case, the graph of \(w\) is a 3d surface because the parametric equations of \(x,y,z\) involve two parameters \(u, v\) (independent variables).
The above two partial derivatives can be expressed as \(\frac{∂w}{∂u}=∇w·\boldsymbol{r}_u, \frac{∂w}{∂u}=∇w·\boldsymbol{r}_v\), where \(∇w=〈\frac{∂w}{∂x},\frac{∂w}{∂y},\frac{∂w}{∂z}〉\) is the gradient vector, and \(\boldsymbol{r}_u=〈\frac{∂x}{∂u},\frac{∂y}{∂u},\frac{∂z}{∂u}〉,\boldsymbol{r}_v=〈\frac{∂x}{∂v},\frac{∂y}{∂v},\frac{∂z}{∂v}〉\) are the tangent vector of the parametrization \(\boldsymbol{r}(u,v)=〈x(u,v),y(u,v),z(u,v)〉\) with respect to \(u, v\). Both partial derivatives can be computed by the dot product of two vectors.
If \(x=x(t),y=y(t),z=z(t)\), then the total derivative \(\frac{dw}{dt}=\frac{∂w}{∂x}\frac{dx}{dt} +\frac{∂w}{∂y}\frac{dy}{dt}+\frac{∂w}{∂z}\frac{dz}{dt}=∇w·\)r'\((t)\), where \(∇w=〈\frac{∂w}{∂x},\frac{∂w}{∂y},\frac{∂w}{∂z}〉\) is the gradient vector, and r'\((t)=〈\frac{dx}{dt},\frac{dy}{dt},\frac{dz}{dt}〉\) the tangent vector. In this case, the graph of the function \(w\) is a space curve because the parametric equations of \(x,y,z\) involve one parameter \(t\).
The chain rule can apply to functions of more than three variables, and the parametric equation of each variable involves more than two parameters following the same logic. Refer to the section "General version of chain rule".
Use the code pattern "vec; grd(f(x, y, z), x, x(u, v), y, y(u, v), z, z(u, v)*tnv(x(u, v)*i + y(u, v)*j + z(u, v)*k, u)" to obtain the partial derivative of f(x, y, z) with respect to u, and "vec; grd(f(x, y, z), x, x(u, v), y, y(u, v), z, z(u, v)*tnv(x(u, v)*i + y(u, v)*j + z(u, v)*k, v)" with respect to v, where "x = x(u, v); y = y(u, v); z = z(u, v)" are the parametric equations for f(x, y, z). The names of these independent variables and parameters are not necessarily (x, y, z) and (u, v), and use any other variables names depending on whatever variables the function "f" and the parametric equations have.
Examples vec;grd(x^2+2*y^2,x,r*cos(t),y,r*sin(t))*tnv(r*cos(t)*i+r*sin(t)*j,r) || vec;grd(x^2+2*y^2,x,r*cos(t),y,r*sin(t))*tnv(r*cos(t)*i+r*sin(t)*j,t) || vec;grd(x^3-2*x*y*z+z^3,x,u+v,y,u-v,z,u*v)*tnv((u+v)*i+(u-v)*j+u*v*k,u) || vec;grd(x^3-2*x*y*z+z^3,x,u+v,y,u-v,z,u*v)*tnv((u+v)*i+(u-v)*j+u*v*k,u) || vec;grd(2*x^3+y^3,x,cos(t),y,sin(t))*tnv(cos(t)*i+sin(t)*j,t) || vec;grd(x^2*y^4,x,2*t^2,y,3*(t-2)^3)*tnv(2*t^2*i+3*(t-2)^3*j,t) || vec;grd(log(x^2+y^2),x,exp(t^2),y,exp(-t))*tnv(exp(t^2)*i+exp(-t)*j,t) || vec;grd(u^3*v^2,u,x+y,v,x-y)*tnv((x+y)*i+(x-y)*j,x) || vec;grd(u^3*v^2,u,x+y,v,x-y)*tnv((x+y)*i+(x-y)*j,x) || vec;grd(x^2-2*y+z^3,x,exp(t),y,log(t),z,cos(t))*tnv(exp(t)*i+log(t)*j+cos(t)*k,t) ||.
Examples If \(f(x,y)=x^2y+y^2x\) and \(y=\frac{1}{1+x^2}\), then \(f_x\) is the first component of the gradient vector vec;grd(x^2*y+y^2*x,x,x,y,1/(1+x^2))* tnv(x*i+j/(1+x^2),x) ||. Substituting \(y\) into \(f(x,y)\), you can differentiate \(f\) with respect to \(x\) by dif;x^2/(1+x^2)+x/(1+x^2)^2;x ||.
Chain rule for path Suppose \(f\) is a scalar function, r\((t)=〈x(t),y(t),z(t)〉\) is a path parametrization, and \(f\) and r are differentiable. Then derivative of the composite function \(f({\bf r}(t))\) is \(\frac{d}{dt}f({\bf r}(t))= ∇f_{r(t)}·{\bf r}'(t)\), where \(∇f_{r(t)}\) is a gradient and \({\bf r}'(t)\) a tangent vector.
Use the same combination of "grd" and "tnv" to find such derivatives by the chain rule for path and writing the vector components as parametric equations "x = x(t)", "y = y(t)" and "z = z(t)" of one parameter.
Examples
(1) If f(x,y,z) = x²y² - z², r(t) = cos(t)i + sin(t)j + tk, then x = cos(t), y = sin(t), and z = t.
The derivative of the composite is given by vec;grd(x^2*y^2-z^2,x,cos(t),y,sin(t),z,t)*tnv(cos(t)*i+sin(t)*j+t*k,t) ||.
(2) If f(x, y) = x + y, r(t) = ti + t²j, the derivative of the composite is 1 + 2t by vec;grd(x+y,x,t,y,t^2)*tnv(t*i+t^2*j,t) ||.
General version of chain rule The derivatives of more complicated composites such as \(f({\bf r}(s,t))\) and \(f({\bf r}(u,v,w))\), which have two or more independent variables, can be obtained by the general version of chain rule \(\frac{∂f}{∂s}=〈\frac{∂f}{∂x},\frac{∂f}{∂y},\frac{∂f}{∂z}〉·〈\frac{∂x}{∂s},\frac{∂y}{∂s},\frac{∂z}{∂s}〉=∇f·{\bf r}_s(s,t)\), and \(\frac{∂f}{∂t}=∇f·{\bf r}_t(s,t)\) for \(f({\bf r}(s,t))\), and \(\frac{∂f}{∂u}=〈\frac{∂f}{∂x},\frac{∂f}{∂y},\frac{∂f}{∂z}〉·〈\frac{∂x}{∂u},\frac{∂y}{∂u},\frac{∂z}{∂u}〉=∇f·{\bf r}_u(u,v,w)\), and \(\frac{∂f}{∂v}=∇f·{\bf r}_u, \frac{∂f}{∂w}=∇f·{\bf r}_w\) for \(f({\bf r}(u,v,w))\).
Observe that in the general version chain rule, \(∇f\) is the gradient vector, and the others \({\bf r}_s,{\bf r}_t,{\bf r}_u,{\bf r}_v,{\bf r}_w\) are tangent vector. Refer to the section Directional Derivatives to learn more about gradient vector, and the section of vector algebra and space geometry to learn more tangent vectors.
Examples Find the derivatives of \(f(x,y)=e^{xy}, {\bf r}(s,t)=(s+t)i+(s-t)j\) by vec;grd(exp(x*y),x,s+t,y,s-t)*tnv((s+t)*i+(s-t)*j,s) || vec;grd(exp(x*y),x,s+t,y,s-t)*tnv((s+t)*i+(s-t)*j,t) ||.
Tangent planes and normal lines Given a function z = f(x, y), let w = f(x, y) - z = 0 be a level surface w = 0. The tangent plane at a point P(a, b, f(a,b)) has a normal vector n = 〈fx, fy, -1〉 = ∇w, so the equation of a tangent plane is z = f(a, b) + fx(x - a) + fb(y - b) by a point-normal form. Or in vector notation n · 〈 x - a, y - b, z - f(a, b)〉 = 0. The normal line can be obtained by the point-direction form P(a, b, f(a,b)) + t∇wP.
Examples The function z = 2x² + 3y² at P(1, 2, 16) has a normal vector 〈4x, 6y, -1〉 = 〈4, 12, -1〉. The equation of the tangent plane z = 16 + 4(x - 1) + 12(y - 2) can be got by vec;(4*i+12*j-k)*((x-1)*i+(y-2)*j+(z-16)*k) ||, and the normal line by vec;(i+2*j+16*k)+t*(4*i+12*j-k) ||. Refer to the section vector for more details on vector algebra and calculus.
For a surface defined by w = f(x, y, z) = k, a normal vector at a point P(a, b, c) on the level surface w = k is its gradient ∇w = 〈fx, fy, fz〉. The equation of the tangent plane at P is ∇wP · 〈x - a, y - b, z - c〉 = 0. So use "grd" and "vec" modules to find the equations of tangent planes and normal lines. Refer to the section gradient vector for more information.
Examples A level surface by the equation z³ + x²y²z² + 2x + y = 5 has a gradient vector 〈6, 3, 2〉 at (1, 1, 1), or the normal vector of its tangent plane at the point is by vec;grd(x^2+x^2*y^2*z^2+2*x+y,x,1,y,1,z,1) ||. So the equation of tangent plane is by vec;(6*i+3*j+2*k)*((x-1)*i+(y-1)*j+(z-1)*k) ||, and the normal line is by vec;(i+j+k)+t*(6*i+3*j+2*k) ||.
Since the total differential is dw = 6dx + 3dy + 2dz, Δw ≈ 6Δx + 3Δy + 2Δz. For level surface w = 5, Δw = 0, and 6Δx + 3Δy + 2Δz = 0 implies 6(x - 1) + 3(y - 1) + 2(z - 1) = 0 is an equation of the tangent plane,
Normal planes and tangent lines The tangent line to a point P on the intersection curve C between two level surfaces f(x, y, z) = a and g(x, y, z) = b has a direction (tangent) vector u orthogonal to both surfaces' normal vectors ∇f and ∇g at P, or u is parallel to the cross product ∇f × ∇g = 〈fx, fy, fz〉 × 〈gx, gy, gz〉. The tangent vector u is normal to a plane through P spanned by ∇fP and ∇gP. Use "grd" and "vec" modules to find a tangent line and normal plane at a common point of two level surfaces.
Examples Find the tangent line and normal plane through the curve of intersection of x² - 2y² + 3z² = 5 and 2x - y + 2z = 4 at (1, 2, 2). The two gradient vectors are by vec;grd(x^2-2*y^2+3*z^2-5,x,1,y,2,z,2) || vec;grd(2*x-y+2*z-4,x,1,y,2,z,2) ||. The direction vector is by vec;(2*i-8*j+12*k)^(2*i-j+2*k) ||, the tangent line is by vec;(i+2*j+2*k)+t*(-4*i+20*j+14*k) ||, and the normal plane is given by vec;(-4*i+20*j+14*k)*((x-1)*i+(y-2)*j+(z-2)*k) ||.
Linearization for functions of two or more variables: [vec;grd( f(x, y, z), x, x0, y, y0, z, z0)]If \(z=f(x,y)\) is differentiable, the total differential is \(dz=f_xdx+f_ydy\). Note that \(dz\) is not \(Δz\), but can be used to approximate \(Δz\) by \(Δz≈f_xΔx+f_yΔy\). Similarly, for \(w=f(x,y,z),dw=f_xdx+f_ydy+f_zdz\), and it tells how the variations of \(w\) are related to the variations of \(x,y,z\).
The linearization of single variable functions can extend to functions of two variables f(x, y) at a point P(a, b), assuming that both first order partial derivatives fx(x, y) and fy(x, y) exist and continuous on an open disk containing P. The linearization of f(x, y) at P is the linear function L(x, y) = f(a, b) + fx(a, b)(x - a) + fy(a, b)(y - b).
In a similar fashion, linearization can extend to functions of more than two variables. The linearization of f(x, y, z) at a point P(a, b, c) is the linear function L(x, y, z) = f(a, b, c) + fx(a, b, c)(x - a) + fy(a, b, c)(y - b) + fz(a, b, c)(z - c).
Use "grd" module to find each partial derivative evaluated at the point P, and then substitute the results into the equation of tangent plane.
Examples
(1) Find the tangent plane for \(z = \sqrt[3]{\frac{x}{y}}\) at P(1, 8, 1/2) by vec;grd((x/y)^(1/3),x,1,y,8) ||, you will get
fx(1, 8) = 1/6 and fx(1, 8) = -1/48. So the equation of tangent plane is T(x, y) = 0.5 + (x - 1)/6 - (y - 8)/48.
(2)
Find the tangent plane of ln(x² + y²) at (1, 1, ln(2)). The gradient vector is by vec;grd(log(x^2+y^2),x,1,y,1) ||, and the tangent plane of
ln(x² + y²) at (1, 1, ln(2)) is T(x, y) = x + y + ln(2) - 2.
The tangent plane can be used to approximate the functions values Δz = T(x, y) - f(a, b) ≈ dz = fxdx + fydy for the points/values of (x, y, f(x, y)) very close to the point P(a, b, f(a, b)), just as linear approximation of functions of single variables does.
Examples
(1) To approximate \(3.01^2(1.02^4)\), let \(z = x^2y^4\) and P(3, 1, 8). Then vec;grd(x^2*y^4,x,3,y,1) || gives the gradient
evaluated at the point. Thus, \(3.01^2(1.02^4)≈8+6(0.01)+36(0.02)=9.78\).
(2) Similarly, to approximate \(\sqrt{(2.03)(1.96)(9.06)}\),
let \(w=\sqrt{xyz}\). Type vec;grd((x*y*z)^(1/2),x,2,y,2,z,9) || to find the gradient, and calculate 6+1.5(0.03)+1.5(-0.04)+0.06/3=6.05.
Tangent plane to level surface Let P(a, b, c) be a point on the level surface f(x, y, z) = k. Then the equation of the tangent plane can be obtained by the equation ∇f(a, b, c)·〈x - a, y - b, z - c〉 = 0, given that the gradient is normal to the level surface at P. Use "grd" module to find ∇f(a, b, c), and then write the equation of tangent plane in point-normal form, and use "vec" module for dot product.
Examples Find the tangent plane to the surface x² + y² + z² = 9 at (2, 2, 1). The gradient at the point is by vec;grd(x^2+y^2+z^2-9,x,2,y,2,z,1) ||, and the equation of tangent plane is 4(x - 2) + 4(y - 2) + 2(z - 1) = 0 by vec;(4*i+4*j+2*k)*((x-2)*i+(y-2)*j+(z-1)*k) ||.
Directional Derivatives
Gradient vectors: [vec;grd(f(x,y,z),x,y,z)], [vec;grd(f(x,y,z),x,x0,y,y0,z,z0)]Since the rate of change of a function of several variables depends on directions, which are represented by vectors, it is natural to use vectors to describe derivatives for a given direction.
The gradient vector of a function \(f\) of \(n\) variables is \(∇ f\) = 〈\(\frac{\partial f}{\partial x_1},\frac{\partial f}{\partial x_2}, \cdots, \frac{\partial f}{\partial x_n}\)〉. Use "grd" (gradient) module to calculate gradient vectors of multivariate functions, and evaluates it at a given point. The "grd" operation supports up to 3-dimensional gradients.
Properties of gradient The gradient \(∇ f\) behaves just as ordinary derivative. Calculate the gradients of their sum, difference, constant multiple, product, and quotient by the following properties.
Sum/Difference \(∇ (f\pm g) =∇ f \pm ∇ g\)
Constant multiple \(∇ (cf) =c∇ f \) for \(c\) any constant
Product rule \(∇ (fg) =g∇ f + f∇ g\)
Quotient rule \(∇ (\frac{f}{g}) = \frac{g∇ f - f∇ g}{g^2}\)
Chain rule \(∇ (H\circ f) =H'(f)∇ f\) if \(H(u)\) is differentiable
Examples
(1) vec;grd(2*x+3*y^2-cos(z),x,y,z) || vec;grd(2*x+3*y^2-cos(z),x,y,z) || show the gradient vector 〈2, 6y, sin(z)〉 of f(x, y, z) = 2x + 3y² - cos(z). If one starts from the point (1, 2, π/6), the direction the most rapid rate of increase of f points to (2, 12, 1) by vec;grd(2*x+3*y^2-cos(z),x,1,y,2,z,pi/2) ||.
(2) vec;grd(x*y*exp(x*y),x,y) || yields 〈\(xy^2e^{xy}, yx^2e^{xy}\)〉 of f(x, y) = xyexy.
(3) vec;grd((u+v^2+w^3)^4,u,v,w) || gives the gradient of \(f(u,v,w)=(u+v^2+w^3)^4\).
(4) The gradient of x³y + z² at point Q(2, 3, -1) is given by vec;grd(x^3*y+z^2,x,2,y,3,z,-1) ||, which is 〈36, 8, -2〉.
It is important to know that ∇g is perpendicular to the level surface g(x, y, z) = c. Take a curve r(t) inside the level surface, then r'(t) is in the tangent plane, and by chain rule, dg/dt = ∇g·r'(t) = 0 because g(x, y, z) is a constant. Thus, ∇g ⊥ r'(t) for every vector r'(t) in the tangent plane.
Directional derivatives: [vec; grd(f(x,y,z),x,y,z)*uexpr/abs(uexpr)], [vec;grd(f(x,y,z),x,y,z)*uexpr/abs(uexpr)]Let \(S\) be the surface of \(z=f(x,y),Q(a,b,f(a,b))\) be a point on \(S\), and \(P(a,b)\) be the projection of \(Q\) onto the xy-plane. Then the vertical plane passes through \(Q\) and \(P\) and parallel to the unit vector u = 〈\(c,d\)〉 intersects the surface \(S\) a trace curve \(C\). The directional derivative \(D\)u\(f(a,b)\) is the rate of change of \(f(x,y)\) at \(P(a,b)\) per unit change in the horizontal direction of u.
Geometrically, it is the slope of the tangent line at the point \(Q(a,b,f(a,b))\) to the trace curve obtained by intersecting the surface \(S\) and the vertical plane through both \(P\) and \(Q\) and in the direction of u.
Computing directional derivatives: [vec; grd(f(x,y,z),x,y,z)*uexpr/abs(uexpr)], [vec;grd(f(x,y,z),x,y,z)*uexpr/abs(uexpr)]
If u is a unit vector, then the directional derivative in the direction of u at the point \(P\) is given by \(D\)u\(f(P)\) = \(∇ f_P\cdot \)u, the dot product of the gradient and direction vectors.
If \(∇ f_P≠ \) 0, \(D\)u\(f(P)\) = \(∇ f_P\cdot \)u = ||\(∇ f_P\)||\(\cos\theta\), where \(\theta\) is the angle \(∇ f_P\) making with u at \(P\). So the rate of change in the given direction varies with \(\cos\theta\). Since \(0\le \theta\le\pi\) and \(-1\le \cos\theta\le 1\), -||\(∇ f_P\)|| ≤ \(D\)u\(f(P)\) ≤ ||\(∇ f_P\)||.
Thus, the maximum directional derivative occurs at \(\theta=0\) because \(\cos\theta=1\) and \(D\)u = ||\(∇ f_P\)||. This means the gradient vector points in the direction of the maximum rate ||\(∇ f_P\)|| of increase.
Similarly, \(\theta=\pi, \cos\theta = -1\) and \(D\)u = -||\(∇ f_P\)||, which means \(f\) decreases most rapidly in the opposite direction of the gradient. When \(\theta=\frac{\pi}{2}, \cos\theta =0\), and \(D\)u\(f(P)\) = 0, which means the rate of change is 0 when the gradient and direction vectors are mutually orthogonal.
Note that for each point \(P\) in the domain of \(f\), there is a unique direction in which \(f(x,y)\) increase most rapidly, and this is the direction of the gradient vector. But for most functions, the direction of maximum rate of increase varies from point to point.
For a function \(f\) of two variables at a given point \(P\), its gradient vector and vectors for its directional derivatives are in the xy-plane. The gradient vector is orthogonal to its level curve at \(P\), or is orthogonal to a line tangent to the level curve at \(P\).
Let \(f\) be a function of three variables, \(S\) be the level surface of \(f(x,y,z)=k\), and \(P\) be a point on \(S\). Then \(∇ f\) is orthogonal to the tangent plane at \(P\), or \(∇ f\) is orthogonal to all possible tangent lines to the curves on \(S\) through \(P\).
Gradient as a normal vector Let \(P(a,b,c)\) be a point on the level surface of \(f(x,y,z)=k\) and assume \(∇ f_P\ne\) 0. Then the gradient \(∇ f_P\) is a vector normal to the tangent plane to the surface at \(P\). Thus, the equation of the tangent plane to the surface at \(P\) is given by \(f_x(a,b,c)(x-a)+f_y(a,b,c)(y-b)+f_z(a,b,c)(x-c)=0\).
To see this result, let r\((t)\) be any path on the surface such that r\((0)\) is the position vector for the point \(P\), and r\('(0)\ne\) 0. Then \(f(\)r\((t))=k\) for all \(t\) because \(f(x,y,z)=k\). Differentiate both side with respect to \(t\) by the chain rule for paths, we have \(∇ F_P\)·r\('(0)=k'=0\). Thus, \(∇ f_P\) is orthogonal to r\('(0)\), which is tangent to the curve at \(P\) and tangent to the surface at \(P\).
We can take r\((t)\) through \(P\) from a different direction and \(∇ f_P\) must be also orthogonal to the tangent vector to the curve. Thus, \(∇ f_P\) is orthogonal to the tangent plane. Since \(∇ f_P\) is normal to the tangent plane through \(P\), the equation of the plane is \(∇ f_P\) ·〈\(x-a,y-b,z-c\)〉 = 0.
In particular, if \(z=f(x,y)\) is not a level surface, the equation of tangent plane to the surface of \(z=f(x,y)\) at \(P(a,b,f(a,b))\) is \(z=f(a,b)+f_x(x-a)+f_y(y-b)\). We can express \(z=f(x,y)\) as \(g(x,y,z)=f(x,y)-z=0\), and then \(g_x=f_x,g_y=f_y,g_z=-1\) and \(c=f(a,b)\). Thus the equation \(f_x(x-a)+f_y(y-b)-(z-c)=0\).
Examples Find a vector normal to the surface x² + 2y² - z² = 5 at P(1, 2, -2) by vec;grd(x^2+2*y^2-z^2-5,x,1,y,2,z,-2) ||.
Use the code pattern "vec; grd(f(x,y,z),x,y,z)*uexpr/abs(uexpr)" to find directional derivatives, where "uexpr" is the expression of the direction vector u, and "x,y,z" are independent variables. The partial derivatives, or the gradient ∇f, can be viewed as the directional derivatives in the direction of the standard basis vectors i, j, k for coordinate axes.
Examples Verify the fact that gradient vector is the partial derivatives along coordinate axes by vec;grd(x^2*y^3/z,x,y,z) || vec;grd(x^2*y^3/z,x,y,z)*i/abs(i) || vec;grd(x^2*y^3/z,x,y,z)*j/abs(j) || vec;grd(x^2*y^3/z,x,y,z)*k/abs(k) ||.
Examples
(1) vec;grd(exp(x*y),x,y)*(3*i+4*j)/abs(3*i+4*j) || vec;grd(exp(x*y),x,y)*(0.6*i+0.8*j)/abs(0.6*i+0.8*j) || give the same directional derivative exy(0.8x + 0.6y).
(2) vec;grd(z-x^2*y,x,y,z)*(i-2*j+2*k)/abs(i-2*j+2*k) || vec;grd(z-x^2*y,x,y,z)*(0.1*i-0.2*j+0.2*k)/abs(0.1*i-0.2*j+0.2*k) || show the same result 2(1 - xy + x²)/3.
Examples
(1) If f(x, y, z) = z³ + x²y, the directional derivative (about 2.41) at (0, 1, 1) in the direction of u = 〈1,-2, 3〉 can be got by vec;grd(z^3+x^2*y,x,y,z)*(i-2*j+3*k)/abs(i-2*j+3*k) || and subjecting the point values in the output.
(2) If f(x, y) = ln(x² + y²), the directional derivative at (2, 1) toward (3, 4) can be obtained by vec;grd(log(x^2+y^2),x,y)*(i+3*j)/abs(i+3*j) ||, because the direction vector is 〈1, 3〉. Substitute the point values (2, 1) to the output to get the value of directional derivative.
Implicit Derivatives
Implicit differentiation: [dif; expr; iv; dv], [dif(expr, iv, dv)]In one variable case, we use implicit differentiation \(\frac{dy}{dx}=-\frac{F_x}{F_y}\) to compute \(y'\) when \(y=y(x)\) is implicitly defined as a differentiable function of \(x\) in an equation \(F(x,y)=0\), where \(F(x,y)\) is a differentiable function. This methods extends to functions of several variables.
Suppose \(z=f(x,y)\) is implicitly defined as a function of \(x\) and \(y\) in an equation \(F(x,y,z)=0\). We don't need to solve an explicit form for \(z=f(x,y)\) to find the derivatives of \(z\) with respect to \(x\) and \(y\). We can treat \(F(x,y,z)\) as a composite function with \(x\) and \(y\) as independent variables and use the chain rule to find the derivatives.
Differentiate the equation on both sides with respect to \(x\), we have \(\frac{\partial F}{\partial x}(1)+\frac{\partial F}{\partial y}(0) + \frac{\partial F}{\partial z}\frac{\partial z}{\partial x} = F_x+F_z\frac{\partial z}{\partial x}=0\), which implies \(\frac{\partial z}{\partial x}=-\frac{F_x}{F_z}\) if \(F_z\ne 0\). In a similar fashion, if we differentiate \(F(x,y,z)=0\) on both sides with respect to \(y\), we obtain \(\frac{\partial z}{\partial y} = -\frac{F_y}{F_z}\).
Note that the surface by the equation \(F(x,y,z)=c\) is not a graph of a function because the vertical line test fails. But a small area near a point \(P\) on the surface may be represented by a graph of function \(z=f(x,y)\). So the partial derivatives \(z_x\) and \(z_y\) are equal to \(f_x\) and \(f_y\), which can be obtained without finding the function \(f(x,y)\) explicitly.
Note that without the assumption \(F_z\ne 0\), the partial derivatives \(z_x\) and \(z_y\) do not exist. Use "idf" module to find implicit derivatives of \(z_x\) and \(z_y\).
Examples If \(x^2z^2+y^2z-z^3=7\) and \(z\) is implicitly defined, then \(F(x,y,z)=x^2z^2+y^2z-z^3-7\), and \(z_x\) is by idf;x^2*z^2+y^2*z-z^3+7;x;z ||, and \(z_y\) is by idf;x^2*z^2+y^2*z-z^3+7;y;z ||.
3 Application of Partial Derivatives
Optimization without Constraints
Critical points: [vec;sol(grd(f(x,y,z), x, y, z),x,y,z)]If a function of several variables has local extreme values, Fermat's theorem states that the local extrema occur at its critical points, where the first order partial derivatives are equal to 0s or do not exist.
Use "grd" and "eqs" modules to find critical points. First, find all partial derivatives by "vec;grd(f(x, y), x, y)", then set each partial derivative equal to 0, and use "eqs" to solve the system of equations simultaneously. Use the combination "vec;sol(grd(f(x, y, z), x, y, z),x,y,z)" to find critical points of f(x, y, z).
Examples
(1) Find the critical points of f(x, y) = xy(x + 2y + 3). First get partial derivatives by vec;grd(x*y*(x+2*y+3),x,y) ||. Solve the
equation by eqs;2*x*y+3*y+2*y^2;4*x*y+3*x+x^2 ||, which shows four critical points.
(2) If f(x, y) = x²y + y²x - xy,
vec;grd(x^2*y+x*y^2-x*y,x,y) || eqs;y^2-y+2*x*y;x^2+x+2*x*y || give four critical points.
(3) If f(x, y) = x³ + y³ + 3x²y²,
vec;grd(x^3+y^3+3*x^2*y^2,x,y) || eqs;6*x*y^2+3*x^2;6*x^2*y+3*y^2 give two critical points. Ignore the complex solutions.
(4) Repeat the above examples by the composite functions vec;sol(grd(x*y*(x+2*y+3),x,y),x,y) || vec;sol(grd(x^2*y+x*y^2-x*y,x,y),x,y) || vec;sol(grd(x^3+y^3+3*x^2*y^2,x,y),x,y) ||.
Attention Critical points are interior points of a region. They do not include boundary points and points where any partial derivative does not exist. Be aware that not every critical point leads to a local extreme value. The second derivative test help determine whether a critical point results in a minimum, maximum or neither (saddle). Just as in one variable case, a critical point may be an inflection point where the horizontal tangent line crosses the function curve. For functions of two variables, a critical point may be a saddle point where there are some curves below and some above the horizontal tangent plane.
Local extreme values of two-variable functions Once you have the set of critical points, use the "sf3; f(x,y)" to graph the surface of f(x,y) to determine which one is a local maximum, which one is a minimum, and which one is neither (saddle), or use the second derivative test, which is described next.
Second derivative test and Hessian determinant: [ vec;hsd(f(x, y), x, a, y, b) ]Suppose f(x, y) has continuous second partial derivatives in an open disk containing the critical point P(a, b). Then if the Hessian determinant H = fxxfyy - (fxy)² > 0, f has an extreme value at P; if H < 0, f has no extreme value at P; if H = 0, the test is inconclusive. In case H > 0, if fxx > 0, f has a minimum value at P; if fxx < 0, f has a maximum value at P.
Using "vec;hsd(f(x, y), x, a, y, b)", you can get the Hessian determinant as well as the values of the second partial derivatives fxx, fyy, and fxy, so test whether a critical point leads to a local minimum, maximum, or neither, where the values (x, y) = (a, b) is the critical point.
Attention The results from function call "vec;hsd(f(x, y), x, a, y, b)" are expressed as a combination "Di + fxxj + fyyk", where D stands for the Hessian determinant, fxx and fyy for the second partial derivatives.
Examples
(1) Test the four critical points in the above example for f(x, y) = xy(x + 2y + 3) by vec;hsd(x*y*(x+2*y+3),x,0,y,0) ||
vec;hsd(x*y*(x+2*y+3),x,-3,y,0) || vec;hsd(x*y*(x+2*y+3),x,0,y,-3/2) || vec;hsd(x*y*(x+2*y+3),x,-1,y,-1/2) ||, which show f has a local maximum at (-1, -1/2), where H = 3, fxx = -1, and f(-1, -1/2) = 1/2.
(2) To test the four critical points of f(x, y) = x²y + y²x - xy, type
vec;hsd(x^2*y+x*y^2-x*y,x,-1,y,0) || vec;hsd(x^2*y+x*y^2-x*y,x,0,y,0) || vec;hsd(x^2*y+x*y^2-x*y,x,0,y,1) || vec;hsd(x^2*y+x*y^2-x*y,x,1,y,-1) ||. No extreme value is found.
(3) To test the critical points of f(x, y) = x³ + y³ + 3x²y², vec;hsd(x^3+y^3+3*x^2*y^2,x,0,y,0) ||
vec;hsd(x^3+y^3+3*x^2*y^2,x,0.5,y,-0.5) || show there is no local extreme value.
(4) Find local maxima and minima of f(x, y) = x³ + y³
+ 3xy + 4 by vec;sol(grd(x^3+y^3+3*x*y+4,x,y),x,y) || vec;hsd(x^3+y^3+3*x*y+4,x,0,y,0) || vec;hsd(x^3+y^3+3*x*y+4,x,-1,y,-1) ||. So f(-1, -1) = 5 is local a minimum.
Also use "hsd" modules to verify some known facts. For instance, the geometric mean is less than or equal to the arithmetic mean of three nonnegative numbers \(\sqrt[3]{abc}≤\frac{a+b+c}{3}\).
Examples
(1) If the sum of three positive numbers is 12, the maximum product of the three numbers is 64. let a, b, c be three numbers.
Then a + b + c = 12. To maximize the product abc is to maximize f(a, b) = ab(12 - a - b). The codes vec;grd(a*b*(12-a-b),a,b) || eqs;b*(12-2*a-b);a*(12-a-2*b) || or vec;sol(grd(a*b*(12-a-b),a,b),x,y) || give four critical points. The second derivative test by vec;hsd(a*b*(12-a-b),a,0,b,0) || vec;hsd(a*b*(12-a-b),a,0,b,12) ||
vec;hsd(a*b*(12-a-b),a,12,b,0) || vec;hsd(a*b*(12-a-b),a,4,b,4) || show the maximum value occur at a = b = 4 and is f(4, 4) = 64.
(2) Conversely, if the product of three positive numbers is 27, the minimum of their sum is 9. Since abc = 27, to minimize a + b + c is to minimize f(a, b) = a + b + 27/ab, type vec;grd(a+b+27/(a*b),a,b) || eqs;1-27/(a^2*b);1-27/(a*b^2) || or vec;sol(grd(a+b+27/(a*b),a,b),x,y) || for critical points. The second derivative test vec;hsd(a+b+27/(a*b),a,3,b,3) || shows f(3, 3) = 9 is the minimum.
Examples Find the shortest distance between two (skew) lines x = 1 + 2t, y = 3 - t, z = 7t and x = -2 + s, y = 3s, z = 5 - 7s. Verify that these two lines are non-parallel and non-intersecting by eqs;1+2*t-(s-2);3-t-3*s ||, because the third equation for z is not compatible for s = 9/7, t = -6/7. To minimize the distance is to minimize f(s, t) = (s - 2t - 3)² + (3s + t - 3)² + (5 - 7s - 7t)² by vec;grd((s-2*t-3)^2+(3*s+t-3)^2+(5-7*s-7*t)^2,s,t) || eqs;100*t+118*s-94;108*t+100*s-64 ||, which give one critical point (67/49, -33/49). The second derivative test by vec;hsd((s-2*t-3)^2+(3*s+t-3)^2+(5-7*s-7*t)^2,s,67/49,t,-33/49) || shows f has a minimum value at s = 67/49, t = -33/49, and f(67/49, -33/49) = 2/7. So the shortest distance is \(\sqrt{\frac{2}{7}}\).
Examples To find a point on the plane 3x - 2y + z = 4 closet to the origin is to minimize f(x, y) = x² + y² + (4 - 3x + 2y)². The results from vec;grd(x^2+y^2+(4-3*x+2*y)^2,x,y) || eqs;20*x-12*y-24;16-12*x+10*y || vec;hsd(x^2+y^2+(4-3*x+2*y)^2,x,6/7,y,-4/7) || 4-3*6/7+2*4/7 || show the point (6/7, -4/7, 18/7) on the plane is closet to the origin.
Absolute extreme values Absolute or global extreme values do not always exist. However, if f(x, y) is continuous on a closed and bounded domain D (e.g., circles, ellipses, triangles and rectangles, and other closed regions in the xy-plane), then f(x, y) has both a minimum and maximum values on D. This is similar to continuous functions g(x) of one variable have absolute extreme values on a closed interval.
These extreme values occur either at the critical points in the interior or at the boundary of D. If the boundary of D consists of line segments, check endpoints and interior points of each line segment. Note that the second derivative test does not apply to the boundary points of D, where the first partial derivatives fail to exist.
Examples To find the absolute maximum and minimum values for f(x, y) = x² + y² - 2x - 4y for 0 ≤ x ≤ 1 and 0 ≤ y ≤ 1 - x,
vec;grd(x^2+y^2-2*x-4*y,x,y) || eqs;-2+2*x;-4+2*y || vec;hsd(x^2+y^2-2*x-4*y,x,1,y,2) || find f has local minimum f(1, 2) = -5. The region is a closed and
bounded right triangle, so check the three line segments.
(1) For 0 ≤ x ≤ 1 and y = 0, f(x, 0) = x² - 2x has a minimum value f(1, 0) =
-1 and maximum value f(0, 0) = 0.
(2) For x = 0, 0 ≤ y ≤ 1, f(0, y) = y² - 4y has a critical number y = 2 by slv(dif(y^2-4*y,y),y) ||, which is not in the interval. Check the endpoints f(0, 0) = 0 and f(0, 1) = -3.
(3) For y = 1 - x, f(x, y) = 2x² - 3 has a minimum f(0, 1) = -3, and the endpoint f(1, 0) = -1. Thus, the absolute minimum value is f(1, 2) = -5 and absolute maximum value is f(0, 0) = 0.
Optimization Subject to Constraints
Lagrange multipliers with one constraint In ordinary optimization problems without a constraint, the global maximum (minimum) is the highest (lowest) height of the surface z = f(x, y) on its domain (in the xy-plane). When z = f(x, y) is subject to a constraint curve g(x, y) = 0, we look for the vertical trace on the surface lying above the constraint curve g(x, y) = 0 (that is in the xy-plane). The maximum (minimum) value subject to the constraint is the highest (lowest) height on the trace above the constraint curve g(x, y) = 0. The method of Lagrange multipliers is a general procedure for solving such optimization problems, and it is valid for functions of any number of variables.
Functions of two variables Assume f(x, y) and g(x, y) are differentiable. If f(x, y) has a local extreme value on the constraint curve g(x, y) = 0 at a point P(a, b), then the Lagrange equations ∇fP = λ∇gP hold for ∇gP a nonzero vector and λ some constant.
Geometrically, a local extreme value of z = f(x, y) subject to constrain g(x, y) occurs at P(a, b), where the level curves of f and g are tangent to each other. Since both ∇fP and ∇gP are orthogonal to their level curves, ∇fP is also orthogonal to g(x, y) = 0 at P, and ∇fP and ∇gP are parallel. Thus, the Lagrange equation.
In simple situations, eliminate one variable by substitution, and determine the extreme values from a function of one fewer variable. But in most cases, use "grd", "eqs" modules or some combination to solve the Lagrange equations along with the constraint simultaneously for possible critical points.
Attention Use the combination "vec;sol(grd(f(x, y), x, y)-m*grd(g(x, y), x, y) + g(x, y, z)*k,x,y,m)" to find critical points for functions of two variables using the Lagrange method. Notice that the code "grd(f(x, y), x, y) - m*grd(g(x, y), x, y)" gives the Lagrange equations, which are two gradient vectors, the last term "g(x, y)*k" is the third equation for the constraint. If you don't get any result, do substitution, simplification and find solutions by "slv" module or by hand.
Examples Find the extreme values of f(x, y) = 2x² + y² subject to a constraint x - 2y = 3. Substituting x = 3 + 2y in f(x, y), you get g(y) = (3 + 2y)² + y². Find critical number y = -6/5 by dif;2*(3+2*y)^2+y^2;y;1;cp ||. Since g(y) is a quadratic curve, it has a minimum g(-4/3) = 2. When y = -4/3, x = 1/3, f(1/3, -4/3) = 2 is local minimum value of f subject to the constrain. Check the graph by sf3;2*x^2+y^2 ||.
Obtain the same result by the method of Lagrange multipliers. First, get gradient vec;grd(2*x^2+y^2,x,y) || vec;grd(x-2*y-3,x,y) ||. Solve the system of equations by eqs;4*x-m;2*y+2*m;x-2*y-3 ||, and you get x = 1/3, y = -4/3, m = 4/3. Thus, f(1/3, -4/3) = 2 is a local minimum subject to the constraint.
Use the combination eqs(dif(2*x^2+y^2,x)-m*dif(x-2*y-3,x),dif(2*x^2+y^2,y)-m*dif(x-2*y-3,y),x-2*y-3) || to get the critical point (m, x, y) = (4/3, 1/3, -4/3).
Use vec;sol(grd(2*x^2+y^2,x,y)-m*grd(x-2*y-3,x,y)+(x-2*y-3)*k,x,y,m) || to get (m, x, y) = (4/3, 1/3, -4/3). Notice that gradients are vectors, so the last equation should be another vector. This combination only works for functions of two variables.
Examples Find a point on the line 2x + 3y = 4 closest to the origin. The distance d of a point (x, y) to the origin satisfies the equation d² = x² + y², and the point (x, y) is on the line, or subject to a constrain 2x + 3y = 4. Using vec;grd(x^2+y^2,x,y) || vec;grd(2*x+3*y-4,x,y) || eqs;2*x-2*m;2*y-3*m;2*x+3*y-4 ||, and you will see the solution is x = 8/13, y = 12/13, m = 8/13, which implies the point (8/13, 12/13) on the line is closest to the origin. If you substitute y = 2(2 - x)/3 in the distance equation, you get a critical number x = 8/13.
Use the combination vec;sol(grd(x^2+y^2,x,y)-m*grd(2*x-3*y-4,x,y)+(2*x-3*y-4)*k,x,y,m) || to solve the unknowns (m, x, y) = (8/13, 8/13, -12/13) in an alphabetical order.
Examples Find extreme values of f(x, y) = xy subject to a constraint 16x² + 9y² = 144. Find gradients by vec;grd(4*x*y,x,y) || vec;grd(x^2/9+y^2/16-1,x,y) ||. Solve equations eqs;y-2*m*x/9;x-m*y/8;x^2/9+y^2/16-1 ||, and no solution is found. Substituting x = my/8 in the first equation, you get y = 0 or m = ±6. Since y = 0 and x = 0 do not satisfy the third equation, you only consider m = ±6, solve eqs;y-4*x/3;x^2/9+y^2/16-1 || eqs;y+4*x/3;x^2/9+y^2/16-1 ||, and the solutions (x, y) as the critical values. Multiplying the coordinates, you see the maximum value is 6, and minimum is -6.
Functions of three variables Find the extreme values of a function w = f(x, y, z) subject to a constraint g(x, y, z) = 0, in particular when eliminating a variable by simple substitution may not work well.
Assume f(x, y, z) and g(x, y, z) are differentiable, and f(x, y, z) has a local extreme value at a point P. Then ∇fP = λ∇gP is the Lagrange equation for ∇gP a nonzero vector and λ some constant. A point P that satisfies the Lagrange equations and the constraint g(x, y, z) = 0 is a critical point. Notice that a critical point, if exists, lies on the intersection between the level surfaces f(x, y, z) = k and g(x, y, z) = 0, so the second derivative test does not apply.
Since f(x, y, z) takes an extreme value at P, ∇fP is orthogonal to the tangent plane at P, and is orthogonal to the tangent vector of every smooth curve on the level surface g(x, y, z) = 0 through P. Since ∇gP is orthogonal to the level surface g(x, y, z) = 0 at every point of P, it is also orthogonal to the tangent vector of every curve through P. Thus, both ∇fP and ∇gP are perpendicular to the same tangent plane, and ∇fP is parallel to ∇gP, or one is a scalar multiple of the other. As a result, extreme values may exist at P where the surfaces f(x, y, z) = k and g(x, y, z) = 0 are tangent.
Attention Use "vec;grd(f(x, y, z), x, y, z) - m*grd(g(x, y, z), x, y, z)" to get the three Lagrange equations.
Examples Find a point on the plane 2x + 3y - z = 7 that is closest to the origin in 3d space. Let the point be (x, y, z). To minimize the distance is to minimize d² = x² + y² + z² subject to the constraint 2x + 3y - z = 70. Get gradients by vec;grd(x^2+y^2+z^2,x,y) || vec;grd(2*x+3*y-z-70,x,y,z) ||, and solve the system of equations by eqs;x-m;2*y-3*m;2*z+m;2*x+ 3*y-z-7 ||. The critical point is at (1, 3/2, -1/2).
Or find the Lagrange equations by vec;grd(x^2+y^2+z^2,x,y,z)-m*grd(2*x+3*y-z-70,x,y,z) ||, and solve the four equations by eqs;x-m;2*y-3*m;2*z+m;2*x+3*y-z-70 ||.
Examples Find the extreme values of x + 2y - 3z subject to x² + 2y² + 4z² = 2. Find gradient by vec;grd(x+2*y-3*z,x,y,z) || vec;grd(x^2+2*y^2+4*z^2-2,x,y,z) ||, and solve the system of equations by eqs;1-2*x*m;1-2*y*m;3+8*z*m;x^2+2*y^2+ 4*z^2-2 ||. The minimum value \(\frac{-\sqrt{42}}{2}\) is at point \((\frac{-2\sqrt{42}}{21}, \frac{-2\sqrt{42}}{21}, \frac{\sqrt{42}}{14})\) and maximum \(\frac{\sqrt{42}}{2}\) at \((\frac{2\sqrt{42}}{21}, \frac{2\sqrt{42}}{21}, \frac{-\sqrt{42}}{14})\).
Or find the Lagrange equations by vec;grd(x+2*y-3*z,x,y,z)-m*grd(x^2+2*y^2+4*z^2-2,x,y,z) || and solve equations by eqs;1-2*x*m;1-2*y*m;3+8*z*m;x^2+2*y^2+4*z^2-2 ||.
Examples Find the point(s) on the ellipsoid x² + 2y² + z² = 13 where f(x, y, z) = xy + z² takes extreme values. Substituting z² = 13 - x² - 2y² into f(x, y, z), you get g(x, y) = xy + 13 - x² - 2y². Now get gradient by vec;grd(x*y+13-x^2-2*y^2,x,y) ||, and slove the system of equations eqs;2*x-y;x-4*y ||. The only critical point is (0, 0). If (x, y) = (0, 0), z² = 13 and the maximum value is 13 at (0, 0, \(±\sqrt{13}\)). Or by vec;sol(grd(x*y+13-x^2-2*y^2,x,y),x,y) ||.
Lagrange multipliers with two constraints For two constraints, the problems become to find the points where f(x, y, z) has extreme values subject to constraints g(x, y, z) = 0 and h(x, y, z) = 0. The critical points must simultaneously satisfy the three equations ∇f = λ∇g + μ∇h, and the equations g(x, y, z) = 0 and h(x, y, z) = 0.
Attention Use "vec;grd(f(x,y,z), x, y, z) - m*grd(g(x,y,z), x, y, z) - n*grd(h(x,y,z), x, y, z)" to get the Lagrange equations. Do substitution and use "slv" or "eqs" to find solutions to the system. Put the two constraints together, there are five equations in the system.
Examples Find extreme values of xyz subject to constrains x + y + z = 3 and x - y + z = 5. Get gradients by vec;grd(x*y*z,x,y,z) || vec;grd(x+y+z-3,x,y,z) || vec;grd(x-y+z-5,x,y,z) ||, and solve the system of equations by eqs;y*z-m-n;x*z-m+n;x*y-m-n;x+y+z-3;x-y+z-5 ||. The critical point at (x, y, z) = (2, -1, 2). The minimum of xyz is -4. The two constraint level surfaces intersect at y = -1, and thus f(x, y, z) = -xz has a minimum along the intersection curve.
Or get the Lagrange equations by vec;grd(x*y*z,x,y,z)-m*grd(x+y+z-3,x,y,z)-n*grd(x-y+z-5,x,y,z) ||. Solve all equations by eqs;y*z-m-n;x*z-m+n;x*y-m-n; x+y+z-3;x-y+z-5 ||, and you get (m, n, x, y, z) = (1, -3, 2, -1, 2).
Examples Find the extreme values of x² + y² + z² subject to constraint x + z = 2 and x - y = 4. Get gradients by vec;grd(x^2+y^2+z^2,x,y,z) || vec;grd(x+z-2,x,y,z) || vec;grd(x-y-4,x,y,z) ||, and solve the system of linear equations eqs;2*x-m-n;2*y+n;2*z-m;x+z-2;x-y-4 ||. The critical point (x, y, z) = (2, -2, 0). Thus, the minimum value of x² + y² + z² is 4.
Or get the Lagrange equations by vec;grd(x^2+y^2+z^2,x,y,z)-m*grd(x+z-2,x,y,z)-n*grd(x-y-4,x,y,z) ||. Solve all equations by eqs;2*x-m-n;2*y+n;2*z-m; x+z-2;x-y-4 ||, and you get (m, n, x, y, z) = (0, 4, 2, -2, 0).