[sage-support] Options for the Sage expand function
I am coming up to speed on Python, Sympy, and Sage by doing some simple problems on all three. Sympy has an option for its expand function, complex=True, that has made some of my expressions easier to read/use. I'm working with quotients of complex numbers. This option allows Sympy to return expressions that look like a + bi broadly speaking with nice relations for a and b. With Sage so far, I can't seem to get the equivalent level of expansion. I'd like to ask if there is a way to invoke that complex=True or its equivalent within Sage. I've done a bit of searching but so far the answer has not jumped out at me. I also tried the other support system but don't have enough points to post. Thanks, JBB -- 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] LaTeX rendering problem in a local installation of the sage notebook server
Hi, I have Sage v6.2 installed 'in the cloud' (Amazon). The OS is RHEL. I have used Sage for a couple of years without incident, but I am suddenly having a problem with LaTeX rendering in the notebook. When I enclose a formula in double dollar signs, it renders just fine as a centered equation. When I enclose a formula in single dollar signs, it does nothing (it just appears as plain text; see attached screenshot). I didn't have this problem with v6.0, but I am sorry to say I can't swear that's the only change that I've made to the server. The server has a working local installation of MathJax. LaTeX functionality in the locally installed wikis works fine. Anyone have advice for diagnosing the problem? Thanks in advance -- Keir -- 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] Defining a Variable so that its Conjugate always Equals Itself
Is there a way that I can define my variables to be real, so that when I take square the modulus, I don't get variables with bars over them when they are assumed real. Thanks, Chris -- 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] How to convert a symbolic expression to a finite field element?
I created a finite field Fq.a = GF(3^10) there is a symbolic expression, for example, ex = (2*a^9 + 2*a^8 + a^4 +1)/(a^5+2*a+2) and we have type(ex) = type 'sage.symbolic.expression.Expression' how can we convert the symbolic expression ex so that it is evaluated as an element in Fq, That is, eval = a^9 + a^8 + a^7 + a^5 + 2*a^4 + a^3 + 2*a^2 + 2*a such that type(eval) = type 'sage.rings.finite_rings.element_givaro.FiniteField_givaroElement'? I tried to use AA(ex) and algebraic(ex, Fq), but they both gave errors. Please help. Thank you. -- 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.
Re: [sage-support] How to convert a symbolic expression to a finite field element?
Avoid using symbolic expressions together with real algebra. This works fine: sage: Fq.a = GF(3^10) sage: (2*a^9 + 2*a^8 + a^4 +1)/(a^5+2*a+2) a^9 + a^8 + a^7 + a^5 + 2*a^4 + a^3 + 2*a^2 + 2*a The a here was defined in the first line to be the generator of your field: sage: type(a) type 'sage.rings.finite_rings.element_givaro.FiniteField_givaroElement' sage: a.parent() Finite Field in a of size 3^10 On 14 June 2014 06:49, Lian Liu csliul...@gmail.com wrote: I created a finite field Fq.a = GF(3^10) there is a symbolic expression, for example, ex = (2*a^9 + 2*a^8 + a^4 +1)/(a^5+2*a+2) and we have type(ex) = type 'sage.symbolic.expression.Expression' how can we convert the symbolic expression ex so that it is evaluated as an element in Fq, That is, eval = a^9 + a^8 + a^7 + a^5 + 2*a^4 + a^3 + 2*a^2 + 2*a such that type(eval) = type 'sage.rings.finite_rings.element_givaro.FiniteField_givaroElement'? I tried to use AA(ex) and algebraic(ex, Fq), but they both gave errors. Please help. Thank you. -- 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. -- 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: LaTeX rendering problem in a local installation of the sage notebook server
Latex in the notebook shouldn't be broken. It was completely broken for 6.1 but was fixed in 6.1.1. There has been no (released) upgrades of the notebook since then. I just checked and inline equations work fine here in 6.1.1 and 6.3.beta3. Sorry, I don't have 6.2 to test. On Saturday, June 14, 2014 6:29:59 AM UTC+8, Keir Lockridge wrote: Hi, I have Sage v6.2 installed 'in the cloud' (Amazon). The OS is RHEL. I have used Sage for a couple of years without incident, but I am suddenly having a problem with LaTeX rendering in the notebook. When I enclose a formula in double dollar signs, it renders just fine as a centered equation. When I enclose a formula in single dollar signs, it does nothing (it just appears as plain text; see attached screenshot). I didn't have this problem with v6.0, but I am sorry to say I can't swear that's the only change that I've made to the server. The server has a working local installation of MathJax. LaTeX functionality in the locally installed wikis works fine. Anyone have advice for diagnosing the problem? Thanks in advance -- Keir -- 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: Defining a Variable so that its Conjugate always Equals Itself
sage: bool(x.conjugate() == x) False sage: assume(x, 'real') sage: bool(x.conjugate() == x) True On Saturday, June 14, 2014 6:12:06 AM UTC+8, Chris Maness wrote: Is there a way that I can define my variables to be real, so that when I take square the modulus, I don't get variables with bars over them when they are assumed real. Thanks, Chris -- 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: Options for the Sage expand function
On Saturday, June 14, 2014 5:43:39 AM UTC+1, jeanbi...@gmail.com wrote: I'm working with quotients of complex numbers. The fraction field of the complex numbers are the complex numbers. For any serious computation you should probably figure out the smallest field you are really working in; E.g. cyclotomics or some algebraic extension. Don't just rely on symbolic computations. -- 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: LaTeX rendering problem in a local installation of the sage notebook server
I was finally quick enough to highlight and copy the MathJax error: File failed to load: https://sage.x.org/javascript/mathjax/config/../../dynamic/mathjax_sage.js But, I am having trouble actually finding this file. When I load the URL in my browser, I get a blank page ('view source' leads to an empty document) and not an error. File failed to load: https://sage.gettysburgmath.org/javascript/mathjax/config/../../dynamic/mathjax_sage.js On Saturday, June 14, 2014 6:43:20 AM UTC-5, P Purkayastha wrote: Latex in the notebook shouldn't be broken. It was completely broken for 6.1 but was fixed in 6.1.1. There has been no (released) upgrades of the notebook since then. I just checked and inline equations work fine here in 6.1.1 and 6.3.beta3. Sorry, I don't have 6.2 to test. On Saturday, June 14, 2014 6:29:59 AM UTC+8, Keir Lockridge wrote: Hi, I have Sage v6.2 installed 'in the cloud' (Amazon). The OS is RHEL. I have used Sage for a couple of years without incident, but I am suddenly having a problem with LaTeX rendering in the notebook. When I enclose a formula in double dollar signs, it renders just fine as a centered equation. When I enclose a formula in single dollar signs, it does nothing (it just appears as plain text; see attached screenshot). I didn't have this problem with v6.0, but I am sorry to say I can't swear that's the only change that I've made to the server. The server has a working local installation of MathJax. LaTeX functionality in the locally installed wikis works fine. Anyone have advice for diagnosing the problem? Thanks in advance -- Keir -- 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.
Re: [sage-support] Re: LaTeX rendering problem in a local installation of the sage notebook server
Is your sagenb installation complete? This file is present and distributed with the notebook: https://github.com/sagemath/sagenb/blob/master/sagenb/data/sage/js/mathjax_sage.js On Sat, Jun 14, 2014 at 10:14 PM, Keir Lockridge keirhar...@gmail.com wrote: I was finally quick enough to highlight and copy the MathJax error: File failed to load: https://sage.x.org/javascript/mathjax/config/../../dynamic/mathjax_sage.js But, I am having trouble actually finding this file. When I load the URL in my browser, I get a blank page ('view source' leads to an empty document) and not an error. -- 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.
Re: [sage-support] Re: LaTeX rendering problem in a local installation of the sage notebook server
I downloaded and complied the sources tarball for 6.0 and had been using sage -upgrade since then. I found these files in the sage directory tree (where the 'sage' executable is), and both are non-empty: ./local/lib/python2.7/site-packages/sagenb-0.10.7.2-py2.7.egg/sagenb/data/sage/js/mathjax_sage.js ./local/lib/python2.7/site-packages/sagenb-0.10.8.2-py2.7.egg/sagenb/data/sage/js/mathjax_sage.js Thanks for your help, by the way. I'm currently compiling 6.1.1 just to see if a that might solve the problem, but it's still working. On Saturday, June 14, 2014 9:23:50 AM UTC-5, P Purkayastha wrote: Is your sagenb installation complete? This file is present and distributed with the notebook: https://github.com/sagemath/sagenb/blob/master/sagenb/data/sage/js/mathjax_sage.js On Sat, Jun 14, 2014 at 10:14 PM, Keir Lockridge keirh...@gmail.com javascript: wrote: I was finally quick enough to highlight and copy the MathJax error: File failed to load: https://sage.x.org/javascript/mathjax/config/../../dynamic/mathjax_sage.js But, I am having trouble actually finding this file. When I load the URL in my browser, I get a blank page ('view source' leads to an empty document) and not an error. -- 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: Options for the Sage expand function
On Saturday, June 14, 2014 6:28:02 AM UTC-7, Volker Braun wrote: On Saturday, June 14, 2014 5:43:39 AM UTC+1, jeanbi...@gmail.com wrote: I'm working with quotients of complex numbers. The fraction field of the complex numbers are the complex numbers. For any serious computation you should probably figure out the smallest field you are really working in; E.g. cyclotomics or some algebraic extension. Don't just rely on symbolic computations. Thanks. My objective is not pure mathematics. I'd like to have some tools for applied problems in optics and some other areas of engineering where lengthy analytical expressions arise and numbers get inserted to calculate observable quantities, uncertainties, and such. I'd ultimately use Sage/Sympy/Python in some combination to check hand calculations as well as do harder calculations. Since Sage incorporates many Python-based packages I thought to ask whether it preserves options such as complex=True in expand(). Perhaps Sage's expand() is not the same as Sympy's expand()? -- 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.
Re: [sage-support] Re: Defining a Variable so that its Conjugate always Equals Itself
Thank you. Chris On Sat, Jun 14, 2014 at 4:47 AM, P Purkayastha ppu...@gmail.com wrote: sage: bool(x.conjugate() == x) False sage: assume(x, 'real') sage: bool(x.conjugate() == x) True On Saturday, June 14, 2014 6:12:06 AM UTC+8, Chris Maness wrote: Is there a way that I can define my variables to be real, so that when I take square the modulus, I don't get variables with bars over them when they are assumed real. Thanks, Chris -- 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. -- 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: Options for the Sage expand function
On 2014-06-14, jeanbigbo...@gmail.com jeanbigbo...@gmail.com wrote: On Saturday, June 14, 2014 6:28:02 AM UTC-7, Volker Braun wrote: On Saturday, June 14, 2014 5:43:39 AM UTC+1, jeanbi...@gmail.com wrote: I'm working with quotients of complex numbers. The fraction field of the complex numbers are the complex numbers. For any serious computation you should probably figure out the smallest field you are really working in; E.g. cyclotomics or some algebraic extension. Don't just rely on symbolic computations. Thanks. My objective is not pure mathematics. I'd like to have some tools for applied problems in optics and some other areas of engineering where lengthy analytical expressions arise and numbers get inserted to calculate observable quantities, uncertainties, and such. there is nothing wrong with using a bit of pure mathematics for applied problems; e.g. cryptographers do this all the time... I'd ultimately use Sage/Sympy/Python in some combination to check hand calculations as well as do harder calculations. Since Sage incorporates many Python-based packages I thought to ask whether it preserves options such as complex=True in expand(). Perhaps Sage's expand() is not the same as Sympy's expand()? it can very well be Maxima's expand(). -- 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: Options for the Sage expand function
If you don't need provably correct answers then just work over CDF or ComplexField with a precision that you'd like. If you want to prove something you can use CIF (floating-point complex interval arithmetic) or QQbar (exact numbers). The difference between pure mathematics and applications is just a choice of goal, not a choice of tools. On Saturday, June 14, 2014 6:03:47 PM UTC+1, jeanbi...@gmail.com wrote: Thanks. My objective is not pure mathematics. I'd like to have some tools for applied problems in optics and some other areas of engineering where lengthy analytical expressions arise and numbers get inserted to calculate observable quantities, uncertainties, and such. I'd ultimately use Sage/Sympy/Python in some combination to check hand calculations as well as do harder calculations. Since Sage incorporates many Python-based packages I thought to ask whether it preserves options such as complex=True in expand(). Perhaps Sage's expand() is not the same as Sympy's expand()? -- 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.
Re: [sage-support] Options for the Sage expand function
On 06/14/2014 12:43 AM, jeanbigbo...@gmail.com wrote: I am coming up to speed on Python, Sympy, and Sage by doing some simple problems on all three. Sympy has an option for its expand function, complex=True, that has made some of my expressions easier to read/use. I'm working with quotients of complex numbers. This option allows Sympy to return expressions that look like a + bi broadly speaking with nice relations for a and b. With Sage so far, I can't seem to get the equivalent level of expansion. I'd like to ask if there is a way to invoke that complex=True or its equivalent within Sage. I've done a bit of searching but so far the answer has not jumped out at me. I also tried the other support system but don't have enough points to post. The sage expand() function doesn't use sympy. However, we have the ability to send symbolic expressions back and forth between sage and sympy, so it is possible. First thing you should do is open a trac ticket with a feature request. It should be possible to add the complex parameter to the sage expand() function using sympy. Second, for a workaround, you can do the following: sage: x = SR.symbol('x') sage: x._sympy_().expand() x sage: x._sympy_().expand(complex = True) re(x) + I*im(x) This will give you the *visual* representation that you want, but it isn't very convenient to work with. It looks like nobody's told sage how to convert the sympy im() function back into a sage expression yet: sage: x._sympy_().expand(complex = True)._sage_() ... AttributeError: 'im' object has no attribute '_sage_' This wouldn't be super difficult to do, though; the following already works in sage: sage: x.real_part() + I*x.imag_part() I*imag_part(x) + real_part(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 http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] Options for the Sage expand function
On Saturday, June 14, 2014 2:04:18 PM UTC-7, Michael Orlitzky wrote: On 06/14/2014 12:43 AM, jeanbi...@gmail.com javascript: wrote: I am coming up to speed on Python, Sympy, and Sage by doing some simple problems on all three. Sympy has an option for its expand function, complex=True, that has made some of my expressions easier to read/use. I'm working with quotients of complex numbers. This option allows Sympy to return expressions that look like a + bi broadly speaking with nice relations for a and b. With Sage so far, I can't seem to get the equivalent level of expansion. I'd like to ask if there is a way to invoke that complex=True or its equivalent within Sage. I've done a bit of searching but so far the answer has not jumped out at me. I also tried the other support system but don't have enough points to post. The sage expand() function doesn't use sympy. However, we have the ability to send symbolic expressions back and forth between sage and sympy, so it is possible. First thing you should do is open a trac ticket with a feature request. It should be possible to add the complex parameter to the sage expand() function using sympy. Second, for a workaround, you can do the following: sage: x = SR.symbol('x') sage: x._sympy_().expand() x sage: x._sympy_().expand(complex = True) re(x) + I*im(x) This will give you the *visual* representation that you want, but it isn't very convenient to work with. It looks like nobody's told sage how to convert the sympy im() function back into a sage expression yet: sage: x._sympy_().expand(complex = True)._sage_() ... AttributeError: 'im' object has no attribute '_sage_' This wouldn't be super difficult to do, though; the following already works in sage: sage: x.real_part() + I*x.imag_part() I*imag_part(x) + real_part(x) This is very helpful, thanks. In Sympy, I did the following: var('A B C D u v', real=True) qi = 1/(u - I*v) qf = (A + B/qi)/(C + D/qi) expand(1/qf, complex=True)A2+2ABu+B2u2+B2v2+ADuA2+2ABu+B2u2+B2v2−iADvA2+2ABu +B2u2+B2v2+BCuA2+2ABu+B2u2+B2v2+iBCvA2+2ABu+B2u2+B2v2+BDu2A2+2ABu+B2u2+B2v2+ BDv2A2+2ABu+B2u2+B2v2 I got a reasonable 7 term expansion of 1/qf so long as I defined real=True in the var statement (I learned that via the Sympy group). Before I learned that step, the expansion was gigantic. In Sage, I did var('A B C D u v', domain = 'real') defined qi, qf, and 1/qf as above When I tried (1/qf)._sympy_().expand(complex = True) I got a huge expression similar to the one Sympy gave me before I learned about the real=True setting on the initial variables. So, it looks like the method you suggested does work. I'll dig deeper into Sage to see how I can get the results to be the same. There may be something in addition to domain='real' that I need to set and/or send into Sympy. Appreciate the help. -- 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] weil_pairing never returns
Hello, I'm trying to calculate a pairing with the SAGE weil_pairing() function while using a distortion map, but the weil_pairing() function never returns and it seems like is eating all the computer memory. Here is the code I'm using: sage: p = 293779600266612700060489507 sage: F = GF(p) sage: E = EllipticCurve(F, [-1,0]) sage: F2.alpha=GF(p^2, name='alpha',modulus=ZZ['x']('x^2+1')); sage: E2 = E.change_ring(F2) sage: def custom_weil_pairing(p1, p2, n): : wp = p1.weil_pairing(E2(-p2[0], alpha*p2[1]), n) : return wp : sage: p1=E2.random_element() sage: p2=E2.random_element() sage: custom_weil_pairing(p1, p2, p1.order()) Actually, p1 and p2 are point with the same order in my real code. I've been googling but I haven't found any known bug explaining this behavior. Am I doing something wrong? Regards. -- 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: weil_pairing never returns
SAGE version: 'Sage Version 6.1.1, Release Date: 2014-02-04' in MacOS X. El domingo, 15 de junio de 2014 01:17:06 UTC+2, Alberto Garcia escribió: Hello, I'm trying to calculate a pairing with the SAGE weil_pairing() function while using a distortion map, but the weil_pairing() function never returns and it seems like is eating all the computer memory. Here is the code I'm using: sage: p = 293779600266612700060489507 sage: F = GF(p) sage: E = EllipticCurve(F, [-1,0]) sage: F2.alpha=GF(p^2, name='alpha',modulus=ZZ['x']('x^2+1')); sage: E2 = E.change_ring(F2) sage: def custom_weil_pairing(p1, p2, n): : wp = p1.weil_pairing(E2(-p2[0], alpha*p2[1]), n) : return wp : sage: p1=E2.random_element() sage: p2=E2.random_element() sage: custom_weil_pairing(p1, p2, p1.order()) Actually, p1 and p2 are point with the same order in my real code. I've been googling but I haven't found any known bug explaining this behavior. Am I doing something wrong? Regards. -- 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.
Re: [sage-support] Options for the Sage expand function
On Sat, Jun 14, 2014 at 3:53 PM, jeanbigbo...@gmail.com wrote: This is very helpful, thanks. In Sympy, I did the following: var('A B C D u v', real=True) qi = 1/(u - I*v) qf = (A + B/qi)/(C + D/qi) expand(1/qf, complex=True)A2+2ABu+B2u2+B2v2+ADuA2+2ABu+B2u2+B2v2-iADvA2+2ABu+B2u2+B2v2+BCuA2+2ABu+B2u2+B2v2+iBCvA2+2ABu+B2u2+B2v2+BDu2A2+2ABu+B2u2+B2v2+BDv2A2+2ABu+B2u2+B2v2 I got a reasonable 7 term expansion of 1/qf so long as I defined real=True in the var statement (I learned that via the Sympy group). Before I learned that step, the expansion was gigantic. In Sage, I did var('A B C D u v', domain = 'real') defined qi, qf, and 1/qf as above When I tried (1/qf)._sympy_().expand(complex = True) I got a huge expression similar to the one Sympy gave me before I learned about the real=True setting on the initial variables. That seems like a bug in the _sympy_ conversion, in that it is discarding that the variables are assumed real. Could you just directly use sympy for what you're doing? Note that you'll have to turn off the Sage preparser, since with it on, you'll run into (surprising) trouble like this: sage: A,B,C,D,u,v = sympy.var('A B C D u v', real=True) sage: type(u) class 'sympy.core.symbol.Symbol' sage: type(1/u) type 'sage.symbolic.expression.Expression' where you've just left the world of sympy behind. Ugh. So, it looks like the method you suggested does work. I'll dig deeper into Sage to see how I can get the results to be the same. There may be something in addition to domain='real' that I need to set and/or send into Sympy. I couldn't figure out how to set it. By the way, Dima claimed above that Sage uses Maxima for expand, which is NOT correct (It was true 5 years ago, but not today). The vast majority of the symbolic computation in Sage is implemented in the C++ library Ginac http://www.ginac.de/. It's easy to convert back and forth between Ginac and Maxima though. z = var('A B C D u v') qi = 1/(u - I*v) qf = (A + B/qi)/(C + D/qi) s = 1/qf s._maxima_() I don't know what problem you're trying to solve, but maybe this code is relevant: z = var('A B C D u v', domain='real') qi = 1/(u - I*v) qf = (A + B/qi)/(C + D/qi) s = 1/qf s.real() which outputs: B*D*u^2/(B^2*u^2 + B^2*v^2 + 2*A*B*u + A^2) + B*D*v^2/(B^2*u^2 + B^2*v^2 + 2*A*B*u + A^2) + B*C*u/(B^2*u^2 + B^2*v^2 + 2*A*B*u + A^2) + A*D*u/(B^2*u^2 + B^2*v^2 + 2*A*B*u + A^2) + A*C/(B^2*u^2 + B^2*v^2 + 2*A*B*u + A^2) WARNING! If you first do this in a session: z = var('A B C D u v') then the above will *NOT* work. As far as I can tell, you cannot redeclare a variable to be real if you ever made it without making it real before in the same session. Similarly, you can't change things with assume, e.g., this works fine: X, Y = var(X Y, domain = 'real') (X+I*Y).real() but this (surprisingly) fails: X, Y = var(X Y) assume(X, 'real') assume(Y, 'real') (X+I*Y).real() It appears that the assume command with second argument a domain is dangerously broken in Sage. So the main upshot for you is to start a new session and declare your variables to be real from the get go. William -- 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: LaTeX rendering problem in a local installation of the sage notebook server
UPDATE: I switched to 6.1.1 and the problem went away. On Friday, June 13, 2014 5:29:59 PM UTC-5, Keir Lockridge wrote: Hi, I have Sage v6.2 installed 'in the cloud' (Amazon). The OS is RHEL. I have used Sage for a couple of years without incident, but I am suddenly having a problem with LaTeX rendering in the notebook. When I enclose a formula in double dollar signs, it renders just fine as a centered equation. When I enclose a formula in single dollar signs, it does nothing (it just appears as plain text; see attached screenshot). I didn't have this problem with v6.0, but I am sorry to say I can't swear that's the only change that I've made to the server. The server has a working local installation of MathJax. LaTeX functionality in the locally installed wikis works fine. Anyone have advice for diagnosing the problem? Thanks in advance -- Keir -- 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.
Re: [sage-support] Options for the Sage expand function
On Saturday, June 14, 2014 4:55:37 PM UTC-7, William wrote: On Sat, Jun 14, 2014 at 3:53 PM, jeanbi...@gmail.com javascript: wrote: This is very helpful, thanks. In Sympy, I did the following: var('A B C D u v', real=True) qi = 1/(u - I*v) qf = (A + B/qi)/(C + D/qi) expand(1/qf, complex=True)A2+2ABu+B2u2+B2v2+ADuA2+2ABu+B2u2+B2v2-iADvA2+2ABu+B2u2+B2v2+BCuA2+2ABu+B2u2+B2v2+iBCvA2+2ABu+B2u2+B2v2+BDu2A2+2ABu+B2u2+B2v2+BDv2A2+2ABu+B2u2+B2v2 I got a reasonable 7 term expansion of 1/qf so long as I defined real=True in the var statement (I learned that via the Sympy group). Before I learned that step, the expansion was gigantic. In Sage, I did var('A B C D u v', domain = 'real') defined qi, qf, and 1/qf as above When I tried (1/qf)._sympy_().expand(complex = True) I got a huge expression similar to the one Sympy gave me before I learned about the real=True setting on the initial variables. That seems like a bug in the _sympy_ conversion, in that it is discarding that the variables are assumed real. Could you just directly use sympy for what you're doing? Note that you'll have to turn off the Sage preparser, since with it on, you'll run into (surprising) trouble like this: sage: A,B,C,D,u,v = sympy.var('A B C D u v', real=True) sage: type(u) class 'sympy.core.symbol.Symbol' sage: type(1/u) type 'sage.symbolic.expression.Expression' where you've just left the world of sympy behind. Ugh. So, it looks like the method you suggested does work. I'll dig deeper into Sage to see how I can get the results to be the same. There may be something in addition to domain='real' that I need to set and/or send into Sympy. I couldn't figure out how to set it. By the way, Dima claimed above that Sage uses Maxima for expand, which is NOT correct (It was true 5 years ago, but not today). The vast majority of the symbolic computation in Sage is implemented in the C++ library Ginac http://www.ginac.de/. It's easy to convert back and forth between Ginac and Maxima though. z = var('A B C D u v') qi = 1/(u - I*v) qf = (A + B/qi)/(C + D/qi) s = 1/qf s._maxima_() I don't know what problem you're trying to solve, but maybe this code is relevant: z = var('A B C D u v', domain='real') qi = 1/(u - I*v) qf = (A + B/qi)/(C + D/qi) s = 1/qf s.real() which outputs: B*D*u^2/(B^2*u^2 + B^2*v^2 + 2*A*B*u + A^2) + B*D*v^2/(B^2*u^2 + B^2*v^2 + 2*A*B*u + A^2) + B*C*u/(B^2*u^2 + B^2*v^2 + 2*A*B*u + A^2) + A*D*u/(B^2*u^2 + B^2*v^2 + 2*A*B*u + A^2) + A*C/(B^2*u^2 + B^2*v^2 + 2*A*B*u + A^2) WARNING! If you first do this in a session: z = var('A B C D u v') then the above will *NOT* work. As far as I can tell, you cannot redeclare a variable to be real if you ever made it without making it real before in the same session. Similarly, you can't change things with assume, e.g., this works fine: X, Y = var(X Y, domain = 'real') (X+I*Y).real() but this (surprisingly) fails: X, Y = var(X Y) assume(X, 'real') assume(Y, 'real') (X+I*Y).real() It appears that the assume command with second argument a domain is dangerously broken in Sage. So the main upshot for you is to start a new session and declare your variables to be real from the get go. William William, Very interesting. I am able to reproduce the result you found by using s.real(). I checked and there is an s.imag() for the complex piece. I'll do a term-by-term comparison a little later with the Sympy result and see if they match. I'll keep the cautions in mind about redefinitions/reassignments as well as I go further in all of these languages. The expressions I am evaluating come up in the propagation of Gaussian optical beams such as the ones generated by many types of laser. We use them to calculate beam parameters such as spot sizes and divergences as various pieces of optics work on an input beam. The A, B, C, and D parameters become specific when considering pure propagation, lenses, mirrors, etc. An entire optical train can be considered by multiplying matrices together. Provide an input parameter qi and the output parameter is easily evaluated. The real part of q is a beam's radius of curvature, the complex part is related to the size of the spot. The above equations are very standard stuff and since I know what the answers ought to be, they are a good way for me to get familiar with Python, Sympy, Sage, etc. I expect that I will mix and match tools as needed down the line when I need to consider more involved problems where I won't know the answer beforehand. There are sophisticated programs that do this kind of thing of course but it is always good to have alternatives, especially ones that are not proprietary, when prototyping in the RD sense. Dima writes: there is nothing wrong with using a bit of pure mathematics for
Re: [sage-support] Options for the Sage expand function
On Sat, Jun 14, 2014 at 6:12 PM, jeanbigbo...@gmail.com wrote: Dima writes: there is nothing wrong with using a bit of pure mathematics for applied problems; e.g. cryptographers do this all the time... Agreed. My formal education was from a time when fields, groups, and such were not common undergraduate fare. They are still not common undergraduate fare, in the US at least. Most math major seniors I've encountered at Univ of Washington know almost nothing about groups, rings and fields. I personally did an undergrad math minor without once ever hearing about groups, rings or fields -- then I ran into a misfiled book [1] in the programming section of a bookstore about abstract algebra, and was instantly hooked. Abstract algebra is a really beautiful and powerful collection of ideas and ways of thinking about mathematics. It's also assumed in a lot of Sage documentation. [1] http://www.amazon.com/Abstract-Algebra-David-M-Burton/dp/0697067610 -- William Stein Professor of Mathematics University of Washington http://wstein.org -- 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: Options for the Sage expand function
jeanbigbo...@gmail.com wrote: Excuse the top-posting, the google groups UI is not as convenient for excerpting as emacs and a good Usenet server... A couple of Sage groups (including this) are available on/through gmane.org as well (gmane.comp.mathematics.sage.*). -leif -- () The ASCII Ribbon Campaign /\ Help Cure HTML E-Mail -- 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: Options for the Sage expand function
On 6/14/14, 7:04 PM, leif wrote: jeanbigbo...@gmail.com wrote: Excuse the top-posting, the google groups UI is not as convenient for excerpting as emacs and a good Usenet server... A couple of Sage groups (including this) are available on/through gmane.org as well (gmane.comp.mathematics.sage.*). Excellent! I had no idea this existed. Configured and sent via gmane. JBB -- 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.