Ask Your Question
1

Basic operations not working in Multivariate Ring over QQbar

asked 2024-10-02 01:19:26 +0200

Barbadrian gravatar image

I have a function and a point on that function, and I want to translate this function so that the point is on the origin. I tried the following code:

sage: R.<x, y>=QQbar[]
sage: f = x^6 + y^4 - y^2*x^2 + y^3 - y^2*x - y*x^2 + x^3
sage: yRoot = f.discriminant(x).univariate_polynomial().roots()[0][0] ; yRoot
-1.439298135437689?
sage: xRoot = f(y=yRoot).univariate_polynomial().roots()[1][0] ; xRoot
-1.076378028605102? - 0.5153869890473267?*I
sage: f(x = x + xRoot, y = y + yRoot)

This last line never finishes computing, and doesn't seem to throw an error either. Given the computation is relatively simple, I expected this to finish pretty much instantly. I looked into it deeper by translating each term and adding them up (which should give the same answer):

fTerms = []
sage: for termTuple in list(f):
....:     fTerms.append(termTuple[0] * termTuple[1])
....:
sage: fTerms
[x^6, -x^2*y^2, y^4, x^3, -x^2*y, -x*y^2, y^3]
sage: resultSum = 0
sage: resultSum += fTerms[0](x = x + xRoot, y = y + yRoot)
sage: resultSum += fTerms[1](x = x + xRoot, y = y + yRoot)
sage: resultSum += fTerms[2](x = x + xRoot, y = y + yRoot)
sage: resultSum += fTerms[3](x = x + xRoot, y = y + yRoot)
sage: resultSum += fTerms[4](x = x + xRoot, y = y + yRoot)
sage: resultSum += fTerms[5](x = x + xRoot, y = y + yRoot)
sage: resultSum += fTerms[6](x = x + xRoot, y = y + yRoot)

This last line never finishes again. Checking further, computing the term gives no problem:

sage: translatedTerm = fTerms[6](x = x + xRoot, y = y + yRoot)
sage: translatedTerm
y^3 + (-4.3178944063131?)*y^2 + 6.2147373680233?*y - 2.9816199686770?
sage: resultSum
x^6 + (-6.458268171630608? - 3.092321934283960?*I)*x^5 + (13.39448867976803? + 16.64253693718441?*I)*x^4 - x^2*y^2 + y^4 + (-6.786915089516893? - 33.08934171990439?*I)*x^3 + 1.8785962708754?*x^2*y + (1.152756057210203? + 1.030773978094654?*I)*x*y^2 + (-5.7571925417508?)*y^3 + (-10.3655289872596? + 28.17627538055642?*I)*x^2 + (-1.1655632303041? - 1.9364081513640?*I)*x*y + (12.6128868526670? - 0.5941154734316342?*I)*y^2 + (10.8962422540875? - 7.47593052592029?*I)*x + (-13.3474152216295? + 0.6007161238107?*I)*y + 2.9816199686770? + 0.?e-14*I
sage: translatedTerm + resultSum

Summing up resultSum + translatedTerm never finishes (or I think sometimes it has thrown an error). Both have parent "Multivariate Polynomial Ring in x, y over Algebraic Field" so this should be a very simple computation. I suspect this is related to the constant term "0.?e-14*I" in resultSum. Any help on finding an alternate solution or understanding what is causing this error would be greatly appreciated. I am using Sage 9.5 if that seems relevant.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2024-10-02 12:19:01 +0200

Emmanuel Charpentier gravatar image

I have trouble rebuilding your problem (on 10.5.beta5). After running your definitions, I note :

sage: %time f(x=xRoot, y=yRoot)
CPU times: user 2.99 ms, sys: 0 ns, total: 2.99 ms
Wall time: 3.01 ms
0.?e-13 + 0.?e-14*I

but

sage: %time f(x=xRoot, y=yRoot).is_zero()
CPU times: user 1min 4s, sys: 15.8 ms, total: 1min 4s
Wall time: 1min 4s
True

Proving an equality in QQbar may be hard.

After this computation :

sage: %time f(x = x + xRoot, y = y + yRoot)
CPU times: user 433 ms, sys: 3.96 ms, total: 437 ms
Wall time: 436 ms
x^6 + (-6.458268171630608? - 3.092321934283960?*I)*x^5 + (13.394488679768032? + 16.64253693718441?*I)*x^4 - x^2*y^2 + y^4 + (-6.786915089516893? - 33.08934171990439?*I)*x^3 + 1.8785962708754?*x^2*y + (1.152756057210203? + 1.030773978094654?*I)*x*y^2 + (-4.7571925417508?)*y^3 + (-10.3655? + 28.1763?*I)*x^2 + (-1.1656? - 1.9364?*I)*x*y + (8.2950? - 0.5941?*I)*y^2 + (10.8963? - 7.4759?*I)*x + (-7.1327? + 0.6007?*I)*y

After reset()ing and rerunning your definitions :

sage: reset()
sage: R.<x, y>=QQbar[]
sage: f = x^6 + y^4 - y^2*x^2 + y^3 - y^2*x - y*x^2 + x^3
sage: yRoot = f.discriminant(x).univariate_polynomial().roots()[0][0] ; yRoot
-1.439298135437689?
sage: xRoot = f(y=yRoot).univariate_polynomial().roots()[1][0] ; xRoot
-1.076378028605102? - 0.5153869890473267?*I
sage: %time foo = f(x = x + xRoot, y = y + yRoot)
CPU times: user 1min 4s, sys: 11.7 ms, total: 1min 4s
Wall time: 1min 4s
sage: foo
x^6 + (-6.458268171630608? - 3.092321934283960?*I)*x^5 + (13.39448867976803? + 16.64253693718441?*I)*x^4 - x^2*y^2 + y^4 + (-6.786915089516893? - 33.08934171990439?*I)*x^3 + 1.8785962708754?*x^2*y + (1.152756057210203? + 1.030773978094654?*I)*x*y^2 + (-4.7571925417508?)*y^3 + (-10.3655289872596? + 28.17627538055642?*I)*x^2 + (-1.1655632303041? - 1.9364081513640?*I)*x*y + (8.2949924463539? - 0.5941154734316342?*I)*y^2 + (10.8962422540875? - 7.47593052592029?*I)*x + (-7.1326778536063? + 0.6007161238107?*I)*y

which does terminates "after a long time".

"L'éternité, c'est long. Surtout vers la fin"... HTH,

edit flag offensive delete link more

Comments

On my machine, attempting to prove also takes "forever" (>30 minutes). I wonder if the version of sage has something to do with it.

Barbadrian gravatar imageBarbadrian ( 2024-10-02 19:43:48 +0200 )edit

f(x = xRoot, y = yRoot).radical_expression() gives zero much faster than .is_zero().

Max Alekseyev gravatar imageMax Alekseyev ( 2024-10-03 05:54:19 +0200 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2024-10-02 01:19:26 +0200

Seen: 138 times

Last updated: Oct 02