Solving $x^2 + py^2 = 4z^3$ with a fixed $z$ Given an odd prime $p$ and a positive integer $z$, I'd like to find all positive integers $x$, $y$ such that
$$
x^2 + p y^2 = 4 z^3.
$$
Because the left is positive definite there is only a finite number of solutions.
I could solve by incrementally guessing values of $y$ and checking if $4z^3-py^2$ is a square, until $py^2> 4 z^3$. But this is slow, and many times the answer just turns out to be there are no solutions, or wasted time after finding the first solution which turns out to be unique.
I've learned the left hand side is called a binary quadratic form. Which has a class size $h(-4p)$. If it  somehow helps, assume I know this value.

*

*Is there an easy way to determine that, if a solution exists, it is unique?


*Is there an easy way to find all the solutions?
 A: I recommend Lehman as an introduction, simultaneous to binary quadratic forms and quadratic number fields.
I'm going to ignore the $4.$  It is there for a reason, but things begin more simply without it.
$$\left( x^2 + p y^2 \right)^3  = \left( x^3 -3 px y^2 \right)^2 + p  \left( 3x^2 y - p y^3 \right)^2 $$
When $p \equiv 3 \pmod 8$ ( and $p>3$) we have
class number  divisible by 3. Sometimes we can use the easiest description (available if we can solve $a^3 - t^2 = p$):
$$\left( ax^2 +2txy + a^2 y^2 \right)^3  = \left(tx^3 + 3a^2x^2 y + 3atxy^2 +(t^2 - p) y^3  \right)^2 +  p  \left( x^3 - 3axy^2 - 2t y^3 \right)^2 $$
The smallest primes for which this works are $11, 19, 67, 83, 107.$ When there is no such expression, for example primes $43, 59,$ there is a less formulaic way to write it out, but there are still infinitely many cubes where your $z$ has no expression as $x^2 + p y^2$
Example $p=11, a=3,t=4.$
$$\left( 3x^2 +8xy + 9 y^2 \right)^3  = \left(4x^3 + 27x^2 y + 36xy^2 +5 y^3  \right)^2 +  11  \left( x^3 - 9xy^2 - 8 y^3 \right)^2 $$
Example $p=19, a=7,t=18.$
$$\left( 7x^2 +36xy + 49 y^2 \right)^3  = \left(18x^3 + 147x^2 y + 378xy^2 +305 y^3  \right)^2 +  19  \left( x^3 - 21xy^2 - 36 y^3 \right)^2 $$
A: I found a necessary condition for there to be a solution which may be useful as a way to rule out some solutions. The condition is: Divide out the highest power of $p$ diving $z$, then what is left must be a quadratic residue mod $p$.
Let's call $x=p^a x'$, $y=p^b y'$ and $z=p^c z'$ respectively, the ' meaning it is the part relatively prime to $p$. So now we are to show that $z'$ must be a quadratic residue for there to be a solution.
$$p^{2a}x'^2 + p^{2b+1}y'^2 = 4p^{3c}z'^3$$
Either $2a$ or $2b+1$ is smaller, since they can't be equal. Whichever the lowest one is, it must be equal to $3c$. This means we can divide out by $p^{3c}$ and one of the two terms on the left is divisible by $p$ at least once. That means we have,
$$x'^2 = 4z'^3 \mod p$$ or $$y'^2 = 4z'^3 \mod p$$
In both cases we must have that $z'^3$ is a quadratic residue mod $p$, which must mean $z'$ is a quadratic residue. If it isn't then we have a contradiction.
