The number of rational solutions to the cubic analogue of Pell's equation The equation:
$x^3+dy^3+d^2z^3-3dxyz = 1\tag{1}$
is the cubic analogue of Pell's equation.  For a given positive integer $d$ not a perfect cube there is essentially one solution in positive integers (although there are an infinite number of solutions, each of these is a power of the smallest one).  My question is how to compute the number of distinct positive rational solutions?  In particular, is there a PARI/GP function that does this?
 A: Here is a very partial answer, likely of a form that you don’t like.
Consider the familiar case of the standard Pell equation, just say $X^2-2Y^2=1$ for simplicity. This is the norm form for the integers $R=\mathbb Z[\sqrt2\>]$ of $\mathbb Q(\sqrt2\>)$, as you probably know. Now in this field, some $\mathbb Q$-primes split, such as $7$. We can use the fact that our ring $R$ has unique factorization to see that $7=(3-\sqrt2\>)(3+\sqrt2\>)$. Note that both the factors have norm $7$, so that their quotient has norm $1$. That quotient is $11/7 + (6/7)\sqrt2$, so that as you see, $(11/7,6/7)$ is a rational solution to your question. Now, you can do this for any prime $p$ that splits in $R$, and these are the primes congruent to $\pm1$ modulo $8$. You get a free-abelian group with one generator for each prime satisfying this condition. Of course many of the elements of the group have one or more negative coordinates.
Now, in many cases, your cubic form is the norm form for the integers $R$ of a cubic field $K=\mathbb Q(d^{1/3})$. This does happen for the case $d=2$, for instance. And $R$ has an additional nice property, which I won’t demonstrate, but is a standard fact: it’s that $R$ is a principal ideal domain, and thus has unique factorization (up to the units, which are of the form $\pm(1-2^{1/3})^n$). I’m going to go through a computational argument to find all numbers $a+bs+cs^2$ of norm $1$, where $s=2^{1/3}$, and the coefficients are rational numbers. That is, this finds all rational triples $a,b,c$ satisfying your condition with $d=2$.
The primes of $\mathbb Z$ are of several types, in relation to our field $K$. First, there are $2$ and $3$, which are ramified: $2=s^3$, and $3$ is $(1+s)^3$ times the unit $s-1$. All other primes either remain prime in $R$, or split in one of two possible ways. The primes that don’t split are not of interest to us, they are the primes $p\equiv1\pmod3$ for which $2$ is not a cube modulo $p$, such as $p=7$. If $p\equiv1\pmod3$ and $2$ is a cube, first example seems to be $p=31$, then since $\mathbb Z/(p)$ has three cube roots of unity, $2$ has three cube roots modulo $p$, not just one. For $31$, these are $4$, $7$, and $20$. That is, modulo $31$, you have $X^3-2=(X-4)(X-7)(X-20)$. I used this fact, plus a lot of thrashing about, to get a complete factorization of $31$: it’s equal to $(1 - 2s^2)(1 - 2s - s^2)(3 + s^2)$. Each factor has norm equal to $\pm31$, so if you divide two of them, you get a number of norm $\pm1$. So, here, if we set $r_1=(1 - 2s^2)/(1 - 2s - s^2)$, you get $19/31 + 16s/31 - 11s^2/31$, whose norm is $1$, and you can check that $-r_1^{-2}$ has all coefficients positive. Of course its norm is $-1$, so I guess you can use $r_1^{-4}$. Another quotient is $-(3 + s^2)(1 - 2s^2)=19/31 + 28s/31 + 7s^2/31$, and it has norm $1$. That is how you handle primes that split completely.
The last case is primes $p\equiv2\pmod3$. Here, the splitting is into one prime of degree one, and one of degree two, corresponding to how $X^3-2$ factors in $\mathbb Z/(p)[X]$. For instance, for $p=5$, $X^3-2=(X-3)(X^2+3X+4)$, modulo $5$.
Again, by messing about, I found that the corresponding factorization of the prime $5$ in $R$ is $(1+s^2)(1+2s-s^2)$. 
The first factor has norm $5$, the second has norm $25$. And if you take an appropriate quotient, namely $(1+s^2)^2/(1+2s-s^2)$, it works out to $ 1 + 6s/5 + 3s^2/5$, which has norm $1$, and gives you a good solution to your problem.
What’s the upshot, for $d=2$? Primes that split completely, like $31$, give you two generators in your group of numbers in $K$ of norm $1$, and primes that split in two, like $5$, give you one. It’s neater not to worry about all coefficients being positive, and I’ll leave that question to you.
The upshot for general $d$ is more of a problem. It may happen that $\{1,d^{1/3},d^{2/3}\}$ is not an integral basis for the ring of integers $R$ of  $K=\mathbb Q(d^{1/3})$, and it will happen frequently that $R$ is not a principal ideal domain. Both of these would complicate the story significantly.
