A Really Quick Derivation of The Cauchy-Riemann Equations

Here is a really quick derivation of the Cauchy-Riemann equations of complex analysis.

Consider a function of a complex variable, z, where z = x + iy, such that:

f(z) = u(z) + i v(z) = u(x+ iy) + i v(x+iy),

where u and v are real-valued functions.

An analytic function is one that is expressible as a power series in z.
That is,

f(z) = \sum_{n=0}^{\infty} a_{n} z^{n}, \quad a_{n} \in \mathbb{C}.


u(x+iy) + i v(x+iy) = \sum_{n=0}^{\infty} a_{n} (x+iy)^{n}.

We formally differentiate this equation as follows. First, differentiating with respect to x, we obtain

u_{x} + i v_{x} = \sum_{n=1}^{\infty} n a_{n} \left(x+iy\right)^{n-1}.

Differentiating with respect to y, we obtain

u_{y} + i v_{y} = i \sum_{n=1}^{\infty} n a_{n} \left(x + i y\right)^{n-1}.

Multiplying the latter equation by -i and equating to the first result, we obtain

-iu_{y} + v_{y} = \sum_{n=1}^{\infty} na_{n} \left(x+iy\right)^{n-1} = u_{x} + i v_{x}.

Comparing imaginary and real parts of these equations, we obtain

\boxed{u_{x} = v_{y}, \quad u_{y} = -v_{x}},

which are the famous Cauchy-Riemann equations.


What are the factors behind Golden State’s and Cleveland’s Wins in The NBA Finals

As I write this, Cleveland just won the series 4-3. What was behind each team’s wins and losses in this series?

First, Golden State: A correlation plot of their per game predictor variables versus the binary win/loss outcome is as follows: 

The key information is in the last column of this matrix: 

Evidently, the most important factors in GSW’s winning games were Assists, number of Field Goals made, Field Goal percentage, and steals. The most important factors in GSW losing games this series were number of three point attempts per game (Imagine that!), and number of personal fouls per game. 

Now, Cleveland: A correlation plot of their per game predictor variables versus the binary win/loss outcome is as follows: 

The key information is in the last column of this matrix: 

Evidently, the most important factor in CLE’s wins was their number of defensive rebounds. Following behind this were number of three point shots made, and field goal percentage. There were some weak correlations between Cleveland’s losses and their number of offensive rebounds and turnovers. 

Note that these results are essentially a summary analysis of previous blog postings which tracked individual games. For example, here , here and a first attempt here. 

The Mathematics of “Filling the Triangle”

I’ve been fascinated by the triangle offense for a long time. I think it is a beautiful way to play basketball, and the right way to play basketball, in the half-court, a “system-based” way to play. For those of you that are interested, I highly recommend Tex Winter’s classic book on the topic.

There is this brief video as well where Tex Winter explains how the triangle offense and a basketball are grounded in geometric principles:


I don’t think people recognize though how deep of a geometry problem this is actually. Looking at when the triangle is filled, as in the video above, we have the following situation:

The 3 triangles that form when one triangle is filled involving all 5 players. The letters a,b,c,d,e,f,g,h,i denote the angles within the triangles. We are assuming NBA court dimensions where the 1/2 court is 47′ long and the team bench area which roughly corresponds to the top of the three-point line is 28′ from the baseline.

The problem I wanted to study was given 5 players’ random positions on the court, could a series of equations be solved yielding (x,y) coordinates that would yield where players should “go” to fill the triangle? 

Using simple geometry, from the diagram above, we see that each player’s position in the triangle offense is governed by the following system of nonlinear equations:

\left(x_4-x_2\right) \left(x_4-x_5\right)+\left(y_4-y_2\right) \left(y_4-y_5\right)=\cos (a) \sqrt{\left(x_2-x_4\right){}^2+\left(y_2-y_4\right){}^2} \sqrt{\left(x_4-x_5\right){}^2+\left(y_4-y_5\right){}^2}

\left(x_4-x_2\right) \left(x_2-x_5\right)+\left(y_4-y_2\right) \left(y_2-y_5\right)=\cos (b) \sqrt{\left(x_2-x_4\right){}^2+\left(y_2-y_4\right){}^2} \sqrt{\left(x_2-x_5\right){}^2+\left(y_2-y_5\right){}^2}

\left(x_2-x_5\right) \left(x_4-x_5\right)+\left(y_2-y_5\right) \left(y_4-y_5\right)=\cos (c) \sqrt{\left(x_2-x_5\right){}^2+\left(y_2-y_5\right){}^2} \sqrt{\left(x_4-x_5\right){}^2+\left(y_4-y_5\right){}^2}

\left(x_2-x_1\right) \left(x_2-x_5\right)+\left(y_2-y_1\right) \left(y_2-y_5\right)=\cos (d) \sqrt{\left(x_1-x_2\right){}^2+\left(y_1-y_2\right){}^2} \sqrt{\left(x_2-x_5\right){}^2+\left(y_2-y_5\right){}^2}

\left(x_2-x_1\right) \left(x_1-x_5\right)+\left(y_2-y_1\right) \left(y_1-y_5\right)=\cos (e) \sqrt{\left(x_1-x_2\right){}^2+\left(y_1-y_2\right){}^2} \sqrt{\left(x_1-x_5\right){}^2+\left(y_1-y_5\right){}^2}

\left(x_1-x_5\right) \left(x_2-x_5\right)+\left(y_1-y_5\right) \left(y_2-y_5\right)=\cos (f) \sqrt{\left(x_1-x_5\right){}^2+\left(y_1-y_5\right){}^2} \sqrt{\left(x_2-x_5\right){}^2+\left(y_2-y_5\right){}^2}

\left(x_1-x_3\right) \left(x_1-x_5\right)+\left(y_1-y_3\right) \left(y_1-y_5\right)=\cos (h) \sqrt{\left(x_1-x_3\right){}^2+\left(y_1-y_3\right){}^2} \sqrt{\left(x_1-x_5\right){}^2+\left(y_1-y_5\right){}^2}

\left(x_1-x_3\right) \left(x_3-x_5\right)+\left(y_1-y_3\right) \left(y_3-y_5\right)=\cos (i) \sqrt{\left(x_1-x_3\right){}^2+\left(y_1-y_3\right){}^2} \sqrt{\left(x_3-x_5\right){}^2+\left(y_3-y_5\right){}^2}

\left(x_1-x_5\right) \left(x_3-x_5\right)+\left(y_1-y_5\right) \left(y_3-y_5\right)=\cos (g) \sqrt{\left(x_1-x_5\right){}^2+\left(y_1-y_5\right){}^2} \sqrt{\left(x_3-x_5\right){}^2+\left(y_3-y_5\right){}^2}

Further, the angles obviously must satisfy the following constraints:

a + b + c = \pi, \quad d + e + f = \pi, \quad g + h + i = \pi

Finally, we require that each player be about 15-20 feet apart in the triangle offense (because the offense is predicated on spacing), and thus have some additional constraints:

15\leq \sqrt{\left(x_2-x_4\right){}^2+\left(y_2-y_4\right){}^2}\leq 20

15\leq \sqrt{\left(x_4-x_5\right){}^2+\left(y_4-y_5\right){}^2}\leq 20

15\leq \sqrt{\left(x_2-x_5\right){}^2+\left(y_2-y_5\right){}^2}\leq 20

15\leq \sqrt{\left(x_1-x_2\right){}^2+\left(y_1-y_2\right){}^2}\leq 20

15\leq \sqrt{\left(x_1-x_5\right){}^2+\left(y_1-y_5\right){}^2}\leq 20

15\leq \sqrt{\left(x_1-x_3\right){}^2+\left(y_1-y_3\right){}^2}\leq 20

15\leq \sqrt{\left(x_3-x_5\right){}^2+\left(y_3-y_5\right){}^2}\leq 20

Solving this highly nonlinear system of equations with constraints is not a trivial problem! It fact, because of the high degree of nonlinearity and dimension of the problem, it is safe to assume that no closed-form solution exists, and therefore, must be solved numerically.

For this task, we used MATLAB, and experimented with the lsqnonlin() and fsolve() commands. The only issue is that (as with all such numerical algorithms) convergence depends very highly on the choice of initial conditions. It is very difficult to choose a priori this many initial conditions, so I wrote a script that randomized initial conditions. I then ran several numerical experiments and obtained the following results:

In the plot above, I have labeled the plots that converged to the triangle formation with the title “this one”. In addition, the five black circles denote the initial positions of the players on the court before they fill the triangles in the offense. One sees just by the diagram above, how difficult such a problem is to solve mathematically, even through a numerical approach. Running more trials would perhaps yield better results, but, it works! I am truly fascinated by this. In the coming days, I will work on optimizing the numerical algorithm, and post my updates as they come.

Here is an animation of one of the scenarios above when the algorithm converges correctly:

In this animation above, the black dots represent the positions of the players on the court. They begin at initial (random) positions and attempt to fill the triangles as described above.

Thanks for reading!

Game 2 of CLE vs GSW Breakdown

As usual, here is the post-game breakdown of Game 2 of the NBA Finals between Cleveland and Golden State. Using my live-tracking app to track the relevant factors (as explained in previous posts) here are the live-captured time series:

Computing the correlations between each time series above and the Golden State Warriors point difference, we obtain:

One sees once again that the most relevant factors to GSW’s point difference in the game was CLE’s personal fouls during the game, GSW’s personal fouls during the game, and not far behind, GSW 3-point percentage during the game. What is interesting is that one can see the importance of these variables played out in real time matching the two graphs above.

In fact, looking at the personal fouls vs. GSW point difference in real time (essentially taking a subset of the time series graph above), we obtain:


Game 1 of CLE vs GSW Breakdown

Using my live tracking app combined with the relevant factors based on this previous work, here is my breakdown of what contributed to the Warriors win in Game 1 of the NBA Finals. 

First, here is the time series graph of several predictor variables: 

Breaking this down a bit further, we have: 

Computing the correlations, we obtain: 

For the graphically inclined: 

One sees that the predictor variable correlated most positively with the Warriors’ lead was the number of fouls Cleveland committed. Therefore, evidently, the most important factor in GSW winning Game 1 was the rate and number of fouls committed by Cleveland during the game.