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.