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?
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 $$