[sage-support] Re: how to obtain an element modulo in a quotient space and how to get the lift of elements of quotient

2017-04-10 Thread Nils Bruin
Does U.lift(U.0) do the trick? 

It looks like (U.0).lift() (and hence lift(U.0) ) attempts to do a 
coordinate-wise lift, which is not what you want. It's perhaps a bug that 
does that.

On Monday, April 10, 2017 at 12:28:12 AM UTC-7, Peng wrote:
>
> I compute a freemodule U=V/M, where V and M are vector space,  as follows.
>
> I'm wondering that how I can get the image in U of v /in V, that is v 
> modulo W.
> On the other hand, how can I get the lift in V of u /in U? For this, I 
> tried the command lift(), but it seems not to work, since I 
> input lift(U.0), but it gives (1), which is not in V.
>
> Any one has an idea please?
>
>
> sage: k. = QuadraticField(-1)sage: A = k^3; V = A.span([[1,0,i], 
> [2,i,0]])sage: W = A.span([[3,i,i]])sage: U = V/W; U
>
>

-- 
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 obtain an element modulo in a quotient space and how to get the lift of elements of quotient

2017-04-10 Thread Nils Bruin
Conversion, U(V.1) should do the trick. The quotient space knows how it was 
constructed from the space V, so it can store how to convert from and to 
it. The space V doesn't know all its quotients, so it doesn't about U 
itself.

On Monday, April 10, 2017 at 1:09:24 AM UTC-7, Peng wrote:
>
> You are right!  (U.0).lift() gives what I want. Thank you very much.
>
> By the way, do you know how to get the image in the modulo space? 
>
>
> On Monday, April 10, 2017 at 3:47:44 PM UTC+8, Nils Bruin wrote:
>>
>> Does U.lift(U.0) do the trick? 
>>
>> It looks like (U.0).lift() (and hence lift(U.0) ) attempts to do a 
>> coordinate-wise lift, which is not what you want. It's perhaps a bug that 
>> does that.
>>
>> On Monday, April 10, 2017 at 12:28:12 AM UTC-7, Peng wrote:
>>>
>>> I compute a freemodule U=V/M, where V and M are vector space,  as 
>>> follows.
>>>
>>> I'm wondering that how I can get the image in U of v /in V, that is v 
>>> modulo W.
>>> On the other hand, how can I get the lift in V of u /in U? For this, I 
>>> tried the command lift(), but it seems not to work, since I 
>>> input lift(U.0), but it gives (1), which is not in V.
>>>
>>> Any one has an idea please?
>>>
>>>
>>> sage: k. = QuadraticField(-1)sage: A = k^3; V = A.span([[1,0,i], 
>>> [2,i,0]])sage: W = A.span([[3,i,i]])sage: U = V/W; U
>>>
>>>

-- 
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: .format of RR-element

2017-04-28 Thread Nils Bruin
Yes, clearly our reals should have __format__ support. In fact, this could 
work a lot better than the "%" formatting support we have now, which I 
think is provided by the "__float__" method. It has issues:

sage: '%.60f'%(pi.n(300),) 
'3.141592653589793115997963468544185161590576171875'
sage: '%.10f'%(RR(10)^(10^10))
'inf'

I don't think we can fix that. I haven't been able to find the 
documentation that specifies that "__float__" is called on the argument 
meant to fill in for a %f field, but it's pretty clear that happens.

-- 
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: What is the difference between two ways to instantiate a variable?

2017-05-04 Thread Nils Bruin
On Thursday, May 4, 2017 at 4:02:11 PM UTC-7, Jim Mooney wrote:
>
> Why do I sometimes see just var('y') and other times see y = var('y')? The 
> result seems to be the same since I can use y in either case.
>

See the doc of SR.var and var.

y=SR.var('y')

is the "fundamental" construct, and assignment is required. 

For interactive use, `var("y")` can be used. It needs some dark magic to 
inject the bindings. `y=var('y")` basically binds y twice. It's a matter of 
taste which you prefer.

-- 
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: QQbar and SR

2017-05-08 Thread Nils Bruin
On Monday, May 8, 2017 at 8:30:32 AM UTC-7, Marcin Kostur wrote:
>
>
> Is it a bug or i do something wrong? ;-)
>
>
Both. Simplify punts to Maxima and elements of QQbar don't survive the 
trip. The "_I" you get back isn't recognized as a square root of -1. To see 
things go wrong more clearly:

sage: SR(QQbar(2).sqrt()).simplify()
TypeError: ECL says: In function CHAR-CODE, the value of the only argument 
is
  -1
which is not of the expected type CHARACTER

Since Maxima doesn't have a type compatible with QQbar, there doesn't seem 
to be a way to support "simplify" on SR encapsulations of QQbar.

-- 
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 send (import) any sage variable back to other software in Sage e.g. Maxima or R

2017-06-22 Thread Nils Bruin
On Thursday, June 22, 2017 at 7:40:43 PM UTC+2, kcrisman wrote:
>
> Just in general, you should be able to do
>
> f = stuff
>
> y = maxima(f)
>
> z = y._sage_() # or maybe sage(y)
>
Furthermore, results transferred to interfaces are assigned to variables 

sage: U=maxima(sin(x))
sage: U.name()
'sage4'
sage: maxima('sage4')
sin(_SAGE_VAR_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: Here is an example

2017-07-10 Thread Nils Bruin
sage has parametric_plot3d. If you read its documentation you can probably 
figure out how to accomplish the same result that you get from mathematica.

On Monday, July 10, 2017 at 11:49:50 AM UTC+2, HG wrote:
>
> Hi,
> This is a mathematica example, but I am not able to do something 
> ressembling this yin yang grid a challenger ?
> https://github.com/aishenri/sage/blob/master/gridyy.pdf
> the cdf and noteboob are on the same dir.
> As sagemath seems to be an alternative would be great ?
> Regards
> Henri
>

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


Re: [sage-support] cyclic algebras

2017-07-10 Thread Nils Bruin
On Monday, July 10, 2017 at 3:38:27 PM UTC+2, John Cremona wrote:
>
> Sage does have a function is_norm() for number field elements so the 
> underlying algebraic problem should be solvable. 
>

It looks like the implementation of this routine requires a galois 
extension:

sage: K.=NumberField(x^3-2)
sage: 7.is_norm(K)
NotImplementedError: is_norm is not implemented unconditionally for norms 
from non-Galois number fields

gp/pari does seem to be able to compute these things via s-unit equations, 
though:

sage: len([i for i in range(100) if gp.bnfisnorm(K,i)[1].norm() == i])
68

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


Re: [sage-support] Re: Here is an example

2017-07-10 Thread Nils Bruin
On Monday, July 10, 2017 at 2:27:10 PM UTC+2, HG wrote:
>
> thanks but I am trying already for a long time... I think that even 
> sagemanifolds is very near capacity of doing it but I am not good to make 
> it !
>
> I don't understand the f[switch_] ;= Module  part 
>
That question might be more suitable for a mathematica forum. It looks to 
me that this is just

def f(switch):
  if switch=="yin":
coords = ...
  else:
coords = ...
  
  return (surfaceRad, surfaceTht, surfacePhi)

-- 
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: Here is an example

2017-07-11 Thread Nils Bruin
On Monday, July 10, 2017 at 11:49:50 AM UTC+2, HG wrote:
>
> Hi,
> This is a mathematica example, but I am not able to do something 
> ressembling this yin yang grid a challenger ?
> https://github.com/aishenri/sage/blob/master/gridyy.pdf
> the cdf and noteboob are on the same dir.
> As sagemath seems to be an alternative would be great ?
> Regards
> Henri
>

You could probably clean up the code a bit, but I think the sage 
construction is more straightforward:


var("r,theta,phi");
def coordfunc(r,theta,phi,switch,shift=0):
if switch=="yin":
return 
(r*sin(theta)*cos(phi)+shift,r*sin(theta)*sin(phi),r*cos(theta))
else:
return 
(-r*sin(theta)*cos(phi)+shift,r*cos(theta),r*sin(theta)*sin(phi))

yin=(parametric_plot3d(coordfunc(1,theta,phi,"yin",1),(theta,pi/4,3*pi/4),(phi,-3*pi/4,3*pi/4))+
  
parametric_plot3d(coordfunc(0.6,theta,phi,"yin",1),(theta,pi/4,3*pi/4),(phi,-3*pi/4,3*pi/4),color="yellow")+
   
parametric_plot3d(coordfunc(r,theta,-3*pi/4,"yin",1),(r,0.6,1),(theta,pi/4,3*pi/4))+
   
parametric_plot3d(coordfunc(r,theta,3*pi/4,"yin",1),(r,0.6,1),(theta,pi/4,3*pi/4))+
   
parametric_plot3d(coordfunc(r,pi/4,phi,"yin",1),(r,0.6,1),(phi,-3*pi/4,3*pi/4))+
   
parametric_plot3d(coordfunc(r,3*pi/4,phi,"yin",1),(r,0.6,1),(phi,-3*pi/4,3*pi/4))
  )
yang=(parametric_plot3d(coordfunc(1,theta,phi,"yang",-1),(theta,pi/4,3*pi/4),(phi,-3*pi/4,3*pi/4))+
  
parametric_plot3d(coordfunc(0.6,theta,phi,"yang",-1),(theta,pi/4,3*pi/4),(phi,-3*pi/4,3*pi/4),color="yellow")+
   
parametric_plot3d(coordfunc(r,theta,-3*pi/4,"yang",-1),(r,0.6,1),(theta,pi/4,3*pi/4))+
   
parametric_plot3d(coordfunc(r,theta,3*pi/4,"yang",-1),(r,0.6,1),(theta,pi/4,3*pi/4))+
   
parametric_plot3d(coordfunc(r,pi/4,phi,"yang",-1),(r,0.6,1),(phi,-3*pi/4,3*pi/4))+
   
parametric_plot3d(coordfunc(r,3*pi/4,phi,"yang",-1),(r,0.6,1),(phi,-3*pi/4,3*pi/4))
  )
(yin+yang).show(viewer="threejs") 

-- 
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: taylor(1/4*x-x^2,x,0.2,3)

2017-07-12 Thread Nils Bruin
On Wednesday, July 12, 2017 at 10:06:13 AM UTC+2, Dima Pasechnik wrote:
>
>
>
> Any idea what's going on? Looks like a Sage bug, or perhaps Sage loads 
> Maxima with an
> option that prevents calling that 'rat' thing...
>
> Yes, sage does turn off the "turn floats into rational numbers" because 
that gives confusing and questionable results. If you trust that your users 
know when to use floats and when rational numbers, then converting from one 
to the other automatically is not so good. 

-- 
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 remove deprecation warning when substituting expressions in this snippet?

2017-07-14 Thread Nils Bruin
On Saturday, July 15, 2017 at 1:21:50 AM UTC+2, Chris Seberino wrote:
>
> I've tried lots of variations of the following to replace a product of 
> functions with y.  They all give the error at the bottom in Sagecell.  How 
> fix?
>
> var("y")
> f = function("f")(x)
> g = function("g")(x)
> eqtn = f(x) * g(x) + 4*f(x)^2 * g(x) == 0
> eqtn = eqtn.substitute({f(x) * g(x) : y})
> show(eqtn)
>
> /home/sc_serv/sage/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py:2881:
>  
> DeprecationWarning: Substitution using function-call syntax and unnamed 
> arguments is deprecated and will be removed from a future release of Sage; 
> you can use named arguments instead, like EXPR(x=..., y=...)
> See http://trac.sagemath.org/5930 for details.
>   exec(code_obj, self.user_global_ns, self.user_ns)
>

Just define
 
f = function("f")
g = function("g")

instead

-- 
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: Polynomial factorization over modular ring

2017-08-15 Thread Nils Bruin
On Tuesday, August 15, 2017 at 7:21:03 AM UTC-7, chandra chowdhury wrote:
>
> Is it possible to factor polynomials completely over modular ring? 
>
> Like 
> x = var('x') 
> factor(x^5-x, IntegerModRing(25)['x'])
> gives
>
> (x-1)*(x+1)*(x^2+1)*x
>
The second argument is simply ignored here, by the looks of it

sage: factor(x^5-x,"moo")
(x^2 + 1)*(x + 1)*(x - 1)*x

You could file that as a (mild) bug.

Factorization of Z/25 directly isn't implemented:

sage: R=IntegerModRing(25)
sage: Rx.=R[]
sage: factor(x^5-x)
NotImplementedError: factorization of polynomials over rings with composite 
characteristic is not implemented

Root finding is apparently implemented:

sage: (x^5-x).roots(multiplicities=False)
[0, 1, 7, 18, 24]

Alternatively, (beccause you're working mod a prime power) you could look 
at p-adic rings:

sage: R=Zp(5,2,"fixed-mod",print_mode="terse")
sage: Rx.=R[]
sage: (x^5-x).factor()
((1 + O(5^2))*x + (1 + O(5^2))) * ((1 + O(5^2))*x + (7 + O(5^2))) * ((1 + 
O(5^2))*x + (18 + O(5^2))) * ((1 + O(5^2))*x + (24 + O(5^2))) * ((1 + 
O(5^2))*x + (0 + O(5^2)))

The "+O(5^2)" is a p-adic thing that would be nice to suppress here.
 

-- 
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: Conversion of libgap data to sage data

2017-09-15 Thread Nils Bruin
On Friday, September 15, 2017 at 8:38:37 AM UTC-7, Simon King wrote:
>
>
> Unfortunately, the transition from libgap to Sage is very 
> slow: Reading the data into libgap takes 16 seconds, 
> translating the data to Sage takes 3 minutes. Most of that 
> time is used for the transformation of the matrices. Actually 
> I am using boilerplate to speed things up, otherwise it 
> would take a lot longer than 3 minutes.


It would seem to me that libgap should be able to do the translation pretty 
efficiently. My first suspicion would be that you hit some generic 
translation cop-out. Something that reverts to strings or so? I would also 
do some timings to see how this scales: it should be roughly linear in 
input. If it seems to be something worse, then that might be an indication 
there's a wrong algorithm involved somewhere.

How fast is converting your list of matrices to a list of lists in gap? 
Perhaps GapMatrix->GapList->SageList->SageMatrix is faster.


-- 
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 factorize a polynomial function of third degree with only variables like coefficient

2017-09-20 Thread Nils Bruin
On Tuesday, September 19, 2017 at 10:45:06 PM UTC-7, Yann Cargouet wrote:
>
> Hi Simon,
>
> Thank you for your answer, I will try the Ansatz and comparison of 
> coefficients.
> To find coefficients a, b, and c I tried to solve a system of three 
> equations but unfortunately it doesn't work. The system is depicted below:
> eq1 = a + b == Rl*Rs*Cc*gm + Rc*Cc + Rl*Cc + Rl*Cl + Rs*Cc + Rs*Cin
> eq2 = c + a*b == Rc*Rl*Cc*Cl + Rc*Rs*Cc*Cin + Rs*Rl*Cc*Cin + Rs*Rl*Cc*Cl + 
> Rs*Rl*Cin*Cl
> eq3 = a*c == Rc*Rl*Rs*Cc*Cin*Cl
> solve([eq1,eq2,eq3],a,b,c)
> Here is the result given by SAGE:
> sage: []
> Why this systen doesn't work ?
>

Why do you think the polynomial factors into lower degree factors. It 
doesn't in QQ[Rl,...Cc,s] (as a simple call to "factor" verifies) and one 
would expect the same to be true in CC[...].

You can already see it from your system above: eq3 gives only finitely many 
combinations for a,c (up to scalars), so given those choices you get a 
bunch of overdetermined systems in b. One would expect none of those are 
solvable. The solve command might have verified that, but I don't think 
"solve" gives any guarantees that it tries anything exhaustive.

>
> Regards,
> Yann
>
> Le mardi 19 septembre 2017 10:23:07 UTC+2, Yann Cargouet a écrit :
>>
>> Hi everybody,
>>
>> I would like to factorize a polynomial function of third degree in order 
>> to obtain the following form:
>> (1 + a*s + b*s^2)*(1 + c*s).
>>
>> Here my test case:
>>
>> When I use the factor() function there is no change on the expression. 
>> Which function I have to use to obtain the wanted simplication ?
>>
>> all my variables are defined with the command var('Cc, Cin,...)
>>
>> Thanks in advance for your answers
>> Yann
>>
>

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


Re: [sage-support] Memory leak in loops (SageMath 8.1)

2017-12-15 Thread Nils Bruin
On Friday, December 15, 2017 at 6:51:37 AM UTC-8, Marco Caselli wrote:
>
> Thank you very much for your prompt replies. I was sure that range(n) 
> creates an iterator instead of the list itself, my bad. 
> In any case, even if the function is creating this list, why is it still 
> stored in memory after the function terminates? It is a local variable, and 
> is not returned so it should be erased from the RAM.
>

And undoubtedly it did (a list of integers has no circular references, so 
it can be deleted just based on reference counts), but obtaining memory 
from and returning memory to the operating system is an expensive 
operation, so python is probably reluctant to do so.
 
get_memory_usage only reports how much memory is allocated to the python 
process, not how much of it python is actually considering as in use.

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


Re: [sage-support] Memory leak in loops (SageMath 8.1)

2017-12-18 Thread Nils Bruin
On Monday, December 18, 2017 at 7:48:34 AM UTC-8, Marco Caselli wrote:
>
>
> So there is a discrepancy between the real amount of memory in use and the 
> one allocated but, when I run a process, my hardware limits the allocated 
> one. So, for instance, I can evaluate ex_f(p) just for very small values of 
> p even if the real amount of memory in use is almost zero for any p. 
>  
>
No, not if there's no memory leak. Memory that is freed by python is 
available for re-use by python. That's actually the reason for python to 
not immediately return freed memory to the operating system: reusing it for 
new python objects is considerably faster.

If your routine f_ex runs out of memory then that would indicate a memory 
leak. If you look at the code for (K^6).__iter__ you'll see it really 
intends to be an iterator that uses limited memory.

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


Re: [sage-support] Memory leak in loops (SageMath 8.1)

2017-12-22 Thread Nils Bruin
On Friday, December 22, 2017 at 3:07:13 AM UTC-8, Marco Caselli wrote:
>
>
>
> Il giorno lunedì 18 dicembre 2017 17:37:48 UTC+1, Nils Bruin ha scritto:
>>
>> If your routine f_ex runs out of memory then that would indicate a memory 
>> leak. If you look at the code for (K^6).__iter__ you'll see it really 
>> intends to be an iterator that uses limited memory.
>>
>
> Yes, it is definitely a memory leak. Running the same routine on Magma I 
> have not experienced any memory issue.
>

I can confirm that

R.=GF(3)[]
f=x^2 + y^2 + z^2 + x + y + z - 1
while True: _=f.factor()

does appear to be leaking memory. It's not leaking in python, though! If I 
compare the python heap before and after with gc.get_objects I'm not seeing 
any serious accumulation of objects. So the leak must be somewhere else; 
probably in the factorization library or the code interfacing with it.

We have some leaking problems with libsingular, see e.g.:
https://trac.sagemath.org/ticket/13447
https://trac.sagemath.org/ticket/15498
but this particular example doesn't seem to be exactly of the above 
reported kinds.


-- 
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: Bug report: Kernel dies after 1 hour while dividing polynomials

2018-02-06 Thread Nils Bruin
On Monday, February 5, 2018 at 9:11:44 AM UTC, Patrick Reichert wrote:
>
> I want to submit an *error report* for SAGE 7.0 and 8.0:
>
> The division of two polynomials in an ideal causes an *kernel death* 
> after one hour of computation.
> Singular performs the calculation in about *one second*.
>
>
It's worth noting that Sage's "quotient ring" does not seem to wrap 
singular directly (although internally it probably does depend on it via 
calling reduce)

*SAGE source code:*
>
> Q. = QQ['E', 'F', 'X', 'Y'];
>
> i1 = F^4+(E^3+E^2-E+2)*F^3+(E^3-3*E+1)*F^2-(E^4+2*E)*F+E^3+E^2;
>
> i2 = Y^2+(E^3+E^2*(3*F+2)-E*(F^2-2*F-1)-F*(F^2+3*F+1))*X*Y+(F*(E+1)*(E-F
> )*(E+F+1)^2*(E^2+E-F)*(E^2+E*F+E-F^2-F))*Y-X^3-(F*(E+1)*(E-F)*(E+F+1)*(E^2
> +E-F))*X^2;
>
> J = Q.ideal(i1, i2);
>
> R. = QuotientRing(Q, J);
>
> poly1 = x^4+(-e^2*f^4+e^4*f+2*e^3*f^2-e*f^4-2*e*f^3+2*f^4+2*e^2*f-6*e*f^2+
> f^3+5*e^2-5*e*f+11*f^2-17*e+18*f+16)*x^3+(-2*e^3-2*e^2*f+e*f^2+f^3-3*e^2+2
> *f^2-e+f)*x^2*y+(-6*e^2*f^5+11*e*f^6-3*f^7+3*e^6-6*e^5*f+17*e^4*f^2-69*e^2
> *f^4+5*e*f^5+17*f^6-5*e^5+26*e^4*f+83*e^3*f^2-106*e^2*f^3-104*e*f^4+71*f^5
> -28*e^4+66*e^3*f+57*e^2*f^2-149*e*f^3+54*f^4-55*e^3+78*e^2*f+9*e*f^2-32*f^
> 3-35*e^2+70*e*f-35*f^2)*x^2+(-e^2*f^7-e^7*f-3*e^6*f^2-2*e^2*f^6-e*f^7-5*e^
> 6*f-e^5*f^2-6*e^2*f^5-6*e*f^6+2*f^7+3*e^5*f-2*e^4*f^2-2*e^2*f^4-15*e*f^5+2
> *f^6-2*e^5-7*e^4*f-4*e^3*f^2-9*e^2*f^3-4*e*f^4+3*e^4+20*e^3*f-43*e^2*f^2-
> 21*e*f^3+28*f^4-e^3-32*e^2*f-61*e*f^2+61*f^3-22*e^2-53*e*f+59*f^2-16*e+16*
> f)*x*y+(e^6+2*e^5*f+3*e^5-4*e^3*f^2-2*e^2*f^3+2*e*f^4+f^5+3*e^4-5*e^2*f^2+
> 2*f^4+3*e^3-3*e^2*f-e*f^2+4*f^3-3*e^2+e*f-9*f^2+17*e-18*f-16)*y^2+(11*e*f^
> 9-3*f^10-3*e^9-5*e^7*f^2-101*e^2*f^7+30*e*f^8+11*f^9-e^8-32*e^7*f-74*e^6*f
> ^2-422*e^2*f^6-117*e*f^7+121*f^8+35*e^7-39*e^6*f-134*e^5*f^2-486*e^2*f^5-
> 660*e*f^6+276*f^7+141*e^6-106*e^5*f-226*e^4*f^2+384*e^2*f^4-1019*e*f^5+36*
> f^6+189*e^5-367*e^4*f-681*e^3*f^2+1382*e^2*f^3+130*e*f^4-884*f^5+61*e^4-
> 1019*e^3*f+565*e^2*f^2+1914*e*f^3-1521*f^4-251*e^3-499*e^2*f+1751*e*f^2-
> 1001*f^3-231*e^2+462*e*f-231*f^2)*y;
>
> poly2 = x+e^5*f+e^4*f^2-e^2*f^4+2*e^4*f+e^3*f^2-3*e^2*f^3+f^5+3*e^3*f-3*e^
> 2*f^2-3*e*f^3+3*f^4+e^3+e^2*f-5*e*f^2+3*f^3+e^2-2*e*f+f^2;
>
> print (poly1 / poly2);
>
>
>
I would not expect that this code would call reduce(poly1/poly2, J). poly2 
doesn't represent a unit modulo J, so the division is problematic. It is 
the case that poly1 in (J+(poly2)), so there is some polynomial that can 
represent poly1/poly2. However, this would in general not be unique modulo 
J (poly2 could still be a zero divisor modulo J).

The operation is still a useful one in practice, of course, so in might be 
worthwhile exposing tools that allow one to easily perform the relevant 
computation. 

-- 
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: Is this a bug?

2018-03-05 Thread Nils Bruin
On Wednesday, February 28, 2018 at 8:00:34 AM UTC, Simon King wrote:
>
> So, we have two x with different roles. It would make sense to disallow 
> the creation of such rings. 
>
> -1. It would mean any structure with named generators would have to go dig 
into the tower that defines it base to check for name clashes. This would 
make for very unfunctorial code:

Rather than having a construction

R['x'] -> create a univariate polynomial ring in 'x' over the ring R. Here 
R can be any (commutative) ring.

it would need:

R is an element of the category of commutative rings having none of its 
generators called 'x'.

I think it makes no sense to build such ridiculous restrictions into the 
system. The corollary of allowing them is having to deal with generators 
whose names might be ambiguous in the tower. It's a little unpleasant, but 
at least explicable, and once one learns how to refer to generators 
unambiguously, quite doable. These name clashes only happen interactively. 
On the other hand, name clashes are particularly prone to happen deep in 
library code, where avoiding them will be very hard.


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


Re: [sage-support] Re: Is this a bug?

2018-03-05 Thread Nils Bruin
On Wednesday, February 28, 2018 at 2:42:26 PM UTC, Ralf Stephan wrote:
>
> It might not be necessary to (re)assign the global variable. Only if the 
> user wants to do operations with the polynomial he wants an x to be that 
> poly variable, and certainly not another x. So, the parser can do the part 
> of figuring out what x is meant, maybe by checking all generator names. 
> Example:
>
> sage: charpoly()
> x + 1
> sage: _ - x
> (parser sees underscore and operation, and an unassigned global, so it 
> checks the object referred by the underscore for variable names)
>

I don't think this would be a job for the parser. You'd want x bound to 
something like "UniversalCoercingNamedGenerator('x')" which would be an 
object that happily coerces into any parent P via essentially P('x'), but 
it could do something more fancy.

In order for  1+UniversalCoercingNamedGenerator('x') to work some more 
magic for finding common covering parents would be necessary. Mind you: 
you'd end up with a polynomial over ZZ then, not a symbolic expression. For 
that you'd need

sin(1)+UniversalCoercingNamedGenerator('x')-sin(1)+1

It could be a fun exercise to write such an object, and I think it would be 
possible. However, I wouldn't be in favour of including it in sage. Its 
behaviour would be too magical to be reliable for a medium to expert level 
user, and a novice would probably be able to find all kinds of unexpected 
edge cases.

-- 
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: [sage-cell] Where Oh Where is my Divide By Zero Error?

2018-03-20 Thread Nils Bruin
On Friday, March 16, 2018 at 7:27:41 PM UTC-7, Andrey Novoseltsev wrote:
>
> On Fri, Mar 16, 2018 at 4:18 PM, Jorge Garcia  > wrote: 
> > Dear Hive Mind: 
> > 
> > Why is there no Divide By Zero Error here: 
> > 
> http://sagecell.sagemath.org/?z=eJwljkELgkAUhO-C_2GiAtek1kuX2Eu4pBc3NjEqCqQ2E-QlpvX3cwuGd5jHzDdjZHGyw6BUZdgoFQXYx1JLa2WxRJTkSSSxPuAotYLUWumR64zRcDEJOecBtFhOA3QitHZpyLRFZ1BR03fDvdb9raISJLjrpKItqDReyNnq9Xh-vJTZkHkXdW9DjUcMvu__F2SIlNxhk-Tyt-UHH76usxUny_a9cMbnfLkgdiHcny1oICI9_8u37AuZcDtw&lang=sage
>  
> Someone probably can, but perhaps not on this list: it has something 
> to do with 0^0 evaluating to 1 and I recall some earlier discussions 
> about it. Forwarding to sage-support. 
>

The issue seems the way that floats deal with division by 0. The expression 
0.06/0 gets evaluated as (0.06)/(0.000) and apparently that gets evaluated 
as +infty. If that gets raised to 0, you get 1.

If you instead write (6/100) / 0 you do get a division by 0 exception.

-- 
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: Cython in jupyter notebook

2018-04-15 Thread Nils Bruin
On Sunday, April 15, 2018 at 7:11:06 AM UTC-7, Simon King wrote:
>
> Hi! 
>
> The following cython code compiles fine in SageMath command line version 
> and it *used* to compile fine in the jupyter notebook one year ago: 
>
>  cython(""" 
>  def mantisse(): 
>  cdef double a = 1 
>  cdef double b = 2 
>  cdef int i = 0 
>  while True: 
>  a += b**(-i) 
>  print("%2d: %.53f"%(i,a)) 
>  if a==1: 
>  return i-1 
>  i += 1 
>  a = 1 
>  """) 
>
> However, in the jupyter notebook I no get the error 
>
>
You can trigger the error by a straight call

sage.misc.cython.cython()

The traceback (there is only one frame):

...

669 except Exception as msg:670 msg = str(msg) + "\n" + 
distutils_messages--> 671 raise RuntimeError(msg.strip())672 
673 if verbose >= 0:
RuntimeError: fileno


I suspect it's this commit:

https://git.sagemath.org/sage.git/commit/?h=c59f37ad5ee719b23293a0f677422f5f818b7981

where this code was committed:

try:
# Capture errors from distutils and its child processes
with open(os.path.join(target_dir, name + ".err"), 'w+') as errfile:
try:
with redirection(sys.stderr, errfile, close=False):
dist.run_command("build")
finally:
errfile.seek(0)
distutils_messages = errfile.read()
except Exception as msg:
msg = str(msg) + "\n" + distutils_messages
raise RuntimeError(msg.strip())



This works on the command line:

sage: F=open("er",'w+')
sage: sage.misc.sage_ostools.redirection(sys.stderr,F)

but in jupyter we get an error:

UnsupportedOperation: fileno


because sys.stderr is now:



It looks like sage_ostools.redirection might need some love.

-- 
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: Cython in jupyter notebook

2018-04-15 Thread Nils Bruin
Problems like this have been encountered before. This seems to work around 
problems in the other direction (i.e., let Jupyter deal with an actual file 
rather than one of its streams):

https://stackoverflow.com/questions/34145950/is-there-a-way-to-redirect-stderr-to-file-in-jupyter

The quickest workaround for now is to just eliminate the whole error 
redirection. We didn't have it before either. If you have control over the 
distribution you use to teach, that might get you through your lecture.

The next step would be to disable the redirection if stderr isn't an actual 
file.

The full solution could probably make do with saving sys.stderr, assigning 
the temporary file to it and afterwards putting it back. You would need the 
right amount of flushes. Furthermore, this is not at all thread-safe (the 
current solution isn't either), so general hygiene would probably require 
forking before redirecting and then reaping the child once the build has 
completed.

-- 
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: Right way to kill notebook server on single-user machine

2018-04-25 Thread Nils Bruin
When you start up the jupyter notebook it writes some files describing its 
state. On Fedora, they end up in in /run/user//jupyter. There's a file 
there nbserver-.json. In the file you'll find some basic data about 
the server, including the "pid", which also appears in the filename.

executing

kill -2 

twice in quick succession has the same result as pressing ctrl-C twice at 
the terminal where the server is running, so that shuts down the notebook 
cleanly.

Obviously there can be multiple notebook servers running, even under the 
same UID, so there can be multiple files there. You'll have to have a way 
to pick the right one.

On Monday, April 16, 2018 at 11:34:41 PM UTC-7, Tevian Dray wrote:
>
> I'm a relatively new Sage user, trying Jupyter for the first time.  OS is 
> Ubuntu 14.04; Sage version is 8.1.  Starting Jupyter from the command line 
> (sage -n jupyter) works as expected, but so far as I can tell the only way 
> to shut down the notebook server after closing the browser is via ctrl-c. 
>  What if sage is not started from a terminal?  Or if stdout is redirected 
> to a file?  For example, if I redirect stdout when starting sage, then send 
> ctrl-c after closing the browser, the sage-notebook process continues to 
> run -- presumably because I have no way to send a second ctrl-c.
>
> I found this 10-year-old post asking essentially the same question:
> 
> https://groups.google.com/forum/#!newtopic/sage-support/sage-support/IrA6obQupKw
> but parts of it are clearly out of date.  However, the suggestion to use 
> "kill -2" sounds promising, but on which process?  I only see two, one 
> running sage-notebook, the other running sage-cleaner.  Or is there some 
> other way?  "killall python" works, but presumably isn't a clean shutdown 
> -- and I certainly wouldn't want to script such a sledgehammer.
>
> It would be really nice if there were a provided script for shutting down 
> the notebook server cleanly!
>

-- 
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: 500: Internal server error when I access the data files

2018-05-03 Thread Nils Bruin
On Thursday, May 3, 2018 at 7:14:32 AM UTC-7, Francisco de Arriba wrote:
>
> We can try to move into Jupyter. But we found two new problems, how can we 
> do to start a Jupyter server for multiple users accounts (using a command 
> line like in notebook(accounts=True))
>

The standard solution is Jupyterhub. That's a non-trivial undertaking to 
set up, though. The processes for the users run in dedicated docker 
containers. sagenb was a lot easier for this, but never properly secure. I 
wouldn't dare asking a sysadmin to deploy a sagenb server. Jupyterhub is 
quite well-engineered.
 

> and how can we transform .sws to a compatible extension in Jupyter?
>

Sage ships with a conversion tool.

Sharing files between different jupyterhub users is going to be more work 
as well. You could equip the docker containers with a shared filesystem 
(your choice to make it read-only or have it writable). Alternatively, you 
can offer files on github or other platforms.


-- 
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: Right way to kill notebook server on single-user machine

2018-05-03 Thread Nils Bruin
On Thursday, May 3, 2018 at 2:32:22 PM UTC-7, Tevian Dray wrote:
>
> Finally had a chance to test this; yes it works -- although it is 
> apparently possible to send the two kill commands too close together. Thank 
> you very much.  Have to say it's a bit of a kluge, though -- the design 
> assumption that notebooks will always be started in shell windows that stay 
> open is surely flawed.
>
> Indeed, there seems to be an even righter way:

https://github.com/jupyter/notebook/issues/1950

apparently you can do

$ jupyter notebook list

$ jupyter notebook stop 

When doing this with sage you'd have to make sure to run it through sage's 
jupyter, so something like

$ sage -sh -c "jupyter notebook list"
$ sage -sh -c "jupyter notebook stop "


-- 
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: editor for sage commands

2018-05-19 Thread Nils Bruin
On Saturday, May 19, 2018 at 10:26:35 AM UTC-7, Francesco wrote:
>
>
> Il giorno sabato 19 maggio 2018 18:58:29 UTC+2, Francesco ha scritto:
>>
>> Can you tell me a good editor for sage shell commands ? I try Texmacs, 
>> but it crashes. 
>> I have kubuntu 18.04 64bit and the version of sage in the repositories, 
>> the 8.1.
>>
>> An editor for interactive sessions, but without the use of web browser, 
> like notebooks - jupyter do.
>

Anything that speaks the jupyter protocol can interface with sage. The 
reality is that the browser-based one is by far the most developed one. Its 
successor, jupyterlab, will also be browser-based. The easiest way to get a 
good interactive interface is probably by just ignoring the window you're 
working in is a browser window ...

Jupyter does come with other clients: the console (which gives you 
essentially the sage command line) and qtconsole (which gives you a command 
line in a separate window).

There must be an emacs mode that handles sage well. If you can get used to 
using emacs, that will be one of the most functional command-line options. 
That said, the standard sage command line is pretty functional already 
thanks to ipython/jupyter.

-- 
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: A "remote sage kzernel" in the Jupiter notebook ?

2018-05-25 Thread Nils Bruin
On Friday, May 25, 2018 at 5:59:55 AM UTC-7, Emmanuel Charpentier wrote:
>
> Dear list,
>
> [ This goes to sage-support becaus I do not know if this is already 
> possible with our current kernel.  Please redirect to sage-devel if you 
> think it more appropriate... ]
>
> Re-hashing the SageTeX documentation, I was reminded that this nice 
> package was able to use a remote Sage interpreter through, fo example, an 
> SSH link.
>
> This made me wonder if it would be possible to implement a 
> "mini-Jupyter-kernel" able to invoke a remote Sage kernel to process a 
> local worksheet.
>
> A possible enhancement of this scheme would be to pass some pointer to the 
> local current directory as a possible point of access for the remote 
> process to access local files, through something not unlike sshfs.
>
> This might allow to offer a somwhat secure access to Sage on machines too 
> small or too exotic to offer a local Sage interpreter (e. g. Windows 
> laptops), as long as they can run the Jupyter notebook.
>
> Since your approach requires the device to run ssh, a much more portable 
option is to run the jupyter server on the remote machine as well 
(listening on localhost) and use ssh to forward the relevant port so that a 
local browser can connect to it. That way the jupyter server browses the 
same file system as the sage kernel and  you can use the standard jupyter 
tools to up- and download files. The jupyter server can even give you a 
terminal on the remote machine in your local browser (but since you have 
ssh, you already have that).

I have seen this work on windows and android devices.

-- 
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: A "remote sage kzernel" in the Jupiter notebook ?

2018-05-25 Thread Nils Bruin
On Friday, May 25, 2018 at 1:24:39 PM UTC-7, Volker Braun wrote:
>
> On Friday, May 25, 2018 at 7:02:19 PM UTC+2, Nils Bruin wrote:
>>
>> Since your approach requires the device to run ssh, a much more portable 
>> option is to run the jupyter server on the remote machine as well 
>> (listening on localhost) and use ssh to forward the relevant port so that a 
>> local browser can connect to it.
>>
>
> If only browsers had a cryptographically secure way of transferring web 
> pages ;-)
>

True, but in terms of attack service there is something to say for this 
approach. Since you let ssh take care of the identification and a big part 
of the authentication check, you're limiting the level to which jupyter has 
to do this securely. Since you're only exposing jupyter on localhost: 
ports, you only have to make sure that the local users each use their own 
port and are careful with their jupyter tokens or set a somewhat decent 
password to limit access to their jupyter server. It's a lot easier sell 
than letting jupyter(hub?) handle logins using regular usercredentials and 
then serve the respective homedirs and privileges on an internet-facing 
port. I can sell the localhost-with-ssh tunnelling to a sysadmin, but 
setting up a multi-user jupyter would draw frowns. A deployment with docker 
images would require even more commitment of sysadmin time and hardware. 
The advantage of ssh tunnelling is that you can make it work on a vanilla 
setup, with sage installed as a normal application (or even compiled and 
run by a user).

-- 
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: A "remote sage kzernel" in the Jupiter notebook ?

2018-05-25 Thread Nils Bruin
On Friday, May 25, 2018 at 3:33:47 PM UTC-7, Volker Braun wrote:
>
> I'm not saying anything against ssh tunnel. Though running jupyter 
> remotely with a self-signed cert and authentication with a fixed token 
> handles network disconnect/reconnects better...
>
 
Would you have particular words to say to sysadmins who get worried about 
users opening up services on all kinds of ports? (and this sysadmin could 
be me) -- of course, it also requires the ability to punch the right holes 
in firewalls.

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


Re: [sage-support] Re: Where is (the) kash?

2018-07-10 Thread Nils Bruin
On Tuesday, July 10, 2018 at 6:01:39 PM UTC-7, Kwankyu wrote:
>
> https://trac.sagemath.org/ticket/22982 (a meta-ticket where kash is a 
>> part of)
>>
>
> Not at all! This is a native implementation of global function fields in 
> Sage.
>

That is wonderful! Note that most parts of the function field 
infrastructure doesn't make use of the fact that residue fields as finite 
(if you do it right, basically only the part that computes divisor class 
groups), so with a bit of care the same code should work in characteristic 
0 for most computations. It would be great if you could include that case 
in your code as well. I think this is also how the function field code in 
magma was developed (start with global function fields, retool the code to 
also work for characteristic 0 (or non-finite positive characteristic base 
field) where it makes sense). 

-- 
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 find the normal for of an elliptic curve using Sage?

2018-08-02 Thread Nils Bruin
On Thursday, August 2, 2018 at 8:58:04 AM UTC-7, jianrong wrote:
>
> Dear All,
>
> Let $C$ be the following curve in $\mathbb{C}^2$.
> \begin{align}
> & 11664 {c_1}^3 {c_2}^2 + 536544 {c_1}^3 c_2 + 6170256 {c_1}^3 + 67068 
> {c_1}^2 {c_2}^2 + 1542564 {c_1}^2 c_2 \\
> & + 3085128 c_1 {c_2}^2 - 32393844 c_1 c_2 + 3085128 c_1 + 17739486 
> {c_2}^2 + 6941538 c_2 = 0.
> \end{align}
> I checked that this curve has genus $1$ using Sage. Therefore it is an 
> elliptic curve. How to change coordinates such that the equation of this 
> curve is of the form $y^2 = f(x)$, where $f$ is some polynomial. Thank you 
> very much. 
>
> A genus 1 curve is only an elliptic curve once you choose a rational point 
on it. Your curve does have rational points (the singularities don't count 
-- we need a point on the desingularization of the curve, but others aren't 
hard to find either), but finding an isomorphism to a Weierstrass model 
requires the choice of one.

Getting the model involves finding functions x,y on C that have pole orders 
2 and 3 at the chosen point, and are regular everywhere else. You can then 
solve for a linear relation between y^2, xy, y, x^3,x^2,x, 1 (which you 
could do with interpolation at that point). Unfortunately, this hasn't been 
implemented as a fully general automatic procedure in sage yet.

What you CAN do (although this is a little insane), is recognize the 
j-invariant of the Jacobian:

S=C.riemann_surface(prec=400)
tau=S.riemann_matrix()[0,0]
CC=parent(tau)
q=exp(2*CC.0*CC.pi()*tau)
J=j_invariant_qexp(100).truncate(100)
sage: J(q).algdep(3)
6586060771822965534*x - 3927422869602298031

so the j-invariant is quite probably

j=3927422869602298031/6586060771822965534

which means that the elliptic curve you are looking for is almost certainly 
a quadratic twist of:

sage: EllipticCurve_from_j(j)
Elliptic Curve defined by y^2 + x*y = x^3 + 120280*x - 864149826 over 
Rational Field

Again, the purely algebraic operation of computing a Weierstrass model of C 
with a point directly is a much better way to go about things.
In fact, with Magma (even the online calculator) it's easy to do. You'll 
find the elliptic curve you're looking for is the twist by 23 of the curve 
above.

-- 
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: Deleting all zero rows in a matrix

2018-10-02 Thread Nils Bruin
On Tuesday, October 2, 2018 at 12:56:54 AM UTC-7, jamison...@vanderbilt.edu 
wrote:
>
>
> How can I delete the all zero rows (rows 2 and 3) for
>
> all any entry of a matrix. I tried the for loop below, but it
>
> doesn't store any of the values and only gives one lines. Please Help!
>
>
> If you know your matrix is in echelon form then you're just looking for a 
submatrix and you can get it by slicing:

A=matrix(GF(q),[[0,0,0],[1,1,0],[0,1,1],[1,0,1]])
E=A.echelon_form()
E[:E.rank(),:]

-- 
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: using parallel & fork decorators with timeout

2018-10-25 Thread Nils Bruin
On Thursday, October 25, 2018 at 7:13:26 AM UTC-7, John Cremona wrote:
>
> sage: for res in apply([f,g]): print res; break
> (((,), {}), 3^2 * 12248508919 * 
> 263416276811813669131602539468011)
>
> The first bit of the output shows that it is f which returns the result.  
> But I don't know if g stops working because of the 'break' -- does it?
>
> I'm almost certain it doesn't. The iterator that is returned by 
apply([f,g]) is not referenced by your code any more after the break, so it 
might be possible it gets destructed at this point. Destruction at that 
point could indeed send a kill to the child processes that haven't 
completed yet (or terminate them otherwise), but in general you can't trust 
that actions triggered by destruction will happen at particular times. As 
far as python is concerned, a no-op gargabe collector would be a compliant 
implementation.

Clearly what you should have is something along the lines of

A=apply([f,g])
res=next(A)
A.stop_remaining_processes()
del A #if you want

(this could be wrapped in a context manager so that you could do something 
like)

with apply([f,g]) as A:
res=next(A)

I would expect the functionality is already there in the underlying library 
that is used by @parallel, but it doesn't seem to be exposed on the wrapper 
you currently get.

-- 
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: using parallel & fork decorators with timeout

2018-10-25 Thread Nils Bruin
On Thursday, October 25, 2018 at 9:12:56 AM UTC-7, Nils Bruin wrote:
>
> On Thursday, October 25, 2018 at 7:13:26 AM UTC-7, John Cremona wrote:
>>
>> sage: for res in apply([f,g]): print res; break
>> (((,), {}), 3^2 * 12248508919 * 
>> 263416276811813669131602539468011)
>>
>> The first bit of the output shows that it is f which returns the result.  
>> But I don't know if g stops working because of the 'break' -- does it?
>>
>> It probably does, but you might program it a little more explicitly.

If you change one of the functions to

def g(N):
while True:
continue
return 0

and do something like

@parallel(ncpus=4)
def apply(func):
return func(29038109543453453498320938204932840238210981)

you have a little better guarantee that there will be a dangling job, so 
you can check with "top" if termination happens.

With

A=apply([f,g])
res=A.next()

I did see a dangling job. This was killed with

del A

As discussed before, that's not something you can formally rely on in 
python. 

As you can see here:

https://github.com/sagemath/sage/blob/6187d261eca3c980e575b53d1a31f580ba8cfdfd/src/sage/parallel/use_fork.py#L230

the generator function that produces the results does clean up after itself 
(and indeed, "delete" of a generator function that is in operation does 
trigger the "finally" clauses, as you'd home). It would be much better if 
that clean-up could be triggered explicitly, but that would require 
exposing a little more of the execution state on the "Parallel" object. It 
would be a fairly straightforward and small for someone with good python 
knowledge.

In fact, in Py3, the support for asynchronous operations and coroutines has 
been MUCH improved, so at some point the parallel tools in sage should 
probably be rewritten to cooperate better in that framework.

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


Re: [sage-support] plot3d doesn't work in jupyterlab / jupyter notebook

2018-11-18 Thread Nils Bruin
It depends a little bit on how you install the sage kernel into your 
jupyter notebook server, but chances are you have to do some extra work to 
install some notebook extensions.

In the sage install, in "/local/share" there are 3 subdirs 
"jsmol, "mathjax", "threejs". These need to be findable as "nbextensions" 
by your jupyter. Having them symlinked in, say, 
/usr/local/share/jupyter/nbextensions should do the trick [if your sage 
kernel lives in .../kernels/sagemath , you would probably want to symlink 
these extensions from .../nbextensions ] 

On Sunday, November 18, 2018 at 2:25:43 PM UTC-8, Kolen Cheung wrote:
>
> sage: y = var('y')
> sage: plot3d(x * y, (x, -1, 1), (y, -1, 1), viewer='threejs')
> Launched html viewer for Graphics3d Object
>
> I didn’t see anything since I’m remote ssh. I tried both ssh -X and ssh -Y 
> but they doesn’t work.
>
> I don’t have a local machine that has a working sage yet. So can’t test 
> that.
>
> Thanks.
> ​
>

-- 
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: Function defined with matrices won't plug in values for function

2018-11-30 Thread Nils Bruin
On Friday, November 30, 2018 at 1:59:40 PM UTC-8, saad khalid wrote:
>
> However, when I try to compute this h(.1), the function doesn't plug in .1 
> in for s in the function, and it returns:
>
> [ s + 1  0]
> [ 0 -s + 1]
>
>
> What exactly is happening?
>
> The problem is that a matrix over SR is not a symbolic expression itself:

sage: parent(M1+s*Mx)
Full MatrixSpace of 2 by 2 dense matrices over Symbolic Ring

The effect of "h(s)=..." is (you can check by calling 
'preparse("h(s)=...")'):

 h = symbolic_expression(M1+s*Mx).function(s)

which "forces" the sage object M1+s*Mx into the symbolic ring. Nearly 
everything can be stuffed into the symbolic ring, but in this case it 
basically becomes a constant:

sage: symbolic_expression(M1+s*Mx).variables()
()
sage: symbolic_expression(M1+s*Mx).is_constant()
True

Once stuffed into SR, it's an opaque entity, and the occurrence of s in it 
is not visible. So turning it into a function of s is straightforward: it's 
a constant function!

The solution here is to use that matrices over symbolic rings do inherit 
some properties of symbolic expressions. One is substitution, so

sage: h=M1+s*Mx
sage: h(s=1.0)
[ 2.00 0]
[0 0.000]

works just fine.

If you want to turn it into something for which h(1.0) works, you can do

h=lambda s0: (M1+s*Mx)(s=s0)

-- 
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: dynamic variable names

2018-12-01 Thread Nils Bruin
On Saturday, December 1, 2018 at 3:36:55 PM UTC-8, Tevian Dray wrote:
>
> How can I create variable names programmatically, then assign values to 
> them?
>
> Python doesn't make that particularly easy, and it also doesn't make 
accessing variables thus created particularly easy. I suspect the 
appropriate solution for you is to construct some container object and 
store the values in there, such as:
D={}
for i in [1..20]:
D[3*i+1] = "value"

for i in [1..20]:
print(D[3*i+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 https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Function defined with matrices won't plug in values for function

2018-12-02 Thread Nils Bruin
On Sunday, December 2, 2018 at 10:22:25 AM UTC-8, saad khalid wrote:
>
> I appreciate the help with solving my problem, though I do have some 
> comments/questions to make with regard to usability for new users:
>
> Why can't matrices be allowed in SR in a nontrivial way?
>

>From a mathematical point of you, you DO want them to have different 
parents: One generally first defines a ring (SR in this case) and THEN 
considers the space of n-by-m matrices over that ring. It's very natural 
for them to NOT have the same parent (e.g., a square matrix would have a 
"determinant" method on it -- a method generally not available on SR 
elements). Hence:

sage: M=matrix(2,2,[1,0,0,x])
sage: M.parent()
Full MatrixSpace of 2 by 2 dense matrices over Symbolic Ring
 
Many "symbolic" methods are now available on this object:

sage: M.variables()
(x,)
sage: M.simplify_trig()
[1 0]
[0 x]

but also matrix-specific ones, including some confusing ones:

sage: M.characteristic_polynomial()
x^2 + (-x - 1)*x + x
sage: M.characteristic_polynomial('t')
t^2 + (-x - 1)*t + x

(note the two different objects that print as "x" in the first expression)

To see the problem that arises from putting matrices into SR, consider for 
instance

sage: A=matrix(2,2,[0,M,M,0])
sage: B=matrix(2,2,[0,SR(M),SR(M),0])

sage: parent(A)
Full MatrixSpace of 2 by 2 dense matrices over Full MatrixSpace of 2 by 2 
dense matrices over Symbolic Ring
sage: parent(B)
Full MatrixSpace of 2 by 2 dense matrices over Symbolic Ring

Especially when you take into account that SR.is_commutative() == True, you 
see that "B" has no chance of acting appropriately, whereas A would 
(matrices over non-commutative rings haven't received much attention in 
Sage yet, so I'd tread carefully, though).

Or, for some function H(s), why cant the behavior H(1) = H(s=1) be the 
> default behavior?
>

sage: var('x,y')
(x, y)
sage: f=x+2*y

Should f(1) return "1+2y" or "x+2" ? It's abmiguous, and therefore 
deprecated. Compare instead

sage: g=f.function(x)
sage: parent(g)
Callable function ring with argument x

Now it's completely clear what g(1) should return.

I guess my issue is that there doesn't seem to be a simple/consistent way 
> to define a function that works, and I believe there should be. Mathematica 
> manages this functionality somehow, what makes it difficult here? I am 
> certainly a fan of using lambda functions, but iirc they are from python 
> and are not inherently Sage/mathematical objects, right?
>

Sage is built on top of python, so there is nothing wrong with using python 
constructs in sage. In fact. that's part of the design: It means that sage 
didn't have to develop all usual programming language infrastructure. The 
functionality provided by "symbolic function" that is not covered between 
symbolic expressions and "lambda" functions is really quite limited. In 
principle, "M.function(x)" could be implemented, returning a "Callable 
matrix over SR with argument x", but there hasn't been suficient demand for 
it.

The most compelling use for "callable expressions" comes from differential 
operators, and doing that for vector-valued functions is quite a different 
beast -- "sage manifolds" deals with that in a more general setting.

Lambda functions aren't the "suggested" way to make functions in the Sage 
> tutorial. Perhaps it is just not known to me, but I would love for there to 
> be some *simple* consistent standard with defining functions such that, 
> if I define one in this way and try to plot it or plug in values with a 
> certain notation, it will Always work and not give me something weird like 
> this.
>

I'd think "lambda functions". There you know exactly what happens when you 
plug something in, because you specify it!
 

> Does such a consistent notation exist that I haven't seen? The page "Some 
> Common Issues with Functions" in the documentation essentially comments on 
> the existence of this issue.
>

Indeed, that page addresses a lot of the issues. Whenever you run into a 
question where "lambda functions" wouldn't do what you want (because of the 
presence of matrices, for instance), there's a good chance that a "callable 
expression" wouldn't do what you want either, because likely you're trying 
to take a derivative or something like that, rather than just evaluate the 
function.

These kinds of problems are fundamental to using a computer algebra system, 
and different systems deal with them in different ways. This means that 
there will be some differences between how "easily" certain tasks are 
completed with different systems. Usually, once you get used to the gotchas 
of a specific system (there always are!) it becomes easier to deal with 
them.

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

[sage-support] Re: attaching files in a jupyter notebook

2018-12-12 Thread Nils Bruin
I would expect magic commands to work a little differently in the jupyter 
gui than on the command line, so the possibility for an error doesn't 
surprise me too much. It can probably be fixed. However, a straight-up 
"attach('')" would hopefully work? It still needs to hook into 
the REPL to actually check for a changed file and do the reloading, but 
that has a better chance of being the same between the IPython CLI shell 
and the Jupyter notebook.


On Wednesday, December 12, 2018 at 9:15:46 AM UTC-8, John Cremona wrote:
>
> I have a file testcong.py which contains various functions I am 
> developing, while testing them in a jupyter notebook.  The first cell in 
> the notebook has the "magic" line "%run testcong.py" and so whenever I make 
> a change to the .py file I have to re-click on that cell.  This gets 
> tedious, especially when the testing notebook has may cells in it since I 
> am forever scrolling up and down.
>
> There has to be a better way.  From the command line one can use attach 
> instead of runfile (which automatically rereads the file when it changes) 
> but I cannot get that to work, even though there is a magic %attach command:
>
> %attach testcong.py
>
> fails with a weird error message which is incomprehensible to me:
>
> "UsageError: Invalid GUI request 'sage', valid ones are:['osx', 'widget', 
> 'qt5', None, 'qt', 'nbagg', 'gtk', 'qt4', 'gtk3', 'notebook', 'tk', 
> 'ipympl', 'inline', 'asyncio', 'wx']"
>
> while 
>
> %attach "testcong.py"
>
> (with quotes) is better, it just cannot find the file (which is in the 
> current directory, i.e. the one I started the notebook from).  But giving 
> the full pathname
>
> %attach "/home/jec/congruences/testcong.py"
>
> also gives "IOError: did not find file 
> '/home/jec/congruences/testcong.py"' to load or attach"
>
> What am I doing wrong?  I did try looking for documentation but failed...
>
>

-- 
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: Function defined with matrices won't plug in values for function

2018-12-15 Thread Nils Bruin
On Wednesday, December 5, 2018 at 10:15:52 AM UTC-8, saad khalid wrote:
>
> Thank you all for the thoughtful responses, your comments helped me a lot. 
> One last bit of trouble that I've been having related to this topic. This 
> was is the code I was running:
>
> Mz = matrix([[0,1],[1,0]])
> Mx = matrix([[1,0],[0,-1]])
> M1 = Matrix([[1,0],[0,1]])
> import numpy as numpy
> #R. = QQ[]
> _ = var('J,hx,alpha')
> alphas = numpy.linspace(0,1,10)
> Bp = Mz.tensor_product(M1).tensor_product(M1).tensor_product(M1) * M1.
> tensor_product(Mz).tensor_product(M1).tensor_product(M1) * M1.
> tensor_product(M1).tensor_product(Mz).tensor_product(M1) * M1.
> tensor_product(M1).tensor_product(M1).tensor_product(Mz)
> Plaqz = Mx.tensor_product(M1).tensor_product(M1).tensor_product(M1)
> F = lambda s: -(1-s)*Bp - s*Plaqz
>
> show(F(.1).eigenvalues())
>
> If I run it, it gives me results with the error: "
>
> UserWarning: Using generic algorithm for an inexact ring, which will probably 
> give incorrect results due to numerical precision issues."
>
> I expected this error to be some minute difference in the far out decimal 
> place range, like I so often see with 
> complex numbers, but the answer I get is actually Quite a bit off from the 
> correct answer. Upon googling, i found that this can
> be fixed by appending CDF to the beginning of every matrix definition, like 
> this:
>  
>
> My question is, why is the default an alg that seems to give incorrect 
> answers, instead of just defaulting to CDF? 
> Also, is there a better way of doing this besides just appending CDF to the 
> beginning every time? 
>
> This is actually a real omission in the code. Using ComplextField(...) 
instead of CDF is slower but provides more options, for instance working 
with more than 53 bits. While computing eigenvalues of matrices numerically 
is fundamentally a tricky operation that generally needs care and error 
control, there are reasonable strategies to do a lot better than what 
happens with ComplexField by default (as you can see with CDF). It would be 
really good if matrices over ComplexField and RealField would use 
algorithms that at least use some common sense. The warning about imprecise 
answers would still apply, but to a much lower degree. (Technical note: 
echelonization for CC and RR presently doesn't even use partial pivoting. 
If we at least do that, we get something that's a little closer to the 
"best effort" result people can reasonably expect.

Of course, by the time you're using numpy anyway, you should probably 
prefer to use the state of the art numerical tools offered there. Only if 
you need more than 53 bits should you consider the sage types.
 

-- 
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: taylor versus series

2018-12-30 Thread Nils Bruin
Looking at the implementation, it seems that the ".series" method uses 
Pynac/Ginac series. A little experimentation seems to suggest that this is 
not properly wrapped. If we break up the expression in small parts and see 
how series expansions of the different components combine, we get 
inconsistent results:

sage: A=(1-x).series(x,6)
sage: B=sqrt(1-6*x+x^2).series(x,6)
sage: C=(2*x).series(x,6)

This seems correct:

sage: A,B
(1 + (-1)*x + Order(x^6),
 1 + (-3)*x + (-4)*x^2 + (-12)*x^3 + (-44)*x^4 + (-180)*x^5 + Order(x^6))

This seems correct too:

sage: A.truncate()-B.truncate()
180*x^5 + 44*x^4 + 12*x^3 + 4*x^2 + 2*x

This is a mess:

sage: (A-B).truncate()
-(1 + (-3)*x + (-4)*x^2 + (-12)*x^3 + (-44)*x^4 + (-180)*x^5 + Order(x^6)) 
+ (1 + (-1)*x + Order(x^6))

This seems fine again:

sage: (A-B).series(x,6)
2*x + 4*x^2 + 12*x^3 + 44*x^4 + 180*x^5 + Order(x^6)

And this seems to be a way of getting a correct answer out (if a little 
lossy):

sage: ((A-B)/C).series(x,6)
1 + 2*x + 6*x^2 + 22*x^3 + Order(x^4)

so it seems that the series code goes haywire when removing the pole. It 
looks like an "upstream" bug in Pynac (and possibly Ginac).

There are other problems with "series" objects:. They don't round-trip to 
maxima very well:

sage: (1/(1-x)).series(x,10).simplify()
ValueError: The name "1" is not a valid Python identifier.

so it looks like either "series" needs a lot of love and support in SR, or 
needs to be pulled. Either one needs significant work from a sufficiently 
expert programmer.

In the mean time, you can accomplish your computations without using SR:

sage: R.=QQ[[]]
sage: (1 - x - sqrt(1 - 6*x + x^2))/(2*x)
1 + 2*x + 6*x^2 + 22*x^3 + 90*x^4 + 394*x^5 + 1806*x^6 + 8558*x^7 + 
41586*x^8 + 206098*x^9 + 1037718*x^10 + 5293446*x^11 + 27297738*x^12 + 
142078746*x^13 + 745387038*x^14 + 3937603038*x^15 + 20927156706*x^16 + 
111818026018*x^17 + 600318853926*x^18 + O(x^19)

which is probably why the state of "series" is so abysmal: people don't use 
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: taylor versus series

2018-12-30 Thread Nils Bruin
On Sunday, December 30, 2018 at 10:30:53 AM UTC-8, Peter Luschny wrote:
>
> > In the mean time, you can accomplish your computations without using SR:
> > sage: R.=QQ[[]]
> > sage: (1 - x - sqrt(1 - 6*x + x^2))/(2*x)
> > 1 + 2*x + 6*x^2 + 22*x^3 + 90*x^4 + 394*x^5 + ...
>
> Does this only work in interactive mode? As soon as I try to
> capture it in a function it doesn't work anymore.
>
> Given

sage: var('x')
sage: f=sqrt(1+x)
sage: R.=QQ[[]]

you'd hope that f(x=t) would do the trick, but unfortunately that tries to 
put t into SR rather than try to evaluate it in R. A workaround:

sage: F=fast_callable(f,vars=[x])
sage: f_as_power_series = F(t)

It depends a bit on how you want to give f to begin with. If you want to 
start with an expression in SR then the approach is fairly efficient. If 
you know you'll be working in Q[[t]] anyway, you might as well start with 
creating f in that ring.

 

> def SERIES(s):
> R. = QQ[[]]
> return s
>

By definining R., you don't change s, so you just get the object s back 
that you passed in. 

What people use depends on their background: I guess that someone
> who comes from Maple or Mathematica almost automatically writes
> 'series' and thinks in terms of SR.
>

Indeed. What I meant was, given that "series" is so poor in sage presently, 
people cannot be using it. So apparently, people who use series in sage do 
so via other means. Indeed, the algebra of series is fairly well-supported 
via power series rings. It would be great if the pynac series would be 
better supported in sage (and if not, we should probably remove them 
entirely, because your example shows they are very misleading), but then 
one has to think: who's going to do the work and why hasn't it happened 
yet? Apparently, people have been sufficiently happy with the other means. 
That said, checking if a ticket exists and, if not, filing one would be 
good. Perhaps someone likes to work on it (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 https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Loading heavy computations

2019-01-17 Thread Nils Bruin
On Thursday, January 17, 2019 at 3:37:36 PM UTC-8, Enrique Artal wrote:
>
> I made some computations, I skip the details for now, but the result was a 
> rational function with rational coefficients and 13 indeterminates. The 
> computation took around three hours and used a lot of memory so I made it 
> using a script. The first time I saved the rational function in a pickle 
> file, the second time in a sobj file.
>

Both are actually pickles, but the standard python "pickle" defaults to an 
older version of the protocol. Sage's "sobj" wrappers select a more modern 
version of the protocol and a more compact (binary) file representation.
 

> The first one was 1.2Gb, the second one around 300Mb. The main issue is 
> that opening a sage session (or using a script) takes much more time than 
> computing (with pickle more than 12 hours, I stopped it, with sobj 10 hours 
> and counting).
>

The pickle format basically consists of a simple programming language with 
instructions to build data structures. To get an idea what it does, you can 
use, for instance,

sage: R.=QQ[]
sage: f=(x^2+y^2)/x
sage: import pickletools
sage: pickletools.dis(sage.misc.explainpickle.comp.decompress(dumps(f)))

or, to get a more or less equivalent piece of sage code:

sage: explain_pickle(dumps(f))
 

> I did not try a text file, but I wonder which is the best strategy to save 
> a heavy result and being able to load it using less time than the actual 
> computation.
>
 
The main thing you learn from the above exercise is that pickle in 
principle does something fairly sensible for rational functions: It 
constructs numerator and denominator via a dictionary.

It may be that this happens with a lot of overhead, so perhaps you can gain 
something if you do it via another route, but it may well be that the 
bottleneck is in the sage-to-libsingular interface, and other construction 
methods won't get around that. 

It's not always the case that reconstructing something from a file store is 
faster than computing it. A silly example:

a=2**(10**10)

completes quite quickly, but writing the bit representation to a file and 
reading it in will be considerable work.

It's unlikely your example is as extreme as the one above, but your 
experience indicates that the size of the polynomials involved in your case 
(the size of the "sobj" file is a poor measure for that) is beyond what 
sage has been tested with regularly. It looks like there's significant room 
for improvement here. Pickle really should be able to do this.

> Ideas would be appreciated. Thanks, Enrique Artal.
>

-- 
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: Loading heavy computations

2019-01-22 Thread Nils Bruin
Thank you for such a detailed description. I think this is a good basis for 
an enhancement ticket. I don't think there is a fundamental reason why 
polynomial construction from a dictionary shouldn't do something efficient 
itself already. As an example of the kind of code we can benchmark on:

sage: R.=QQ[]
sage: f=(x+y+z)^20
sage: D=f.dict()
sage: L=[{k:v} for k,v in D.items()]
sage: %timeit R(D)
1000 loops, best of 3: 244 µs per loop
sage: %timeit sum(R(t) for t in L)
1000 loops, best of 3: 1.32 ms per loop

clearly you found that if f has sufficiently many terms, the time for R(D) 
gets out of control, whereas the second construction should remain 
reasonable (or perhaps things need to be chunked a little bigger that 
term-by-term). Drilling down on where that happens should show how to 
improve the libsingular interface. There's a clear reason to optimize this 
path: pickle uses it and that should be the method of choice to store the 
result of very  large results.


-- 
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: Loading heavy computations

2019-01-22 Thread Nils Bruin
See:

https://trac.sagemath.org/ticket/27091

Balanced summing (which you are basically doing) already makes a bit of a 
difference. If that's indeed the issue then using a balanced summing 
strategy already gives a better order on the algorithm.

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


Re: [sage-support] Getting Live Data

2019-02-05 Thread Nils Bruin
On Tuesday, February 5, 2019 at 3:14:56 AM UTC-8, Ingo Dahn wrote:
>
> See 
> http://doc.sagemath.org/html/en/reference/finance/sage/finance/stock.html. 
> I'd be interested in any alternative source for live data for use in 
> statistics classes.
>
> Haven't used it so I can't vouch for the quality, but 
https://pypi.org/project/yahoo-fin/ looks like it's been updated recently. 
At least installing it should be easy and then reshaping the data to fit in 
pandas or some sage data structure should be straightforward.

I don't think we'd want it to be a dependency for sage, but we certainly 
wouldn't want to *replicate* it in sage without a good reason.

-- 
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: maximal integrals

2019-02-19 Thread Nils Bruin
On Tuesday, February 19, 2019 at 2:04:54 PM UTC-8, slelievre wrote:
>
> but how does one get information in a Maxima session about settings
> such as besselexpand, display2d, domain, keepfloat,
>

These are just global variables, so "display2d;" will give you the value.
 

> and loaded
> modules such as to_poly_solve, simplify_sum, abs_integrate, diag?
>

I think apropos("");  will usually give different results, 
depending on whether the package has been loaded or not.

-- 
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: simplification options

2019-03-11 Thread Nils Bruin
On Monday, March 11, 2019 at 11:05:04 AM UTC-7, Michael Beeson wrote:
>
>  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.  
>

Checking a result is usually much easier: Take the original form of the 
equation, subtract the simplified form, and check that the difference is 
divisible by the relations you impose, such as b^2-(1-a^2). No special 
normal forms are required, just a divisibility test. This gets more 
complicated when there are more relations, because then you'll need an 
ideal membership test, but then you can just present that as "the 
computational tool" (plus, with a bit of luck you can extract the way in 
which the difference can be expressed in terms of the generating relations. 
The algorithm in principle encounters that information on the 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] Re: A case of immaculate conception...

2019-03-19 Thread Nils Bruin
On Tuesday, March 19, 2019 at 4:52:19 AM UTC-7, Emmanuel Charpentier wrote:
>
> Defining a symbolic function seems to declare its arguments. Is this 
> expected ?
>
It's certainly explicit programmed:

sage: preparse("f(x)=1")
'__tmp__=var("x"); f = symbolic_expression(Integer(1)).function(x)

On the plus side, we have very concise syntax for defining symbolic 
variables without having to write quotes:

sage: _(x,y,z)=1
sage: x^2+y^2+z^2
x^2 + y^2 + z^2

which is shorter than var("x,y,z") AND it doesn't cause a tuple to be 
printed.

-- 
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: A case of immaculate conception...

2019-03-20 Thread Nils Bruin
On Wednesday, March 20, 2019 at 4:37:49 AM UTC-7, Emmanuel Charpentier 
wrote:
>
> But I wont, because I tend to think that, as long as we are insisting on 
> explicit creation of symbolic variables,
>

An argument that has been used in that context is that in "f(x)=sin(x)" the 
`x` does occur on the LHS of the assignment, so it is part of what is 
"assigned to". Just as in "R.=QQ[]", the assignment does mention `x` 
explicitly on the LHS, so it is an explicit assignment.
 

>
>
>1. raise an error if the arguments of a symbolic function are not yet 
>existing in the name space, or
>
> I expect that would break too much. If you're worried to losing 
information, we could inject something in the code produced by the 
preparser that issues an error or a warning if the assigned-to variable 
names already have a binding that doesn't agree with what they are being 
bound to. 

>
>1. 
>2. automatically create undeclared variables as symbolic variables (as 
>in Maxima, Mathematica und so weiter...).
>
> I don't think that follows as a corollary from being "explicit" because 
the variables are mentioned explicitly on the LHS in our current syntax. 
However, if you'd run a full fragment through the python parser, you should 
be able to get a tree back from which you can read off what symbols need to 
take their binding from outside. That's how python decides which variables 
are local, global, or part of a closure. So we'd need a "postparser" for 
that. I would not support that.

I would say the ship has sailed on this one: this is how the preparser was 
designed to define symbolic functions with a concise short-hand syntax that 
would otherwise be a syntax error in python. Breaking that now will affect 
too much code that's already out there; in particular little examples 
people have prepared to use in teaching, where breakage is likely not 
detected (checking pre-prepared materials that worked before is just a 
chore) and is embarrassing in front of a large audience, doing great damage 
to the perception of sage being useful as a classroom tool. 

It's convenient for beginner use of sage, where the objective is to quickly 
do something calculus-like without having to dwell on the peculiarities of 
mathematics software: the WolframAlpha scenario. If you don't like the 
implications of the syntax, don't use it, but call something like

f = (sin(x)).function(x)

instead. That's straight-up valid python syntax with no hidden preparser 
complications. The preparser is not tuned towards serious programming.

-- 
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: Can Sage determine the Residue of a pole of symbolic order, i.e. exp(-z)/z^n?

2019-04-02 Thread Nils Bruin
On Tuesday, April 2, 2019 at 7:36:32 AM UTC-7, Christopher Duston wrote:
>
> I have been doing a demo of Maple, and have run into something it cannot 
> do that I need for my work. I thought I would toss it over here, and see if 
> Sage can do it.
>
> I want to determine the residue of integrals of the type exp(-z/A)/z^n, 
> where n is an integer and A is a constant. I was told by someone on the 
> help forums at Maple that "Maple cannot compute the residue at a pole with 
> symbolic order", referring to the unspecified integer n.
>
> I think based on the result:

sage: var("z,A,n")
sage: assume(n,"integer")
sage: fz=exp(-z/A)/z^n
sage: fz.series(z,3)
(1/(0^n)) + (-0^(n - 1)*n/0^(2*n) - 1/(0^n*A))*z + (-1/2*0^(n - 
2)*n^2/0^(2*n) + 1/2*0^(n - 2)*n/0^(2*n) + 0^(2*n - 2)*n^2/0^(3*n) + 0^(n - 
1)*n/(0^(2*n)*A) + 1/2/(0^n*A^2))*z^2 + Order(z^3)

the answer is no. You can ask for fz.residue(z==0), but that will base its 
result on the answer above and thus return 0. It would be better if we'd 
get an error instead.

Knowing where the n comes into the expression does allow us to get a 
non-symbolic expression that does the right thing:

sage: res=lambda n:exp(z/A).series(z,n).coefficient(z,n-1)

and basically shows you one place where this would need work: We'd need to 
somehow get the formal power series for exp(z):

sage: sum(z^n/factorial(n),n,0,oo,hold=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: reconnect to remote sagemath jupyter notebook?

2019-04-10 Thread Nils Bruin
On Wednesday, April 10, 2019 at 11:19:22 AM UTC-7, Daniel Friedan wrote:
>
> However, disconnecting my browser from a remote jupyter notebook aborts 
> the calculation.
>
> That shouldn't need to happen. Jupyter notebook has configuration options 
for killing "idle" notebooks (for various form of "idle", including "not 
having a connected browser"):

https://jupyter-notebook.readthedocs.io/en/stable/config.html?highlight=idle

In addition, JupyterHub probably has its own ways of culling inactive 
servers, for various forms of "inactive".

I suspect this is something you'll have to fix in the configuration of 
JupyterHub, or perhaps in your own jupyter notebook settings.

 

> Is there any way to get reconnectability in the sagemath jupyter notebook?
>
> Or should I stick with the deprecated sagemath notebook?
>
> thanks,
> Daniel
>
> Daniel Friedan
>
>
>
>

-- 
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: Sorting a list of variables

2019-04-21 Thread Nils Bruin
sorted(L, key=lambda v: (v[:1],int(v[1:])))

would do the trick. In general, you could look at something like 
https://pypi.org/project/natsort/. It might be able to make a more natural 
sortkey in more examples (in general, the idea would be to split your 
string in alphabetic and numerical substrings and make a tuple of strings 
and integers out of it and sort that).

-- 
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: reconnect to remote sagemath jupyter notebook?

2019-04-22 Thread Nils Bruin
On Monday, April 22, 2019 at 5:56:42 AM UTC-7, Daniel Friedan wrote:
>
> The kernel is still running.  The problem is not the culling of idle 
> notebooks.
>
> When I close the browser tab and then reopen the notebook, the kernel is 
> still running but output is lost and output from ongoing calculations does 
> not appear.  When the ongoing calculations are finished, I can interact 
> with the notebook again.
>
> Google tells me that this is a long-standing deficiency of Jupyter.
>

Ouch, I see. I didn't know that. I've tried and can confirm the behaviour. 

The (deprecated) SageMath notebook behaves properly on reconnecting, as if 
> there was no interruption.
>
> This behavior is indispensable to me, so I can't switch to the Jupyter 
> notebook until Jupyter behaves properly when reconnecting.
>
 
This deficiency in Jupyter is not going to make the resources available to 
maintain the sagenotebook, so I'm afraid the reality is going to be we're 
going to have to do without it. You could take a look if cocalc does a 
better job. It has its own notebook and I think they wrote/adapted their 
own ipynb frontend too.

Otherwise, a work-around would be to structure long-running computations a 
little differently to write state to a separate file rather than depending 
on logging into the notebook. The kernel doesn't seem to lose state; it's 
just output, so once the process has completed (which you could then see 
from the file), the notebook is ready for interaction again.

Another workaround is to not close the browser but instead use something 
like VNC or xpra to disconnect/reconnect (remotely) to your running browser.

It's pretty obvious that different behaviour of Jupyter would be the better 
solution, but if the deficiency has been around for a long time and you 
don't have definite plans to fix it yourself (I wouldn't know how to), the 
reality is that this will likely not change.

-- 
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: reconnect to remote sagemath jupyter notebook?

2019-04-22 Thread Nils Bruin
On Monday, April 22, 2019 at 11:13:23 AM UTC-7, Daniel Friedan wrote:
>
> One of the advantages of SageMath over Mathematica is SageMath's ability 
> to run a remote notebook without continuous network connection.  The 
> Mathematica remote kernel requires continuous connection.  It's sad that 
> SageMath is regressing to the level of Mathematica in this respect.
>

I guess providing a platform for people to vent frustration about the state 
of third party components used in sage out of necessity due to developer 
shortage is also a form of support so you're welcome :-).

For future reference:

This is an issue that tracks this problem in jupyterlab:

https://github.com/jupyterlab/jupyterlab/issues/2833

It refers to the following issue, which handles "real time collaboration" 
in jupyterlab, and as a consequence will deal with the 
output-loss-on-reconnection problem:

https://github.com/jupyterlab/jupyterlab/issues/5382

The latter is under active development (and there's a branch there that 
supposedly has most of what is required), so perhaps we'll get this in the 
not-too-distant future. Note this is for JupyterLab. I'm not so sure this 
will be backported to jupyter notebook. I already regularly use JupyterLab 
for sage, python, and magma, and it seems to be working fine.

For maintainability in the future, we might want to make is even easier 
still to provide sagemath as a kernel to globally installed jupyters, 
rather than just a prepackaged one.

-- 
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: reconnect to remote sagemath jupyter notebook?

2019-04-22 Thread Nils Bruin
On Monday, April 22, 2019 at 12:31:14 PM UTC-7, John H Palmieri wrote:
>
> If you're willing to use the Sage command-line interface rather than the 
> notebook, then you might try the "screen" program, which should already be 
> installed on linux or Mac OS X.
>

And for graphical interfaces, "xpra" works surprisingly well. Yes, it's 
just forwarding basically bitmaps of the graphical interface, but it can do 
it on a per-window basis and I've found it surprisingly responsive on 
reasonable-but-not-super-fast network connections. They advertise it as 
"screen for GUI" and it works surprisingly well!
It's a bit heavy-handed for the jupyter notebook problem but it does 
provide a work-around for many similar scenarios as well.

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


Re: [sage-support] Re: Computing a Groebner Basis (singular algorithm) raises an error

2019-05-27 Thread Nils Bruin
On Monday, May 27, 2019 at 11:40:00 AM UTC-7, Tracy Hall wrote:
>
> Thanks for the reply. That's disappointing—I'm not crazy about the idea of 
> spawning a hundred million Sage processes, most of them to do about 1/50th 
> of a second's worth of calculation, just because a few of them will need to 
> be timed out before they take hours or days or run out of memory.
>

That shouldn't be quite necessary. A normal way of setting up 
longer-running computations is to write "check points" at regular 
intervals. In your case, that could consist of writing the results of each 
individual case to a file (and be sure to flush buffers when you do, so 
that the file is actually updated -- open file, append line, close file is 
the simple way of ensuring that happens). When your long-running process 
crashes, you know which things were completed, so you can restart at the 
point where things were left off. An advantage of such a setup is that it 
also lends itself to parallelization.

If there is a chance that some jobs won't finish, you could run the process 
with a CPU time quota, so that it gets killed when it has used up a lot of 
time. The case it was working on at that time either got killed because it 
was unlucky to be scheduled when almost no quota was left or because it 
took a lot of time itself. That's easily figured out by rerunning this one 
job by itself.

You'd not be spawning a hundred million processes, just perhaps a few 
hundred over the course of the computation. Setting the quota gives you a 
trade-off between how many restarts and how much time you want to waste on 
impossible jobs.

It's only after an unexpected interruption that we can't fully trust the 
state of various libraries (and quite frankly, I wouldn't trust any 
computer algebra system under those conditions. It requires a lot of work 
and overhead to ensure that interruptions leave the system in an entirely 
consistent state (and even then -- which one?). I don't trust programmers 
of high-performance computational software to not cut corners on that 
somewhere (if they even try).

The reason why they probably don't try is because for long-running 
computations you need to checkpoint anyway, which means the cost of 
restarting isn't huge, so it's probably a price worth paying for the 
increased performance of not caring about interrupt clean-up too much.

It's worth learning the general tools that unix provides for setting quota 
and for scripting batch jobs in a restartable way, because they are 
applicable to all software. It's much more efficient than equipping each 
individual program with such tools and requiring people to learn the 
particulars of that one program.




-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/beb3a273-b85b-45d6-bc2a-7820fb7f93da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: compute regulator of quadratic field

2019-07-24 Thread Nils Bruin


On Wednesday, July 24, 2019 at 7:43:10 AM UTC-7, Michael Beeson wrote:
>
> 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)))
>

I think your problem is here: you need to take abs(u) before taking the 
log; otherwise you can get some funny complex number back. You also want to 
take the embedding into R that is larger than 1 in absolute value, but if 
you take the abs of the log afterwards it doesn't matter.
 

> 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/6caa4472-67ae-454e-8150-90c7148c61ad%40googlegroups.com.


[sage-support] Re: Sage equivalent for GP's "padicappr"?

2019-08-01 Thread Nils Bruin
Is this what you're looking for?

sage: Qp=pAdicField(7)
sage: g=Qp['x'](x^2-2)
sage: g.hensel_lift(4)

You can use pari rather directly; relying on sage converting its data types 
to appropriate pari types:

pari(g).padicappr(Qp(4))

-- 
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/208f7804-3ca8-4bbf-bfea-a2e6ba64b5de%40googlegroups.com.


Re: [sage-support] Re: Sage equivalent for GP's "padicappr"?

2019-08-02 Thread Nils Bruin
 
>
> Questions:
>
> Do Qp(7) and pAdicField(7) do the same thing?
>

Yes, I think so. They also accept arguments to set things like default 
precision for that ring. 

> K[x] and K['x'] seem to do the same thing as well. Is that right? 
>

Yes, they do. `x` is predefined as a symbolic variable. `K[x]` is tolerant 
enough to accept an object like a symbolic variable and treat it by its 
print name, which is 'x'. Indeed, `K['x']` creates a univariate polynomial 
ring over `K` with its generator named 'x'.

Perhaps neater and more efficient:

Kx=PolynomialRing(K,'x')
x=Kx.gen(0)

then x^2-2 will immediately be constructed to be a polynomial over K.

The lines above can also be abbreviated to

Kx=K['x']; x=Kx.gen(0)

or

Kx.=K['x']

or even

Kx.=K[]


-- 
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/9e1c87df-0d6a-4d7a-8d2c-fda74d3e37d5%40googlegroups.com.


[sage-support] Re: power series and strings for p-adics

2019-08-08 Thread Nils Bruin


On Thursday, August 8, 2019 at 7:16:21 AM UTC-7, Fernando Gouvea wrote:
>
> In certain contexts, I'd like to work in the power series mode up until 
> the end, but display my answer in digits mode. The only way I know how to 
> do this is to find the answer w and then use answer=Kd(w) to turn it into 
> digits. Is there an easier way? I expected something like print a.digits() 
> to work, but there's no such attribute.
>

The print-mode does not affect how the computations are done. So your work 
will be done the same way no matter what print-mode is selected

To access the p-adic digits, you can use "Qp(7)(1/42).list()"

You can give a mode to the "str" method that returns a string 
representation. e.g. Qp(7)(1/42).str(mode="bars") gives a presentation that 
makes the digits obvious. In principle Qp(7)(1/42).str(mode="digits") 
should work but it seems to miss some initialization. You could work around 
that by coercing into another p-adic ring with the desired print options 
set:

k1=Qp(7)
k2=Qp(7,print_mode="digits")
a=k1(2).sqrt()
print k2(a)

 

> Thanks,
>
> Fernando
>
> -- 
> =
> Fernando Q. Gouvea http://www.colby.edu/~fqgouvea
> Carter Professor of Mathematics
> Dept. of Mathematics and Statistics
> Colby College  
> 5836 Mayflower Hill
> Waterville, ME 04901   
>
> Deck us all with Boston Charlie,
> Walla Walla, Wash., an' Kalamazoo!
> Nora's freezin' on the trolley,
> Swaller dollar cauliflower, alleygaroo!
> Don't we know archaic barrel,
> Lullaby Lilla Boy, Louisville Lou.
> Trolley Molly don't love Harold,
> Boola boola Pensacoola hullabaloo!
>   --Walt Kelly
>
>
>

-- 
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/8fd20d0f-89c8-4f6b-a7c3-1ab4f4c6963c%40googlegroups.com.


[sage-support] Re: How change request for my Sage mirror domain?

2019-08-16 Thread Nils Bruin
On Friday, August 16, 2019 at 6:41:18 PM UTC-7, John McGahey wrote:
>
> Hi all,
> I want to change my mirror domain from sage.asis.io to sage.asis.sh. I 
> don't know here is the right place to ask this question or not. but please 
> help me.
> My request is changing IO --> SH.
> Very thanks
> _factoreal from ASIS
>

Dear John,

I'm not sure this is the right place, but there's a pretty good chance that 
the maintainer of the mirror list does read this forum. The domain you 
mention is referenced on
http://www.sagemath.org/mirrors.html under Asia: ASIS, Tehran, Iran (and 
it's indeed reported as defunct). See contact info on 
http://www.sagemath.org/contact.html for who to contact concerning mirrors.


-- 
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/ad64cb87-e93d-46da-a401-d5ee9688b204%40googlegroups.com.


Re: [sage-support] Re: Tracking memory usage and time

2019-09-03 Thread Nils Bruin


On Tuesday, September 3, 2019 at 2:43:27 AM UTC-7, Jori Mäntysalo (TAU) 
wrote:
>
> There is also at least %mprun magic. Googling that will give you some 
> examples. 
>
> Looking at the memory footprint of the entire process (as a function of 
time) gives some indication of memory use of a certain implementation of an 
algorithm, but there are many factors that influence it. CPython probably 
has a slight preference for reusing (freed/reclaimed) memory over 
requesting new memory from the OS, but there is not an actual guarantee. 
And CPython might be seriously lax in reclaiming memory, or it might be 
prevented by a memory leak in sage that is not due to the implementation of 
the algorithm. So you can take results like that only as an indication and 
not as authoritative. Determining memory usage of an algorithm in the 
mathematical sense probably needs code analysis.

(that said, memory claimed from the OS definitely gives an UPPER BOUND on 
the memory usage of a certain algorithm; for obvious reasons)

-- 
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/66674d87-2f64-4da1-89f9-009b2898d3a4%40googlegroups.com.


[sage-support] Re: Loading a sage worksheet inside a notebook

2019-10-11 Thread Nils Bruin
On Friday, October 11, 2019 at 5:23:15 AM UTC-7, cyrille piatecki wrote:
>
> Hello, 
>
> dispite all my effort under windows 10, I am not able to load any 
> notebook inside a current notebook with the command load(). I hav tried 
> "c://..." c:/..." "c:\\...". From this I cannot explain to sage that 
> Gurobi is on my computer. What can I do ? 
>
> For one thing, I don't think you can load *notebooks* with the "load" 
command.  

>From the help that you can get on "load" by typing in "load?":

   Load Sage object from the file with name filename, which will have
   an ".sobj" extension added if it doesn't have one.  Or, if the
   input is a filename ending in ".py", ".pyx", ".sage", ".spyx",
   ".f", ".f90" or ".m", load that file into the current running
   session.

Notebooks usually use the ".ipynb" extension, which is not mentioned. The 
"ipynb" are handled by jupyter, not by sage, so that's why the sage command 
"load" doesn't have a clue about what to do with "ipynb" files.

If paths are actually the problem, I'd probably try if *writing* a file 
does work. For instance, do something like

save("we write this string to a file", "string_object.sobj")

and if that succeeds, see where the file "string_object.sobj" was written. 
One would expect that

load("string_object.sobj")

should then work too.

-- 
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/ce780bfe-51bb-447d-884a-13eb903bf0da%40googlegroups.com.


[sage-support] Re: Sage cell server file input

2019-10-22 Thread Nils Bruin
On Tuesday, October 22, 2019 at 8:52:44 AM UTC-7, david.guichard wrote:
>
> I have a cocalc sage worksheet that reads data from a csv file. Is there 
> any way to do this in the single cell server, that is, read data from an 
> external file? I'm guessing not, but it would be handy.
>

Accessing a file from a single cell server should be possible via the 
normal means. Putting the file in a location where the single cell server 
has access to it is probably a problem. If you put the data at a publicly 
accessible http(s) location, you should be able to refer to the resource by 
its URL and fetch your data that way. Obviously, you should run pretty 
quickly into resource limitations put on sagecell processes. If you don't 
then you'll probably find that that particular sagecell server will be very 
unreliable, because it will be put out of commission by people running very 
resource-hungry processes on 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/62418fab-5bae-4819-a688-a0ec389b6d81%40googlegroups.com.


[sage-support] Re: Sage cell server file input

2019-10-24 Thread Nils Bruin
On Tuesday, October 22, 2019 at 1:36:24 PM UTC-7, david.guichard wrote:
>
> Thanks for the suggestion, but it doesn't appear to work for me. My code is
>
> csv.reader(open('http://myserver/xxx.csv'))
>
>
I don't think python's standard "open" supports opening URLs. You need 
something like urllib.request for it (or indeed, a tool (for instance some 
Pandas routine) that wraps that functionality for 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/5131daa6-ffd8-4046-8c64-50bc4a3d5c9a%40googlegroups.com.


[sage-support] Re: Possible bug in integrate ?

2019-10-25 Thread Nils Bruin
Yes, that's a bug. It happens in F(x).operator()._tderivative_ It 
differentiates the bounds in case those vary with the differentiation 
variable, and that does not work for "0". If you define

var('y')
F(x)=integrate(f(t),y,x)

you get the right result (with y not being a function of t).

The bounds should be checked for being constants before being 
differentiated.

-- 
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/2c81211f-c71e-4b00-be05-97c6edb790e1%40googlegroups.com.


[sage-support] Re: Possible bug in integrate ?

2019-10-25 Thread Nils Bruin
On Friday, October 25, 2019 at 3:27:42 AM UTC-7, Emmanuel Charpentier wrote:
>
> Thanks a lot ! That's perfectly clear...
>
> Any hints on how to file a ticket for this issue ?
>
> The minimal example excellently shows the problem, so including that would 
be great. It's easy to find the problematic code from it. Referencing this 
google groups thread and the ask.sagemath question is probably good too. 
And put forward references to the ticket at those places too, just to fully 
document.

Component can be symbolics, I think. Priority "major" seems fine too.

(the ticket filing itself would happen at trac.sagemath.org, but I think 
you know that)

-- 
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/699b670c-334e-4132-a447-db9a5cd34439%40googlegroups.com.


Re: [sage-support] Re: sage building with python3

2019-11-04 Thread Nils Bruin
On Monday, November 4, 2019 at 10:27:02 AM UTC-8, Dima Pasechnik wrote:
>
> Incidentally this brings up the question on how one should deal with 
> outdated (as they had to by Python2-compatible) 
> Sage's iPython and Jupyter. 
>
>  What has worked for me for a long time is to install the sage ipython 
kernel for the system-wide jupyter install (or rather, just installing it 
on a personal level). That has worked quite well with just the Py3-based 
jupyter that fedora ships. The sage kernel would just run on its own 
python2, and jupyter uses its normal pipe-based communication with the 
kernel. It seems that the jupyter notebook kernel protocol is sufficiently 
backward compatible that it was happy to run between a modern py3-jupyter 
server and sage's (outdated?) jupyter kernel. Importing the extensions that 
sage uses into the py3-jupyter server doesn't even seem to be a problem.

Perhaps that's a useful/encouraging data point??

-- 
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/1708a5b7-93d7-4937-8dcd-6762aaf89f54%40googlegroups.com.


Re: [sage-support] Re: sage building with python3

2019-11-04 Thread Nils Bruin
On Monday, November 4, 2019 at 2:53:18 PM UTC-8, Dima Pasechnik wrote:
>
> Is Sage Jupyter kernel pipe-based?
> (Jupyter uses zeromq, which can do inproc communication, and as far as I 
> know some kernels do this)
>
> Oh sorry. Perhaps. I didn't investigate. I'd expect that the jupyter 
ipython kernel uses the most advanced communication protocol. In any case, 
it's a form of IPC, so the server and the kernel can easily be different 
version -- no binary compatibility required.

-- 
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/4a3380c1-c0d8-4c69-b378-d7774104a778%40googlegroups.com.


[sage-support] Re: Symbolic inverse in finite field

2019-11-07 Thread Nils Bruin
On Thursday, November 7, 2019 at 7:50:00 AM UTC-8, Subrata Nandi wrote:
>
>
>
> On Thursday, November 7, 2019 at 9:13:17 PM UTC+5:30, Subrata Nandi wrote:
>>
>> Thanks Emmanuel Charpentier for your reply. But the entry of my matrix 
>> is only symbolic variables. For example I am giving one short matrix.
>>
>R.=Boolean 
> PolynomialRing()  
>
>> y=[
>>
>> [x0   x1   x2   x3   x4   x5 
>>   x6   x7   x8   x9]
>> [x1   x2   x3   x4   x5   x6 
>>   x7   x8   x9  x0 + x3]
>> [x2   x3   x4   x5   x6   x7 
>>   x8   x9  x0 + x3  x1 + x4]  
>> [x3   x4   x5   x6   x7   x8 
>>   x9  x0 + x3  x1 + x4  x2 + x5]
>> [x4   x5   x6   x7   x8   x9 
>>  x0 + x3  x1 + x4  x2 + x5  x3 + x6]
>> [x5   x6   x7   x8   x9  x0 + x3 
>>  x1 + x4  x2 + x5  x3 + x6  x4 + x7]
>> [x6   x7   x8   x9  x0 + x3  x1 + x4 
>>  x2 + x5  x3 + x6  x4 + x7  x5 + x8]
>> [x7   x8   x9  x0 + x3  x1 + x4  x2 + x5 
>>  x3 + x6  x4 + x7  x5 + x8  x6 + x9]
>> [x8   x9  x0 + x3  x1 + x4  x2 + x5  x3 + x6 
>>  x4 + x7  x5 + x8  x6 + x9 x0 + x3 + x7]
>> [x9  x0 + x3  x1 + x4  x2 + x5  x3 + x6  x4 + x7 
>>  x5 + x8  x6 + x9 x0 + x3 + x7 x1 + x4 + x8]
>>
>> ]
>>
> This is a 10 x 10 matrix where each xi in GF(2). I need to find 
> (0,0,0,0,0,0,0,0,0,1)*y^(-1). This is a small example of what I need. In 
> actual case, n=512. Can you help me to find the inverse. Thanks in advance 
> man.
>

Note that in boolean polynomial rings, all elements except 0,1 are 
zero-divisors, so I think matrices with a determinant different from 1 are 
not going to be invertible.
Another problem: a 512x512 matrix might still be workable, but if you also 
have 512 variables, then entries could easily be sums of something like 
2^512 terms; so that's probably not going to fit in memory. 

 

>
>> On Monday, November 4, 2019 at 12:20:50 AM UTC+5:30, Emmanuel Charpentier 
>> wrote:
>>>
>>> One can check that Sage's built-in methods can invert such a GF(2) 
>>> maytrix in reasonable time:
>>>
>>> sage: MS=MatrixSpace(GF(2),512,512)
>>> sage: while True:
>>> : M=MS.an_element()
>>> : if M.is_unit(): break
>>> : 
>>> sage: %time IM=M^-1
>>> CPU times: user 2.99 ms, sys: 243 µs, total: 3.23 ms
>>> Wall time: 113 ms
>>> sage: bool(IM*M==diagonal_matrix(GF(2),[GF(2)(1)]*512))
>>> True
>>>
>>> But, being totally ignorant of your domain, I have trouble seeing how to 
>>> use this result for boolean logic. A glimpse at the relevant 
>>> documentation 
>>>  hints that 
>>> I should refrain from commenting further...
>>>
>>> HTH, nevertheless,
>>>
>>>
>>> Le jeudi 31 octobre 2019 10:51:27 UTC+1, Subrata Nandi a écrit :

 My research area is symmetric key cryptology. I need an efficient 
 algorithm for solving inverse of symbolic matrix of size 512 x 512 in 
 GF(2). Can anyone share 
 Idea regarding that? 
>>>
>>>

-- 
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/4fc70729-f5b6-422b-a46e-e7d6b90747e8%40googlegroups.com.


[sage-support] Re: Deprecation warning for a Sage interact

2019-12-21 Thread Nils Bruin
The problem is fairly subtle, but it boils down to the fact that input_box 
wants a *string* as default value , because a string is also what it gets 
from the user. Note that your names x and y are bound to x(t) and y(t) 
respectively. Input box turns its default parameter to a string, so the 
expression 3*x-2*y turns into the string "3*x(t)-2*y(t)".

Later when this is evaluated, it is evaluated in the context of the global 
bindings that are currently in force in your sage session, so with x,y 
being bound to x(t) and y(t) this turns into evaluating

3*x(t)(t)-2*y(t)(t)

for which the deprecation warning is entirely correct.

The solution is to quote your arguments to input_box as strings, i.e.,

... input_box(default = "3*x - 2*y") ...

-- 
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/7af11856-1e50-43d4-9718-82ac49fdbb70%40googlegroups.com.


Re: [sage-support] sage with python3, mpmath

2020-01-14 Thread Nils Bruin
On Tuesday, January 14, 2020 at 5:36:27 AM UTC-8, Александр Ватузов wrote:
>
> Now I constantly know, that problem was in using
>
> divmod(n, base**half)
>
> instead of
>
> n // (base**half), n % (base**half)
>

The second option yields a performance regression relative to the first, 
because you would end up doing an integer division twice rather than one 
(integer division yields both the quotient and the remainder, so throwing 
one away and then recomputing it to find it anyway is wasteful). You're 
also performing an exponentiation twice.

I think it would be better to find/write a "divmod" that works in py3 as 
well.

-- 
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/78a83c70-0f12-4df0-a2e4-d4a499b388bf%40googlegroups.com.


[sage-support] Re: sage 9.0: mismatch in sr-to-maxima translation

2020-01-18 Thread Nils Bruin
On Saturday, January 18, 2020 at 7:19:03 AM UTC-8, mendes wrote:
>
>
> RuntimeError: Encountered operator mismatch in sr-to-maxima translation
>
>
The error indicates that the sage-to-maxima dictionary used in sr_to_max is 
in an inconsistent state. Its state is a mix of preinitialization and 
caching translations as it goes along, so inconsistent state indicates 
there's a fragile initialization somewhere. the py2/py3 switch has all 
kinds of small effects, so it could change the enumeration order of a set 
somewhere, so that the initialization happened to go right in py2 but now 
ends up going wrong in py3.

Concerning your hint of a bug:

integrate(unit_step(x),x,-1,1)

works just fine for me (it leaves the integral unevaluated). Without a 
piece of code that reliably reproduces the error you encounter it's 
virtually impossible to find what's 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/902de18c-fcc1-4347-b1e0-41fdc6325633%40googlegroups.com.


[sage-support] Re: sage 9.0: mismatch in sr-to-maxima translation

2020-01-19 Thread Nils Bruin
You should file a ticket. Symbols are getting mixed up. Recently there were 
some changes to the order in which different integration algorithms are 
used, and I suspect that this happens as a side effect.

I can tell you what I see happen:

This is what the actual "unit_step" function should be.

sage: type(unit_step) 
 

When you run into the error:

RuntimeError: Encountered operator mismatch in sr-to-maxima translation

we have a function "op" with the following properties:

ipdb> p op 
unit_step 
ipdb> p type(op) 
 

so that's a function with the same print-name as "unit_step", but it's a 
different function. The sage-to-maxima (and vice versa) dictionaries know 
how to translate the original `unit_step`, but at this point it is noticed 
that this "new" function `unit_step` would cause a name clash at the maxima 
side. Hence the error. It seems to me the maxima interface is operating as 
it should. The error is probably that the expression was manipulated (by 
integrate) before that point by some interface; problably the sympy one; 
which confused the system.

Smoking gun:

sage: type(unit_step(x).operator()) 
 
sage: type(unit_step(x)._sympy_()._sage_().operator()) 
 

Even if this is not the source of the bug you're experiencing this is 
something that needs to be fixed: sympy needs to be taught about unit_step.



On Sunday, January 19, 2020 at 6:46:50 AM UTC-8, mendes wrote:

> Thank you Bruin and Kcrisman, for your attention.
>
> The following  codes are examples of the problem:
>
> # fg denotes  the convolution product f*g. The expected result is f*g = 0, 
> if t < 1 and f*g = t^2/2-t+1/2, if t > 1.
> # For 0 < t < 1, it runs ok:
> var('x,t')
> assume(0 f=unit_step(t-1)
> g=t
> fg = integrate(f(t=x)*g(t=t-x),x,0,t).simplify_full().expand()
> show(fg)
> forget()  
>
> #But, for t>1, there is a RuntimeError: mismatch in sr-to-maxima
> var('x,t')
> assume(1 f=unit_step(t-1)
> g=t
> fg = integrate(f(t=x)*g(t=t-x),x,0,t).simplify_full().expand()
> show(fg)
> forget()
>
> #In previous versions of Sage the answer, in the case piecewise functions 
> like  f*g,   could employ the functions like sign()  or abs(),  but  no 
> Error messages appeared 
>
> #The following alternative raises no Error, but does not evaluate the f*g 
> function to  t^2/2-t+1/2, as desired:
> var('x,t')
> assume(1 f=unit_step(t-1)
> g=t
> fg = integrate(f(t=x)*g(t=t-x),x,0,t,hold=False)
> show(fg)
> forget()
>
> Thank you again.
>
>
>
>>>

-- 
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/410953b7-2edc-4590-8726-c6f022a4a78e%40googlegroups.com.


[sage-support] Re: sage 9.0: mismatch in sr-to-maxima translation

2020-01-20 Thread Nils Bruin
On Sunday, January 19, 2020 at 6:46:50 AM UTC-8, mendes wrote:
>
> #But, for t>1, there is a RuntimeError: mismatch in sr-to-maxima
> var('x,t')
> assume(1 f=unit_step(t-1)
> g=t
> fg = integrate(f(t=x)*g(t=t-x),x,0,t).simplify_full().expand()
> show(fg)
> forget()
>
> In the meantime, you can, as a workaround, use f=heaviside(t-1). That does 
not give an error. Unfortunately, it gives a nonsensical result: it returns 
"sage4", which is undoubtedly a symbol that somewhere was supposed to be 
bound to the actual result, but which didn't get bound. Looks like it needs 
another ticket :-):

sage: var("b") 
sage: assume(b>0) 
sage: integrate(heaviside(x),x,0,b)
sage4

 

> #In previous versions of Sage the answer, in the case piecewise functions 
> like  f*g,   could employ the functions like sign()  or abs(),  but  no 
> Error messages appeared 
>
> #The following alternative raises no Error, but does not evaluate the f*g 
> function to  t^2/2-t+1/2, as desired:
> var('x,t')
> assume(1 f=unit_step(t-1)
> g=t
> fg = integrate(f(t=x)*g(t=t-x),x,0,t,hold=False)
> show(fg)
> forget()
>
> Thank you again.
>
>
>
>>>

-- 
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/a0c2304e-7e7b-47c7-bd95-4d503767c736%40googlegroups.com.


[sage-support] Re: Endomorphism Rings of Elliptic Curves

2020-01-21 Thread Nils Bruin


On Tuesday, January 21, 2020 at 5:23:43 PM UTC-8, Eric Zhu wrote:
>
> Is there a way to get the endomorphism ring of an elliptic curve in Sage? 
>

with

d=E.cm_discriminant() 

you know that End(E) is the cm order of discriminant d. If E does not have 
cm, then End(E)=Z

-- 
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/c9656d31-3e4b-4f9f-a783-5d0d25f92717%40googlegroups.com.


[sage-support] Re: defining symbolic function

2020-02-22 Thread Nils Bruin
http://doc.sagemath.org/html/en/reference/calculus/sage/calculus/var.html#sage.calculus.var.function

-- 
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/6a21883f-c12d-49b1-9d56-5aaf697d32db%40googlegroups.com.


[sage-support] Re: defining (partial) inverse image of a ring homomorphism

2020-03-10 Thread Nils Bruin
On Tuesday, March 10, 2020 at 6:22:45 AM UTC-7, Dima Pasechnik wrote:
>
> Suppose I have 
>
> R.=QQ[] 
> K.=QQ[] 
> f=R.hom([u*v,u^2,v^2-u^2]) 
>
> then for any even degree p in K one can compute 
> a preimage under f (e.g. u^4-u*v goes to y^2+x, etc) 
>

I think the general way (which should be pretty performant for such a nice 
example) is to do it via reduction wrt. the graph ideal:

sage: R.=PolynomialRing(QQ,order="degrevlex(2),degrevlex(3)") 
sage: I=R.ideal([x-u^2,y-u*v,z-v^2]) 
sage: inv=lambda f:QQ['x,y,z']((I.reduce(f))) 
sage: inv(u^2) 
x 

Obviously, the term order chosen will dictate what representative you get 
back, if the map isn't injective. You should of course choose an 
elimination order.

-- 
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/3e738cad-5167-4add-a28a-a1c0d52ba008%40googlegroups.com.


[sage-support] Re: Sage functions arenot accepted by scipy fsolve

2020-04-10 Thread Nils Bruin
On Friday, April 10, 2020 at 1:02:12 AM UTC-7, Ne reknu wrote:
>
> Hello. 
> I need a root finder of a real function which work with a initial guess. 
> That can be done by scipy fsolve, but if I try to aply it on a gamma (or 
> Bessel) function in Sage, I recieve following error message:
>
> NotImplementedError: The Function gamma does not support numpy arrays as 
> arguments
>>
>>
> I have encoutered this before - then the solution was replacing  x[i]  by  
> x.item(i). I am however not skilled enough to do this chenge inside scipy 
> library. Any sugestions?
>
> Change the function you pass on instead, so that it does follow numpy's 
broadcasting rules: opt.fsolve(numpy.vectorize(Rce),ktip) probably does 
work.
While numpy's broadcasting rules are useful for numpy, they would probably 
not play nice with the other uses of functions in sage, so I don't think 
it's something we can accommodate by default. Users will have to rely on 
numpy's convenient wrapper.

-- 
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/4315ea09-c381-4cf3-a3a1-d85655af0cb7%40googlegroups.com.


[sage-support] Re: Sage functions arenot accepted by scipy fsolve

2020-04-10 Thread Nils Bruin
On Friday, April 10, 2020 at 1:05:15 PM UTC-7, Ne reknu wrote:
>
> Thank you for your answer. Unfortunatelly the  numpy.vectorize(Rce) 
> generates the very same error (I tried to plot it). Or pehaps I 
> misunderstood your intention?
>

No, my guess would have been that would work, but then apparently it 
doesn't. It does give you a route to arrive at a solution, though. The 
problem here isn't sage-specific: it's just that normally, python functions 
don't broadcast over numpy arrays. There should be plenty of examples 
around the web that show how to get broadcast behaviour in place. It looked 
to me like numpy.vectorize would do the trick, but there should be other 
solutions, or perhaps you should use the vectorized function differently.

By realizing that the question is not sage-specific, I think it will be 
easy to find a ready-made solution elsewhere or find another forum with 
more specific expertise. Or perhaps someone else here knows more about 
numpy.

-- 
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/4a9f1594-c2ef-4058-99fa-0d4b58075f87%40googlegroups.com.


[sage-support] Re: Change default power operator output to '**' rather than '^' .

2020-05-01 Thread Nils Bruin
On Friday, May 1, 2020 at 12:30:10 PM UTC-7, John Atom wrote:
>
> If I define a function: 
>
> f(x) = x**2
>
> and then print it, sage always prints it as `x^2`. 
>
> Is it possible to change the default output of the power operator to '**' 
> ? 
>

I suspect it will be hard, because these "^" are coming from lots of 
places, including third party libraries that know how to produce a string 
representation of their internal representation. I think:

str(f).replace('^','**')

is going to be the most reliable way of accomplishing this.
 

-- 
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/6a107b78-3f7f-4646-9867-d00c80441362%40googlegroups.com.


Re: [sage-support] space sign in 'show'

2020-06-18 Thread Nils Bruin
On Thursday, June 18, 2020 at 12:18:40 AM UTC-7, Dima Pasechnik wrote:
>
>
> Python's print() function allows you to do formatting, whereas show() is 
> just a quick hack.
>
> little correction here: python's strings allow you to do formatting, 
meaning that whatever formatting you want to do, you can do on the string 
and then feed it to show or print as you like.

show('gx = {}'.format(gx(x,y)))

to get this to work with latex typesetting would require some other tricks 
(but in that case, you shouldn't be worrying about placing spaces in 
yourself but rather about how to get input to the latex typesetter so that 
it puts the spaces in the right spots).

-- 
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/8bc46019-a779-47fd-8a0c-d05dab4b010fo%40googlegroups.com.


[sage-support] Re: Jupyter kernels for R, gp, gap, etc

2020-08-03 Thread Nils Bruin
On Monday, August 3, 2020 at 9:26:38 PM UTC-7, Tim McLarnan wrote:
>
> I tried copying the kernel folders from CoCalc and editing them in what I 
> thought was the right way and putting them with the kernel folders on my 
> machine.  This produced kernels that show up in Jupyter, but that don't 
> work.  No doubt someone who knows the right things to put in the .json 
> files could make this work, but I can't.  This has to be an absurdly 
> complicated approach, though.  Surely there's just some trivial thing I 
> don't know about.
>

That got you the configuration of the kernels, but likely not the actual 
code that implements them. Jupyter kernels are basically stand-alone 
programs. Often, they are written in python (but they don't have to be!) 
and installing them consists of two steps: installing the software and 
informing the jupyter notebook installation of their presence.

For kernels written in python, you end up needing to install python 
software, for which there are excellent tools.

A very simple example, that I happen to have written myself, so that's why 
I'm familiar with it, but needs "magma" present on your machine to work.

https://github.com/nbruin/magma_kernel

The instructions indeed show two installation steps: one for installing the 
python package and the other for setting up the jupyter notebook 
registration.

To make extra kernels known to the *sage* jupyter notebook server, you have 
to make sure that you run the configurations in the sage copy of python. 
You'd want to do something like "sage -sh" (on linux or OSX) to get a shell 
that is set up with the sage environment, and run the configurations in 
there.

An alternative is to register the sage kernel with the system-wide jupyter 
notebook. This has the advantage that other kernels that come prepackaged 
with your OS distribution are easier to install (just use your OS tools). 
It has the big disadvantage that currently, rhis is still not a 
straightforward process; it requires some hackery, so I would not recomment 
it as your first experiment.

A big disadvantage of the python ecosystem is that one often end up with 
multiple copies of python living side-by-side on your OS and it's often 
hard to tell which version gets run for what.

-- 
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/6e56fd3d-e424-4573-b3b2-b4aab46b88c0o%40googlegroups.com.


[sage-support] Re: Reduction over Ideal

2020-08-05 Thread Nils Bruin
On Wednesday, August 5, 2020 at 4:28:42 AM UTC-7, Santanu wrote:
>
> Dear all,
> Consider ideal I= over the binary field GF(2). 
> Then (x2).reduce(I) gives x2. I want it to be x0*x1. 
> In fact , I want this kind of reduction always should give quadratic 
> polynomial 
> (I know that this is possible for my problems).
>
> That means you should try and put a monomial order on your ring that gives 
x2 a higher weight than x0*x1. "lex" would do that. It may be that you need 
to order your variables as [x2,x0,x1] instead (i.e., that the first 
variable has the highest weight)

I don't know what you mean by "should always give a quadratic polynomial". 
With your ideal, x2^3 is not reducible to a quadratic polynomial. Do you 
want to work with a Boolean ring instead, where the relations 
x0^2-x0=1^2-x1=x2^2-x2=0 are implied as well?
 

-- 
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/42a8a173-432d-40e1-85bb-7e59f3a32f6ao%40googlegroups.com.


[sage-support] Re: Reduction over Ideal

2020-08-05 Thread Nils Bruin
On Wednesday, August 5, 2020 at 10:19:57 AM UTC-7, john_perry_usm wrote:
>
>
> It's possible that you want a local term ordering. Unlike global term 
> orderings, in a local ordering 1>t for any monomial t.
>
> TO = TermOrder("negdegrevlex",3)
> R = PolynomialRing(GF(2),'x',3,order=TO)
> R.inject_variables()
>  Defining x0, x1, x2
> I = R.ideal([x0*x1+x2])
> x2.reduce(I)
>  x0*x1
>
>
In which case you need to realize that you're not working in a polynomial 
ring but in its localization! This has been the source of many bug reports 
already, and is currently not sufficiently documented.

-- 
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/20761051-9668-462a-aaea-191f10a9def2o%40googlegroups.com.


Re: [sage-support] Subgroups of subgroups aren't subgroups?

2020-08-16 Thread Nils Bruin
On Sunday, August 16, 2020 at 4:22:22 AM UTC-7, Dima Pasechnik wrote:
>
>
> I guess this has to do with Python hashing; objects are not checked 
> for `==` equality when you do {}, 
> but for equality w.r.t. to certain internal representation: 
> sage: g = libgap.SymmetricGroup(3) 
> sage: x = g.Subgroup(libgap.eval('[(1, 2), (2, 3)]')) 
> sage: y = g.Subgroup(libgap.eval('[(1, 3), (2, 3)]')) 
> sage: z = g.Subgroup(libgap.eval('[(1, 3), (2, 3)]')) 
> sage: len(libgap.Set([x,y,z])) # so this is sane on GAP/libgap level 
> sage: len({x,y,z})   # but! 
> 2 
> sage: x==y, y==z, x==z # while this makes sense 
> (True, True, True) 
>
>
No, it means that libgap breaks the __hash__/__eq__ contract in python. 
Python sets do not compare wrt. internal representation. They just assume 
that objects that test equal have equal hashes. When you can't compute a 
hash that respects equality, then you shouldn't make your object hashable. 
Given the variety of objects that libgap implements, I think libgap should 
not support hashing. It may be possible to skirt the rules a bit and make 
some nicer objects hashable, but if we're just going to allow hashing of 
everything, I think errors like this are unavoidable. Alternatively, we can 
implement a constant hash function for them. That would revert everything 
to equality testing, and would completely break performance in python.

-- 
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/3e1cf0fd-af6e-4b92-969a-628c55cb1d7ao%40googlegroups.com.


[sage-support] Re: Loading an object containing a matrix that was saved in Python 2 sage

2020-08-19 Thread Nils Bruin
On Wednesday, August 19, 2020 at 5:24:48 AM UTC-7, Paul Leopardi wrote:
>
> See also 
> https://groups.google.com/g/sage-support/c/3WKui-LojKs/m/DgEPBGF3AQAJ and 
> https://trac.sagemath.org/ticket/28444
>
> On Wednesday, 19 August 2020 at 22:17:40 UTC+10 Paul Leopardi wrote:
>
>> Hello,
>> I am currently trying to convert my Boolean-Cayley-graphs project from 
>> Python 2 to Python 3 Sage. 
>> https://github.com/penguian/Boolean-Cayley-graphs/tree/23-port-to-python-3
>>
>> I have succeeded in converting the code, but am having a tough time 
>> trying to load objects that were saved by my previous Python 2-based code. 
>> These objects contain matrices as members.What do I need to do to be able 
>> to load these objects?
>>
>> As far as I can tell, load(...,encoding='latin-1') doesn't work with a 
>> dict containing a matrix but load(...,encoding='bytes') does. See the 
>> attachment.
>> Thanks!
>>
>
Yes, we know how to fix it and it's not complicated: if "bytes" is expected 
in a pickle and a "str" is found, we should assume it represents the 
bytes-object via latin-1. It's come up in matrices elsewhere and we should 
just make this change. We've already determined that "encoding='bytes'" is 
a lot harder to get to work.

Please open a ticket. Fixing this should save a LOT of pickles.

-- 
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/017828a5-9275-463f-aa14-852ec95b3a9do%40googlegroups.com.


[sage-support] Re: You've been approved for GitHub Sponsors

2020-08-28 Thread Nils Bruin
Thank you for setting this up!  It looks like a very generous move from 
GIthub to run the donation collection infrastructure and still give 100% to 
the sponsored party. I think people might be more inclined to donate if it 
were clearer where the money went. Is it the intention that this money goes 
to the Sage Foundation (at least that's a registered charity somewhere, so 
it has some fiscal oversight)?

On Friday, August 28, 2020 at 8:41:16 AM UTC-7, Dima Pasechnik wrote:
>
> Please share widely - one can now sponsor SageMath via GitHub "Sponsor" 
> button on https://github.com/sagemath
> (see also https://github.com/sponsors/sagemath for details - and let me 
> know whether it should be improved/changed)
>
> -- Forwarded message -
> From: GitHub >
> Date: Fri, Aug 28, 2020 at 3:54 PM
> Subject: You've been approved for GitHub Sponsors
> To: 
>
>
>   
> [image: GitHub] You've been approved for GitHub Sponsors 
>   
>   Your GitHub Sponsors profile is live 
>   
>
> 🎉 Now that your profile is complete, it’s time to start sharing! Here are 
> some next steps for your sponsorship page: 
>   Share your sponsorship page 
>
> It’s important to let your community know that they can sponsor you 
> through GitHub Sponsors. We’ve provided a few examples of how to share your 
> sponsorship page—check it out! 
>   
> Learn more ways to share 
>  
>   
> [image: welcometocat] 
>   
>   
>
>   
>
> GitHub, Inc. ・88 Colin P Kelly Jr Street ・San Francisco, CA 94107
> 
>

-- 
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/59dd80b8-4be0-40cf-8b4e-87404f1b6aaao%40googlegroups.com.


Re: [sage-support] Re: You've been approved for GitHub Sponsors

2020-08-28 Thread Nils Bruin
On Friday, August 28, 2020 at 10:36:20 AM UTC-7, Dima Pasechnik wrote:
>
> technically, money goes to a registered charity Open Collective, which 
> takes a 10% cut for admin etc costs (and Stripe takes a cut, too) and gives 
> the rest to us. At least the setup is very easy - noone had time so far to 
> get Sage into NumFocus sponsoring programme, something that takes much  
> more admin. 
>

OK, great. I think it would help if you link to a place where this is 
disclosed and where you specify the "us", and what "us" pledges to use the 
money towards, and if there are further overheads creamed off. 


-- 
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/0c1e8039-4623-4cfb-9a37-52b05aed1f97o%40googlegroups.com.


[sage-support] Re: Sage cells

2020-09-10 Thread Nils Bruin
On Thursday, September 10, 2020 at 6:50:11 AM UTC-7, cyrille piatecki wrote:
>
>
> I would like to know is there is a way to centerr results in SageCells.
>

I'd expect that with a cunning use of CSS style sheets, you can pretty much 
change any aspect of the formatting. It would require that you embed 
sagecell instances in your own webpage, but that is an easy and 
well-documented procedure.

Also when we have acces several times in an html page to sagecells is 
> there a way to ask toi remember the results of a previous acces ? 
>

That's rather fundamentally not possible. Once you start managing state, 
you basically have a notebook. I don't think you'll find anyone willing or 
capable of running a notebook without any kind of access restriction or 
authentication. 

-- 
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/023ebef2-f808-4e1b-9b83-2900a74df721o%40googlegroups.com.


[sage-support] Re: factorial

2020-11-29 Thread Nils Bruin
With the current regexp-based rewriting we'd need a pattern of the kind 
'!' -> 'factorial( '**" but that's very 
basic and doesn't need any context. To change an implicit unary postfix 
operator to an explicitly parenthesized prefix operator need almost 
complete parsing. Had the factorial been explicitly parenthesized as well, 
it would be a little easier, since now you could do it with parenthesis 
counting -- still not regex territory, but possibly reasonably efficiently 
done if one concentrates on the case where the expected string before the ! 
is short.

Insisting on parens does not satisfy the people who'd request this, I 
imagine. Writing (5)! instead of 5! doesn't really do the trick.

I consider this weird postfix notation as a peculiarity that works somewhat 
OK in written math but, just as implicit multiplication, as bad in CAS use. 
So I'm not in favour of it. I estimate that the number of arguments against 
it is at least 3!

On Sunday, November 29, 2020 at 5:32:30 AM UTC-8 Simon King wrote:

> On 2020-11-29, Simon King  wrote:
> > Hi Emmanuel,
> >
> > On 2020-10-28, Emmanuel Charpentier  wrote:
> >> Nope. This syntactic sugar is provided by `Maxima`'s and 
> `Mathematica`'s 
> >> readers, but not by Sage preparser.
> >
> > Would it be nice (and easy) to have in Sage? What prevents the preparser
> > from understanding "!"?
>
> To be more precise: If I understand correctly, the preparser can be made
> to accept any syntax, provided that this syntax is in no conflict with
> valid Python syntax.
>
> There is a special meaning of "?" and "??" in Python, but I think there
> isn't a special meaning to "!". Sage accepts "!" at the beginning of a
> line, meaning that it executes a shell command, such as
> sage: !ls
> But it should be possible that the preparser could turn "(expression)!" 
> into
> "gamma(expression+1)".
>
> Do people agree? Unfortunately I do not volonteer to implement it, I'
> not familiar with the innards of the preparser.
>
> Best regards,
> Simon
>
>

-- 
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/0f70ad8a-bf21-4352-a863-0b8d596e509cn%40googlegroups.com.


Re: [sage-support] Re: factorial

2020-11-30 Thread Nils Bruin

On Sunday, November 29, 2020 at 1:23:36 PM UTC-8 list...@gmail.com wrote:

>
> I agree with you, but at the same time I wonder what would be wrong with 
> replacing
> '!' → '.factorial()'
>
> Good observation: python already has postfix operators! I still don't like 
factorial notation; not even in math writing because it clashes with the 
custom of punctuation on math expressions that are part of a sentence, but 
technically that should cover most (all?) cases. 

-- 
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/b0bdd33b-65c4-43c2-89fd-bdfc302e4b51n%40googlegroups.com.


[sage-support] Re: Trouble getting *collect* to work with derivatives.

2021-01-24 Thread Nils Bruin
I suspect you want to collect wrt. the second partial derivatives of 
f(x,y,z,t) with respect to x,y,z,t ; evaluated at xp,yp,zp,tp. Those are 
not the same as the partial second derivatives of f(xp,yp,zp,tp) with 
respect to (x,y,z,t). If you inspect what derivative(f(xp, yp, zp, tp), x, 
2) gives you, you'll see it's a complicated expression. "collecting" 
relative to it doesn't make sense from first principles and if you try to 
make the notion precise you'll find there are fundamental ambiguities that 
prevent it from being a well-defined operation in general.

The operation you probably intend is quite doable, though. You first have 
to construct the expressions that you want to collect relative to:

V=[x,y,z,t] 
Ds=[derivative(f(x,y,z,t),V[i],V[j])({x:xp,y:yp,z:zp,t:tp}) for j in 
range(4) for i in range(j+1)]

You can inspect the entries in Ds: these are all just purely expressions of 
the form D[i,j](f), so from the perspective of expression manipulations 
such as "subs" and "collect" and "coeffient", they are "atomic": they 
behave as polynomial variables themselves. For instance, we could replace 
them by actual, named variables to exhibit this. We'll call these variables 
D00,...,D33:

Dvars=[SR.symbol('D{}{}'.format(i,j))  for j in range(4) for i in 
range(j+1)]

We can substitute those:

eD=e.subs(dict(zip(Ds,Dvars)));eD 
D11 + D22 + (D00/sqrt(-v^2/c^2 + 1) - D03*v/(c^2*sqrt(-v^2/c^2 + 
1)))/sqrt(-v^2/c^2 + 1) - v*(D03/sqrt(-v^2/c^2 + 1) - 
D33*v/(c^2*sqrt(-v^2/c^2 + 1)))/(c^2*sqrt(-v^2/c^2 + 1)) - 
((D00*v/sqrt(-v^2/c^2 + 1) - D03/sqrt(-v^2/c^2 + 1))*v/sqrt(-v^2/c^2 + 1) - 
(D03*v/sqrt(-v^2/c^2 + 1) - D33/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1))/c^2

And we can check this is correct by substituting back and comparing (many 
CAS packages have rough edges in this area, where they'll allow you to do 
something but not necessarily do what you thought you would do; so checking 
is good!)

 bool(eD.subs(dict(zip(Dvars,Ds))) == e) 
True 

Note that multivariate calculus books describe the linear algebra that 
partial derivatives obey under these kinds of operations. That would allow 
you to get this expression eD right away.
On Friday, January 22, 2021 at 10:46:35 AM UTC-8 cseb...@gmail.com wrote:

>
> I'm trying to collect all the terms in an expression with the same
> second partial derivative but it doesn't seem to be working.
> I can't figure out why.
>
> Here is my code
>
> # 
>
> function("xp yp zp tp f")
> var("x y z t v c")
>
> xp = (x - v * t) / sqrt(1 - v^2 / c^2)
> yp = y
> zp = z
> tp = (t - v * x / c^2) / sqrt(1 - v^2 / c^2)
>
> e = derivative(f(xp, yp, zp, tp), x, 2) + derivative(f(xp, yp, zp, tp), y, 
> 2) + derivative(f(xp, yp, zp, tp), z, 2) - derivative(f(xp, yp, zp, tp), t, 
> 2) / c^2
>
> e.collect(derivative(f(xp, yp, zp, tp), x, 2))
>
> #  
>
> Here is the output.  I added spaces at a subtraction to make it easy to see
> there are TWO of those D[0, 0](f) terms (each at the beginning of the 
> sections).
>
> (D[0, 0](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, (t - 
> v*x/c^2)/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1) - v*D[0, 3](f)(-(t*v - 
> x)/sqrt(-v^2/c^2 + 1), y, z, (t - v*x/c^2)/sqrt(-v^2/c^2 + 
> 1))/(c^2*sqrt(-v^2/c^2 + 1)))/sqrt(-v^2/c^2 + 1) - v*(D[0, 3](f)(-(t*v - 
> x)/sqrt(-v^2/c^2 + 1), y, z, (t - v*x/c^2)/sqrt(-v^2/c^2 + 
> 1))/sqrt(-v^2/c^2 + 1) - v*D[3, 3](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, 
> (t - v*x/c^2)/sqrt(-v^2/c^2 + 1))/(c^2*sqrt(-v^2/c^2 + 
> 1)))/(c^2*sqrt(-v^2/c^2 + 1)) 
>
> - 
>
> ((v*D[0, 0](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, (t - 
> v*x/c^2)/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1) - D[0, 3](f)(-(t*v - 
> x)/sqrt(-v^2/c^2 + 1), y, z, (t - v*x/c^2)/sqrt(-v^2/c^2 + 
> 1))/sqrt(-v^2/c^2 + 1))*v/sqrt(-v^2/c^2 + 1) - (v*D[0, 3](f)(-(t*v - 
> x)/sqrt(-v^2/c^2 + 1), y, z, (t - v*x/c^2)/sqrt(-v^2/c^2 + 
> 1))/sqrt(-v^2/c^2 + 1) - D[3, 3](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, (t 
> - v*x/c^2)/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1))/c^2 
> + D[1, 1](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, (t - 
> v*x/c^2)/sqrt(-v^2/c^2 + 1)) + D[2, 2](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, 
> z, (t - v*x/c^2)/sqrt(-v^2/c^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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/50191e08-64e7-4026-aade-6905a4ba04a9n%40googlegroups.com.


Re: [sage-support] Calling Words in a function gives an error

2021-01-24 Thread Nils Bruin
On Thursday, January 21, 2021 at 7:21:52 AM UTC-8 Nikos Apostolakis wrote:

> Dear Vincent,
>
> Thank you very much, that fixes it.
>
> IMHO this is a bug though, or at least an inconsistent behavior.  Most of 
> the time Sage silently coerces things to the appropriate type so commands  
> just work.  For example:
>
 

>
> sage: m = 11
>> sage: l = (m-1)/2 -1
>>
> sage: l
>> 4
>> sage: range(5)[l]
>> 4
>
>
> There's a subtle difference here: The python interface here requires an 
index to be something that can be converted into an integer; i.e., 
something for which the __int__ method does the right thing. "Coercion" in 
sage has a more restricted notion; see the docs. In sage, there is no 
coercion from QQ to ZZ, because there is no natural map from one to the 
other. There is a conversion, though, which is allowed to be a partial map.

Generally, coercion maps only exist in one direction. Otherwise, things 
like ZZ(1)+QQ(2) whould have an ill-determined type.

Whether "Words" should attempt to convert its second argument to an integer 
is a different matter. Generally it is best to start interface design by 
doing only a minimal amount of processing to the argument, because being 
"smart" for one thing can easily hide errors in another case.

The error message that is currently given is perhaps a little generic, but 
it does clearly indicate that the arguments given to "Words" are 
problematic. Once you check that the *apparent* arguments work fine if 
entered directly, it's clear there's probably a type issue. If you use 
IPython's interactive debugger ("%debug") you can dive into the problematic 
code and query the arguments and their types directly, within the context 
where the error was raised. That can be a big time saver, because it can 
help you find the error without having to construct a stand-alone 
reproducible test case that you would need if you want to communicate the 
error to other people.

-- 
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/01a9d1dc-c402-444e-81c8-e8aa86b2945an%40googlegroups.com.


Re: [sage-support] Re: Trouble getting *collect* to work with derivatives.

2021-01-25 Thread Nils Bruin
On Monday, January 25, 2021 at 7:16:00 AM UTC-8 ... wrote:

> Is this the same as derivative(f(xp(x, y, z, t), yp(x, y, z, t), zp(x, y, 
> z, t), tp(x, y, z, t)) , x, 2)?
>
> No, it is not. Look up "Multivariable Chain rule".

-- 
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/f1b2f629-fb33-4157-b591-289d29e464c9n%40googlegroups.com.


Re: [sage-support] Calling Words in a function gives an error

2021-01-25 Thread Nils Bruin
On Monday, January 25, 2021 at 7:09:32 AM UTC-8 Nikos Apostolakis wrote:

> Dear Nils,
>
> [...] I think treating rational integers as integers is safe.  Actually 
> Sage does that
>
> sage: 8/2 in ZZ
> True
>
>
> So to have a function with integer input throw an error when you feed it a 
> rational integer, is surprising and counterintuitive.  To me at least.
>
> Ah right, Sage takes a rather liberal interpretation of "in" here: since 
the target is given, it's apparently read as "can 8/2 be converted to an 
integer". I'm neutral on what Words should do with its arguments.

-- 
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/7dd1068b-c03b-4955-b550-7e45bb5252a3n%40googlegroups.com.


[sage-support] Re: How to get the symbolic expression of eigenvalues and eigenvectors of this 3x3 real symmetric matrix

2015-01-21 Thread Nils Bruin
On Wednesday, January 21, 2015 at 10:56:29 AM UTC-8, Jon wrote:
>
> Hi all, I used the following code in notebook but it fails to give 
> results. Any suggestions?
>
> var('a11,a12,a13,a14,a15,a16,a22,a23,a24,a25,a26,a33,a34,a35,a36,a44,a45,a46,a55,a56,a66,p,q,r',
>  
> domain='real')
> g11=a11*p*p+a66*q*q+a55*r*r+2.0*a16*p*q+2.0*a15*p*r+2.0*a56*q*r;
> g22=a66*p*p+a22*q*q+a44*r*r+2.0*a26*p*q+2.0*a46*p*r+2.0*a24*q*r;
> g33=a55*p*p+a44*q*q+a33*r*r+2.0*a45*p*q+2.0*a35*p*r+2.0*a34*q*r;
> g12=a16*p*p+a26*q*q+a45*r*r+(a12+a66)*p*q+(a14+a56)*p*r+(a46+a25)*q*r;
> 
> g13=a15*p*p+a46*q*q+a35*r*r+(a14+a56)*p*q+(a13+a55)*p*r+(a36+a45)*q*r;
> 
> g23=a56*p*p+a24*q*q+a34*r*r+(a46+a25)*p*q+(a36+a45)*p*r+(a23+a44)*q*r;
>
> g0=matrix(3,3,[g11,g12,g13,g12,g22,g23,g13,g12,g33]).eigenvectors_right()
>
> It shows error "TypeError: ECL says: Memory limit reached. Please jump to 
> an outer pointer, quit program and enlarge the memory limits before 
> executing the program again." I have 9GB ram, and it fails before 
> exhausting the ram. 
>

Currently, maxima_calculus (the maxima instance that is used for some 
symbolic calculations, apparently among which is the symbolic computation 
of eigenvectors) has a memory limit of 1GB. You can lift that restriction 
with the following command:

sage: maxima_calculus(1) #trigger the initialization of maxima
1
sage: from sage.libs.ecl import ecl_eval
sage: ecl_eval("(ext:set-limit 'ext:heap-size 0)")


That said, I suspect doing so will just postpone failure, since the answer 
you're asking likely doesn't fit in any computer. It tends to be true in 
general that things that maxima is useful for tend to fit in a modest 
amount of memory. So failing be default on a relatively low memory limit 
gives early failure in cases that would likely fail anyway.

To get an idea of how big your answer likely is, you can estimate the 
degree of the coefficients in the characteristic polynomial (3 times the 
degree of the terms in the matrix) and count how many monomials in 24 
variables of that degree exist. That gives you a ballpark number of term 
you're likely asking maxima to work with.

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


  1   2   3   4   5   6   >