[sage-support] factoring in Gaussian integers
The following seems fishy: `` sage: K. = QuadraticField(-*1*) sage: K.factor(*13*) (Fractional ideal (-3*a - 2)) * (Fractional ideal (2*a + 3)) `` -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/71469fc7-dcca-4540-bb2a-a6d421f8560an%40googlegroups.com.
[sage-support] something seems wrong here
sage: d = *6* sage: p = d/*2* sage: p 3 sage: is_prime(p) False # Huh?!! sage: is_prime(*3*) True sage: p==*3* True This happens in version 8.7 and also in the current version (installed yesterday) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/9cb13872-298c-4463-b27d-b77ea288bfedn%40googlegroups.com.
[sage-support] regulator
I want to compute the regulator of a real quadratic field Q(sqrt d) to high precision, accurately enough to compute the fundamental unit. The default breaks at d = 331 where fundamental unit needs more than 53 bits (the precision of doubles). The documentation says that Pari computes to a higher precision than SageMath. Also somewhere it says that if you get a good enough approximation to the regulator, it's trivial to refine it to high accuracy. It refers to "the tutorial" without a link; I read the Pari-GP tutorials on algebraic number theory without finding any explanation of that remark. So actually there are two questions here: point me to an explanation of refining the computation of the regulator, and secondly, fix the following code so that it doesn't print "oops" when d = 331. gp.set_real_precision(256) # doesn't seem to do anything def check_unit(N): for d in range(10,N): if not is_squarefree(d): continue K. = QuadraticField(d) G = K.unit_group() [x,y] = G.gen(1).value() x = abs(x) R = K.regulator(None) twox = round(exp(R)) x2 = twox/2 y2 = round(twox/sqrt(d))/2 print(d,x,x2,y,y2,exp(R)/2) if x != x2 or y != y2: print("oops!") return if norm_is_negative(x,d): print("norm is negative") -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/1775cda8-6650-4073-92ea-a5918f896631n%40googlegroups.com.
[sage-support] Re: log to the base 2
And also sage: log(*2*,x) log(2)/log(x) which goes a long ways to explain the previous results. So log(2,x) is not actually log to the base 2 of x. On Saturday, July 18, 2020 at 11:45:06 AM UTC-7, Michael Beeson wrote: > > sage: n(log(*2*,*408*/*370*)) > > 7.08999206263157 > > sage: log(*2*,*2*) > > 1 > > sage: *2*^*7* > > 128 > > sage: n(log(*2*,*408.0*/*370*)) > > 7.08999206263157 > > sage: version() > > 'SageMath version 8.7, Release Date: 2019-03-23' > > sage: n(log(*2*,*1.001*)) > > 693.493696416899 > > sage:log(2,1) gives an error instead of 0. > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/be80ff3d-5a5f-4a0a-9b5f-e5c227976d7do%40googlegroups.com.
[sage-support] log to the base 2
sage: n(log(*2*,*408*/*370*)) 7.08999206263157 sage: log(*2*,*2*) 1 sage: *2*^*7* 128 sage: n(log(*2*,*408.0*/*370*)) 7.08999206263157 sage: version() 'SageMath version 8.7, Release Date: 2019-03-23' sage: n(log(*2*,*1.001*)) 693.493696416899 sage:log(2,1) gives an error instead of 0. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/89cc7e10-6752-440e-9ed2-f4cf4b120089o%40googlegroups.com.
[sage-support] compute regulator of quadratic field
SageMath has built-in functions to compute the regulator and the fundamental unit of a quadratic field. The regulator of a quadratic field is the log of the absolute value of the fundamental unit. So, the following code should print out the same number on each line. But, as you can check, it does so only some of the time. Try checkRegulator(30) for example.I am using version 8.7. I also wrote other code (not included here) based on the Dedekind zeta function to compute the regulator. It agrees with SageMath's "regulator" function rather than with log of the fundamental unit. def checkRegulator(N): for d in range(3,N): if not is_squarefree(d): continue K. = QuadraticField(d) G = K.unit_group() u = G.gen(1).value(); Rdirect = abs(n(log(u))) RSage = K.regulator() print(d,RSage,Rdirect) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/e0dfaf5a-d0d8-4ab1-acb8-595946c5f743%40googlegroups.com.
[sage-support] Re: simplification options
I appreciate Eric's post, and I do use subs sometimes, but it makes me nervous since it will happily substitute any old thing you tell it to, even an incorrect thing. So, if your idea is to check a computation, it is a dangerous thing. True, if you put only correct equations in, you'll usually get correct ones out. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] simplification options
In the following example I would like to make Sage realize that (p,q,r) are constants and (a,b) are variables so in the end everything should be expressed as a polynomial in a,b. In particular b^2 should be rewritten as 1-a^2 (b and a are actually sin and cosine of something) but b should not be rewritten as sqrt(1-a^2). And, in the end the terms should be grouped so we see explicitly the coefficients of a,b,1, and a^2. Of course this example is simple enough to do by hand, but I want to know how to control Sage enough to get this to happen in Sage. I tried various simplification functions.I suppose I could start over, not using "symbolic expressions" but declaring K to be a suitable field or ring, maybe a quadratic extension of the field of rational functions in a. That is probably the "right" way to do it. But I wish there were a simpler way. I'm writing a paper with little snippets of Sage code with which the reader, who will be a mathematician probably unfamiliar with SageMath, can check the computations, or see how the computations can be checked. So the code should be readable to such a person, ruling out the introduction of new fields.The code below is perfectly readable in that sense, but it doesn't quite do the job. def mar11b(): var('p,q,r,a,b') b = sqrt(1-a^2) lam = p*a + r*b + q mu = r*a - p*b lam = sqrt(N/2) eq = lam^2 - (p*a+r*b+q)^2 eq = eq.expand() print(eq) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: solution of a 4th degree equation is real despite containing I but causes trouble
Oh, and range(0,n(t)) also crashes. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] solution of a 4th degree equation is real despite containing I but causes trouble
The solution of a cubic or quartic may require the use of complex numbers. (Indeed that's how the complex numbers were first discovered.) Below I exhibit a long expression for such a number that solve() found for me. It evaluates using n(t) to a real (decimal) number, and it passes " t in RR" although that takes five minutes and turns the fan of my laptop on (a sign of serious CPU use). Then I enter this number in range(0,t), which should be OK if t is real, but it causes the same crash that range(0,I) causes, complaining that t is complex. Below is the code (Sage version is 8.0--I plan to update Real Soon Now). Well, so you may wonder "what is the actual question"? It is, how can I get my hands on this number in a form that I can actually put into range? I want to bound a search by the size of the solution of a quartic and could not manage it because of this problem. def test(): t = -2/3*((sqrt(3)*sqrt((675*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(2/3) + 552*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) + 364)/(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3)) - 45*sqrt(-(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) - 704/225*sqrt(3)/sqrt((675*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(2/3) + 552*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) + 364)/(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3)) - 364/675/(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) + 368/225) + 6)^2 - 90*sqrt(3)*sqrt((675*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(2/3) + 552*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) + 364)/(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3)) + 4050*sqrt(-(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) - 704/225*sqrt(3)/sqrt((675*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(2/3) + 552*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) + 364)/(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3)) - 364/675/(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) + 368/225) - 4590)/((sqrt(3)*sqrt((675*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(2/3) + 552*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) + 364)/(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3)) - 45*sqrt(-(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) - 704/225*sqrt(3)/sqrt((675*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(2/3) + 552*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) + 364)/(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3)) - 364/675/(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) + 368/225) + 6)*(sqrt(1/3)*sqrt((675*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(2/3) + 552*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) + 364)/(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3)) - 15*sqrt(-(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) - 704/75*sqrt(1/3)/sqrt((675*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(2/3) + 552*(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) + 364)/(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3)) - 364/675/(88/30375*I*sqrt(79)*sqrt(3) + 1328/3375)^(1/3) + 368/225) + 2)) + 0.0100 print(n(t)) print(t in RR) print(range(0,t)) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] trig simplify disappointed me
sage: t tan(1/2*arctan(12/5)) sage: t.trig_simplify() sin(1/2*arctan(12/5))/cos(1/2*arctan(12/5)) sage: n(t) 0.667 But trig_simplify couldn't get 2/3. Maybe there is a fancier command that will do it? -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: solve() behavior
after solving an equation (or not) for x, I can check if the answer still contains x by ans.has(x). That should weed out any non-explicit solutions. But still: am I guaranteed for any class of equations, e.g. polynomial equations of degree <= 4, that if solve produces an empty list there really are no solutions? (I mean of course, am I guaranteed that if there are no bugs, this is true?) > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: solve() behavior
When I try to reproduce Eric's post, I get an error message about an unexpected keyword argument (maybe my version of Sage is too old.) But look at this: sage: solve(*2**(x+sqrt(*1*-x^*2*))-*7*,x,explicit_solutions=True) [1/4*I*sqrt(41) + 7/4 == -1/2*sqrt(7/2*I*sqrt(41) + 2), 1/4*I*sqrt(41) + 7/4 == 1/2*sqrt(7/2*I*sqrt(41) + 2)] That doesn't look like an "explicit solution" to me. How can I force solve to return only actual solutions, i.e. x = something not containing x? -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: solve() behavior
Eric's post shows me how to get that particular example solved. But my real concern is, when my code (inside some deep loop) calls solve, I want to know (a) if it returns an answer, that answer really is a solution, and (b) if it returns an empty list, there really is no solution. So this example shows that (a) is sometimes false. And when is (b) true? On Monday, February 18, 2019 at 12:56:56 PM UTC-8, Michael Beeson wrote: > > sage: solve(*2**(x+sqrt(*1*-x^*2*))-*7*,x) > > [x == -sqrt(-x^2 + 1) + 7/2] > > > sage: version() > > 'SageMath version 8.0, Release Date: 2017-07-21' > > > That doesn't look like a solution to me because x still appears on the > right. > > Is this the intended behavior? > > > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] solve() behavior
sage: solve(*2**(x+sqrt(*1*-x^*2*))-*7*,x) [x == -sqrt(-x^2 + 1) + 7/2] sage: version() 'SageMath version 8.0, Release Date: 2017-07-21' That doesn't look like a solution to me because x still appears on the right. Is this the intended behavior? -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: please explain casting in this example
Well, the real cure is to use IntegerRange instead of range. Sorry to bother those of you who actually can read a manual. On Friday, February 15, 2019 at 2:56:14 PM UTC-8, Michael Beeson wrote: > > def test(p,q): > t = p/q; > print(p,q,p/q,t) > def test2(): > for p in range(1,4): > for q in range(1,4): > test(p,q) > > sage: test2() > > (1, 1, 1, 1) > > (1, 2, 0, 0) > > (1, 3, 0, 0) > > (2, 1, 2, 2) > > (2, 2, 1, 1) > > (2, 3, 0, 0) > > (3, 1, 3, 3) > > (3, 2, 1, 1) > > (3, 3, 1, 1) > > sage: test(*2*,*3*) > > (2, 3, 2/3, 2/3) > > sage: version() > > 'SageMath version 8.0, Release Date: 2017-07-21' > > > When test(2,3) is executed at top-level, 2/3 is not cast to an integer. > But when > > it is executed inside test2, 2/3 becomes 0. Why? and how to prevent it? > > > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: please explain casting in this example
And it can be fixed by inserting p = sage.rings.integer.Integer(p) after p is generated by range. Comments on this still welcome. This may be a dumb question but now I'm worried that perhaps this problem exists silently elsewhere in my code. On Friday, February 15, 2019 at 2:56:14 PM UTC-8, Michael Beeson wrote: > > def test(p,q): > t = p/q; > print(p,q,p/q,t) > def test2(): > for p in range(1,4): > for q in range(1,4): > test(p,q) > > sage: test2() > > (1, 1, 1, 1) > > (1, 2, 0, 0) > > (1, 3, 0, 0) > > (2, 1, 2, 2) > > (2, 2, 1, 1) > > (2, 3, 0, 0) > > (3, 1, 3, 3) > > (3, 2, 1, 1) > > (3, 3, 1, 1) > > sage: test(*2*,*3*) > > (2, 3, 2/3, 2/3) > > sage: version() > > 'SageMath version 8.0, Release Date: 2017-07-21' > > > When test(2,3) is executed at top-level, 2/3 is not cast to an integer. > But when > > it is executed inside test2, 2/3 becomes 0. Why? and how to prevent it? > > > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: please explain casting in this example
I see by inserting print(type(p)) that range produces objects of type int, while when it's called from top-level the types of p and q are sage.rings.integer.Integer. So that answers "why" but not "how to prevent". On Friday, February 15, 2019 at 2:56:14 PM UTC-8, Michael Beeson wrote: > > def test(p,q): > t = p/q; > print(p,q,p/q,t) > def test2(): > for p in range(1,4): > for q in range(1,4): > test(p,q) > > sage: test2() > > (1, 1, 1, 1) > > (1, 2, 0, 0) > > (1, 3, 0, 0) > > (2, 1, 2, 2) > > (2, 2, 1, 1) > > (2, 3, 0, 0) > > (3, 1, 3, 3) > > (3, 2, 1, 1) > > (3, 3, 1, 1) > > sage: test(*2*,*3*) > > (2, 3, 2/3, 2/3) > > sage: version() > > 'SageMath version 8.0, Release Date: 2017-07-21' > > > When test(2,3) is executed at top-level, 2/3 is not cast to an integer. > But when > > it is executed inside test2, 2/3 becomes 0. Why? and how to prevent it? > > > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] please explain casting in this example
def test(p,q): t = p/q; print(p,q,p/q,t) def test2(): for p in range(1,4): for q in range(1,4): test(p,q) sage: test2() (1, 1, 1, 1) (1, 2, 0, 0) (1, 3, 0, 0) (2, 1, 2, 2) (2, 2, 1, 1) (2, 3, 0, 0) (3, 1, 3, 3) (3, 2, 1, 1) (3, 3, 1, 1) sage: test(*2*,*3*) (2, 3, 2/3, 2/3) sage: version() 'SageMath version 8.0, Release Date: 2017-07-21' When test(2,3) is executed at top-level, 2/3 is not cast to an integer. But when it is executed inside test2, 2/3 becomes 0. Why? and how to prevent it? -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: documentation?
Thank you, that was very instructive to see the "right way" to start by using an appropriate ring. I guess you can go on to divide out by the other linear factor and get the quadratic equation, and solve it, but I got that far myself, and then could not work with the solutions of the quadratic equation. But you may be able to do that because then they will belong to some algebraic number field which will come equipped with useful algorithms. On Thursday, November 15, 2018 at 9:47:24 AM UTC-8, slelievre wrote: > > For the problem at hand here, I would work with polynomials in `x` > with coefficients in the ring of polynomials in `N` and `M` over > the field of algebraic numbers, and do something like the following. > > Define the ring of polynomials over the field of algebraic numbers. > > sage: R. = QQbar[] > > Define the ring of polynomials over the above polynomial ring. > > sage: S. = R[] > > Define `a`, `i`, `b`, `c`, `X`, `f` from the question. > > sage: a = QQbar(3).sqrt() / 2 > sage: i = QQbar(I) > sage: b = (x - ~x) / (2 * i) > sage: c = (a * (x + ~x) + b) / 2 > sage: X = (M / 3) * (a + b + c) > sage: f = 24 * (X^2 - N * b * c) * x^2 > > Note that the definition of `b` involves the inverse of `x` (which can be > denoted by `~x` or `x^-1`) and therefore lives in the fraction field of > `S`, > rather than in `S` itself. Therefore, so do `c`, `X`, and `f`. > > Check if `f` however represents an element in `S` as follows: > > sage: f in S > True > > and then construct the corresponding element of `S` (we could call it `f` > but here we call it `ff`). > > sage: ff = S(f) > > Check that `ff` vanishes at `-1`, or equivalently is divisible by `x + 1`. > > sage: ff(-1) > 0 > sage: d = x + 1 > sage: d.divides(ff) > True > > Perform exact division (to stay in the polynomial ring `S` rather than move > to its fraction field). > > sage: g = ff // d > > Define `t` as an algebraic number. > > sage: t = QQbar(exp(-pi*I/3)) > > Check that `g` vanishes at `t` or equivalently is divisible by `x - t`. > > sage: g(t) > 0 > sage: dd = x - t > sage: dd.divides(g) > True > > Perform exact division. > > sage: h = g // dd > > Inspect the result: > > sage: h > ((-1.000? - 1.732050807568878?*I)*M^2 > + (3.000? + 5.196152422706632?*I)*N)*x^2 > + ((1.000? - 1.732050807568878?*I)*M^2 > + (3.000? - 5.196152422706632?*I)*N)*x > + 2*M^2 + (-6)*N > > Or as a list (the list of coefficients of `x^j`, for `j` from `0` to the > degree): > > sage: h.list() > [2*M^2 + (-6)*N, > (1.000? - 1.732050807568878?*I)*M^2 > + (3.000? - 5.196152422706632?*I)*N, > (-1.000? - 1.732050807568878?*I)*M^2 > + (3.000? + 5.196152422706632?*I)*N] > > Define somme pretty_print functions to inspect these algebraic numbers: > > def pretty_print_qqbar(z): > a, b = z.real().radical_expression(), z.imag().radical_expression() > return "{} + {}*i".format(a, b) > > def pretty_print_x_coeff(xc): > return " + ".join("({})*{}".format(pretty_print_qqbar(xc[m]), m) > for m in xc.monomials()) > > and print `h` in a nice form: > > print("h = " + > "\n+ ".join("({})*x^{}".format(pretty_print_x_coeff(xc), k) > for k, xc in enumerate(g.list( > > The result is: > > h = ((-1 + sqrt(3)*i)*M^2 + (3 + -3*sqrt(3)*i)*N)*x^0 > + ((3 + sqrt(3)*i)*M^2 + (-3 + 3*sqrt(3)*i)*N)*x^1 > + ((3 + -sqrt(3)*i)*M^2 + (-3 + -3*sqrt(3)*i)*N)*x^2 > + ((-1 + -sqrt(3)*i)*M^2 + (3 + 3*sqrt(3)*i)*N)*x^3 > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] documentation?
After quite some searching I did not succeed to find documentation for sage functions to work with complex numbers as much as I would like. For example if I have a complicated rational expression, how can I tell Sage "bring this to the form a + bi". It seems real() and imag() only work if no pre-processing is needed. How about "multiply numerator and denominator by denominator.conjugate()" ? There's probably a chapter in the documentation about this, could someone please point me to it, I seem to be incompetent at finding it, sorry. Since people want something concrete to look at, not just a general question, here is some code. You'll see that it computes a certain complex function (actually two of them) with integer parameters N and M, the solution(s) of a certain equation. I'd like to compute that the absolute value of those expressions must be 1. The code below computes it numerically for some more or less random values of N and M, and it is 1. for those values, but I can't figure out how to compute it symbolically. Also, if there's a better way to do polynomial division than I've used below, please tell me. def nov13b(): var('p,q,r,N,M,x') a = sqrt(3)/2 b = (x-x^(-1))/(2*i) c = (sqrt(3)/2)* (x+x^(-1))/2 + (1/2)*(x-x^(-1))/(2*i) X = (M/3)*(a+b+c) f = 24*(X^2-N*b*c)*x^2 g = (f.maxima_methods().divide(x+1)[0]).full_simplify() print(g.full_simplify()) print("") t = exp(-pi*i/3) print(g(x=t).full_simplify()) print("") h = (g.maxima_methods().divide(x-t)[0]).full_simplify() print("h = ") print(h) print("") answers = solve(h,x) assume(N,'integer') assume(M,'integer') for u in answers: print("") ans = u.rhs().simplify() for k in range(230,245): ans_numerical = abs(ans.substitute(M=11,N=243)).simplify() print(n(ans_numerical)) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: documentation?
Oops, "243" in my post should have been "k". I don't know how to edit a post after I've posted it. On Wednesday, November 14, 2018 at 10:31:34 PM UTC-8, Michael Beeson wrote: > > After quite some searching I did not succeed to find documentation for > sage functions to work with complex numbers as much as I would like. > For example if I have a complicated rational expression, how can I tell > Sage "bring this to the form a + bi". It seems real() and imag() only > work > if no pre-processing is needed. How about "multiply numerator and > denominator by denominator.conjugate()" ? There's probably a chapter in > the documentation about this, could someone please point me to it, I > seem to be incompetent at finding it, sorry. > > Since people want something concrete to look at, not just a general > question, here is some code. You'll see that it computes a certain > complex function (actually two of them) > with integer parameters N and M, the solution(s) of a certain equation. > I'd like to compute that the absolute value of those expressions must be 1. > The > code below computes it numerically for some more or less random values of > N and M, and it is 1. for those values, but I can't figure out how to > compute it symbolically. Also, if there's a better way to do polynomial > division than I've used below, please tell me. > > def nov13b(): > var('p,q,r,N,M,x') > a = sqrt(3)/2 > b = (x-x^(-1))/(2*i) > c = (sqrt(3)/2)* (x+x^(-1))/2 + (1/2)*(x-x^(-1))/(2*i) > X = (M/3)*(a+b+c) > f = 24*(X^2-N*b*c)*x^2 > g = (f.maxima_methods().divide(x+1)[0]).full_simplify() > print(g.full_simplify()) > print("") > t = exp(-pi*i/3) > print(g(x=t).full_simplify()) > print("") > h = (g.maxima_methods().divide(x-t)[0]).full_simplify() > print("h = ") > print(h) > print("") > answers = solve(h,x) > assume(N,'integer') > assume(M,'integer') > for u in answers: > print("") > ans = u.rhs().simplify() > for k in range(230,245): > ans_numerical = abs(ans.substitute(M=11,N=243)).simplify() > print(n(ans_numerical)) > > > > > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: different result from file or at prompt
Justin, that is right. "return" caused a graph to be drawn. Now that you pointed out why it didn't work, I see another solution: graph = complex_plot(g, (-3, 3), (-3, 3)) graph.show() which doesn't require a return statement; since my original intention was to put the drawing command inside a loop and draw a lot of graphs, I'll need to do it with "show" rather than "return". Thank you. Michael On Tuesday, November 13, 2018 at 8:38:52 PM UTC-8, Michael Beeson wrote: > > def nov13(): > var('M,N,z') > f = (M^2-3*N)*(-i *sqrt(3)-1) *z^3 > f = f + (M^2 *(-i *sqrt(3) +3) + 3*N*(-i *sqrt (3) - 1))*z^2 > f = f + (M^2 *(i *sqrt(3)+3) + 3*N* (i* sqrt(3)-1))*z + (M^2-3*N)* (i* > sqrt(3)-1) > g = f.substitute(M=6,N=11) > complex_plot(g, (-3, 3), (-3, 3)) > > if this code is put in a file and the file is "attached" I get no plot, > but if > I paste the function body in to a prompt then I do get a (very nice) plot. > > I expected it would run from an attached file, which is how I usually use > SageMath. > Can someone explain why I don't get a plot that way? > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] different result from file or at prompt
def nov13(): var('M,N,z') f = (M^2-3*N)*(-i *sqrt(3)-1) *z^3 f = f + (M^2 *(-i *sqrt(3) +3) + 3*N*(-i *sqrt (3) - 1))*z^2 f = f + (M^2 *(i *sqrt(3)+3) + 3*N* (i* sqrt(3)-1))*z + (M^2-3*N)* (i* sqrt(3)-1) g = f.substitute(M=6,N=11) complex_plot(g, (-3, 3), (-3, 3)) if this code is put in a file and the file is "attached" I get no plot, but if I paste the function body in to a prompt then I do get a (very nice) plot. I expected it would run from an attached file, which is how I usually use SageMath. Can someone explain why I don't get a plot that way? -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] full_simplify() gets wrong answer
def demo(): var('N,x') test = ((N*(3*I*sqrt(3) + 9) + N*(3*I*sqrt(3) - 3)))*x print("test = ") print(test) print("test.full_simplify() = ") print(test.full_simplify()) Here is the output sage: demo() test = (N*(3*I*sqrt(3) + 9) + N*(3*I*sqrt(3) - 3))*x test.full_simplify() = (36*I*sqrt(3)*N + 6)*x The answer should have 6 where it has 36. If you take the "*x" off the end of test, then Sage answers correctly. sage: version() 'SageMath version 8.0, Release Date: 2017-07-21' -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] please explain this output
def test(): for b in range(5,6): for c in range(b+1,b+2): print(b,c,n(c/b)) print(5,6,n(6/5)) And the output sage: test() (5, 6, 1.00) (5, 6, 1.20) sage: version() 'SageMath version 8.0, Release Date: 2017-07-21' And the question: why are the two lines not identical? -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: How to define L-series?
I tried to follow Guninski's instructions. I found eulerprod.py and put it in the right directory and then I got an error due to not having psage.ellcurve.lseries.helper. I googled for that file and put it in helper.py but I still get an error. Maybe the file needs to have a complicated path matching the module name? What do I do now? sage: load eulerprod.py --- ImportError Traceback (most recent call last) /Users/beeson/ in () /Applications/sage/local/lib/python2.6/site-packages/sage/misc/preparser.pyc in load(filename, globals, attach) 1634 1635 if fpath.endswith('.py'): -> 1636 execfile(fpath, globals) 1637 elif fpath.endswith('.sage'): 1638 if (attach and attach_debug_mode) or ((not attach) and load_debug_mode): /Users/beeson/eulerprod.py in () 4 from sage.rings.all import is_RationalField, ZZ, Integer, QQ, O, ComplexField, CDF, primes, infinity as oo 5 from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve > 6 from psage.ellcurve.lseries.helper import extend_multiplicatively_generic 7 from sage.misc.all import prod 8 from sage.modular.abvar.abvar import is_ModularAbelianVariety ImportError: No module named psage.ellcurve.lseries.helper -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] plot command doesn't work from a function
sage: def testPlot(): : u = [[1,2],[3,4],[5,7]] : list_plot(u) : sage: testPlot() sage: doesn't produce any plot, but executing the body of the function directly at the sage prompt does produce a plot. What am I doing wrong? -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: Pell's equation
This question was simply a result of my misreading the example on page 93, where it says "We first solve Pell's equation x2 5y2 = 1 with d = 5 by nding the units of the ring of integers of Q(sqrt(5) using Sage." Of course I should have realized that just finding those units will give me the solutions of x^2 - 5 y^2 = plus or minus 1, not just 1. I'm sorry for taking your time to point that out. On Friday, October 31, 2014 9:14:02 AM UTC-7, Michael Beeson wrote: > > Here I attempt to solve Pell's equation with d = 1621 following the method > on page 93 of Stein's book. > But the solution produced is instead a solution of the negative Pell > equation x^2-y^2 = -1 (instead of 1). > Actually, the example on page 93 (after correcting the typo "v" to "u") > has the same problem: it claims > that [-2,1] solves Pell's equation with d=5, whereas, it really solves > the negative Pell equation. > > sage: K. = QuadraticField(1621) > sage: G = K.unit_group() > sage: u = G.1 > sage: L = [list(u^i) for i in [0..3]] > sage: L > [[1, 0], [4823622127875/2, 119806883557/2], [23267330432525342852015627/2, > 577903134597288688851375/2], [56116404965454319198851772383057215250, > 1393793173905903098261469193463230841]] > sage: x = L[2][0]; > sage: y = L[2][1]; > sage: x > 23267330432525342852015627/2 > sage: x = L[3][0]; > sage: y = L[3][1]; > sage: x > 56116404965454319198851772383057215250 > sage: y > 1393793173905903098261469193463230841 > sage: x^2-1621*y^2 > -1 > > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Pell's equation
Here I attempt to solve Pell's equation with d = 1621 following the method on page 93 of Stein's book. But the solution produced is instead a solution of the negative Pell equation x^2-y^2 = -1 (instead of 1). Actually, the example on page 93 (after correcting the typo "v" to "u") has the same problem: it claims that [-2,1] solves Pell's equation with d=5, whereas, it really solves the negative Pell equation. sage: K. = QuadraticField(1621) sage: G = K.unit_group() sage: u = G.1 sage: L = [list(u^i) for i in [0..3]] sage: L [[1, 0], [4823622127875/2, 119806883557/2], [23267330432525342852015627/2, 577903134597288688851375/2], [56116404965454319198851772383057215250, 1393793173905903098261469193463230841]] sage: x = L[2][0]; sage: y = L[2][1]; sage: x 23267330432525342852015627/2 sage: x = L[3][0]; sage: y = L[3][1]; sage: x 56116404965454319198851772383057215250 sage: y 1393793173905903098261469193463230841 sage: x^2-1621*y^2 -1 -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] is this a bug?
K. = FractionField(PolynomialRing(QQ,10,'pdegmfhlrN')) R. = K[] x = s + h/(4*l) G = e*l*x^4 - e*h*x^3 + (-3*e*l-e*r+N)*x^2 + 2*e*h*s + 2*e*l + 2*e*r-N print G The response looks fishy: e*l*s^4 + ((-30423614405477505635920876929024*e*h^2 - 243388915243820045087367015432192*e*l^2 - 81129638414606681695789005144064*e*l*r + 81129638414606681695789005144064*l*N)/(81129638414606681695789005144064*l))*s^2 + ((-2417851639229258349412352*e*h^3 + 9671406556917033397649408*e*h*l^2 - 9671406556917033397649408*e*h*l*r + 9671406556917033397649408*h*l*N)/(19342813113834066795298816*l^2))*s + (-3072*e*h^4 - 49152*e*h^2*l^2 + 524288*e*l^4 - 16384*e*h^2*l*r + 524288*e*l^3*r + 16384*h^2*l*N - 262144*l^3*N)/(262144*l^3) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-support] Re: polynomial remainder
Sage hangs on the following input: sage: K. = FractionField(PolynomialRing(QQ,4,'pdeN')) sage: R. = K[] sage: a = x-x^-1 sage: b = x^6-x^-6 sage: c = x^7-x^-7 sage: X = p*a + d*b + e*c sage: F = N*a*b*c - X^2*(x-x^-1) and also on this closely related input sage: K. = FractionField(PolynomialRing(QQ,4,'pdeN')) sage: R.= K[] sage: a = x-x^-1 sage: b = x^6-x^-6 sage: c = x^7-x^-7 sage: X = p*a + d*b + e*c sage: F = N*a*b*c sage: G = X^2*(x-x^-1) sage: F = F-G but if the last line is changed to sage: F = R(x^15*F) - R(x^15*G) then it works fine. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
[sage-support] Re: sage crashes on this input
So one problem with the original post was that the thing I was trying to cast to a polynomial isn't a polynomial. I should have multiplied by x^32, not x^16. The correct input works correctly (see below). Still, attempting to cast a rational function with too big a denominator to a polynomial ought to just fail, not crash. sage: K. = FractionField(PolynomialRing(QQ,4,'pdeN')) sage: R. = K[] sage: a = x^3-x^-3 sage: b = x^5-x^-5 sage: c = x^8-x^-8 sage: X = p*a + d*b + e*c sage: X = R(x^8*X) sage: X e*x^16 + d*x^13 + p*x^11 - p*x^5 - d*x^3 - e sage: f = X^2 - N*b*c*x^32 sage: f = R(f) sage: psi = cyclotomic_polynomial(30) sage: f.quo_rem(psi)[1] (-p^2 - 6*p*d - 2*p*e - N)*x^7 + (-4*p*d - 2*d*e - N)*x^6 + (p^2 + 2*p*d + 2*p*e - 2*d*e + N)*x^5 + (4*p*d + 2*d*e + 2*N)*x^4 + (8*p*d + 4*d*e + N)*x^3 + (4*p*d + 2*p*e + 2*d*e + e^2 + N)*x^2 + (2*p^2 - 2*p*d + 3*d^2 + 2*p*e + 2*d*e + 2*e^2)*x - p^2 - 6*p*d + e^2 -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
[sage-support] Re: sage crashes on this input
oh, never mind, this isn't the same computation as I didn't square X. On Monday, January 14, 2013 2:54:08 PM UTC-8, Michael Beeson wrote: > > If I break the computation into smaller pieces it works OK: > > > sage: K. = FractionField(PolynomialRing(QQ,4,'pdeN')) >> sage: R. = K[] >> sage: a = x^3-x^-3 >> sage: b = x^5-x^-5 >> sage: c = x^8-x^-8 >> sage: X = p*a +d*b + e*c >> sage: H = R(x^8 * X) >> sage: f = H - N*b*c*x^16 >> sage: f >> -N*x^29 + N*x^19 + e*x^16 + (d + N)*x^13 + p*x^11 - p*x^5 + (-d - N)*x^3 >> - e >> sage: psi = cyclotomic_polynomial(30) >> sage: psi >> x^8 + x^7 - x^5 - x^4 - x^3 + x + 1 >> sage: f.quo_rem(psi)[1] >> -d*x^7 + (p + N)*x^6 + (-p + d + N)*x^5 + (d - N)*x^4 + (-d - 2*N)*x^3 - >> N*x^2 + (-p - d - e - N)*x - d - e >> > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
[sage-support] Re: sage crashes on this input
If I break the computation into smaller pieces it works OK: sage: K. = FractionField(PolynomialRing(QQ,4,'pdeN')) > sage: R. = K[] > sage: a = x^3-x^-3 > sage: b = x^5-x^-5 > sage: c = x^8-x^-8 > sage: X = p*a +d*b + e*c > sage: H = R(x^8 * X) > sage: f = H - N*b*c*x^16 > sage: f > -N*x^29 + N*x^19 + e*x^16 + (d + N)*x^13 + p*x^11 - p*x^5 + (-d - N)*x^3 - > e > sage: psi = cyclotomic_polynomial(30) > sage: psi > x^8 + x^7 - x^5 - x^4 - x^3 + x + 1 > sage: f.quo_rem(psi)[1] > -d*x^7 + (p + N)*x^6 + (-p + d + N)*x^5 + (d - N)*x^4 + (-d - 2*N)*x^3 - > N*x^2 + (-p - d - e - N)*x - d - e > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
[sage-support] sage crashes on this input
sage: K. = FractionField(PolynomialRing(QQ,4,'pdeN')) sage: R. = K[] sage: a = x^3-x^-3 sage: b = x^5-x^-5 sage: c = x^8-x^-8 sage: X = p*a + d*b + e*c sage: f = x^16 *(X^2- N*b*c) and Sage does not answer. It just hangs and I have to kill the session. If it would answer I would like to continue with F = R(f) psi = cyclotomic_polynomial(30) g = F.quo_rem(psi)[1] g -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
[sage-support] substitution
sage: K. = FractionField(PolynomialRing(QQ,10,'depgmfuvjN')) sage: R. = K[] sage: w=u sage: u=0 sage: w u Why doesn't Sage answer 0 for the value of w here? More generally, if I have some complicated expression and I assign a value to one of its variables, Sage knows the value I've just assigned, but it doesn't propagate into the value of previously defined expressions using that variable. Please comment and please tell me how to force the substitution to take effect in previously defined expressions. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
[sage-support] Re: polynomial division
I want to take, for example, x^2 + 1 mod a*x and get quotient (1/a)*x and remainder 1.It doesn't work if I work in PolynomialRing because then you can't have 1/a. It doesn't work in the quotient field because then you always get remainder 0.To have f.quo_rem(g) work, I must anticipate all denominators that might occur in the coefficients and multiply f by them to begin with, as shown in the following example. But I'd rather have sage treat x as a polynomial variable and the others, like a, as rational variables. Can that be done? -- | Sage Version 4.8, Release Date: 2012-01-20 | | Type notebook() for the GUI, and license() for information.| -- sage: R. = PolynomialRing(QQ,2) sage: f = x^2 + 1 sage: g = a*x sage: f.quo_rem(g) (0, x^2 + 1) sage: f.parent() Multivariate Polynomial Ring in a, x over Rational Field sage: f = a*(x^2+1) sage: f.quo_rem(g) (x, a) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.
Re: [sage-support] Re: mwrank output
Dear John (please forgive my use of your first name, I should use your proper title but I don't know it) Thank you very much for taking the time to write that letter. I certainly did not mean to complain! I am very grateful to you for writing mwrank and making it available to us all! I did not mean to imply that the output was "cryptic". I am not an expert on elliptic curves nor am I an expert on Sage. Thank you also for showing me the proper way to interrogate Sage about an elliptic curve. The function E.rank() is indeed mentioned in the Sage Tutorial, p. 30, but not E.torsion_subgroup(). That said, the output I receive from mwrank is not the output you quote in your email. There is probably some mundane reason for that, but as the author, you might want to investigate why. Below I've pasted in what I got one minute ago (and also before of course) on Mac OSX with Sage version 4.8. You can see it's not quite as nice as what you quoted. Again, I'm not complaining about the output. I'm just reporting that it's not, on my machine, what it apparently is on your machine. The words "found points of rank 0" were the ones I did not understand, and I still don't understand, probably because I know only the very basics about elliptic curves, but I only know what "rank" means when applied to the MW group, not when applied to a point, so that is what confused me. I note that the output you quote doesn't contain that phrase. I'm sorry to have taken so much of your time with an essentially trivial question--you certainly don't need to reply with any further explanation. I have understood very clearly what mwrank is telling me, thanks to your first letter. Michael Beeson sage: E=EllipticCurve([0,40,0,300,0]); sage: E Elliptic Curve defined by y^2 = x^3 + 40*x^2 + 300*x over Rational Field sage: E.mwrank sage: E.mwrank() "Curve [0,40,0,300,0] : Working with minimal curve [0,1,0,-233,663] via [u,r,s,t] = [1,-13,0,0]\n\n3 points of order 2:\n[-17:0:1], [3:0:1], [13:0:1]\n\n\n* Using 2-isogeny number 1 *\n\n\nUsing 2-isogenous curve [0,100,0,100,0] (minimal model [0,1,0,-3233,69663])\n---\nFirst step, determining 1st descent Selmer groups\n---\nAfter first local descent, rank bound = 0\nrk(S^{phi}(E'))= 2\nrk(S^{phi'}(E))= 0\n\n---\nSecond step, determining 2nd descent Selmer groups\n---\n...skipping since we already know rank=0\nAfter second local descent, rank bound = 0\nrk(phi'(S^{2}(E)))= 2\nrk(phi(S^{2}(E')))= 0\nrk(S^{2}(E))= 2\nrk(S^{2}(E'))= 1\n\nThird step, determining E(Q)/phi(E'(Q)) and E'(Q)/phi'(E(Q))\n---\n1. E(Q)/phi(E'(Q))\n---\n(c,d) =(-50,600)\n(c',d')=(100,100)\nThis component of the rank is 0\n---\n2. E'(Q)/phi'(E(Q))\n---\nThis component of the rank is 0\n\n---\nSummary of results:\n---\n rank(E) = 0\n #E(Q)/2E(Q) = 4\n\nInformation on III(E/Q):\n #III(E/Q)[phi']= 1\n #III(E/Q)[2] = 1\n\nInformation on III(E'/Q):\n #phi'(III(E/Q)[2]) = 1\n #III(E'/Q)[phi]= 1\n #III(E'/Q)[2] = 1\n\n\nUsed descent via 2-isogeny with isogenous curve E' = [0,1,0,-3233,69663]\nRank = 0\nRank of S^2(E) = 2\nRank of S^2(E') = 1\nRank of S^phi(E') = 2\nRank of S^phi'(E) = 0\n\nSearching for points (bound = 8)...done:\n found points of rank 0\n and regulator 1\nProcessing points found during 2-descent...done:\n now regulator = 1\nSaturating (bound = 100)...done:\n points were already saturated.\n\n\nRegulator = 1\n\nThe rank and full Mordell-Weil basis have been determined unconditionally.\n (0.092342 seconds)" sage: On Thu, May 24, 2012 at 5:13 AM, John Cremona wrote: > Hello, I'm the author of mwrank. Maybe I am biased, but is the output > really so cryptic? You quote one phrase from the output which ends > > Summary of results: > --- > > rank(E) = 0 > #E(Q)/2E(Q) = 4 > > Information on III(E/Q): > > #III(E/Q)[phi'] = 1 > #III(E/Q)[2] = 1 > > Information on III(E'/Q): > #phi'(III(E/Q)[2]) = 1 > #III(E'/Q)[phi] = 1 > > #III(E'/Q)[2] = 1 > > > Used descent via 2-isogeny with isogenous curve E' = [0,1,0,-3233,69663] &g
[sage-support] mwrank output
E = EllipticCurve([sage: E = EllipticCurve([0,40,0,300,0]) sage: E.mwrank() Then mwrank reports that the rank is 0, which is good, but it also has a cryptic remark that "points of rank 0 were found". I independently wrote a short C program that uses the Nagel-Lutz theorem to verify there are no points of finite order on this curve, but of course, I might have made a mistake. What does mwrank mean by that remark, "points of rank 0 were found."? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] polynomial division
Sage version 4.6.1 (I know it's old, new one is downloading now, but I don't think this is a version problem.) Given: polynomial f in x with some letters for the coefficients, and polynomial psi of lower degree in x with constant coefficients. Wanted: remainder of f on division by psi as polynomials in x, with coefficients involving the letters in f. Problem: Sage treats f as a polynomial in many variables and I can't convince it to treat it as a polynomial in x only and perform the division (or pseudo division). Example: sage: R. = PolynomialRing(QQ,6) sage: a = x - x^-1 sage: b = x^4-x^-4 sage: c = x^9 - x^-9 sage: f = N*a*b*c - (p*a+r*c)*(m*a + l *c) sage: t = x^2 - x^-2 sage: f = x^20*(N*a*b*c - (p*a+r*c)*(m*a + l *c)*t) sage: f -x^40*r*l + x^36*r*l + x^34*N - x^32*r*m - x^32*p*l - x^32*N + x^30*r*m + x^30*p*l + x^28*r*m + x^28*p*l - x^26*r*m - x^26*p*l - x^26*N - x^24*p*m + x^24*N + 2*x^22*p*m + 2*x^22*r*l - 2*x^18*p*m - 2*x^18*r*l + x^16*p*m - x^16*N + x^14*r*m + x^14*p*l + x^14*N - x^12*r*m - x^12*p*l - x^10*r*m - x^10*p*l + x^8*r*m + x^8*p*l + x^8*N - x^6*N - x^4*r*l + r*l Now psi should be the 28-th cyclotomic polynomial x^12-x^10+x^8...; so in a multivariate polynomial I can't compute that directly, first sign of trouble. So I typed it in, and then f.quo_rem(psi) does not yield the desired answer, because as polynomials in 6 variables, psi does not divide f. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: real part incorrectly simplified away
It seems that var('z') makes sage think z is real. simplify(real(z)) returns z and simplify(imag(z)) returns 0. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] real part incorrectly simplified away
Here are the contents of a sage file. var('z') C = ComplexField() i = C(0,1) X = real(integral(z,z)) print X X = simplify(X) print X Here is the corresponding output 1/2*real_part(z)^2 - 1/2*imag_part(z)^2 1/2*z^2 The first line is already surprising as I expected 1/2 * real_part(z^2). But it's mathematically correct! The second line, however, is not correct. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] sage-64.txt
I downloaded the latest 64-bit dmg of Sage for OS X and installed it. It works, but I get a strange error message about sage-64.txt. Specifically, if I put the following lines in a sage file and run sage with that file for input, (here are the lines) L = [[cos(pi*i/100),sin(pi*i/100)] for i in range(200)] print "1"; p = polygon(L, rgbcolor=(1,1,0)) print "2"; p.show() print "3" then I do get the plot from p.show, but in the console window I get the following output: Detected SAGE64 flag Building Sage on OS X in 64-bit mode Building Sage on OS X in 64-bit mode Creating SAGE_LOCAL/lib/sage-64.txt since it does not exist Detected SAGE64 flag Building Sage on OS X in 64-bit mode Building Sage on OS X in 64-bit mode Creating SAGE_LOCAL/lib/sage-64.txt since it does not exist Detected SAGE64 flag Building Sage on OS X in 64-bit mode 1 2 3 Michael-Beesons-iMac:~ beeson$ The error messages repeat once for every line in the input file (yet the all precede the output from any of the commands). If sage is started from the shell prompt, I get this error message just once, and the interactive session is thereafter normal. Googling the error message produced a reference to patch 9960 but I couldn't make sense of what to do to fix it. Searching this site for the error message or for sage-64.txt produced no results. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: basic plotting
Thanks. This version of sage worked fine for all the things I wanted to do till today; I'll get the latest version immediately. In case your questions were not merely rhetorical: I did see that warning message, but since what I was doing was graphical (i.e. numerical) and it refers to symbolic computations, and since I did many symbolic computations successfully in spite of that message, I have grown used to ignoring that message. On Jan 30, 3:03 pm, William Stein wrote: > On Sun, Jan 30, 2011 at 1:54 PM, Michael Beeson wrote: > > -- > > | Sage Version 4.2.1, Release Date: 2009-11-14 | > > | Type notebook() for the GUI, and license() for information. | > > -- > > WARNING: There is one major unsolved bug in some versions of > > Sage on OS X 10.6 that causes an 'Abort trap' crash when > > doing certain symbolic computations. > > Seehttp://trac.sagemath.org/sage_trac/ticket/7095/. > > sage: circle((1,1),1) > > /Applications/sage/local/bin/sage-sage: line 203: 56490 Abort > > trap sage-ipython "$@" -i > > logout > > > [Process completed] > > > Running on Mac OS X. I get this same error message when running any > > of the first few plotting examples from either the sage online > > documentation or page 31 of the "Sage Tutorial" book. > > Sage seems to be correctly installed as I have done many other > > (symbolic) computations in Sage with good results. > > Why are you using Sage-4.2.1, which is from 2009? Also, did you see > the big warning messages that specifically says you'll get an issue, > exactly like you get. > > Fortunately, Craig Citro heroically fixed the problem you're seeing > well over a year ago. Just get the new version of Sage. > > -- William -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] basic plotting
-- | Sage Version 4.2.1, Release Date: 2009-11-14 | | Type notebook() for the GUI, and license() for information.| -- WARNING: There is one major unsolved bug in some versions of Sage on OS X 10.6 that causes an 'Abort trap' crash when doing certain symbolic computations. See http://trac.sagemath.org/sage_trac/ticket/7095/. sage: circle((1,1),1) /Applications/sage/local/bin/sage-sage: line 203: 56490 Abort trap sage-ipython "$@" -i logout [Process completed] Running on Mac OS X. I get this same error message when running any of the first few plotting examples from either the sage online documentation or page 31 of the "Sage Tutorial" book. Sage seems to be correctly installed as I have done many other (symbolic) computations in Sage with good results. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] field of symbolic expressions
I want to create a vector space of dimension three, over the field whose elements are symbolic expressions. (The reason is that then I can do vector calculus on such objects, which represent surfaces in 3- space if the expressions depend on 2 parameters.) How can I do this? The following, for example, doesn't work: sage: cos(t) cos(t) sage: type(cos(t)) sage: V = VectorSpace(Expression,3) --- AttributeErrorTraceback (most recent call last) /Users/beeson/ in () /Applications/sage/local/lib/python2.6/site-packages/sage/modules/ free_module.pyc in VectorSpace(K, dimension, sparse, inner_product_matrix) 399 TypeError: Argument K (= Integer Ring) must be a field. 400 """ --> 401 if not K.is_field(): 402 raise TypeError, "Argument K (= %s) must be a field." % K 403 if not sparse in (True,False): AttributeError: type object 'sage.symbolic.expression.Expression' has no attribute 'is_field' -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] norm or absolute value
sage: var('z'); var('a');var('b'); sage: F = a*z + i*b*z^2 sage: Now F.norm() or something should give me (a*z)^2 + (b*z^2)^2, but I can't find a command to do that. I want to do this when F is a polynomial of degree 6 with complex rational coefficients to eliminate i and produce a polynomial of degree 12 with rational coefficients. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] possible error in manual
On the page http://www.sagemath.org/doc/reference/sage/symbolic/expression.html the first example has eqn.subs(x==5) and I think it should be eqn.subs(x=5) -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: resultant
Oh, gcd is the multivariate gcd, not the gcd as a polynomial in z. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: resultant
But look at this: sage: F.gcd(G) z^2 + 1 Reply comes back instantly. This is really strange as it should have to perform more or less the same computation for the gcd as for the resultant, shouldn't it? And I would have expected the gcd to involve all those parameters, or at least some of them. On Jan 31, 6:37 pm, Michael Beeson wrote: > So taking your suggestion to use a quadratic number field, I get rid > of syntax errors at last. But I guess the problem is too difficult > as no answer comes back in a few minutes. > I let Mathematica run a similar problem for 36 hours with no reply; > but I don't understand why it's too difficult. Seems like it should > be 16 polynomial quasi-divisions. I guess the > coefficient expressions must blow up. But even if they have > thousands of terms, polynomial division is quadratic so should happen > in a few seconds. > > sage: R. = QQ[i] > sage: K. = R[] > sage: F = i*m*z^14 + (d+g)*z^13 + i*(f-p)*z^12 + e*z^11 + i*f*z^10 + > (e-g)*z^9 + i*(m+p)*z^8 + 2*d*z^7 - i*(m+p)*z^6 + (e-g)*z^5 -i*f*z^4 + > e*z^3 - i*(f-p)*z^2 + (d+g)*z - i*m > sage: G = d*z^16 - (l+i*p)*z^15 + (e+i*h)*z^14 - r*z^13 + e*z^12 - (r > - i*p)*z^11 + (d-i*h)*z^10 - l*z^9 + l*z^7 - (d + i*h)*z^6 + (r+i*p) > *z^5 - e*z^4 + r*z^3 - (e-i*h)*z^2 + (l-i*p)*z -d > sage: F.resultant(G) -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: resultant
So taking your suggestion to use a quadratic number field, I get rid of syntax errors at last. But I guess the problem is too difficult as no answer comes back in a few minutes. I let Mathematica run a similar problem for 36 hours with no reply; but I don't understand why it's too difficult. Seems like it should be 16 polynomial quasi-divisions. I guess the coefficient expressions must blow up. But even if they have thousands of terms, polynomial division is quadratic so should happen in a few seconds. sage: R. = QQ[i] sage: K. = R[] sage: F = i*m*z^14 + (d+g)*z^13 + i*(f-p)*z^12 + e*z^11 + i*f*z^10 + (e-g)*z^9 + i*(m+p)*z^8 + 2*d*z^7 - i*(m+p)*z^6 + (e-g)*z^5 -i*f*z^4 + e*z^3 - i*(f-p)*z^2 + (d+g)*z - i*m sage: G = d*z^16 - (l+i*p)*z^15 + (e+i*h)*z^14 - r*z^13 + e*z^12 - (r - i*p)*z^11 + (d-i*h)*z^10 - l*z^9 + l*z^7 - (d + i*h)*z^6 + (r+i*p) *z^5 - e*z^4 + r*z^3 - (e-i*h)*z^2 + (l-i*p)*z -d sage: F.resultant(G) -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: resultant
"i" is sqrt(-1), which sage seems usually to realize without being told. Anyway there is no "i" in my first post on the resultant, and also I get the same error with "CC" in place of "QQ". On Jan 31, 3:38 pm, William Stein wrote: > 2010/1/31 Michael Beeson : > > > another failed attempt to compute a resultant, that doesn't involve > > any quotient fields: > > > sage: R.=QQ[] > > sage: F = i*m*z^14 + (d+g)*z^13 + i*(f-p)*z^12 + e*z^11 + i*f*z^10 + > > (e-g)*z^9 + i*(m+p)*z^8 + 2*d*z^7 - i*(m+p)*z^6 + (e-g)*z^5 -i*f*z^4 + > > e*z^3 - i*(f-p)*z^2 + (d+g)*z - i*m > > What is "i" above? It's not an element of R. Did you forget to > define it? Or do you really want sqrt(-1)... in which case you should > replace QQ by a quadratic number field. > > > > > > > sage: G = d*z^16 - (l+i*p)*z^15 + (e+i*h)*z^14 - r*z^13 + e*z^12 - (r > > - i*p)*z^11 + (d-i*h)*z^10 - l*z^9 + l*z^7 - (d + i*h)*z^6 + (r+i*p) > > *z^5 - e*z^4 + r*z^3 - (e-i*h)*z^2 + (l-i*p)*z -d > > sage: F.resultant(G) > > --- > > AttributeError Traceback (most recent call > > last) > > > /Users/beeson/ in () > > > AttributeError: 'sage.symbolic.expression.Expression' object has no > > attribute 'resultant' > > > and I get the same result with "CC" in place of "QQ" > > > -- > > To post to this group, send email to sage-support@googlegroups.com > > To unsubscribe from this group, send email to > > sage-support+unsubscr...@googlegroups.com > > For more options, visit this group > > athttp://groups.google.com/group/sage-support > > URL:http://www.sagemath.org > > -- > William Stein > Associate Professor of Mathematics > University of Washingtonhttp://wstein.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] resultant
another failed attempt to compute a resultant, that doesn't involve any quotient fields: sage: R.=QQ[] sage: F = i*m*z^14 + (d+g)*z^13 + i*(f-p)*z^12 + e*z^11 + i*f*z^10 + (e-g)*z^9 + i*(m+p)*z^8 + 2*d*z^7 - i*(m+p)*z^6 + (e-g)*z^5 -i*f*z^4 + e*z^3 - i*(f-p)*z^2 + (d+g)*z - i*m sage: G = d*z^16 - (l+i*p)*z^15 + (e+i*h)*z^14 - r*z^13 + e*z^12 - (r - i*p)*z^11 + (d-i*h)*z^10 - l*z^9 + l*z^7 - (d + i*h)*z^6 + (r+i*p) *z^5 - e*z^4 + r*z^3 - (e-i*h)*z^2 + (l-i*p)*z -d sage: F.resultant(G) --- AttributeErrorTraceback (most recent call last) /Users/beeson/ in () AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'resultant' and I get the same result with "CC" in place of "QQ" -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] resultant
The following sage session shows a call to compute the resultant of two polynomials that fails, and another call that seems quite similar in syntax and semantics that succeeds just fine. What's going on here? It seems to not realize that f is a polynomial, since it says it's a FractionFieldEle object. Is there a way to make it realize that f is a polynomial? sage: R. = QQ[] sage: a = z^2 - z^-2 sage: f = z^2 *(p-a) sage: f -z^4 + z^2*p + 1 sage: f.resultant(z-p) --- AttributeErrorTraceback (most recent call last) /Users/beeson/ in () AttributeError: 'sage.rings.fraction_field_element.FractionFieldEle' object has no attribute 'resultant' sage: f.resultant(z^4-1) --- sage: h = z-q sage: g = z-p sage: h.resultant(g) -p + q -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] simplify using an assumption
after declaring variables make these definitions sage: a = Z - Z^-1 sage: b = L - L^-1 sage: c = Z^2L-Z^-2L^-1 sage: f = (p*a + q*b + r *c) *a + (n*a + m *b + l*c) * a*b Now I can tell it assume(Z^3 * L^2 == -1)but I can't get it to use that assumption in something like simplify(expand(Z^3*L^2*f)) Indeed after assume(Z^3*L^2 == -1) it still returns Z^3*L^2 as the value of that expression, instead of -1 as hoped. How can I get it to use what it has assumed? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] Re: polynomial remainder
Thanks, that's a start, but my polynomials have some parameters a,b,c,... in the coefficients. In Mathematica you say PolyomialRemainder[f,g,x] where the last 'x' names the polynomial variable, so all other variables are parameters. When I tried to modify your code by inserting a=var('a') and then f=a*x^10, it didn't work, because now f only belongs to sage.symbolic.expression.Expression, and not to P. Well, obviously, because I didn't specify that a belongs to QQ. Is there a way to do that so that I can work with parameters in the coefficients of a polynomial? Various guesses as to what might be the way to do that didn't work. If there's an easy way that I should have been able to look this up for myself I would like to know that even more than the specific answer. On another subject: The documentation mentions the "ring" of symbolic expressions. To be a ring one needs to know when two symbolic expressions are equal. Is 1/0 a symbolic expression and if so is it equal to oo ? How about x- x and 0?x/x and 1?More generally has anything been written about the or "a" semantics for Sage? Michael On Jan 3, 12:42 pm, bump wrote: > On Jan 3, 10:59 am, Michael Beeson wrote: > > > I am just learning Sage. I tried to define a polynomial and then > > find the polynomial remainder upon division by the > > cyclotomic_polynomial(18), which is 1-x^3+x^6. This is easily > > accomplished in Mathematica using the PolynomialRemainder function. > > But I could not find the analog of that function in the Sage > > documentation. > > What is the right way to do this in Sage? > > I think this is what you are trying to do: > > sage: P. = PolynomialRing(QQ) > sage: f = x^10+2*x^8+3*x+1 > sage: f in P > True > sage: g = cyclotomic_polynomial(18); g > x^6 - x^3 + 1 > sage: f.quo_rem(g) > (x^4 + 2*x^2 + x, 2*x^5 - 2*x^2 + 2*x + 1) > > The first term is the quotient and the second is the remainder. See > sage: f.quo_rem? > > for the description of the method. > > Daniel Bump -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
[sage-support] polynomial remainder
I am just learning Sage. I tried to define a polynomial and then find the polynomial remainder upon division by the cyclotomic_polynomial(18), which is 1-x^3+x^6.This is easily accomplished in Mathematica using the PolynomialRemainder function. But I could not find the analog of that function in the Sage documentation. I expected it to be a method of the Polynomial class. I suspect my difficulty lies in converting a symbolic expression to a polynomial. In fact, if I knew how to do that properly I shouldn't even need PolynomialRemainder. The plan is to create the ring Q(z) where z is a primitive 18th root of 1, and then enter some expression such as (z^5-1/z^5 )(z - 1/z) (but much longer) and see it expressed as a polynomial of degree 5 in z. In Mathematica I just multiplied by a sufficient power of z and then used PolynomialRemainder (I'm going to set the result to zero so multiplying by a power of z is fine). What is the right way to do this in Sage? -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org