[sage-support] Re: Is there a way to use Sage's Jupyter outside the sage shell ?

2024-04-08 Thread Nils Bruin
If you run `jupyter --paths` and  `sage -sh <<<"jupyter --paths"` you see 
the difference in paths. The relevant ones for you are probably the 
sage-specific ones
$SAGE-LOCAL/var/lib/sage/venv-python3.10/share/jupyter
Whatever is there will get picked up by sage's jupyter but, naturally, not 
by your standard jupyter.
So the kernels that live there could be copied to a location that is 
accessed by your system jupyter:
$HOME/.local/share/jupyter
or something like that.

Note that the files there might need some surgery, because starting those 
kernels probably needs to happen through sage's python (or at least its 
venv); similar to how to get the sage kernel working in a system jupyter.

On Monday 8 April 2024 at 11:16:45 UTC-7 Emmanuel Charpentier wrote:

> Setup : Sage 10.4.beta1 running on Ubuntu 22.04 LTS under WSL2 in Windows 
> 11 (don’t get me started…). I also installed emacs and its juyter 
>  package, which is able to use 
> Sage-installed kernels … when emacs is started from the Sage shell. [ Yes, 
> there is a point to this…]
>
> What I want to do is to be able to use these Sage-installed kernels from 
> outside the Sage shell environment, thus avoiding to duplicate the Sage 
> Jupyter installation. In other words, I want a jupyter command that is 
> able to finfd the Sage-instaled kernels in their correct environment.
>
> Is there any way to do 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/92d5f86e-6ab1-40f6-9211-ce2e4c1fbc1en%40googlegroups.com.


Re: [sage-support] Antisymmetry Definition in SageMath for DiGraphs

2024-03-18 Thread Nils Bruin
On Monday 18 March 2024 at 06:45:17 UTC-7 Hellen Colman wrote:

"A graph represents an *antisymmetric relation* if ... " 

It is not saying a graph is antisymmetric, but is introducing a new 
definition of antisymmetric relation.


Ah, indeed! The person must have been interested in transitive relations 
and probably thought of the transitive relation represented by a digraph. 
It does make sense to represent a transitive relation by only a partial 
graph whose transitive closure gives the relation of interest. So the 
routine as-is could be documented as "a graph represents a transitive 
relation that is antisymmetric if ...". Then it's a question if the other 
meaning is worthwhile to have available as well. That splits the change 
into a simple bugfix by updating the documentation and a possible new 
feature (including renaming of methods, if desired)

-- 
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/61b6b91e-f57c-4bae-8a43-dcc3aa12be99n%40googlegroups.com.


Re: [sage-support] Antisymmetry Definition in SageMath for DiGraphs

2024-03-15 Thread Nils Bruin
On Friday 15 March 2024 at 15:08:34 UTC-7 Hellen Colman wrote:

Let me just clarify the main point of his question just in case we can 
still obtain a helpful answer. Essentially the question is: Why is Sage 
calling "antisymmetric" to a property that is not the standard 
antisymmetric property?


I agree that a relation gives rise to a graph, but I wouldn't presume that 
the standard notion of "antisymmetric" for relations would agree with that 
on graphs (or even that there would be a property of graphs that is called 
"antisymmetric).  So if there is something transferable to be learned for 
for students here it is perhaps that terminology is not perfectly aligned 
between different areas in mathematics. Given that the word "antisymmetric" 
is now taken to mean something specific for graphs (I assume whoever did 
that consulted some graph-theory books), it will have considerable inertia 
because changing it to something else would break backward compatibility.

If you feel strongly that a change in terminology would be beneficial, you 
could collect some references corroborating your proposed meaning. If 
someone else feels strongly enough about preserving the present meaning, 
they would likely counter with their own set of references. At that point 
hopefully a consensus would grow, with a (slight) preference for the status 
quo. If both notions have support, we'd likely look into a way of 
supporting both; probably by dangling the appropriate adjectives in front 
of "antisymmetric", like "edge_antisymmetric" and "path_antisymmetric" or 
something like that.

For your research, you might be interested in an 
is_homotopically_equivalent method.

-- 
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/8b537b0f-d1bb-41eb-95f6-33c8a2c4c3d6n%40googlegroups.com.


Re: [sage-support] bug in plot?

2024-03-15 Thread Nils Bruin
On Friday 15 March 2024 at 12:42:49 UTC-7 kcrisman wrote:

Or rather, should the default be useoffset False?


Yes, I think that would be reasonable to do. Clearly, offsets being used 
without the user knowing they exist can easily lead to confusion and 
misinterpreting the graph, as had been demonstrated here. With the default 
off, the user would get an ugly graph. If they want to improve it, they 
would hopefully read the documentation. If we document "useoffset" then the 
user could find it there.

-- 
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/24d2b075-0b6f-40f2-8170-67d7a2b36c36n%40googlegroups.com.


Re: [sage-support] bug in plot?

2024-03-14 Thread Nils Bruin
I get the impression that without setting ymin,ymax you just end up with a 
tiny range for the y-axis and its labelling is just very weird. I think the 
labels displayed are shifted and scaled. So the error is just how the 
labels are printed. That looks the same as 
https://github.com/sagemath/sage/issues/34233

The default behaviour would be to derive ymin and ymax from the sampled 
points, and in your point plot example, those values vary from 1-1e-6 to 
1+0e-6. So I think the range is derived appropriately. The labels on the 
y-axis are just printed in a misguided 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/469759c8-09a9-4b61-aa1c-aeda68bdbc7dn%40googlegroups.com.


[sage-support] Re: Question related to Sagemath permission on Github

2024-01-22 Thread Nils Bruin
On Sunday 21 January 2024 at 04:25:42 UTC-8 Juan Grados wrote:

To protect the repo from arbitrary deletion, I need to know if Github 
allows adding a rule to avoid a repository being deleted by a single 
person. 

If you encourage a workflow with forks and pull requests then everybody 
will have their own copy anyway. Then the question is more: is there a way 
to reinstate a repo after it is deleted? Then it will be recovering from an 
admin mistake, just as any misjudged commit will be (if you have to worry 
about your admins inadvertently deleting your repo then you'll have to 
worry about wrong merges even more). And if you expect that your admins are 
prone to making mistakes, people will probably be much happier living 
mainly in their own repo and only interacting with the central one if they 
have to (for pull requests). It of course does add a level of indirection 
to staying up-to-date, but I think the sage github documentation has some 
tips on minimizing the pain in that (and otherwise other projects will). 

-- 
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/0663f1c7-fc7b-4252-8bb9-07b3f48de6fcn%40googlegroups.com.


Re: [sage-support] Re: limitations of "solve"?

2024-01-01 Thread Nils Bruin
The documented effect is usually of most impact:

https://maxima.sourceforge.io/docs/manual/maxima_46.html#index-domain

there may be other undocumented effects, but the one above tends to explain 
a lot already.

On Sunday 3 December 2023 at 06:26:20 UTC-8 Oscar Benjamin wrote:

> What does "set domain to complex" mean in terms of Maxima's settings?
>
> Maxima's solve seems to compute complex solutions by default:
>
> (%i21) solve(x^2 + 1);
> (%o21) [x = - %i, x = %i]
>
> On Sun, 3 Dec 2023 at 13:37, Dima Pasechnik  wrote:
> >
> > Yes, Sage modifies the defaults of Maxima, in particular we set domain 
> to complex.
> >
> > On 3 December 2023 12:28:45 GMT, Oscar Benjamin  
> wrote:
> > >On Wed, 29 Nov 2023 at 12:40, Eric Gourgoulhon  
> wrote:
> > >>
> > >> Le mardi 28 novembre 2023 à 18:25:04 UTC+1, kcrisman a écrit :
> > >>
> > >> Yes. Maxima's attitude is that the square root of negative one is an 
> expression which might have multiple values, rather than just picking one 
> you hope might be consistent over branch points.
> > >>
> > >> To enforce Maxima to work in the real domain, avoiding to play too 
> much with complex square roots, one can add at the beginning of the Sage 
> session:
> > >>
> > >> maxima_calculus.eval("domain: real;")
> > >>
> > >> Then the second example in the initial message of this thread yields
> > >>
> > >> [[x == 2/5*sqrt(6)*sqrt(5), y == 16, l == 1/9*18750^(1/6)], [x == 
> -2/5*sqrt(6)*sqrt(5), y == 16, l == -1/9*18750^(1/6)]]
> > >>
> > >> instead of an empty list.
> > >
> > >When using Maxima (5.45.1) directly I get this result with default 
> settings:
> > >
> > >(%i1) f: 10*x^(1/3)*y^(2/3)$
> > >
> > >(%i2) g: 5*x^2 + 6*y$
> > >
> > >(%i3) solve([diff(f,x)=l*diff(g,x), diff(f,y)=l*diff(g,y), g=120], 
> [x,y,l]);
> > > 1/6
> > > 2 sqrt(6) 18750
> > >(%o3) [[x = -, y = 16, l = ],
> > > sqrt(5) 9
> > > 1/6
> > > 2 sqrt(6) 18750
> > > [x = - -, y = 16, l = - ]]
> > > sqrt(5) 9
> > >
> > >Does Sage modify some Maxima settings related to this or does it call
> > >something other than solve?
> > >
> > >--
> > >Oscar
> > >
> >
> > --
> > 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...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-support/6F4839F2-38B6-40F2-B080-EFCC1C0C3B65%40gmail.com
> .
>

-- 
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/454c0dbc-ead3-45c4-9557-fdb2391a9ce9n%40googlegroups.com.


Re: [sage-support] smith form may be too slow

2023-12-13 Thread Nils Bruin
(side note: Q is generally considered a PID, but indeed it makes little 
sense worrying about Smith normal form over it)

Concerning the slow performance: from the documentation, 
R._matrix_smith_form would allow an optimized routine to kick in. That 
doesn't exist, though. 
ZZ doesn't have it either, but there is a whole different class for that in 
sage/matrix/matrix_integer_dense.pyx that provides a specific-for-ZZ smith 
form algorithm. For QQ['t'] you end up with the generic algorithm, which is 
liable to be inefficient and have quirks such having large variations in 
runtime, depending on the specific input.

So: it makes sense it's not very optimal (yet?). It would require work to 
get a better implementation specific for QQ['t']. This could be worthwhile 
to do well. Summer of Code?


On Thursday 14 December 2023 at 04:05:47 UTC+13 Enrique Artal wrote:

> It is over the ring of polynomials in one variable over Q.
>
> El miércoles, 13 de diciembre de 2023 a las 15:05:00 UTC+1, Dima Pasechnik 
> escribió:
>
>> On Wed, Dec 13, 2023 at 10:55 AM Enrique Artal  
>> wrote: 
>> > 
>> > I have the toy example belowto compare the direct use of smith_form and 
>> the combination of hermite_form and smith_form. 
>> > 
>> > Last execution (there are random inputs) gave: 
>> > CPU times: user 2.22 s, sys: 5.93 ms, total: 2.23 s Wall time: 2.23 s 
>> CPU times: user 454 ms, sys: 990 µs, total: 455 ms Wall time: 456 ms 
>> > 
>> > % 
>> > R. = QQ[] 
>> > n = 3 
>> > m = 5 
>> > ds = (n, m) 
>> > M = MatrixSpace(R, n, m) 
>> > V = random_vector(R, n) 
>> > A0 = Matrix(R, n, m) 
>> > A0[0, 0] = R.random_element() 
>> > for j in range(1, n): 
>> > A0[j, j] = A0[j -1, j - 1] * R.random_element() 
>> > def par(n): 
>> > i1 = ZZ.random_element(0,n) 
>> > j1 = i1 
>> > while j1 == i1: 
>> > j1 = ZZ.random_element(0,n) 
>> > return (i1, j1) 
>> > def smith_hermite(A): 
>> > D1, U1 = A.hermite_form(transformation=True) 
>> > D, U2, V = D1.smith_form() 
>> > U = U2 * U1 
>> > return D, U, V 
>> > P = {j: identity_matrix(R, ds[j]) for j in range(2)} 
>> > s = 20 
>> > for k in range(2): 
>> > for a in range(s): 
>> > i, j = par(n) 
>> > f = R.random_element() 
>> > P[k].add_multiple_of_row(i, j ,f) 
>> > i, j = par(n) 
>> > P[k].swap_rows(i, j) 
>> > i, j = par(n) 
>> > f = R.random_element() 
>> > P[k].add_multiple_of_column(i, j ,f) 
>> > i, j = par(n) 
>> > P[0].swap_columns(i, j) 
>> > A = P[0] * A0 * P[1] 
>> > %time D, U, V = A.smith_form() 
>> > %time D1, U1, V1 = smith_hermite(A) 
>>
>> hmm, what's Smith form of a matrix over Q ? 
>> Q is not a PID. 
>> > 
>> > -- 
>> > 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...@googlegroups.com. 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sage-support/dec24250-3a00-4c3e-a2e6-e352cde6ff2bn%40googlegroups.com.
>>  
>>
>>
>

-- 
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/eae0bd95-4ba8-4e8e-a5c7-c6ec8d83518an%40googlegroups.com.


Re: [sage-support] Re: Canonical divisor help

2023-10-29 Thread Nils Bruin


On Monday, 30 October 2023 at 00:19:47 UTC+13 Kwankyu wrote:

What is your code? 

P2. = ProjectiveSpace(QQ, 2)
f = 2*x^5 - 4*x^3*y*z + x^2*y*z^2 + 2*x*y^3*z + 2*x*y^2*z^2+ y^5
C = Curve(f)
kC = C.function_field()
D = kC(kC.base_field().gen(0)).differential().divisor()
L,m,s = (-D).function_space()
#the routine below is a bit of a shortcut based on how the affine patch for 
kC
#is chosen. In more general code this would need to be a little more 
sophisticated
def liftkC(u):
return sum([(m.numerator()(y/x))/(m.denominator()(y/x))*(z/x)^i for i,m 
in enumerate(u.list())])
liftedbasis = [liftkC(m(b)) for b in L.basis()]
den = lcm([b.denominator() for b in liftedbasis])
liftedbasis = [parent(x)(b*den) for b in liftedbasis]
phi = P2.hom(liftedbasis,P2)
phi(C) # this fails
C._forward_image(phi,check=False) #this seems to work!
 
Of course, one could also do some linear algebra with (-D).function_space() 
and (-2*D).function_space() to figure out this image.

-- 
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/41cd62ea-4707-4ebc-bc5c-f37427a0f0c6n%40googlegroups.com.


Re: [sage-support] Re: ideal intersection in ZZ

2023-10-29 Thread Nils Bruin
On Monday, 30 October 2023 at 00:26:55 UTC+13 G. M.-S. wrote:

If I understand you correctly, SageMath is a bit loose at the moment about 
its categories.


That's not what I meant also not what is indicated by what I noticed: by 
the looks of it, sage does know about euclidean domains and has quite a bit 
of ED-specific functionality. It's just that no-one has bothered 
specializing the *ideals* of euclidean domains. The definition of a 
Euclidean domain doesn't really mention ideals and indeed the subsequent 
properties of its ideals are established by lemmas and propositions. 
Basically, no-one has bothered making sagemath aware of those theorems (or 
even put the infrastructure in place to teach it about those results). So, 
no evidence of looseness in its categories. Just a little uneducated.


-- 
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/88d2040e-b498-4486-a64a-c79d1b4730d8n%40googlegroups.com.


Re: [sage-support] Re: Canonical divisor help

2023-10-28 Thread Nils Bruin
On Saturday, 28 October 2023 at 18:50:12 UTC-7 Nils Bruin wrote:

On Saturday, 28 October 2023 at 15:26:35 UTC-7 Kwankyu wrote:


f1, f2, f3 are univariate polynomials (say in y) over rational function 
field (say in x). Then x and y are not always the variables X and Y of the 
coordinate ring of the affine plane. Things are more complicated if the 
curve is in space (of dim > 2).
 

Sure. But you did get x,y somehow from the model with which C was given. 
Most likely, the A2 on which x,y are coordinates is obtained via projection 
from whatever model C was given by? Even if it is not a linear map, there 
are still expressions through which you can pull back x,y to the original 
model. You're right that the representations may get rather bad, but I'm 
not sure there's really something you can do about that. 


The most pressing problem in sage at the moment seems to be that presently 
there only seem to be morphisms between schemes. You need rational maps for 
this (especially from a singular model, the map to a canonical model might 
only be a rational map).

So I think we'd first need a bit of a push to get some infrastructure for 
rational maps. In fact "maps" between schemes in magma are just rational 
maps. So presently there is really a difference in functionality.

There are some conceptual problems with the main "map" type between schemes 
being a rational map. But it is very convenient and certainly for curves a 
much better fit than maps that are clearly morphisms.

I might be overlooking something ... currently sage allows for the 
construction of a rational map P2 -> P2, but then asking for the image of a 
curve C in P2 leads to

TypeError: map must be a morphism

(which should probably be a ValueError). Perhaps the code is just 
unnecessarily picky? 

-- 
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/efdf5070-97a8-49b1-876b-1cdce5b61455n%40googlegroups.com.


Re: [sage-support] Re: Canonical divisor help

2023-10-28 Thread Nils Bruin
On Saturday, 28 October 2023 at 15:26:35 UTC-7 Kwankyu wrote:


f1, f2, f3 are univariate polynomials (say in y) over rational function 
field (say in x). Then x and y are not always the variables X and Y of the 
coordinate ring of the affine plane. Things are more complicated if the 
curve is in space (of dim > 2).
 

Sure. But you did get x,y somehow from the model with which C was given. 
Most likely, the A2 on which x,y are coordinates is obtained via projection 
from whatever model C was given by? Even if it is not a linear map, there 
are still expressions through which you can pull back x,y to the original 
model. You're right that the representations may get rather bad, but I'm 
not sure there's really something you can do about 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/3ea279ab-4b25-43ee-856f-8e9ca8bcc147n%40googlegroups.com.


Re: [sage-support] Re: Canonical divisor help

2023-10-28 Thread Nils Bruin
On Saturday, 28 October 2023 at 05:39:26 UTC-7 Kwankyu wrote:

I looked the Magma code in ask.sagemath. There's no problem in computing a 
canonical divisor for the curve (through the attached function field). 
Computing a basis of the Riemann-Roch space is no problem as well. Actually 
the hard part is to construct the morphism from C to P2 from the basis. 
Magma does this seamlessly. But Sage lacks this functionality (perhaps 
because I did not implement it). I think, the gist of the matter is to 
convert an element of the function field to a rational function of the 
coordinate ring of P2.


That's actually trivially simple: if [f1,f2,f3] is the basis of your 
Riemann-Roch space, you just consider the map defined by [f1:f2:f3]. So you 
lift f1,f2,f3 to rational functions on the affine space that contains your 
curve: you just take the rational function representation and forget the 
algebraic relations between the variables. You now have rational functions 
in a rational function field, so you can clear denominators there. Now you 
have a rational map (described by polynomials) A^2->P^r under which the 
rational image of your curve C in A^2 is the corresponding projective 
image. Computing that image is the usual groebner-basis operation for 
finding images of rational maps, so that's potentially quite expensive.

In practice, you know something about the denominators of the 
representations of f1,f2,f3, so you can probably do a little better.

At its core, that is what the magma code does too, although perhaps it has 
some smart tricks here and there to try and keep degrees in check a bit.

-- 
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/ddd052ef-029c-4237-b2b7-9d5328201e07n%40googlegroups.com.


Re: [sage-support] Re: ideal intersection in ZZ

2023-10-28 Thread Nils Bruin
On Saturday, 28 October 2023 at 10:22:15 UTC-7 G. M.-S. wrote:


Thanks, Nils.

My question was motivated by using SageMath in my teachings.

Do you think it would be difficult/worthwhile taking care of this?
I mean, ideals in euclidean rings (or at least in ZZ).


Mathematically or algorithmically not difficult of course. I'd expect that 
to make it play nice with the category framework you'll need to do a lot of 
work. By the looks of ZZ.categories(), there is a category of "euclidean 
domains". The parent of ideals in ZZ, however, looks rather generic. I 
don't think the euclidean properties are propagated to the monoid of ideals 
at all at the moment. The "appropriate" level of generality would be there. 
However, there's not much to be gained from ideals in euclidean domains: we 
already have lcm and gcd! So I suspect that's why it's not implemented at 
the moment.

I can see how having such ideals may seem instructive for teaching. I think 
that's a matter of philosophy / opinion. I happen to not believe that 
teaching students formalisms in computer algebra packages without real 
benefit/content (beyond lcm and gcd that they'll learn anyway) helps them 
much, so I wouldn't think it's worthwhile. Perhaps for having facilities 
for ideals universally available, it could be useful if ideals in ZZ have 
"intersection" implemented, but I have trouble seeing where that would come 
up.

There are rings with ZZ as a subring for which intersection works on ideals 
proper, since we have groebner bases over ZZ, apparently:

sage: R.=ZZ['x','y']
sage: I=R.ideal(15)
sage: J=R.ideal(35)
sage: I.intersection(J)

So you could use that ... or if you manage to define a multivariate 
polynomial ring over ZZ in 0 variables, you'd be good to go too. Free 
ZZ-modules of rank 1 would also get you the right behaviour.
 

Guillermo

On Sat, 28 Oct 2023 at 18:44, Nils Bruin  wrote:

I'm sure its omission is just an oversight. For fractional ideals in number 
fields it is defined:

sage: K.=QuadraticField(7)
sage: I=K.fractional_ideal(5)
sage: J=K.fractional_ideal(3)
sage: I.intersection(J)
Fractional ideal (15)

I doubt that just knowing a ring is a PID makes computing intersections of 
ideals easy. So the omission may be because there doesn't seem to be 
ZZ-specific (or euclidean ring-specific) ideal code. And with lcm around, 
the need for it has been low, I expect.

On Saturday, 28 October 2023 at 02:36:51 UTC-7 G. M.-S. wrote:


I wonder why SageMath cannot compute the intersection of 2 ideals in ZZ.

Is this due to the fact that ZZ would "only" be a PID?

Guillermo

┌┐

│ SageMath version 10.1, Release Date: 2023-08-20│

│ Using Python 3.11.1. Type "help()" for help.   │

└┘

sage: n1,n2=720,756

sage: d,m=gcd(n1,n2),lcm(n1,n2)

sage: n1,n2,d,m

(720, 756, 36, 15120)

sage: I1,I2=ZZ.ideal(n1),ZZ.ideal(n2)

sage: I1,I2

(Principal ideal (720) of Integer Ring, Principal ideal (756) of Integer 
Ring)

sage: I1+I2

Principal ideal (36) of Integer Ring

sage: I1.intersection(I2)

---

AttributeErrorTraceback (most recent call last)

Cell In [7], line 1

> 1 I1.intersection(I2)


File 
/private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:488,
 
in sage.structure.element.Element.__getattr__ 
(build/cythonized/sage/structure/element.c:4846)()

*486* AttributeError: 
'LeftZeroSemigroup_with_category.element_class' object has no attribute 
'blah_blah'

*487* """

--> 488 return self.getattr_from_category(name)

*489* 

*490* cdef getattr_from_category(self, name):


File 
/private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:501,
 
in sage.structure.element.Element.getattr_from_category 
(build/cythonized/sage/structure/element.c:4958)()

*499* else:

*500* cls = P._abstract_element_class

--> 501 return getattr_from_other_class(self, cls, name)

*502* 

*503* def __dir__(self):


File 
/private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/cpython/getattr.pyx:362,
 
in sage.cpython.getattr.getattr_from_other_class 
(build/cythonized/sage/cpython/getattr.c:2773)()

*360* dummy_error_message.cls = type(self)

*361* dummy_error_message.name = name

--> 362 raise AttributeError(dummy_error_message)

*363* attribute = attr

*364* # Check for a descriptor (__get__ in Python)


AttributeError: 'Ideal_pid' object has no attribute 'intersection'

sage: 

 

-- 
You received this message because you a

[sage-support] Re: ideal intersection in ZZ

2023-10-28 Thread Nils Bruin
I'm sure its omission is just an oversight. For fractional ideals in number 
fields it is defined:

sage: K.=QuadraticField(7)
sage: I=K.fractional_ideal(5)
sage: J=K.fractional_ideal(3)
sage: I.intersection(J)
Fractional ideal (15)

I doubt that just knowing a ring is a PID makes computing intersections of 
ideals easy. So the omission may be because there doesn't seem to be 
ZZ-specific (or euclidean ring-specific) ideal code. And with lcm around, 
the need for it has been low, I expect.

On Saturday, 28 October 2023 at 02:36:51 UTC-7 G. M.-S. wrote:

>
> I wonder why SageMath cannot compute the intersection of 2 ideals in ZZ.
>
> Is this due to the fact that ZZ would "only" be a PID?
>
> Guillermo
>
> ┌┐
>
> │ SageMath version 10.1, Release Date: 2023-08-20│
>
> │ Using Python 3.11.1. Type "help()" for help.   │
>
> └┘
>
> sage: n1,n2=720,756
>
> sage: d,m=gcd(n1,n2),lcm(n1,n2)
>
> sage: n1,n2,d,m
>
> (720, 756, 36, 15120)
>
> sage: I1,I2=ZZ.ideal(n1),ZZ.ideal(n2)
>
> sage: I1,I2
>
> (Principal ideal (720) of Integer Ring, Principal ideal (756) of Integer 
> Ring)
>
> sage: I1+I2
>
> Principal ideal (36) of Integer Ring
>
> sage: I1.intersection(I2)
>
> ---
>
> AttributeErrorTraceback (most recent call 
> last)
>
> Cell In [7], line 1
>
> > 1 I1.intersection(I2)
>
>
> File 
> /private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:488,
>  
> in sage.structure.element.Element.__getattr__ 
> (build/cythonized/sage/structure/element.c:4846)()
>
> *486* AttributeError: 
> 'LeftZeroSemigroup_with_category.element_class' object has no attribute 
> 'blah_blah'
>
> *487* """
>
> --> 488 return self.getattr_from_category(name)
>
> *489* 
>
> *490* cdef getattr_from_category(self, name):
>
>
> File 
> /private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/structure/element.pyx:501,
>  
> in sage.structure.element.Element.getattr_from_category 
> (build/cythonized/sage/structure/element.c:4958)()
>
> *499* else:
>
> *500* cls = P._abstract_element_class
>
> --> 501 return getattr_from_other_class(self, cls, name)
>
> *502* 
>
> *503* def __dir__(self):
>
>
> File 
> /private/var/tmp/sage-10.1-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/cpython/getattr.pyx:362,
>  
> in sage.cpython.getattr.getattr_from_other_class 
> (build/cythonized/sage/cpython/getattr.c:2773)()
>
> *360* dummy_error_message.cls = type(self)
>
> *361* dummy_error_message.name = name
>
> --> 362 raise AttributeError(dummy_error_message)
>
> *363* attribute = attr
>
> *364* # Check for a descriptor (__get__ in Python)
>
>
> AttributeError: 'Ideal_pid' object has no attribute 'intersection'
>
> sage: 
>
>

-- 
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/f54544d4-93f5-4411-99c9-335a67de25f3n%40googlegroups.com.


[sage-support] Re: Canonical divisor help

2023-10-27 Thread Nils Bruin
On Friday, 27 October 2023 at 15:42:24 UTC-7 Nils Bruin wrote:

It doesn't look like we quite have computation of Riemann-Roch spaces 
natively in sage yet


Correction, that DOES seem to be implemented as well:

sage: kC=C.function_field()
sage: D=kC(kC.base_field().gen(0)).differential().divisor()
sage: (-D).function_space()

That's actually a great gain in functionality! That code really deserves to 
be exercised and, inevitably, debugged from bugs that would be uncovered by 
extensive testing.

-- 
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/03d96b5c-63c8-4944-bf9c-81a0370cf229n%40googlegroups.com.


[sage-support] Re: Canonical divisor help

2023-10-27 Thread Nils Bruin
A canonical divisor is the divisor of any differential on C so the 
following does the trick:

sage: kC=C.function_field()
sage: kC(kC.base_field().gen(0)).differential().divisor()

It doesn't look like we quite have computation of Riemann-Roch spaces 
natively in sage yet, so finding effective representatives requires a 
little more work. In the RiemannSurface code this is done using singular's 
adjoint ideal code (or by Baker's theorem in cases where it applies). For 
this curve the canonical class is of degree -2, so there are no effective 
representatives in this case.

On Friday, 27 October 2023 at 15:14:00 UTC-7 John H Palmieri wrote:

> If anyone here knows anything about canonical divisors and their 
> implementation in Sage, please see 
> https://ask.sagemath.org/question/74034/converting-algebraic-geometry-magmas-code-to-sage/.
>  
> The setup:
>
> sage: P2. = ProjectiveSpace(QQ, 2)
> sage: f = 2*x^5 - 4*x^3*y*z + x^2*y*z^2 + 2*x*y^3*z + 2*x*y^2*z^2+ y^5
> sage: C = P2.curve(f)
>
> How do you get the canonical divisor for C?
>
> (I encourage you to post answers directly to ask.sagemath.org, if you're 
> willing.)
>
> -- 
> John
>
>

-- 
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/91b14570-b83e-4dbf-8bca-0a2eff538a50n%40googlegroups.com.


[sage-support] Re: help debugging latex() printing with trace()

2023-10-27 Thread Nils Bruin
On Thursday, 26 October 2023 at 16:03:27 UTC-7 Eric Majzoub wrote:

I would like to debug the latex printing of an expression that ambiguous.

To reproduce it:
t = var('t')
x = function('x')(t)
latex( diff(x,t)^2 )

This produces ambiguous output, essentially:

partial_t x^2

instead of

(partial_t x)^2

I have tried:
from sage.misc.trace import trace
trace("latex( diff(x,t)^2 )")

but I can't understand in which .py file the translation of "diff" occurs. 
As I understand the source code, there should be a _latex_(self) for every 
object or method to display latex code, but I can't seem to find it here. 


It happens here:

https://github.com/sagemath/sage/blob/07a2afd65fb4b0a1c9cbc43ede7d4a18c921a000/src/sage/symbolic/pynac_impl.pxi#L691

However, the code deciding whether the base of an exponential expression 
needs parentheses is elsewhere.

-- 
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/92e62d2d-4b88-49c3-981d-dab6f01925e8n%40googlegroups.com.


[sage-support] Re: Question about cysignals installation

2023-08-27 Thread Nils Bruin
I think it was written elsewhere that cysignals has not been ported to 
cython 3.0.0 yet. In fact, sage as a whole hasn't been upgraded to compile 
with cython 3.0.0 yet.

On Wednesday, 16 August 2023 at 06:57:05 UTC-7 JC wrote:

> Dear Sage developers,
>
> I'm trying to install the cysignals 1.11.2 package in Python 3.9.7 using 
> pip (on a computer with macOS system and Apple M2 chip) and have already 
> installed the prerequisite packages Cython and Sphinx, but still failed 
> with some Cython compiling errors (please see the error message attached). 
> Do you know what the problem might be and how I can fix it?
>
> Thank you very much!
>

-- 
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/188ebeef-8ee7-44cb-861e-110d6079fad6n%40googlegroups.com.


Re: [sage-support] Importing sympy breaks CyclotomicField

2023-08-18 Thread Nils Bruin
Perhaps superfluously: the reason why redefining `Integer` (in your example 
through "from sympy import *") can break a command in sage that does not 
seem to involve `Integer`:

sage: preparse("K = CyclotomicField(32)")
'K = CyclotomicField(Integer(32))'

Due to Sage's preparser, any use of integer constants involves `Integer`. 
Even calling `int` on them:

sage: preparse("int(32)")
'int(Integer(32))'

there is a special postfix you can use to really get a python int, without 
involvement of `Integer`:

sage: preparse("32r")
'32'

-- 
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/d2e07668-8b64-4f07-853d-1a41d9a458fen%40googlegroups.com.


[sage-support] Re: HPC Multi Node/Cluster Install Question

2023-08-10 Thread Nils Bruin
This response is very much in the "new direction or place to search" 
category.

Sagemath's build process has been undergoing quite some changes. It used to 
be the case that sage-the-distribution kept virtually everything in-house, 
so that an install on shared folder would work great on a cluster with many 
(identical) nodes. The build system now has much more preference for 
relying on system-supplied components. As long as all nodes are still 
identical *and have the same system-supplied components in place*, it 
should still work.

Sagemath is now quite viably buildable in conda, where conda is used to 
supply many components. So if a plain install isn't working on a cluster 
(or looks potentially problematic), it could be very instructive to read up 
on how conda deals with such situations -- that might well be applicable to 
sagemath (built in conda) now as well.

On Thursday, 10 August 2023 at 15:13:54 UTC+2 Andrew wrote:

> I've done some research, googled around, searched though ask sage, looked 
> at some of the thematic tutorials and have finally come to this google 
> group (ask sage, in all fairness, never approved this post, deleted me and 
> it, and no idea why and it was from my corporate email address? But ask a 
> question on the sage page leads there...).
>
> Can anyone point me towards some documentation, how-tos, or git gist in 
> and around installing sage on a multi-node HPC cluster? We have a job 
> manager (PBS family, so like PBS Pro or Torque). Multiple compute nodes, 
> use modules for the environmental variables 
>
> That said, it is not clear to me about the best approach to laying this 
> down. Some software lends itself to a shared folder install (though that is 
> often built from source or installed on a master node), others with a local 
> install on each node. Maybe it is some kind of mental block, but have 
> installed others without issue and sliced and diced this question before. 
>
> Just curious about the best approach to install sage (I did find this bit 
> for mpi support, sage -pip install mpi4py but I can't imagine there isn't 
> more information that I am somehow just not searching right for) 
>
> Even a new direction or place to search would be a great answer.
>
> Thanks,
>
> A
>

-- 
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/fdbdbc0e-0997-4bed-8325-2eb6da0b89b9n%40googlegroups.com.


[sage-support] Re: help with memory (sage)

2023-06-20 Thread Nils Bruin
On Monday, 19 June 2023 at 12:10:49 UTC+2 ayan.mah...@gmail.com wrote:


Another crazy thing is that suppose I see 40% usage in memory and kill the 
program by cntrl-c but keep sage running. Then I start a new process in 
sage. The memory increases from 40%. As if there is some permanent stuff 
stored in the memory that can only be erased by shutting down sage.

It's most definitely the case that partial results from your interrupted 
run are reachable from active scopes and therefore their memory remains 
allocated.  Shutting down sage will most certainly release the memory, but 
if you can trace where it old results are still referenced, you could break 
those references and the memory would be released. These things can be hard 
to track down, particularly when you've interrupted code and hence may have 
left data structures in inconsistent states.


 

-- 
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/6d825d36-298b-4a6b-a9c5-704989284352n%40googlegroups.com.


Re: [sage-support] Re: sage-10.0 not working in Jupyter Lab

2023-06-01 Thread Nils Bruin
On Thursday, 1 June 2023 at 07:29:27 UTC-7 Luis Finotti wrote:


I am not sure I will miss them (and other packages that depended on it -- 
fflas-ffpack libgivaro-dev libgivaro9 liblinbox-dev python3-brial 
python3-sage), but isn't there a way to force Jupyter to use Sage's one?

 
I don't think jupyter cares about givaro. However, it sounds like your 
jupyter sets up some things about the library search path (perhaps an 
LD_LIBRARY_PATH)? that gets inherited by the sage process that gets 
subsequently run to start the kernel. The sage script normally seems to set 
search paths in such a way that it picks the right libgivaro, but when run 
in the environment created by jupyter apparently it doesn't any more.

That sounds like a bit of a bug to me. You've found a work-around by making 
sure the only givaro on your system is the one sage built. But really, the 
way sage sets up its environment shouldn't be derailed by what another 
jupyter install does prior to it.

The first candidate for causing this is a value for LD_LIBRARY_PATH, so if 
you could look check

"LD_LIBRARY_PATH" in os.environ

in both your command-line sage and in sage through jupyterlab then you'd 
know if there's a difference. Generally comparing the contents of 
os.environ between the two may give you some insight in what might be 
causing the difference in behaviour.

The whole point of python's "venv" is that you CAN run different programs 
with conflicting library requirements easily. So you could help if you can 
pinpoint what is going wrong here -- perhaps it's a misconfiguration on 
your system but it could also be a bug/oversight in how python's venvs are 
managed.

-- 
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/032ca71d-5f67-44db-89dc-ed0423201135n%40googlegroups.com.


Re: [sage-support] Re: sage-10.0 not working in Jupyter Lab

2023-06-01 Thread Nils Bruin
On Wednesday, 31 May 2023 at 18:14:59 UTC-7 Luis Finotti wrote:

Here is one with your suggested change: 
https://web.math.utk.edu/~finotti/misc/jl1.out

Here is one with the original version: 
https://web.math.utk.edu/~finotti/misc/jl2.out

the line:
 
calling init: /usr/lib/x86_64-linux-gnu/libgivaro.so.9

is definitely indicating that you are picking up a system libgivaro.

Perhaps you can check in the same way which libgivaro gets linked when you 
run sage in a way where you don't get the "undefined symbol" error? If it's 
a different library then the system library is perhaps the problem.

-- 
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/96e2ad55-2d7e-4400-9b66-5e5221b62aaen%40googlegroups.com.


Re: [sage-support] Re: sage-10.0 not working in Jupyter Lab

2023-05-30 Thread Nils Bruin
On Tuesday, 30 May 2023 at 06:09:23 UTC-7 Luis Finotti wrote:


I looked at it, but I cannot tell if it is really the same issue, or how I 
could check.

well ... it looks like the symbol that is found undefined is indeed of the 
type mentioned there. So that would suggest that indeed a system givaro is 
picked up while sage is apparently compiled with a "too advanced" c++ ABI 
for that library. However, you're not getting errors when you just run 
sage-10.0, so it would seem there is a givaro library that can satisfy the 
needs (it probably built its own givaro)

So in your case there seems to be something about the environment in which 
jupyter starts sage that confuses the library resolution process. I imagine 
it could be something where juoyter runs using a python that has its own 
venv and that the initialization of sage (which should set up its venv) 
somehow misses overriding something or erroneously inherits something from 
the jupyter venv. 

In that case I would expect this issue was basically always present, but 
has only recently become relevant because now the system givaro doesn't cut 
it any more.

-- 
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/24724ea0-edcc-4470-8b30-56cde325caf2n%40googlegroups.com.


[sage-support] Re: sage-10.0 not working in Jupyter Lab

2023-05-29 Thread Nils Bruin
On Monday, 29 May 2023 at 10:51:27 UTC-7 Luis Finotti wrote:

Any ideas on how to fix it?  Is it just me, or a bug with version 10.0?  I 
followed the same steps I've always followed: 
https://doc.sagemath.org/html/en/installation/launching.html#setting-up-sagemath-as-a-jupyter-kernel-in-an-existing-jupyter-notebook-or-jupyterlab-installation

I guess, to rule out that it's not something weird with jupyterlab, you'd 
want to try "jupyter notebook" as well and see if the kernel misbehaves 
then as well (but it would be really weird if it didn't because lab and 
notebook will be starting their kernels in exactly the same way)

the problem is this symbol:
_ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char
so perhaps if the problem is sage 10.0-specific: did Givaro get upgraded in 
10.0? Perhaps you're picking up a different/old Givaro when starting the 
kernel whereas starting sage "properly" manages to find a givaro built 
by/for sage 10.0?

You can check: 
$HOME/.local/share/jupyter/kernels/sagemath/kernel.json

what command is used to start sage. You could check if that command (bare) 
works and if it works if you execute " --python"
and then "from sage.all import *"

It could be that the sage script itself got changed and somehow doesn't set 
the environment as it needs to be to resolve the givaro library properly.

I'm sorry, I don't really have a ready-made solution for you. Hopefully 
this helps in finding what's wrong and/or may jog someone else into 
responding.

-- 
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/046e9888-80e6-4aec-bbd0-3960f3202673n%40googlegroups.com.


[sage-support] Re: sage-10.0 not working in Jupyter Lab

2023-05-29 Thread Nils Bruin
On Monday, 29 May 2023 at 07:39:33 UTC-7 Luis Finotti wrote:

 
ImportError: /home/finotti/src/sage-10.0/src/sage/matrix/
matrix_modn_dense_float.cpython-311-x86_64-linux-gnu.so: undefined symbol: 
_ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char
_traitsIcESaIcEEEB5cxx11Ev

Any ideas on what is wrong?

That looks like a linking error. Probably it's picking up a library from a 
different sage install. Did you check that sage-10.0 runs fine by itself? 
Did you check that sage-10.0 runs fine with its "own" notebook, using "sage 
--notebook"?

If those do work then I expect that the kernel you point jupyterlab to ends 
up starting sage with at least part of the environment correct for 
sage-10.0 (the file you get the error in does lie in sage-10.0) but 
probably not quite with the right venv set up.
 

-- 
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/7c35c276-b499-4e7a-8243-533dfe164cdan%40googlegroups.com.


[sage-support] Re: test for floats and co.

2023-05-03 Thread Nils Bruin


On Wednesday, 3 May 2023 at 08:58:35 UTC-7 Nils Bruin wrote:

However, be careful:

sage: A=matrix(RR,2,2,[1,2,3,4])
sage: parent(A).is_exact()
True

because matrix rings presently aren't aware of inexactness of their base 
rings. 


This is something that is considered a bug; see 
https://github.com/sagemath/sage/issues/34247

-- 
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/3fbe5f77-bd0d-4da3-bce8-281c0a9a6f52n%40googlegroups.com.


[sage-support] Re: test for floats and co.

2023-05-03 Thread Nils Bruin
On Wednesday, 3 May 2023 at 08:21:39 UTC-7 G. M.-S. wrote:


Related to a recent discussion, is there a (simple) way to find whether an 
expression contains non exact explicit numbers?

For symbolic expression you should probably walk the entire expression tree.

For sage objects, examining the parents involved should do the trick:

sage: QQ.is_exact()
True
sage: RR.is_exact()
False

However, be careful:

sage: A=matrix(RR,2,2,[1,2,3,4])
sage: parent(A).is_exact()
True

because matrix rings presently aren't aware of inexactness of their base 
rings. So you should walk the construction of a parent and see if there are 
any inexact constituents:

sage: parent(A).construction()
(MatrixFunctor, Real Field with 53 bits of precision)

 

-- 
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/05ec01f7-eef6-44a9-8c25-668821efa8b7n%40googlegroups.com.


[sage-support] Re: '' in CC fails

2023-05-03 Thread Nils Bruin
On Wednesday, 3 May 2023 at 08:11:25 UTC-7 G. M.-S. wrote:


This gives an error:

sage: '' *in* CC

[…]



^

SyntaxError: invalid syntax

It looks like this error comes from the fact that "eval('')" raises this.  
Apparently an empty string is not valid python for the parser. It is a 
little strange that an empty string is getting parsed to test for 
membership in CC. Many non-empty strings that are invalid python code do 
return "False", so it looks like the empty string ends up in a wrong code 
path somewhere. Worth a bug report, I'd say.

-- 
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/e999819e-a82e-4b9c-9599-3d8b4d6e10b9n%40googlegroups.com.


[sage-support] Re: A very short introduction to Sage

2023-04-17 Thread Nils Bruin
Nice work!

For saving images of 3d-pictures: In the jupyter notebook with the 
"threejs" viewer you can click on the "i" in the lower right corner. That 
gets you a menu from which you  can "sage as png". It will save a snapshot 
of what you're viewing. You can also get camera and viewpoint from that 
menu, but I don't know what you can then do with that.

3d plots also have a "save_image" method that can save the image. Of 
course, choosing the camera point is rather essential for getting a nice 
picture. I'm not sure if we now finally have options for setting camera 
position and direction (and viewport angle) that influence the picture 
generated by save_image.

-- 
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/f63e5690-8c6f-494c-ba5a-23b0b81f887en%40googlegroups.com.


Re: [sage-support] Current advice for generic SageMath install advice

2023-03-29 Thread Nils Bruin
On Wednesday, 29 March 2023 at 13:46:04 UTC-7 Matthias Koeppe wrote:

On Wednesday, March 29, 2023 at 1:33:07 PM UTC-7 Nils Bruin wrote:

$ sage --help
...
Sage-the-distribution options:
  --optional  -- list all optional packages that can be installed
  --experimental  -- list all experimental packages that can be 
installed
  --info [packages]   -- print the SPKG.txt or SPKG.rst of the given 
packages,
 and some additional information.
  -i [packages]   -- install the given Sage packages


This part of the help comes from build/bin/sage-site. Usually in binary 
distributions, this is not present.
On which distribution do you see this?

Source distribution! It didn't cross my mind this could be different on 
binary builds. 

-- 
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/df1de793-464f-4173-9115-bd33599ad36bn%40googlegroups.com.


Re: [sage-support] Current advice for generic SageMath install advice

2023-03-29 Thread Nils Bruin
On Wednesday, 29 March 2023 at 13:06:25 UTC-7 Matthias Koeppe wrote:

On Tuesday, March 28, 2023 at 10:18:23 PM UTC-7 Nils Bruin wrote:


[...] leads me to believe that it's probably nor possible to install 
pynormaliz via "make" in a binary distribution.


If you install Sage from a binary distribution, then there is no relation 
whatsoever to a source tree of Sage.

right ... with "make" it's indeed pretty clear that it's hard to find the 
place where you could even run this. With "sage -i" some idle hope was 
raised that that would still work in a binary distribution. If it doesn't 
(and/or if it never did) then that would be an extra reason to deprecate 
it. It is currently still provided:

$ sage --help
...
Sage-the-distribution options:
  --optional  -- list all optional packages that can be installed
  --experimental  -- list all experimental packages that can be 
installed
  --info [packages]   -- print the SPKG.txt or SPKG.rst of the given 
packages,
 and some additional information.
  -i [packages]   -- install the given Sage packages

-- 
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/c6018dc4-7d12-47d3-ab8d-ebb9d130b04dn%40googlegroups.com.


Re: [sage-support] Current advice for generic SageMath install advice

2023-03-28 Thread Nils Bruin
On Tuesday, 28 March 2023 at 21:06:26 UTC-7 Matthias Koeppe wrote:

On Monday, March 27, 2023 at 6:34:50 PM UTC-7 Nils Bruin wrote:

In my experience, sagelib needs rebuilding to interface with normaliz (I 
think it's "make normaliz pynormaliz" nowadays, or perhaps one needs a pip 
install).


No, there is no such build-time dependency. And "make pynormaliz" suffices; 
it builds normaliz and its dependencies.

If I recall correctly, "make pynormaliz" did trigger a rebuild of sagelib, 
with quite a bit of cython action. This leads me to believe that it's 
probably nor possible to install pynormaliz via "make" in a binary 
distribution.

If in conda installing "pynormaliz" works fine without sagelib needing to 
be rebuilt then that is great. I think it does mean that in binary 
distributions, optional packages need to be installed via a package manager 
outside of sage. So "spkg" is only for source-based installs.

-- 
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/f1bab22f-3e3f-4833-8a82-4b7a20b8e1a6n%40googlegroups.com.


Re: [sage-support] Current advice for generic SageMath install advice

2023-03-27 Thread Nils Bruin
On Monday, 27 March 2023 at 17:47:54 UTC-7 Isuru Fernando wrote:


We used to have separate architecture specific builds, but `sage` is now a 
meta-package that is architecture neutral (i.e. noarch).
So, you get sage-9.8 for all architectures. We support sage-9.8 for the 
following OS and architecture combinations
- linux-x86_64  (glibc>=2.12, most distros after 2010)
- linux-aarch64  (glibc>=2.17, most distros after 2014)
- macos-x86_64  (macos>=10.9)
- macos-arm64  (macos>=11.0)
You can have a look at https://anaconda.org/conda-forge/sagelib to see the 
architecture-specific builds.


Thanks! I was hoping for an answer like that.Then it sounds like conda is 
presently the best option to get up to date binary sage.
 

> Also: if students want to use packages like normaliz, can they install 
those on binary installs? When I do it on source-built versions, it 
triggers extensive recompilation.

With conda, you can install binary packages for normaliz and thousands of 
other packages into the same environment as sage.


I'm not sure that's quite enough. In my experience, sagelib needs 
rebuilding to interface with normaliz (I think it's "make normaliz 
pynormaliz" nowadays, or perhaps one needs a pip install). I would expect 
that the binary distribution of sage for conda is built without 
normaliz/pynormaliz support, because those are optional packages. 
Installing these as prerequisites in conda wouldn't automatically activate 
the interfaces in sagemath. Does conda do something to get that to work? 
Has sagemath grown better at dynamically detecting libraries to interface 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/5a6a27ad-750d-4bfc-86d6-a354f5e6a0e2n%40googlegroups.com.


[sage-support] Current advice for generic SageMath install advice

2023-03-27 Thread Nils Bruin
What would the current (Spring 2023) easiest instructions be for people to 
install sage? I'm asking in support of an install-fest for students, so the 
objective is to have easy solutions for giving students access on whatever 
platform they have available.
I know about cloud-based solutions, so I'll definitely point them to those. 
I'm asking for "the next step up".

In the install advice I see:
for OSX:
 - binary build of SageMath 
 (looks like an 
excellent solution)
- https://anaconda.org/conda-forge/sage (would be a great place to point 
students to, because it's a rich environment for computational software). 
However: https://anaconda.org/conda-forge/sage seems to indicate that 
various architecture-specific builds are woefully outdated: "noarch" seems 
to be on point, but the architecture-specific ones seem stuck on 9.2. Am I 
reading the info wrong? Obviously I don't want to point people to 9.2 
installs.

for windows:
 - OK WSL; that's great. However, it looks like Ubuntu would be the easiest 
linux distribution to get and as far as I can see, Ubuntu has 9.5 packaged 
at most? That's not great either.
 - conda: see above

for linux:
 - same thing.
 - conda: see above.

So is building from source the only way nowadays? That's sad. I'm fine 
doing that for myself, but for an installfest, that's really not feasible. 
Probably some machines will go in thermal meltdown as a result! Or should I 
just send them to 9.2 and 9.5 etc.

Also: if students want to use packages like normaliz, can they install 
those on binary installs? When I do it on source-built versions, it 
triggers extensive recompilation.

-- 
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/d1717bce-b359-4f83-902d-68edc2399d2dn%40googlegroups.com.


Re: [sage-support] sagemathlib only building single-threaded

2023-02-11 Thread Nils Bruin
On Saturday, 11 February 2023 at 01:51:47 UTC-8 Dima Pasechnik wrote:
>
>make -j8 normaliz pynormaliz
>
> "sage -i"  is obsolete - at least in my mind :-)
OK -- thanks! so what used to be "spkg"s are now makefile targets. That 
reduces the possibility of having "third party" spkgs -- I guess that means 
they should be packaged as "pip" packages instead.

Also for this, sage itself actually instructed me to install it with `sage 
-i`, so if "make" is now preferred, we should change docs on that. I think 
it even suggested something like "!sage -i normaliz" which is difficult to 
find a make analogue of.

-- 
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/661123bb-17ea-4436-8f91-8849b96f7484n%40googlegroups.com.


Re: [sage-support] sagemathlib only building single-threaded

2023-02-10 Thread Nils Bruin
On Tuesday, 7 February 2023 at 09:56:06 UTC-8 Dima Pasechnik wrote:
> I don't think setting MAKE is a good idea.
> 
> Did you try simply
> 
 >   make -j8 build

This actually causes a bit of a problem when you want to install additional 
packages, like `sage -i normaliz pynormaliz`: I wouldn't know how to pass 
the "-j8" option to the implicitly called make in that situation. 

-- 
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/b004c7b4-d4ca-4ced-817a-08a2b30a4335n%40googlegroups.com.


Re: [sage-support] sagemathlib only building single-threaded

2023-02-07 Thread Nils Bruin
On Tuesday, 7 February 2023 at 09:56:06 UTC-8 dim...@gmail.com wrote:
I don't think setting MAKE is a good idea.

Did you try simply

 make -j8 build
 
Thanks! I've tried "touch src/sage/structure/*" -- that triggers quite a 
large part of sagemathlib to be rebuilt. It used only 4 processes during 
cythonization (when it was running just python processes), but it happily 
used in the range of 8 processes during compilation (and that's the much 
more expensive phase).

It reported less than 10 minutes real time for about 60 minutes user. With 
the previous single thread, it took about 30 minutes (real and user). I 
don't know if that's because this is on a 4-core machine with 
hyperthreading or because of other bottlenecks.

Documentation I was able to find is still recommending MAKE="...". So we 
should probably change that now that we have a more make-centric build 
system.

-- 
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/7653bddd-bcc0-4724-a685-64f9b5e8ec12n%40googlegroups.com.


[sage-support] sagemathlib only building single-threaded

2023-02-07 Thread Nils Bruin
For the trac-to-github transition I decided to move over my git upstream 
and origin. That all seems to have worked fine and I pulled the latest 
develop and ran "make configure" (was already happy) and then "make". This 
worked fine for the most part and with export MAKE="make -j8" it went quite 
quickly too. Until I got to "sagemathlib". It seemed to cythonize quite 
quickly but then spent about 30 minutes compiling and did so with a single 
job at a time.

I think previously sagemathlib built in parallel. What settings should I 
flip to convince the build system to build sagemathlib with multiple 
processes in parallel?

-- 
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/22f0873f-aeaf-4a83-9905-0fca0992c780n%40googlegroups.com.


[sage-support] Re: Somethog in rotten is the state of Maxima...

2022-10-09 Thread Nils Bruin
On Sunday, 9 October 2022 at 08:45:36 UTC-7 Emmanuel Charpentier wrote:

> ... and all is not fresh in Sympy's realm either.
>
> Full details in [this ask.sagematjh.org question](
> https://ask.sagemath.org/question/64344/solving-a-system-of-linear-equations-with-complex-numbers-yields-false-solution/?answer=64363#post-id-64363
> ).
>
> ... 

> Advoce requested on how to file tickets/bug reports efficiently.
>
For now, it's still through trac, I believe, but in a few weeks it would 
but a through github issues. With the reproduction in maxima standalone, 
especially because the erroneously solved system is obtained by 
specialization from a system that is solved correctly, this can be reported 
"upstream" to maxima and I'm sure it will get due attention eventually.

Their bug reporting hasn't changed, I think: 
https://sourceforge.net/p/maxima/bugs/ 

-- 
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/5a34ebb5-1f70-492f-a358-aa13226dc014n%40googlegroups.com.


[sage-support] Re: Citing Sage properly in a paper

2022-09-04 Thread Nils Bruin
On Sunday, 4 September 2022 at 10:31:42 UTC-7 george...@gmail.com wrote:

> All,
> I am about to submit a math paper to a journal. I would like to include a 
> proper citation for Sage. The Sage web page says:
>
> "Also, be sure to find out which components of SageMath, e.g. NumPy, PARI, 
> GAP, Sage-Combinat, that your calculation uses and properly attribute those 
> systems."
>
> My question is: which component am I using?
>
> I am doing the following:
>
> x, y, z = var('x, y, z')
> factor(x^6+y^6)
> factor(x^6-y^6)
> expand((3*x^2+y^2)*(x^2+3*y^2))
>

That kind of use generally attracts a "using a computational algebra 
system" since it's such a routine operation. In fact, people wouldn't blink 
at no explanation at all or a comment about "manual computation".

Otherwise, on https://wiki.sagemath.org/Publications_using_SageMath

it lists the following code to figure out what components you use 
(probably):

sage: from sage.misc.citation import get_systems
sage: get_systems("integrate(cos(x^2), x)")
['MPFI', 'ginac', 'GMP', 'Maxima']

If you don't have it enabled already, it will give you a warning that 
cython profiling must be enabled to get reliable result. Indeed, in your 
case it would only report "ginac" (really the form "pynac" that sagemath 
uses for its symbolics) as well as "Maxima".
Note that this tool may identify externally developed software that is used 
in sage, but it doesn't look at which parts of the sage library are used. 
There are several state-of-the-art implementations made fully in the 
sagemath library of very specialist algorithms. It makes sense to look at 
authorship of some of the top-level routines you use to see if there are 
papers you can find that describe the implementation (the documentation 
does have literature references) and then refer to those papers, since in a 
sense you are using their result.


-- 
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/48d61579-af83-4d7d-a0ab-0d3966363b34n%40googlegroups.com.


[sage-support] Re: Create the Lorentz group in Sagemath.

2022-06-01 Thread Nils Bruin
On Wednesday, 1 June 2022 at 05:41:33 UTC+2 hongy...@gmail.com wrote:

> On Wednesday, June 1, 2022 at 1:55:45 AM UTC+8 Nils Bruin wrote:
>
>> The "GO" mentioned here should correspond to the O(3;1) (or perhaps 
>> O(1;3) ) mentioned in the wikipedia article.
>>
>
> Do you mean that these two ways of writing are a matter of convention?
>

setting t,x,y,z as coordinates on 4-space, O(3;1) is the group of matrices 
preserving the quadratic form t^2+x^2+y^2-z^2 (three plusses, one minus) 
and O(1;3) the group of matrices preserving the quadratic form 
t^2-x^2-y^2-z^2 (one plus, three minuses).
Hence, the definitions of the two groups are different: it's not just 
convention. The two groups are isomorphic, though, and one isomorphism is 
given by swapping t and 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/3f021d93-7d5f-4eed-8f45-8c700d9ee857n%40googlegroups.com.


[sage-support] Re: Create the Lorentz group in Sagemath.

2022-05-31 Thread Nils Bruin
The "GO" mentioned here should correspond to the O(3;1) (or perhaps O(1;3) 
) mentioned in the wikipedia article.

The problem with the "real numbers" is that representing many elements 
exactly in it is complicated. For many algebraic questions, you can 
probably get away with considering the group over Q (or some finite 
extensions).

I'm not entirely sure if the connected component SO^+ is readily 
implemented in sage.

"creation" of a mathematical object (particularly an infinite one) is a 
rather relative notion anyway: technically speaking

class LorentzGroup:
pass

can be passed off as a class whose instances represent the Lorentz group: 
there are just many features that haven't been implemented (yet). It's 
probably worth checking if the object described above meets your needs. If 
not, then describing a little more about what you need might help an expert 
in giving you further tips.
On Tuesday, 31 May 2022 at 08:43:54 UTC+2 hongy...@gmail.com wrote:

> On Sunday, May 29, 2022 at 6:27:18 PM UTC+8 Nils Bruin wrote:
>
>> It depends a little on what coefficients you want. If you're happy with 
>> rational numbers then this should do the trick:
>>
>
> As far as the Lorentz group is concerned, I think it should be 
> constructed on real numbers filed in general, but I'm not sure if sage math 
> has the corresponding implementation on real numbers filed.
>  
>
>>
>> G = diagonal_matrix(QQ,4,[-1,1,1,1])
>> lorentz_group = GO(4,QQ,invariant_form=G)
>>
>> which just constructs the group of (in this case QQ-valued) matrices that 
>> preserve the quadratic form -t^2+x^2+y^2+z^2. Depending on what you 
>> actually want to do with it, you may be more interested in SO
>>
>
> SO only includes the part where the determinant is equal to 1 in GO, which 
> is not in line with the requirements of Lorentz group, IMO.
>
> or perhaps the construction of its lie group/algebra.
>>
>
> The Lorentz group is *a Lie group of symmetries of the spacetime of 
> special relativity, as described here* [1]. So, I'm not sure if your 
> above code snippet also corresponds to a *Lie group.*
>
> [1] 
> https://en.wikipedia.org/wiki/Representation_theory_of_the_Lorentz_group 
>
> Regards,
> HZ
>  
>
>>
>> On Thursday, 26 May 2022 at 09:11:55 UTC+2 hongy...@gmail.com wrote:
>>
>>> How can I create the Lorentz group, as described here [1], in Sage math?
>>>
>>> [1] https://en.wikipedia.org/wiki/Lorentz_group#Basic_properties
>>>
>>> Regards,
>>> HZ
>>>
>>>

-- 
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/6fa167ff-4d20-4f0d-91c4-b544340cb740n%40googlegroups.com.


[sage-support] Re: Create the Lorentz group in Sagemath.

2022-05-29 Thread Nils Bruin
It depends a little on what coefficients you want. If you're happy with 
rational numbers then this should do the trick:

G = diagonal_matrix(QQ,4,[-1,1,1,1])
lorentz_group = GO(4,QQ,invariant_form=G)

which just constructs the group of (in this case QQ-valued) matrices that 
preserve the quadratic form -t^2+x^2+y^2+z^2. Depending on what you 
actually want to do with it, you may be more interested in SO or perhaps 
the construction of its lie group/algebra.

On Thursday, 26 May 2022 at 09:11:55 UTC+2 hongy...@gmail.com wrote:

> How can I create the Lorentz group, as described here [1], in Sage math?
>
> [1] https://en.wikipedia.org/wiki/Lorentz_group#Basic_properties
>
> Regards,
> HZ
>
>

-- 
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/82d914e8-cef4-4a30-9ac4-ef6c7e2d341bn%40googlegroups.com.


[sage-support] Re: Need help with symbolic polynomials,

2022-05-05 Thread Nils Bruin
On Thursday, 5 May 2022 at 02:03:30 UTC-7 Ha wrote:

> For Example:  I tried this:
>
> f(X[1] = 1, X[2] = 5) 
>
> and got this error:
>
> File "", line 10 f(X[Integer(1)] = 
> Integer(1), X[Integer(2)] = Integer(5)) 
> ^ SyntaxError: keyword can't be an expression
>
> Indeed, that does not work. The syntax f(x0=1,x1=5) works via python's 
keyword parameter mechanism. For it to work. the keyword argument used (x0 
and x1 in the example) must match the print names of the variables of the 
polynomial ring. Those print names are x0,x1,...,x9 in your example. The 
names X[1] and X[2] do not match. What's worse: they are not valid python 
keywords, as the error says! So you don't even get to the matching phase.

What you would need is the *value* of X[1], X[2] instead (which is 'x1' and 
'x2' respectively). 

Python has some magic that allows you to specify the keyword names through 
expressions:

f(**{X[1]: 1, X[2]: 5})

should do the trick. It basically evaluates to f(**{'x1': 1, 'x2': 5}), and 
f(x1=1,x2=5) basically translates to f(**{'x1':1,'x2':5}) as well.

The keyword trick is really just there for convenience. The workarounds 
above may reduce convenience by quite a bit, so perhaps you prefer to just 
use "full evaluation" instead. For instance, for your example, you could do

v=list(X)
v[1]=1
v[2]=5
f(v)

(as presented here, it's less compact, but in your actual application it 
may be more direct)

-- 
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/2b14d6bd-f4e6-4f42-97dc-4109a7f605a0n%40googlegroups.com.


[sage-support] Re: Need help with symbolic polynomials,

2022-04-29 Thread Nils Bruin
Can you explain a little more about what does not work? When I try to 
replicate your example, everything works as expected:

sage: n=2
: F = GF(7)
: Rx=PolynomialRing(F,n,'x')
: X=Rx.gens()
sage: f=X[0]+X[1]
sage: f(x0=1)
x1 + 1
sage: f(x0=1,x1=1)
2

Alternatively you can evaluate using positional arguments: in a polynomial 
ring there is a clear implied order on the generators, so the following is 
unambiguous (and accepted):

sage: f(1,1) #gives values for x0 and x1 in order
2
On Friday, 29 April 2022 at 04:33:36 UTC-7 Ha wrote:

> Hi,
> I need to create a polynomial ring with arbitrary number of variables [n] 
> and 
> at some point during computation should be able to substitute values
> for a subset of variables.   I can use the following method to generate
> my ring:
> ##
> n=2
> F = GF(7)
> Rx=PolynomialRing(F,n,'x')
> X=Rx.gens()
> ##--
> But if I take an element f = x0+x1 then how to substitute values for x0 
> and x1?
> In general I could use f(x0 = 1, x1 = 1) but with above method this 
> doesnot seem to work. 
>
> Any help is highly appreciated
>

-- 
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/4e03c52d-f5a8-44fb-a794-886edde344afn%40googlegroups.com.


Re: [sage-support] Re: 2 questions on var

2022-04-16 Thread Nils Bruin
On Saturday, 16 April 2022 at 05:37:16 UTC-7 list...@gmail.com wrote:

>
> Thanks Samuel and Emmanuel.
>
> Follow up question:  Why does
> var('lambda',n=1)
> fail?
>

Because the code in question tests the string actually passed in for 
whether it's a valid python identifier.

Probably this is because the "n" optional argument was only added later. 
However, there's been quite a discussion on what the appropriate binding 
behaviour should be. One option would be to bind the actual returned result 
(a tuple of the constructed symbols) to a name in the current namespace. 
i.e., the result of

x = SR.var('x',n=3) 

For that behaviour, the passed-in name would have to be a valid identifier. 
So to future-proof sage, perhaps it's better to have this stricter check.

You can create symbols without the check: SR.symbol('lambda') works just 
fine. To create the symbols you'd like, you can do:

L = (SR.symbol("lambda{}".format(i)) for i in range(3))

binding them to corresponding symbols would require a little more work . 
It's basically

for c in L:
globals()[str(c)] = c

which works when typed in as-is, but requires some more trickery if it is 
wrapped in a function in some module, due to the semantics of the actual 
"globals()" call in python.

[in general, for anything other than direct interactive use, you should 
probably not rely on binding injections]

-- 
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/99f5b3eb-5e57-4f3f-922c-4a907cea4ba2n%40googlegroups.com.


[sage-support] Re: 2 questions on var

2022-03-06 Thread Nils Bruin
On Sunday, 6 March 2022 at 09:13:42 UTC-8 list...@gmail.com wrote:

>
> Beginner's questions, I guess.
>
> Some time ago, Emmanuel Charpentier wrote
>
> var("v", n=2)
>
> which gives
>
> (v0, v1)
>
> Where is this documented?  I have been unable to find keywords for var 
> other than domain and latex_name.  Are there any others?
>

This is documented on SR.var , which is slightly different from the 
top-level "var" you are referring to. It looks like the documentation on 
the top-level one wasn't updated when the feature was added to SR.var. 
Since top-level var just wraps SR.var, it automatically got the feature too.
 

> Another question:
> I have learnt to write
> x,y,z=var('x,y,z')
>

You can do that, but with the top-level var it's not necessary (this is 
exactly where it differs from SR.var) :
it will inject bindings for the created symbols in the current name space. 
This is a hack that is convenient for interactive use. In library code, you 
must use SR.var instead, in which case you have to write

x,y,z = SR.var('x,y,z')

( with just "SR.var('x,y,z')" you'd create the symbols but you wouldn't 
bind them to anything).

Is it possible to do the same for
> v0,v1,v2=var('v', n=3)
> without having to write explicitly the LHS?
>

Yes, that already works. If you use 

var('v', n=3)

the names v0,v1,v2 in your current scope will be bound to the newly created 
symbols.

There's been discussion about this when it was implemented:

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

-- 
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/316f7db3-2c35-4766-8de1-1dbe14958943n%40googlegroups.com.


[sage-support] Re: type problem, I think

2022-02-11 Thread Nils Bruin
On Friday, 11 February 2022 at 07:51:17 UTC-8 mille...@gmail.com wrote:

> I'm trying to do some least squares linear algebra. I built a matrix from 
> lists that I converted into column vectors and used the 'augment' function.


Small detail, but slightly more efficient (it may not matter for your 
application) is to just give sage a list of lists and create a matrix from 
that directly. It will cost less copying around than iteratively augmenting 
the matrix. For the most part, matrices are stored row-major (i.e., 
basically as an array of rows), so column augmentations require more 
fiddling internally than row operations. Better to just construct the 
matrix from rows and then transpose if required.

When I type() an entry in the vector, I get:
>
> 'sage.modules.free_module_element.FreeModuleElement_generic_dense'
>
> Important part is actually the *parent* of the vector, and more 
specifically its *base ring*, i.e., ask v.base_ring()

In your case, I think the base ring should be some type of real field (if 
you're doing least-squares ...). If it is the symbolic ring, you probably 
want to change that first.

To convert a vector to a polynomial with coefficients equal to the entries 
in the vector, you can do:

R=v.base_ring()
R['s'](v)
 
(or, if you want the leading term to be the leftmost entry, i.e., a 
reversed vector):

R['s'](v[::-1])

or

R['s'](reversed(M['0']))

If you're going to be using the ring R['s'] a lot, it will be better to 
define

Rs.=R[]

and use

Rs(v).

-- 
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/fa55af14-efb3-4505-b2d9-de55ca8a3f1fn%40googlegroups.com.


[sage-support] Re: Eigen spaces of algebraic matrices broken ?

2022-02-02 Thread Nils Bruin
On Monday, 31 January 2022 at 15:19:49 UTC-8 Emmanuel Charpentier wrote:

> As advertised, an atempt at a minimal (non-)working example :
>
> # Reproducible minimal example
> with seed(0): M = matrix(AA, 3, 3, lambda u,v: AA.random_element())
> # Working ring
> WR = M.base_ring().algebraic_closure()
> # A variable to carry the eigenvalues
> l = SR.var("l")
> # Vector of unknowns for the eigenvectors
> V =vector(list(var("v", n=2))+[SR(1)])
> # M.eigenvalues does not return. Get them by hand
>
> Actually, for me on 9.5beta9, `M.eigenvalues()` works just fine. So the 
problem is perhaps just platform-dependent, or there is a very recent 
change that affected this (my M gets just integer entries from {-2..2})

Looking at the example a bit: you'd be forcing sage to work with a huge 
compositum if you're actually getting a 3x3 matrix with non-rational 
algebraic entries: even if they are just independent quadratics, you'd end 
up in an extension of degree 2^9. This will only work in very limited 
cases. 

One way to get this kind of thing to work is to work with high-precision 
floats, use numerically (fairly) stable methods to compute the desired 
answer, and then try to recognize it as algebraic. You probably only care 
if it is one of fairly low height. You can then try to turn your 
computation into proof, possibly by tracing through height bounds and 
showing your precision was sufficient to identify the right solution 
uniquely.

You could work on automating this kind of thing, but I doubt you'd ever get 
it to work on a reasonable range of examples; just because the height 
bounds would be rather ill-behaved.

You can still trace the root cause further on this and perhaps improve 
arithmetic in AA a bit, but the general shape of the problem you're trying 
to deal with does not look promising for generally performant methods. 

-- 
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/0536dc64-3013-428d-b321-a474890543b0n%40googlegroups.com.


[sage-support] Re: Eigen spaces of algebraic matrices broken ?

2022-01-30 Thread Nils Bruin


On Saturday, 29 January 2022 at 13:51:14 UTC-8 Emmanuel Charpentier wrote:

> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py
>  
> in pari_field(self) 
>
>>3134 if self._pari_field is None:
>>3135 pari_pol = self._field.pari_polynomial("y")
>> -> 3136 self._pari_field = pari_pol.nfinit(1)
>>3137 return self._pari_field
>>3138 
>>
>> cypari2/auto_gen.pxi in cypari2.gen.Gen_base.nfinit()
>> KeyboardInterrupt:
>>
>>
>> nf_init is a perfectly respectable place to hang. After interruption, can 
you "%debug"  and see what the value of pari_pol is? I'd expect that nfinit 
determines the ring of integers, which means factoring the discriminant. 
[QQbar shouldn't need the ring of integers of element arithmetic, but this 
has been stumbled on before: QQbar often tries to find an "optimized" form 
of the number field, which for small examples is often quite doable and, if 
you end up doing a LOT of arithmetic in the same field, is often worth the 
investment. However, because of factoring of the discriminant, it's fully 
subexponential in complexity, whereas all the things QQbar needs to do are 
polynomial time. So we already know that QQbar will do things with the 
wrong theoretical asymptotic complexity. That can come back and bite you, 
when reality and asymptotics start behaving similarly (which happens 
eventually ... asymptotically speakinh)

-- 
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/41718278-dace-4909-9dfe-48c404efcc87n%40googlegroups.com.


[sage-support] Re: Snowman

2022-01-14 Thread Nils Bruin
In a blizzard? 

P=sage.plot.graphics.Graphics()
P.show(axes=False)

In general, though, this is not a very mathematical question, nor one for 
which a computer algebra package is going to be the best tool. Perhaps if 
you give some more context, someone will be able to give you more useful 
help.

On Friday, 14 January 2022 at 08:37:38 UTC-8 iva.po...@gmail.com wrote:

> Hey!
>
> Does anyone know how to draw a snowman?
>
> Iva
>

-- 
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/df5e4b5d-61c1-4c07-be53-92363f3802a6n%40googlegroups.com.


[sage-support] Re: substitution in list

2021-12-28 Thread Nils Bruin
That's a python question. See for instance,

https://stackoverflow.com/questions/2582138/finding-and-replacing-elements-in-a-list

If you scroll down, there are some suggestions there that deal with 
multiple replacements as well

On Tuesday, 28 December 2021 at 06:09:35 UTC-8 cyrille piatecki wrote:

> First I have seen that perhaps my question has an answer in AskSagemath 
> but currently it doesn't answer.
>
> Suppose I have a list of variables x_1, x_2, x_3,...x_n
>
> I have some sub-list of variables say [x_4, x_1, x_6...]. But whenever 
> x_4, x_5,x_6 belong to this list I want the substitution x_4 ->epsilon_0, 
> x_5 -> epsilon_1... (this is an only an example. Is there a way to do this 
> in the same way that we have a substitution in a fonction in Sagemath?  
>

-- 
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/764fe9f5-d8b3-4033-afcf-183474f5e318n%40googlegroups.com.


[sage-support] Re: regulator

2021-12-27 Thread Nils Bruin
The "regulator" access routine should indeed at least allow to produce the 
regulator with the precision that pari used.

If you look at the source of "regulator" you can see how to get the 
regulator to better precision. If K is your number field, then:

K.pari_bnf().bnf_get_reg().sage()

gets you the regulator straight from pari (pari should really be choosing 
an appropriate working precision here by itself).

I'm not so sure that computing the regulator this way is efficient for 
quadratic extensions: there are way better special algorithms for that 
(continued fractions do a lot of the work already, for instance). The 
general algorithm determines the regulator by determining the class group 
and unit group. So finding the fundamental unit through a regulator 
computation wouldn't really  make much sense.


On Sunday, 26 December 2021 at 12:21:18 UTC-8 Michael Beeson wrote:

> I want to compute the regulator of a real quadratic field Q(sqrt d)  to 
> high precision,
> accurately enough to compute the fundamental unit.  The default 
> breaks at d = 331  where fundamental unit needs more than 53 bits (the 
> precision of doubles).   The documentation says that Pari computes to a 
> higher precision than 
> SageMath.  Also somewhere it says that if you get a good enough 
> approximation to the regulator, it's trivial to refine it to high accuracy. 
>   It refers to "the tutorial"  without a link; I read the Pari-GP tutorials 
> on algebraic number theory without finding any explanation of that remark. 
>   So actually there are two questions here:  point me to an explanation of 
> refining the computation of the regulator,  and secondly,  fix the 
> following code 
> so that it doesn't print "oops"  when d = 331.
>
> gp.set_real_precision(256)  # doesn't seem to do anything
>
> def check_unit(N):
> for d in range(10,N):
> if not is_squarefree(d):
> continue
> K. = QuadraticField(d)
> G = K.unit_group()
> [x,y] = G.gen(1).value()
> x = abs(x) 
> R = K.regulator(None)
> twox = round(exp(R))
> x2 = twox/2
> y2 = round(twox/sqrt(d))/2
> print(d,x,x2,y,y2,exp(R)/2)
> if x != x2 or y != y2:
> print("oops!")
> return 
> if norm_is_negative(x,d):
>   print("norm is negative")
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/3ffe812a-75ec-4804-ac67-6ffc30f27357n%40googlegroups.com.


Re: [sage-support] How do I run sage in python3?

2021-10-23 Thread Nils Bruin
I think Ubuntu 18.04 might only have an old, python2-based, version of 
sagemath packaged:

https://packages.ubuntu.com/bionic/sagemath

https://www.sagemath.org/download.html does host binary builds for 18.04, 
so downloading from there could get you version 9.4, which does run on 
python3. Or you can build from source.

On Saturday, 23 October 2021 at 13:32:03 UTC-7 mob...@gmail.com wrote:

> I use google colab to work with sage. Unfortunately google colab only 
> gives Ubuntu 18.04 version. How can this problem be solved?
>
> суббота, 23 октября 2021 г. в 21:40:18 UTC+3, Jan Groenewald: 
>
>> How did you start python?
>>
>> (and I guess why not use sage directly, but that is another question.
>>
>> Run in a terminal:
>>
>> python3
>> or
>> ipython3
>> or
>> jupyter notebook
>>
>> ... then try again.
>>
>> Regards,
>> Jan
>>
>> On Sat, 23 Oct 2021 at 19:55, Dew Debra  wrote:
>>
>>> I want to run sage scripts using python3
>>> i installed in Ubuntu 18.04
>>> through the command
>>>
>>>   sudo apt-get install sagemath
>>>
>>>   then using  the sage module into a file
>>>  
>>> from sage.all import *
>>>
>>> but the script was launched only in  python2  , but can I run it in 
>>> python3?
>>>
>>>
>>> How do I run sage in python3?
>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/sage-support/daa9a26d-e040-4ed7-b3ea-0694e4b542d6n%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>
>>
>> -- 
>>   .~. 
>>   /V\ Jan Groenewald
>>  /( )\www.aims.ac.za
>>  ^^-^^ 
>>
>

-- 
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/ef16e512-01a0-4224-8666-fbd498293a74n%40googlegroups.com.


[sage-support] Re: differentiation in InfinitePolynomialRing

2021-09-08 Thread Nils Bruin
On Wednesday, 8 September 2021 at 09:24:15 UTC-7 max...@gmail.com wrote:

> Hi Simon,
>
> Thank you for your insight, and let me state that I 
> find InfinitePolynomialRing useful in combinatorics to deal with 
> (truncated) multivariate generating functions with apriori unknown number 
> of variables, and so basic operations (such as differentiation) on 
> polynomials would be very welcome here. Btw, is there 
> InfinitePowerSeriesRing or alike available by any chance?
>
> From what you said, I think it should be easy to fix (making it work) at 
> least ISSUE#2 -- one just needs to extend the underlying finite 
> PolynomialRing with the differentiating variable(s) before delegating the 
> actual differentiation to it.
>
 
I don't think any extending is required: if the differentiation variables 
do no lie in the parent of the representing finite polynomial ring for the 
actual element then the answer is 0.

def derivative(self, *args):
R=self._p.parent()
try:
L=[R(c) for c in args]  
except TypeError:  #perhaps test a little more here
return 
self.parent().zero()
return R(self._p.derivative(*L))

-- 
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/20121a4b-5851-44f0-827c-a61ccb8b7771n%40googlegroups.com.


[sage-support] Re: differentiation in InfinitePolynomialRing

2021-09-08 Thread Nils Bruin
On Wednesday, 8 September 2021 at 07:30:21 UTC-7 Simon King wrote:

>
> As I said, differentiation is not supposed to work. But I (as original 
> author) don't fully understand *why* it sometimes works and how to fix 
> that (by "fix", I mean "make it not work and, in the best case, suggest 
> to convert to a symbolic expression"). 
>
> InfinitePolynomialRing was created for a very narrow purpose, namely 
> computing symmetric Gröbner bases. In particular, calculus was not in 
> the scope. If someone wants to extend its functionality, I wouldn't 
> mind though. 
>
> Hm, I wouldn't say derivatives of polynomials are "calculus". 
Differentiation is perfectly valid formal algebraic operation with 
well-studied properties and many applications in algebraic settings that 
are not covered by "calculus". That doesn't change that the original 
designer of InfinitePolynomialRing didn't put it in the scope, but I think 
we can be a little more enthusiastic about potential attempts at remedying 
that lack in functionality:

>From what Simon describes, differentiation in InfinitePolynomialRing only 
works "by chance". The function "derivative" goes out of its way to make 
sense of its arguments, mainly by putting them into SR (with variable 
degree of success). This is its implementation:

try: 
return f.derivative(*args, **kwds) 
except AttributeError: 
pass 
if not isinstance(f, Expression): 
f = SR(f) 
return f.derivative(*args, **kwds) 

so, if one would simply implement a derivative method on 
infinitepolynomialring elements, then things would work.

-- 
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/3fe3c9b5-98db-406c-b1ac-6a66355af7bdn%40googlegroups.com.


[sage-support] Re: Memory issues when running simple program

2021-09-02 Thread Nils Bruin
I'd suspect the problem is not the ray tracing but the description of the 
object. Probably, `parametric_plot` produces a description of your shape 
with tubular segments and with a min_depth=20 it probably produces *very* 
many of them. So you probably don't get to ray tracing: you're stuck in 
computing the description of the scene. With smaller numbers for min_depth 
and max_depth it produces a picture very quickly and with no visible 
artifacts.

The interface with Tachyon probably ends up constructing the input to 
Tachyon (which is a text-file description) as a big string in memory, so a 
scene with very many geometric shapes would indeed pose a significant 
memory strain (Tachyon would be similarly strained to work with such a 
description).

On Thursday, 2 September 2021 at 10:45:31 UTC-7 brittc...@gmail.com wrote:

> I'm running SageMath 9.2 on windows (and also tried 9.0 on Ubuntu). My 
> specs are: Intel i5-10600K CPU @ 4.10GHz, 32.0 GB RAM, and a RTX 3060 
> graphics card.
>
> When I run the following program, it seems to starts leaking memory until 
> all 32 GB is consumed, then crashes. I may be doing something silly in the 
> below example (though it is roughly copy/paste from 
> http://sporadic.stanford.edu/reference/plot3d/sage/plot/plot3d/tachyon.html
> )
>
> Or perhaps I simply don't have enough memory--which would be odd 
> considering I can ray trace much more complicated objects on Blender with 
> no trouble.
>
> f = lambda t: (t, t^2, t^3)
> t = Tachyon(camera_center=(5,0,4))
> t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.1,  opacity=1.0, 
> color=(1.0,0,0))
> t.light((-20,-20,40), 0.2, (1,1,1))
> t.parametric_plot(f, -10, 10,'t', min_depth=20, max_depth=40)
> t.save(filename='parametric.png', verbose=0, extra_opts='')
>
> Thanks for the time,
> Britt
>

-- 
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/105debfb-61d2-4cf9-8a9d-ec24b9443263n%40googlegroups.com.


[sage-support] Re: Possible bugs in SR

2021-07-08 Thread Nils Bruin
On Thursday, 8 July 2021 at 09:49:18 UTC-7 Emmanuel Charpentier wrote:

> Dear Nils, dear list,
>
> Le jeudi 8 juillet 2021 à 01:01:44 UTC+2, Nils Bruin a écrit :
>
>> I think the main problem in f(x) is a preparser problem: 
>> https://trac.sagemath.org/ticket/11621
>>
>
> This is likely ; I don't see how to check this, but I'll accept it for now.
>
> You can check it in the following way, which makes it behave as the 
problem on the ticket: move the plus at the start of the second line to the 
end of the first line. Now the preparser mangles the string into an 
ungrammatical one, rather than a grammatical one with a different meaning. 

-- 
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/6594e5c2-9001-466a-9f0c-5663432eca56n%40googlegroups.com.


[sage-support] Re: Possible bugs in SR

2021-07-07 Thread Nils Bruin
I think the main problem in f(x) is a preparser problem: 
https://trac.sagemath.org/ticket/11621

The other problems could just be numerical instability. The normal 
precision is 53 bits, which is good for about 16 decimal digits. The 
constants in the formula are more than that, so if there is significant 
cancellation, it may be this is just expected. Perhaps try and evaluatie 
with a larger precision? .n(500) or so? If the answers are now closer then 
it could just be numerical. The factored expression should give a different 
evaluation scheme for what is presumably the same quantity.

On Wednesday, 7 July 2021 at 13:46:33 UTC-7 Emmanuel Charpentier wrote:

> The same ask.sagemath question 
> 
>  
> may have revealed two different bugs in symbolics handling.
> Input interpretation. Raw input, with spaces, indents and newlines : 
>
> f(x) = (3/174465461165747500*pi*(-175*I*pi*x^3 - 3125*(224*pi + 
> 45*sqrt(448*pi + 2025) + 2025)*x^2
> + 17500*I*pi*x)
> *sqrt(92821652156334811582567480952850314403/10*pi^2/(224*pi + 
> 45*sqrt(448*pi + 2025) + 2025)
>   + 9848979414202449817586228719725*pi*sqrt(448*pi + 2025)
>   /(224*pi + 45*sqrt(448*pi + 2025) + 2025) + 
> 771351762089863616280858441176625*pi
>   /(224*pi + 45*sqrt(448*pi + 2025) + 2025) + 
> 659225266976959904108326638192187500*sqrt(448*pi + 2025)
>   /(224*pi + 45*sqrt(448*pi + 2025) + 2025) + 
> 29665137013963195684874698718648437500
>   /(224*pi + 45*sqrt(448*pi + 2025) + 2025))
> /(63*pi^2*x^4 - (504000*I*pi^2 + 67500*I*pi*(sqrt(448*pi + 2025) + 
> 45))*x^3
>   - 300*(560224*pi^2 + 45*pi*(sqrt(448*pi + 2025) + 45))*x^2 + 
> 84*pi^2
>   - (-5040*I*pi^2 - 675*I*pi*(sqrt(448*pi + 
> 2025) + 45))*x))
>
> Single-line reformatted code (deleting blanks, indents and newlines, 
> adding a space before ‘+’ and ‘-‘) 
>
> g(x) = (3/174465461165747500*pi*(-175*I*pi*x^3 - 3125*(224*pi + 
> 45*sqrt(448*pi + 2025) + 2025)*x^2 + 
> 17500*I*pi*x)*sqrt(92821652156334811582567480952850314403/10*pi^2/(224*pi
>  + 45*sqrt(448*pi + 2025) + 2025) + 
> 9848979414202449817586228719725*pi*sqrt(448*pi + 2025)/(224*pi + 
> 45*sqrt(448*pi + 2025) + 2025) + 
> 771351762089863616280858441176625*pi/(224*pi + 45*sqrt(448*pi + 2025) + 
> 2025) + 659225266976959904108326638192187500*sqrt(448*pi + 2025)/(224*pi + 
> 45*sqrt(448*pi + 2025) + 2025) + 
> 29665137013963195684874698718648437500/(224*pi + 45*sqrt(448*pi + 2025) + 
> 2025))/(63*pi^2*x^4 - (504000*I*pi^2 + 67500*I*pi*(sqrt(448*pi + 2025) + 
> 45))*x^3 - 300*(560224*pi^2 + 45*pi*(sqrt(448*pi + 2025) + 45))*x^2 + 
> 84*pi^2 - (-5040*I*pi^2 - 
> 675*I*pi*(sqrt(448*pi + 2025) + 45))*x))
>
> Notwithstanding formatting differences, these functions should be equal ; 
> they are *not* :
>
> sage: f(1).n()
> 418409.917305474 + 1.28757494213663e11*I
> sage: g(1).n()
> 1.39111866114058e-12 + 6.95559330500736e-6*I
>
> factor bug 
>
> sage: F = f.real()^2 + f.imag()^2
> sage: Ff = (f.real()^2 + f.imag()^2).factor()
> sage: G = g.real()^2 + g.imag()^2
> sage: Gf = (g.real()^2 + g.imag()^2).factor()
> sage: F(1).n()
> 1.65784923163565e22
> sage: Ff(1).n()
> 4.77205703148314e29
> sage: G(1).n()
> 4.83802782246652e-11
> sage: Gf(1).n()
> 0.00139260822082924
>
> These two bugs may have a common origin in SR code (pynac comes to mind).
>
> My question is : how to file bugs about these ones, which seem extremely 
> serious (silent errors in basic symbolics abilities) ?
> ​
>

-- 
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/0cd1af34-bb0a-4c7e-a8a0-c3420d7284d7n%40googlegroups.com.


Re: [sage-support] Conveniently running and building sage on Win10

2021-06-01 Thread Nils Bruin
Thank you all! I needed a few steps here that were mentioned on 
aka.ms/wsl2-install :

dism.exe /online /enable-feature 
/featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all 
/norestart

(restart)

wsl --set-default-version 2
wsl --set-version Ubuntu 2

(the last bit took a while to convert an existing install to WSL2)

It's now a lot more in line with the performance I'd expect:

sage: P2.=ProjectiveSpace(QQ,2) 
sage: C=Curve(X^4+Y^4+Z^4) 
sage: S=C.riemann_surface() 
sage: %time S.riemann_matrix() 

On my linux laptop:

CPU times: user 532 ms, sys: 68.9 ms, total: 601 ms 
Wall time: 678 ms 

On the Surface:

CPU times: user 967 ms, sys: 0 ns, total: 967 ms 
Wall time: 1.18 s 

That performance is al least comparable, and could easily be because the 
CPU on the Surface is throttled or somehow a much less capable "core i5" 
than my laptop has (Intel really has made it impossible to tell from their 
serial numbers nowadays).

So with this in place, I'd say: running sage on WSL2 on Windows is quite a 
reasonable solution; WSL1 is 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/0525271f-8c66-4e2a-8de5-8b255655ebb8n%40googlegroups.com.


Re: [sage-support] Conveniently running and building sage on Win10

2021-06-01 Thread Nils Bruin
Thank you! I'm still getting inconclusive results. I've googled "Ubuntu – 
WSL: Am I running version 1 or version 2":

* running "wsl -l -v" in a windows shell gives me:
NAME STATE VERSION
Ubuntu Running 1
Getting a version number at all is apparently an indication of running WSL2.

* running "uname -r" (without options, uname only given back "Linux" which 
I don't think is distinguishing information) I get
4.4.0-19041-Microsoft

I guess 4<19. On the other hand, 4.4 > 4.19, so I'm not sure what that is 
telling me.

In any case: do people get "fair" performance under WSL or WSL2? Does 
Cygwin give better performance? Is development even possible/convenient 
under Cygwin?

My impression (with both my laptop and the Surface Pro 7 having an intel 
core i5) was that I should be getting similar performance. On the other 
hand, the Surface doesn't seem to show any fan action at any point whereas 
the laptop is quite happy whirring away whenever some load comes its way, 
so it could just be that the Surface is passively cooled and therefore 
throttled into computational mediocrity (the surface is really just a 
tablet to write on and as a tablet OS, win10 seems to be performing just 
fine). I think the students who'd be using Win10 for development would have 
beefier machines.


On Tuesday, 1 June 2021 at 01:36:31 UTC-7 dim...@gmail.com wrote:

> On Tue, Jun 1, 2021 at 2:25 AM Nils Bruin  wrote:
> >
> > Update:
> > wsl --help isn't particularly eager to divulge version information, but 
> some of it inadvertently has slipped through: in the description of the 
> "--shutdown" option there is a mention of "the WSL 2 lightweight utility 
> virtual machine",
> > so unless wsl has a mysterious option that has a side-effect to kill any 
> wsl2 virtual machines that happen to be running alongside it, I think 
> there's a good chance I'm using WSL2 here.
>
> "From the WSL shell prompt, run uname. If the kernel version => 4.19,
> it's WSL Version 2."
>
> >
> > --
> > 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...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-support/37ef0bb2-156e-429a-8a28-310a8629bbe6n%40googlegroups.com
> .
>

-- 
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/b137a925-b60a-4022-8a55-5de6a62e5d54n%40googlegroups.com.


Re: [sage-support] Conveniently running and building sage on Win10

2021-05-31 Thread Nils Bruin
Update:
wsl --help isn't particularly eager to divulge version information, but 
some of it inadvertently has slipped through: in the description of the 
"--shutdown" option there is a mention of "the WSL 2 lightweight utility 
virtual machine",
so unless wsl has a mysterious option that has a side-effect to kill any 
wsl2 virtual machines that happen to be running alongside it, I think 
there's a good chance I'm using WSL2 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/37ef0bb2-156e-429a-8a28-310a8629bbe6n%40googlegroups.com.


Re: [sage-support] Conveniently running and building sage on Win10

2021-05-31 Thread Nils Bruin
On Monday, 31 May 2021 at 17:57:34 UTC-7 wst wrote:

> I also think there are some subtleties with WSL versus WSL2 - which were 
> you actually using?  They are dramatically different technologies…

How do I tell which one I'm running as a user? I wasn't particularly 
planning on learning how to use Win10 for this experiment; I was really 
hoping that other people would be able to tell me where to point students 
to.

-- 
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/aeaea662-e1b0-4817-a3e8-617f692f4342n%40googlegroups.com.


[sage-support] Conveniently running and building sage on Win10

2021-05-31 Thread Nils Bruin
Asking for a friend ... or rather linux-challenged students:
What's the most convenient and workable way of running sage on Win10 if you 
want to do a moderate amount of sage development as well (so, things like 
`sage -b` or `make build` should probably work, as should `git track push` 
etc.) ?

I tried the WSL route and was for the most part pleasantly surprised with 
how well it worked:
 - activating wsl worked as advertised; required a reboot, though.
 - getting ubuntu in the "microsoft store" felt oxymoronic, but worked fine
 - sudo apt update; sudo apt upgrade got me a functional system
 (restarted for good measure)
 - sudo apt install  
worked fine
 - git clone  got me the sage source tree
 - make configured the mirrors and downloaded a bunch of required spkgs, 
and then complained about configure
 - running ./configure worked well
 - export MAKE="make -j8"; make took a long while, but produced a working 
sage

However, it is rather slow! Starting up may be slow due to the underlying 
file system; however, I tested some CPU-bound computations as well and I 
found a factor 8 difference in performance!

Win 10: Surface Pro 7; Intel Core i5-1035G4
Linux: Dell XPS 13 Intel Core i5-8250U

Given that the Surface Pro is newer, I'd assume these processors are 
comparable. So it would seem Win10 is doing something to significantly 
hobble the performance of the Linux virtual machine.

It's nice that the WSL route is entirely based on "officially supported" 
solutions and that you end up running code in a genuine linux environment; 
the best supported environment for many of the sage components. However, 
the performance penalty makes me hesitate to recommend it to other people. 
Would Cygwin be better? Other solutions? I can offer my students remote 
access to a linux server to do their development on, but that requires the 
navigation of multiple hurdles too, so I'd imagine they'd be  happier and 
possibly more productive if they can do it all on their local machine.

Best,

Nils

-- 
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/c3687314-1fdb-4ba1-a311-49c6ca9bca0cn%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.


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


[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] 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: 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.


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


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


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


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


[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: Jupyter kernels for R, gp, gap, etc

2020-08-04 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.


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


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


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


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


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.


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.


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


[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: 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: 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: Loading a sage worksheet inside a notebook

2019-10-12 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.


  1   2   3   4   5   6   >