Re: question on converting a decimal back into an algebraic number

Karim Belabas <[email protected]>
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <[email protected]>
Hi Radall,

* American Citizen [2025-06-27 10:14]:
> This is a question about moving points on an elliptic curve from reals to a
> number field, and from a number field to reals (which uses a subst and a
> lift)
> 
> I can do a subst(lift) command on an algebraic number to find a decimal
> value
> 
> Example:
> 
> Mod(-1156/4489*x + 24633/4489, x^2 - 290), Mod(387549/300763*x -
> 11978472/300763, x^2 - 290)]
> 
> lifts* under the nf (x^2-290) to
> 
> [x,y] = [1.1020337181976119964245667123185152487,
> -17.883683642175364504497552094101227420]

This is not well-defined a priori: a number field L has (exactly) [L:Q]
complex embeddings; you need to specify your choice of embedding.
Nothing I write below is specific to the reals, you can just as well
use complex numbers if your number field doesn't have a real embedding.

I advise to create an 'nf' structure then use the high level functions.
In your case, 'nfeltembed' and approximate complex embeddings.

In general, if T is the polynomial defining your number field (integral,
irreducible, monic), and nf = nfinit(T), the embeddings are associated
to the complex roots of T, or nf.roots

\\ your data
  nf = nfinit(x^2 - 290);
  a = Mod(-1156/4489*x + 24633/4489, x^2 - 290)

? nf.roots
%2 = [-17.029386365926401166133321823877322706, 17.029386365926401166133321823877322706]

?  nfeltembed(nf, a)
%1 = [9.8727936375609088322677923877037614276, 1.1020337181976119964245667123185152487]

There are two (real) embeddings and you chose the 2nd one, attached to the
second root nf.roots[2].

\\ restricting to the 2nd embedding
?  nfeltembed(nf, a, 2)
%2 = 1.1020337181976119964245667123185152487

\\ low level alternative (don't do that):
? subst(lift(a), 'x, nf.roots[2])
%3 = 1.1020337181976119964245667123185152487


> But how do I go the reverse direction? This question is 2 parts. The first
> is if I know the nf polynomial, x^2 - 290, and I suspect it is easy to find
> the algebraic number. But the second part of the question is if I don't know
> the algebraic field.

[...]

> Suppose I have a decimal value for a point
> 
> [48.524409093877418991299749586199724677,
> -358.16199519959579719705531742590169930]
> 
> How do I recover
> 
> [Mod(x^2 - 3, x^4 - 1752*x^2 + 87616), Mod(-591/592*x^3 + 57/37*x, x^4 -
> 1752*x^2 + 87616)]

I'm answering the first question. It's not "easy" and it can fail.

\\ Your data :
  T = x^4 - 1752*x^2 + 87616;
  nf = nfinit(T);
  P = [48.524409093877418991299749586199724677, \
       -358.16199519959579719705531742590169930];

\\ we now have a quartic field and 4 embeddings
? nf.roots 
%4 = [-41.236823239746809829774803782284534820, -7.1780505078940074975081601345298894069, 7.1780505078940074975081601345298894069, 41.236823239746809829774803782284534820]

Here's a naive solution with lindep, using the first embedding by default:

nfrecognize(nf, z, j = 1) = 
{
  my(M = Mat(apply(conjvec, Mod(nf.zk, nf.pol))));
  \\ N.B. we actually have M = nf[5][1]
  my(L = lindep(concat(nf[5][1][j,], z)));
  my(a = L[#L]);
  if (abs(a) != 1, error("Failed to recognize ", z));
  if (a == 1, L = -L);
  nfbasistoalg(nf, L[1..-2]);
}

\\ using the default (= first) embedding; not what you expected.
? nfrecognize(nf, P[1])
%5 = Mod(-x^2 + 1749, x^4 - 1752*x^2 + 87616)
? nfrecognize(nf, P[2])
%6 = Mod(-3495/592*x^3 + 371769/37*x, x^4 - 1752*x^2 + 87616)
? nfrecognize(nf, Pi) \\ Good.
  ***   user error: Failed to recognize 3.1415926535897932384626433832795028842

? apply(z->nfrecognize(nf,z), P)
%7 = [Mod(-x^2 + 1749, x^4 - 1752*x^2 + 87616), Mod(-3495/592*x^3 + 371769/37*x, x^4 - 1752*x^2 + 87616)]

\\ using the second embedding
? apply(z->nfrecognize(nf,z,2), P)
%8 = [Mod(x^2 - 3, x^4 - 1752*x^2 + 87616), Mod(591/592*x^3 - 57/37*x, x^4 - 1752*x^2 + 87616)]

Maybe algdep + nfrecognize will solve the second part of your question.

If not, please make it more precise.

Cheers,

    K.B.
-- 
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.