Smallest positive real solution with InverseWeierstrassP

How can I get the smallest positive real solution with InverseWeierstrassP[p, {g2, g3}] for real $g_2, g_3$ (if it exists)?

The documentation just says, that the function gives a values of $u$ for which the Weierstrass function $\wp(u,g_2,g_3)$ is equal to $p$.

In many cases it suffices to take the absolute value, e.g. for

N[InverseWeierstrassP[2, {0, 1}], 20])] = -0.70870542625436725012.


But for N[InverseWeierstrassP[-1/2, {1, -1}], 20] the output is $0.4503458373984861376 + 1.4343014857897211158 i\$ although I would like to have $2.379880191665208495\dots$

Calculate the inverse using FindRoot

iwp = u /.
FindRoot[WeierstrassP[u, {1, -1}] == -1/2, {u, 1/10},
WorkingPrecision -> 20]

(* 2.3798801916652084955 *)


Verifying,

WeierstrassP[iwp, {1, -1}] // Chop[#, 10^-16] &

(* -0.5000000000000000 *)


Chop removes an imaginary artifact caused by use of inexact numbers.

Elliptic functions

Instead of playing with numerical solvers, we can exploit a canonical exact approach. Since the Weierstrass elliptic function $$\wp$$ is doubly periodic (as every elliptic function), taking an inverse of it makes sense only locally and so some kind of arbitrariness is inevitable, otherwise we would get an infinite lattice of points $$\wp^{-1}(\frac{1}{2};1,-1)$$, see e.g. ( 1, 2). Double periodicity means that $$\wp$$ is defined on a fundamental parallelogram and with help of periods we can extend its definition on the whole complex plane. This implies also by the Liouville theorem that in every parallelogram there must be a singularity.

Let's find periods of $$\wp$$ by the Weierstrass half-periods:

{p1, p2, p3} = 2 Through @ { WeierstrassHalfPeriodW1,
WeierstrassHalfPeriodW2, WeierstrassHalfPeriodW3} @ {1, -1};


Double argument of $$\wp^{-1}$$

There is a double argument in InverseWeierstrassP, namely a pair $$(p,q)$$ such that $$\;q^2-4p^3+g_2\; p+g_3=0$$ This is a basic ODE satisfied by $$\wp$$, where $$p=\wp(x;g_2,g_3)\;$$ and $$q=\wp'(x,g_2,g_3)$$.

Solve[q^2 - 4 (-1/2)^3 + (-1/2) - 1 == 0, q]

{{ q -> -1}, { q -> 1}}


and finally a symbolic solution reads InverseWeierstrassP[{-(1/2), -1}, {1, -1}] - p1, which can be evaluated with arbitrary precission, e.g.:

InverseWeierstrassP[{-(1/2), -1}, {1, -1}] - p1 // N[#, 50] & // Chop

2.3798801916652084954875662184452287387253505855238


The both solutions for two different $$q$$ in the fundamental paralellogram spanned by two of three vectors of $$p_1, p_2, p_3$$:

pts = ReIm[ InverseWeierstrassP[{-(1/2), #}, {1, -1}] & /@ {1, -1}
- p1 // N // Chop]

{{0.450346, 1.4343}, {2.37988, 0}}


Graphical representation

To illustrate the basic concepts we'll add a plot. Although there is quite versatile ComplexPlot I prefer more involved construction with ContourPlot to achieve clearer explanation of all those auxiliary functions related to elliptic functions.

f[x_, y_] := WeierstrassP[x + I y, {1, -1}]
{v1, v2, v3} = ReIm @ {p1, p2, p3} // N;
Show[
ContourPlot[ Re[f[x, y]], {x, -1, 7}, {y, -4, 4},
ColorFunction -> "DeepSeaColors", Contours -> 10],
ContourPlot[{Re[f[x, y]] == -1/2, Im[f[x, y]] == 0, Re[f[x, y]] == 0,
Im[f[x, y]] == -1/2}, {x, -1, 7}, {y, -4, 4}, Evaluated -> True,
ContourStyle -> {{Thick, Cyan}, {Thick, Magenta}, {Dashed, Red},
{Dotted, Yellow}},
PlotLegends -> Placed["Expressions", Below], PerformanceGoal -> "Quality",
PlotPoints -> 80, MaxRecursion -> 5],
Graphics[{ Arrowheads[Large], Thick, Lighter @ Orange,
Arrow[{v3, v3 + v2}], Arrow[{v3 + v2, v3 + v1 + v2}],
Arrow[{v3 + v1 + v2, v3}], Red, PointSize[0.025], Point[pts]}]]


The orange arrows denote periods of $$\wp$$, only two of them are linearly independent since $$p_1 +p_2 + p_3=0$$. Points where cyan curves and magenta lines intersect (outside centers of quatrefoil patterns, since therein are singularities) are solutions $$\wp(x; 1,-1)=-\frac{1}{2}$$. Two solutions in the chosen paralellogram are denoted by red points.