Re: [sage-support] polynomials over QQ

2011-07-03 Thread William Stein

On 7/3/11 8:44 PM, robin hankin wrote:

Hi.

thank you for this.

OK, so it's "promoting" the coefficients to a more general set?

Where would a sage newcomer like me find documentation for this?


* http://wiki.sagemath.org/coercion

* http://www.sagemath.org/doc/reference/sage/structure/coerce.html

* 
http://sagemath.blogspot.com/2010/11/brief-history-and-motivation-behind.html


* http://www.youtube.com/watch?v=a3_fEXAXq9o



cheers

Robin


On Mon, Jul 4, 2011 at 3:25 PM, D. S. McNeil  wrote:

My understanding was that 'x' was the indeterminate
of the ring of polynomials over QQ, i.e. the rationals.  So how come
the polynomial
has coefficients which are not rational?

Because the polynomial isn't living where you think it does anymore:

sage: R.  = QQ['x']
sage: R
Univariate Polynomial Ring in x over Rational Field
sage: parent(x)
Univariate Polynomial Ring in x over Rational Field
sage:
sage: f = (x-sqrt(2))*(x+sqrt(2))
sage: f
(x - sqrt(2))*(x + sqrt(2))
sage: parent(f)
Symbolic Ring
sage: R(f)
---
TypeError Traceback (most recent call last)
[...]
TypeError: unable to convert -sqrt(2) to a rational
sage: R(expand(f))
x^2 - 2

In this case, the introduction of the sqrt terms pushed the expression
out of R and into SR.  We can convert back, but only if the expression
is in a form that Sage can recognize as belonging to R.


Doug

--
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






--
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


Re: [sage-support] polynomials over QQ

2011-07-03 Thread robin hankin
Hi.

thank you for this.

OK, so it's "promoting" the coefficients to a more general set?

Where would a sage newcomer like me find documentation for this?

cheers

Robin


On Mon, Jul 4, 2011 at 3:25 PM, D. S. McNeil  wrote:
>> My understanding was that 'x' was the indeterminate
>> of the ring of polynomials over QQ, i.e. the rationals.  So how come
>> the polynomial
>> has coefficients which are not rational?
>
> Because the polynomial isn't living where you think it does anymore:
>
> sage: R. = QQ['x']
> sage: R
> Univariate Polynomial Ring in x over Rational Field
> sage: parent(x)
> Univariate Polynomial Ring in x over Rational Field
> sage:
> sage: f = (x-sqrt(2))*(x+sqrt(2))
> sage: f
> (x - sqrt(2))*(x + sqrt(2))
> sage: parent(f)
> Symbolic Ring
> sage: R(f)
> ---
> TypeError                                 Traceback (most recent call last)
> [...]
> TypeError: unable to convert -sqrt(2) to a rational
> sage: R(expand(f))
> x^2 - 2
>
> In this case, the introduction of the sqrt terms pushed the expression
> out of R and into SR.  We can convert back, but only if the expression
> is in a form that Sage can recognize as belonging to R.
>
>
> Doug
>
> --
> 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
>



-- 
Robin Hankin
Uncertainty Analyst
hankin.ro...@gmail.com

-- 
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


Re: [sage-support] polynomials over QQ

2011-07-03 Thread D. S. McNeil
> My understanding was that 'x' was the indeterminate
> of the ring of polynomials over QQ, i.e. the rationals.  So how come
> the polynomial
> has coefficients which are not rational?

Because the polynomial isn't living where you think it does anymore:

sage: R. = QQ['x']
sage: R
Univariate Polynomial Ring in x over Rational Field
sage: parent(x)
Univariate Polynomial Ring in x over Rational Field
sage:
sage: f = (x-sqrt(2))*(x+sqrt(2))
sage: f
(x - sqrt(2))*(x + sqrt(2))
sage: parent(f)
Symbolic Ring
sage: R(f)
---
TypeError Traceback (most recent call last)
[...]
TypeError: unable to convert -sqrt(2) to a rational
sage: R(expand(f))
x^2 - 2

In this case, the introduction of the sqrt terms pushed the expression
out of R and into SR.  We can convert back, but only if the expression
is in a form that Sage can recognize as belonging to R.


Doug

-- 
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] polynomials over QQ

2011-07-03 Thread robin hankin
Hi


I am having difficulty understanding the following:

R. = QQ['x']; ((x+sqrt(2))*(x+sqrt(3))).expand()

This gives



x^2 + sqrt(2)*x + sqrt(3)*x + sqrt(2)*sqrt(3)


but how can this be right?  My understanding was that 'x' was the indeterminate
of the ring of polynomials over QQ, i.e. the rationals.  So how come
the polynomial
has coefficients which are not rational?




-- 
Robin Hankin
Uncertainty Analyst
hankin.ro...@gmail.com

-- 
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: Highlight code

2011-07-03 Thread Alex Juarez
>
> Hmm...I think we'd have to go higher than the body tag.  IIRC, tinyMCE (so
> maybe EditArea too) does things inside of an iframe so that the buttons work
> well with selections, but codemirror2 does things just inside of a div
> (again, IIRC).
>
> Again, good luck (that's not sarcastic; I wish you the best).  It certainly
> seems like an ambitious project to rewrite EditArea and then maintain it.
>
> If I were doing smarter code cells, I'd probably stick with just trying to
> implement straight CodeMirror2 code cells, even if only just to test if it's
> even feasible these days. (It hasn't been in the past when we've tried
> because it was way too slow and buggy, but CodeMirror has been rewritten now
> and browsers are *much* faster at javascript these days).


You are correct. What I am suggesting is putting the code mirror precursors
in the html generator for TinyMCE, so that it generates a div that code
mirror would then latch onto and validate. But you are correct implementing
just codemirror2 would be much easier, and it appears to be quite feasible,
still not as nice as a unified solution ascetically at least but surely
faster.

Thanks,
Alex

On Sat, Jul 2, 2011 at 11:56 PM, Jason Grout wrote:

> On 7/3/11 1:31 AM, Alex Juarez wrote:
>
>> Hi Jason,
>>
>> From what you're saying, it's pretty clear to me that I don't have
>>the same understanding of EditArea that you do (not surprising,
>>since you've spent a lot of time with EditArea and I haven't).  For
>>example, when I search for traces of codemirror in editarea, I see
>>nothing:
>>
>>~/Downloads/editarea_0_8_2% grep -ri mirror *
>>~/Downloads/editarea_0_8_2%
>>
>>
>> As far as I can tell, the reason this doesn't show up in the quick
>> search is because the coder obfuscated the code for some unknown reason
>> renaming functions that were ports from tinyMCE and codeMirror. Making
>> the project more difficult to work with.
>>
>
> That's true that it would be harder to work with.  The search above went
> through all of the source (un-minified) and all of the docs for EditArea.  I
> figured that at least a mention of codemirror would show up *somewhere* in
> the docs, if nothing else.  What evidence leads you to believe that editarea
> used code from codemirror?
>
>
>
>  As for a response, I am not suggesting that we use EditArea in
>> production, because it as you pointed out does not fully implement code
>> mirror or tinyMCE. But, what I am suggesting is that we look to it as a
>> frame work to create a unified solution. The way that I would for see
>> approaching this is taking the TInyMCE, prompt ripping out the normal
>> window and replacing that with a codemirror window to create a hybrid
>> code-text editor.
>>
>> It would start with > contenteditable="true" spellcheck="false" dir="ltr"> and changing
>> that content be produced through codeMirror. Then we could validate it
>> at javascript level running it through code validator as EditArea did.
>> (in this case it would be code mirror for us.)
>>
>
> Hmm...I think we'd have to go higher than the body tag.  IIRC, tinyMCE (so
> maybe EditArea too) does things inside of an iframe so that the buttons work
> well with selections, but codemirror2 does things just inside of a div
> (again, IIRC).
>
> Again, good luck (that's not sarcastic; I wish you the best).  It certainly
> seems like an ambitious project to rewrite EditArea and then maintain it.
>
> If I were doing smarter code cells, I'd probably stick with just trying to
> implement straight CodeMirror2 code cells, even if only just to test if it's
> even feasible these days. (It hasn't been in the past when we've tried
> because it was way too slow and buggy, but CodeMirror has been rewritten now
> and browsers are *much* faster at javascript these days).
>
> Thanks,
>
> Jason
>
> --
> Jason Grout
>

-- 
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] Flask notebook server?

2011-07-03 Thread Simon King
Hi!

Recetly, I was told that I should better change from sagenb to flask,
since the latter was supposed to be more stable. But now, flask is
down since a couple of days. Is this going to change any time soon?

Cheers,
Simon

-- 
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