If x0=0, f(x)=f(0)+f′(0)x+2!f′′(0)x2+⋯+n!f(n)(0)xn+⋯
Taylor’s series are often used to represent functions in power series terms. For example, Taylor’s series for three common transcendental functions, ex, sinx and cosx, at x0=0 are
The Taylor’s series can also be expressed as the sum of the nth-degree Taylor polynomial Tn(x)=f(x0)+f′(x0)(x−x0)+2!f′′(x0)(x−x0)2+⋯+n!f(n)(x0)(x−x0)n and a remainder Rn(x): f(x)=Tn(x)+Rn(x).
For some x~ between x0 and x, Rn(x)=(n+1)!f(n+1)(x~)∣x−x0∣n+1. Let M be the maximum of f(n+1)(x~) for all x~ between x0 and x, we get constraint ∣Rn(x)∣≤(n+1)!M×∣x−x0∣n+1.
A. What is ii?
Solution: The solution to this problem uses Euler’s formula, eiθ=cosθ+isinθ, which can be proven using Taylor’s series. Let’s look at the proof. Applying Taylor’s series to eiθ, cosθ and sinθ, we have
Combining these three series, it is apparent that eiθ=cosθ+isinθ.
When θ=π, the equation becomes eiπ=cosπ+isinπ=−1. When θ=π/2, the equation becomes eiπ/2=cos(π/2)+isin(π/2)=i.3 So lni=ln(eiπ/2)=iπ/2.
Hence, ln(ii)=ilni=i(iπ/2)=−π/2⇒ii=e−π/2.
B. Prove (1+x)n≥1+nx for all x>−1 and for all integers n≥2.
Solution: Let f(x)=(1+x)n. It is clear that 1+nx is the first two terms in the Taylor’s series of f(x) with x0=0. So we can consider solving this problem using Taylor’s series.
For x0=0 we have (1+x)n=1 for ∀n≥2. The first and secondary derivatives of f(x) are f′(x)=n(1+x)n−1 and f′′(x)=n(n−1)(1+x)n−2. Applying Taylor’s series, we have
Since x>−1 and n≥2, we have n>0, (n−1)>0, (1+x~)n−2>0, x2≥0.
Hence, n(n−1)(1+x~)n−2x2≥0 and f(x)=(1+x)n≥1+nx.
If Taylor’s series does not jump to your mind, the condition that n is an integer may give you the hint that you can try the induction method. We can rephrase the problem as: for every integer n≥2, prove (1+x)n≥1+nx for x>−1.
The base case: show (1+x)n≥1+nx,∀x>−1 when n=2, which can be easily proven since (1+x)2≥1+2x+x2≥1+2x,∀x>−1.
The induction step: show that if (1+x)n≥1+nx,∀x>−1 when n=k, the same statement holds for n=k+1: (1+x)k+1≥1+(k+1)x,∀x>−1. This step is straightforward as well.
So the statement holds for all integers n≥2 when x>−1.
Newton’s method
Newton’s method, also known as the Newton-Raphson method or the Newton-Fourier method, is an iterative process for solving the equation f(x)=0. It begins with an initial value x0 and applies the iterative step xn+1=xn−f′(xn)f(xn) to solve f(x)=0 if x1,x2,⋯ converge.4
Convergence of Newton’s method is not guaranteed, especially when the starting point is far away from the correct solution. For Newton’s method to converge, it is often necessary that the initial point is sufficiently close to the root; f(x) must be differentiable around the root. When it does converge, the convergence rate is quadratic, which means (xn−xf)2(xn+1−xf)2≤δ<1, where xf is the solution to f(x)=0.
A. Solve x2=37 to the third digit.
Solution: Let f(x)=x2−37, the original problem is equivalent to solving f(x)=0. x0=6 is a natural initial guess. Applying Newton’s method, we have
If you do not remember Newton’s method, you can directly apply Taylor’s series for function f(x)=x with f′(x)=21x−1/2:
f(37)≈f(36)+f′(36)(37−36)=6+1/12=6.083.45
Alternatively, we can use algebra since it is obvious that the solution should be slightly higher than 6. We have (6+y)2=37⇒y2+12y−1=0. If we ignore the y2 term, which is small, then y=0.083 and x=6+y=6.083.
B. Could you explain some root-finding algorithms to solve f(x)=0? Assume f(x) is a differentiable function.
Solution: Besides Newton’s method, the bisection method and the secant method are two alternative methods for root-finding.5
Bisection method is an intuitive root-finding algorithm. It starts with two initial values a0 and b0 such that f(a0)<0 and f(b0)>0. Since f(x) is differentiable, there must be an x between a0 and b0 that makes f(x)=0. At each step, we check the sign of f((an+bn)/2). If f((an+bn)/2)<0, we set bn+1=bn and an+1=(an+bn)/2; If f((an+bn)/2)>0, we set an+1=an and bn+1=(an+bn)/2; If f((an+bn)/2)=0, or its absolute value is within allowable error, the iteration stops and x=(an+bn)/2. The bisection method converges linearly, xn−xfxn+1−xf≤δ<1, which means it is slower than Newton’s method. But once you find an a0/b0 pair, convergence is guaranteed.
Secant method starts with two initial values x0, x1 and applies the iterative step xn+1=xn−f(xn)−f(xn−1)xn−xn−1f(xn). It replaces the f′(xn) in Newton’s method with a linear approximation xn−xn−1f(xn)−f(xn−1). Compared with Newton’s method, it does not require the calculation of derivative f′(xn), which makes it valuable if f′(x) is difficult to calculate. Its convergence rate is (1+5)/2, which makes it faster than the bisection method but slower than Newton’s method. Similar to Newton’s method, convergence is not guaranteed if initial values are not close to the root.
Lagrange multipliers
The method of Lagrange multipliers is a common technique used to find local maximums/minimums of a multivariate function with one or more constraints.6
46
Let f(x1,x2,⋯,xn) be a function of n variables x=(x1,x2,⋯,xn) with gradient vector ∇f(x)=⟨∂x1∂f,∂x2∂f,⋯,∂xn∂f⟩. The necessary condition for maximizing or minimizing f(x) subject to a set of k constraints
is that ∇f(x)+λ1∇g1(x)+λ2∇g2(x)+⋯+λk∇gk(x)=0, where λ1,⋯,λk are called the Lagrange multipliers.
What is the distance from the origin to the plane 2x+3y+4z=12?
Solution: The distance (D) from the origin to a plane is the minimum distance between the origin and points on the plane. Mathematically, the problem can be expressed as