Ask Your Question
1

Understanding sqrt of sage

asked 2020-12-19 14:38:37 +0200

anonymous user

Anonymous

updated 2020-12-19 15:22:13 +0200

I'm reading the following piece of code:

p = 10000000000000001119

R.<x> = GF(p)[]; y=x
f = y + prod(map(eval, 'yyyyyyy'))
C = HyperellipticCurve(f, 0)
J = C.jacobian()

test=[J(C(x, min(f(x).sqrt(0,1)))) for x in (11,22,33)]

where $J$ is the jacobian of my hyper elliptic curve $C$.

I don't undestad what the sqrt function with those two arguments does. Reading from the docs it seems that I'm enabling the all flag:

all - Whether to return a list of all square roots or just a square root (default: False)

Can you explain what is mathematically doing that sqrt?

edit retag flag offensive close merge delete

Comments

You should provide the construction of J, C and f so that people can reproduce your situation.

tmonteil gravatar imagetmonteil ( 2020-12-19 14:55:05 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-12-19 16:10:09 +0200

slelievre gravatar image

In many settings,

  • the square function $x \mapsto x^2$ is mostly two-to-one, except at zero
  • given $y$ in some ring $R$ with a product operation, there can be zero, one or two values of $x$ for which $x^2 = y$ (i.e. $x \cdot x = y$). When two such $x$ exist, they are opposites of each other, and called "the square roots of $y$"
  • in many cases there is a way to extend the ring $R$ to a bigger ring $S$ where all nonzero elements have two square roots. For example if $R$ is the field $\mathbb{R}$ of real numbers then we can take $S$ to be the field $\mathbb{C}$ of complex numbers

When working with the real numbers, - zero is its own unique square root - positive numbers have two square roots in the real numbers - negative numbers have no square root in the real numbers, but two square roots in the complex numbers

The two square roots of a positive number being opposite to each other, one is negative and one is positive. Since we find positive numbers more "natural", we often decide to give the positive root a special role and to call it "square root of $y$", which could be thought of as short for "the positive square root of $y$". The other root is then referred to as "minus square root of $y$".

In computer algebra systems, one has to decide what to do when the user asks for square roots a command such as sqrt(y) or y.sqrt():

  • regarding where to look for square roots:
    • stay in the ring where $y$ lives
    • or extend it, if necessary, to a larger ring where square roots exist, if they did not in the ring where $y$ lives
  • regarding how many square roots to return:
    • return all the square roots of its argument,
    • or return one particular square root (e.g. the positive one when that makes sense)?

I suppose the documentation you are referring to is the SageMath documentation for sage.structure.element.CommutativeRingElement.sqrt.

It explains that y.sqrt() takes two optional parameters, extend to decide whether to look for square roots in a larger ring if necessary, and all to decide whether to return all square roots or a preferred square root when there is one. There's an additional optional parameter name to name the extra generator of the new ring if you decide to extend.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-12-19 14:38:37 +0200

Seen: 644 times

Last updated: Dec 19 '20