# Computing quadratic differential trajectories with Mathematica

There was a question about a particular case of this, Quadratic differentials; seemingly it contained too little information, so let me try again. This will be also a second take on my previous question Getting rid of discontinuities in plots caused by square roots, logarithms, Arg, etc focussed on the particular case of square roots.

A quadratic differential is simply an expression of the form $$f(z)dz^2$$, where $$f(z)$$ is (for my purposes) some meromorphic function. For example, it can be a rational function, although I in fact need things like products of the Weierstrass function or some other elliptic functions.

A trajectory of such differential would be a standard solution of a differential equation if there would be $$dz$$ instead of $$dz^2$$: a (piecewise) smooth parametric curve $$(x(t),y(t))$$ that at every point $$z$$ it passes forms the same constant angle (counted always in the same, say counterclockwise direction) with the vector $$(\operatorname{Re}(f(z)),\operatorname{Im}(f(z)))$$. We could then obtain it by solving, for any given angle $$\alpha$$, the system \begin{align*} x'(t)&=\operatorname{Re}(e^{i\alpha}f(x+iy))\\ y'(t)&=\operatorname{Im}(e^{i\alpha}f(x+iy)) \end{align*} with, say, NDSolve, or visualize it using StreamPlot.

However the term $$dz^2$$ means that it must form constant angle with the vector $$\pm\sqrt{f(z)}$$ rather than $$f(z)$$. And since this vector now has two possible (opposite) directions, the condition now becomes that the curve forms either angle $$\alpha$$ or $$\alpha+\pi$$ with ReIm of $$\sqrt{f(z)}$$. This means we now have instead of a vector field, a field of tangent lines with unspecified direction.

There are easy examples showing that the resulting ambiguity cannot be avoided: with $$f(z)=-z$$ and $$\alpha=\pi/2$$, the stream plot for ReIm[I Sqrt[-(x+I y)]] is

so that the positive horizontal half-axis gets conflicting directions. For more complicated $$f(z)$$ I failed to find any general consistent way to compute with Sqrt[f[z]].

Is there some alternative way? More specifically, given a smoothly varying family of lines $$\ell_{x,y}$$ passing through each point $$(x,y)$$, like this -

how to calculate and draw curves tangent to $$\ell_{x,y}$$ at each point $$(x,y)$$ they pass through?