[sage-support] please explain this output

2018-11-10 Thread Michael Beeson
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

[sage-support] full_simplify() gets wrong answer

2018-11-12 Thread Michael Beeson
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

[sage-support] different result from file or at prompt

2018-11-13 Thread Michael Beeson
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

[sage-support] Re: different result from file or at prompt

2018-11-14 Thread Michael Beeson
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*

[sage-support] Re: documentation?

2018-11-14 Thread Michael Beeson
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-support] documentation?

2018-11-14 Thread Michael Beeson
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

[sage-support] Re: documentation?

2018-11-16 Thread Michael Beeson
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 quadrat

[sage-support] please explain casting in this example

2019-02-15 Thread Michael Beeson
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: versio

[sage-support] Re: please explain casting in this example

2019-02-15 Thread Michael Beeson
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 UT

[sage-support] Re: please explain casting in this example

2019-02-15 Thread Michael Beeson
M 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) > &g

[sage-support] Re: please explain casting in this example

2019-02-15 Thread Michael Beeson
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 rang

[sage-support] solve() behavior

2019-02-18 Thread Michael Beeson
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 y

[sage-support] Re: solve() behavior

2019-02-18 Thread Michael Beeson
ution. 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() > > 'SageMa

[sage-support] Re: solve() behavior

2019-02-19 Thread Michael Beeson
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)

[sage-support] Re: solve() behavior

2019-02-20 Thread Michael Beeson
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 re

[sage-support] trig simplify disappointed me

2019-02-20 Thread Michael Beeson
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 Googl

[sage-support] solution of a 4th degree equation is real despite containing I but causes trouble

2019-02-20 Thread Michael Beeson
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"

[sage-support] Re: solution of a 4th degree equation is real despite containing I but causes trouble

2019-02-20 Thread Michael Beeson
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 ema

[sage-support] simplification options

2019-03-11 Thread Michael Beeson
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 no

[sage-support] Re: simplification options

2019-03-11 Thread Michael Beeson
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

[sage-support] compute regulator of quadratic field

2019-07-24 Thread Michael Beeson
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

[sage-support] log to the base 2

2020-07-18 Thread Michael Beeson
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

[sage-support] Re: log to the base 2

2020-07-18 Thread Michael Beeson
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-support] polynomial remainder

2010-01-03 Thread Michael Beeson
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

[sage-support] Re: polynomial remainder

2010-01-05 Thread Michael Beeson
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

[sage-support] Re: polynomial division

2013-01-05 Thread Michael Beeson
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 a

[sage-support] substitution

2013-01-08 Thread Michael Beeson
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 ass

[sage-support] sage crashes on this input

2013-01-14 Thread Michael Beeson
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

[sage-support] Re: sage crashes on this input

2013-01-14 Thread Michael Beeson
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^

[sage-support] Re: sage crashes on this input

2013-01-14 Thread Michael Beeson
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-support] Re: sage crashes on this input

2013-01-14 Thread Michael Beeson
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 polynomi

[sage-support] Re: polynomial remainder

2013-01-18 Thread Michael Beeson
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

[sage-support] is this a bug?

2013-02-05 Thread Michael Beeson
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 - 8112963841460

[sage-support] Pell's equation

2014-10-31 Thread Michael Beeson
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

[sage-support] Re: Pell's equation

2014-11-02 Thread Michael Beeson
ts 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

[sage-support] plot command doesn't work from a function

2014-11-03 Thread Michael Beeson
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 bec

[sage-support] Re: How to define L-series?

2015-01-04 Thread Michael Beeson
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

[sage-support] simplify using an assumption

2010-01-22 Thread Michael Beeson
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*

[sage-support] resultant

2010-01-31 Thread Michael Beeson
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

[sage-support] resultant

2010-01-31 Thread 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 sage: G = d*z^16 -

[sage-support] Re: resultant

2010-01-31 Thread Michael Beeson
"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 Micha

[sage-support] Re: resultant

2010-01-31 Thread Michael Beeson
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. Se

[sage-support] Re: resultant

2010-01-31 Thread Michael Beeson
me 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

[sage-support] Re: resultant

2010-01-31 Thread Michael Beeson
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] possible error in manual

2010-03-12 Thread Michael Beeson
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.

[sage-support] norm or absolute value

2010-03-12 Thread Michael Beeson
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 o

[sage-support] field of symbolic expressions

2010-09-06 Thread Michael Beeson
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

[sage-support] basic plotting

2011-01-30 Thread Michael Beeson
-- | Sage Version 4.2.1, Release Date: 2009-11-14 | | Type notebook() for the GUI, and license() for information.| -- WARNING: There

[sage-support] Re: basic plotting

2011-01-30 Thread Michael Beeson
bolic 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 Beeso

[sage-support] sage-64.txt

2011-01-30 Thread Michael Beeson
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

[sage-support] real part incorrectly simplified away

2011-01-31 Thread Michael Beeson
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 i

[sage-support] Re: real part incorrectly simplified away

2011-01-31 Thread Michael Beeson
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,

[sage-support] polynomial division

2012-04-22 Thread Michael Beeson
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

[sage-support] mwrank output

2012-05-22 Thread Michael Beeson
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 a

Re: [sage-support] Re: mwrank output

2012-05-24 Thread Michael Beeson
u 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 Be

[sage-support] regulator

2021-12-26 Thread Michael Beeson
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

[sage-support] something seems wrong here

2022-01-01 Thread Michael Beeson
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] factoring in Gaussian integers

2022-06-24 Thread Michael Beeson
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 be