Re: [sage-support] Re: Possible problem with our interfaces to maxima

2024-09-01 Thread Emmanuel Charpentier


Ticket filed <https://github.com/sagemath/sage/issues/38599>. This boils 
down to *“upgrade to Maxima 5.47.0”*.

HTH,
​
Le dimanche 25 août 2024 à 11:49:43 UTC+2, jan.gro...@gmail.com a écrit :

> Hi
>
> Debian Stable's maxima 46 also shows the error:
>
> 0 jan@jan-latitude:~$dpkg -l maxima|grep ii
> ii  maxima 5.46.0-11amd64Computer algebra system -- 
> base system
> 0 jan@jan-latitude:~$maxima -q
> (%i1) 
> (%i2) 
> PQUOTIENT: Quotient by a polynomial of higher degree (case 2a)
>  -- an error. To debug this try: debugmode(true);
>
> Regards,
> Jan
>
>
>
> On Sun, 25 Aug 2024 at 11:25, Dima Pasechnik  wrote:
>
>>
>>
>> On 25 August 2024 09:52:20 BST, Emmanuel Charpentier <
>> emanuel.c...@gmail.com> wrote:
>> >
>> >
>> >*Correction :* 
>> >
>> >   - /usr/bin/maxima, the “standalone” version of maxima provided by 
>> Debian 
>> >   testing, runs without error : 
>> >
>> >(%i3) t:taylor(g, x4, 0, 8)$ (%i4) 
>> >   
>> >   - /usr/local/sage-10/local/bin/maxima, “our” version of Maxima, fails 
>> to 
>> >   compute the Taylor series : 
>> >
>> >(%i4) t:taylor(g, x4, 0, 8)$ PQUOTIENT: Quotient by a polynomial of 
>> higher 
>> >degree (case 2a) -- an error. To debug this try: debugmode(true); (%i5) 
>>
>>
>> our Maxima version is older by one or two versions. (5.45 vs 5.47)
>>
>> Dima
>>
>> >
>> >Ticket underway (slowly).
>> >
>> >HTH,
>> >​
>> >Le jeudi 22 août 2024 à 17:42:06 UTC+2, Nils Bruin a écrit :
>> >
>> >> By the looks of it, the place of failure is the same in both cases. In 
>> the 
>> >> case of using maxima_lib, the maxima error generation doesn't quite 
>> work 
>> >> though: as you can see, a condition RAT-ERR is not defined. That means 
>> >> there is code that "throws" the condition, assuming there's a "catch" 
>> set 
>> >> up around it. maxima_lib was originally designed to provide lower 
>> overhead 
>> >> for maxima access as well as provide a more robust interface by 
>> avoiding 
>> >> string parsing as much as possible. So it tries to run maxima code in 
>> a 
>> >> lisp environment that is as cheaply set up as possible. There is some 
>> >> catching, but I did not trace through all of maxima to see what 
>> catches can 
>> >> occur. Note that maxima sets up its evaluation loop once with all its 
>> >> catches around it, so set up is amortized. For maxima_lib, every 
>> command 
>> >> will exit back completely, so the stack frames holding the condition 
>> >> catches all need to be built up and torn down for every access to 
>> >> maxima_lib.
>> >>
>> >> That explains why you see the message about RAT-ERR rather than the 
>> >> PQUOTIENT message (presumably, the RAT-ERR condition has some extra 
>> data 
>> >> hanging off it that the corresponding catch can use to generate a 
>> message 
>> >> with more data)
>> >>
>> >> As to why something fails when called via sage and succeeds when 
>> executed 
>> >> in maxima directly: that will require some drilling down. There are 
>> >> non-standard settings that sage makes for its maxima-calculus 
>> instance, but 
>> >> that's unlikely to make a difference for polynomial division. There 
>> may be 
>> >> a small inequivalence between the code that is actually generated 
>> (note 
>> >> that maxima_lib will be entering and exiting the maxima environment 
>> for 
>> >> every method call, leaving the return value on ECL's heap to serve as 
>> input 
>> >> for the next call, whereas the maxima evaluation loop has its own way 
>> of 
>> >> chaining things together)
>> >>
>> >> It looks to me it could be made into a ticket/issue.
>> >>
>> >> On Thursday 22 August 2024 at 04:04:32 UTC-7 Emmanuel Charpentier 
>> wrote:
>> >>
>> >>> Inspired by this ask.sagemath.org question 
>> >>> <
>> https://ask.sagemath.org/question/78686/taylor-expansion-in-sagemath-returns-error/
>> >
>> >>> .
>> >>>
>> >>> Compare this Maxima standalone execution :
>> >>> (%i1) display2d:false; (%o1) false (%i2) g: 
>> >>> 1/4*((w1^2*w3^2*x1^4*x2^6*

[sage-support] Re: Possible problem with our interfaces to maxima

2024-08-25 Thread Emmanuel Charpentier


*Correction :* 

   - /usr/bin/maxima, the “standalone” version of maxima provided by Debian 
   testing, runs without error : 

(%i3) t:taylor(g, x4, 0, 8)$ (%i4) 
   
   - /usr/local/sage-10/local/bin/maxima, “our” version of Maxima, fails to 
   compute the Taylor series : 

(%i4) t:taylor(g, x4, 0, 8)$ PQUOTIENT: Quotient by a polynomial of higher 
degree (case 2a) -- an error. To debug this try: debugmode(true); (%i5) 

Ticket underway (slowly).

HTH,
​
Le jeudi 22 août 2024 à 17:42:06 UTC+2, Nils Bruin a écrit :

> By the looks of it, the place of failure is the same in both cases. In the 
> case of using maxima_lib, the maxima error generation doesn't quite work 
> though: as you can see, a condition RAT-ERR is not defined. That means 
> there is code that "throws" the condition, assuming there's a "catch" set 
> up around it. maxima_lib was originally designed to provide lower overhead 
> for maxima access as well as provide a more robust interface by avoiding 
> string parsing as much as possible. So it tries to run maxima code in a 
> lisp environment that is as cheaply set up as possible. There is some 
> catching, but I did not trace through all of maxima to see what catches can 
> occur. Note that maxima sets up its evaluation loop once with all its 
> catches around it, so set up is amortized. For maxima_lib, every command 
> will exit back completely, so the stack frames holding the condition 
> catches all need to be built up and torn down for every access to 
> maxima_lib.
>
> That explains why you see the message about RAT-ERR rather than the 
> PQUOTIENT message (presumably, the RAT-ERR condition has some extra data 
> hanging off it that the corresponding catch can use to generate a message 
> with more data)
>
> As to why something fails when called via sage and succeeds when executed 
> in maxima directly: that will require some drilling down. There are 
> non-standard settings that sage makes for its maxima-calculus instance, but 
> that's unlikely to make a difference for polynomial division. There may be 
> a small inequivalence between the code that is actually generated (note 
> that maxima_lib will be entering and exiting the maxima environment for 
> every method call, leaving the return value on ECL's heap to serve as input 
> for the next call, whereas the maxima evaluation loop has its own way of 
> chaining things together)
>
> It looks to me it could be made into a ticket/issue.
>
> On Thursday 22 August 2024 at 04:04:32 UTC-7 Emmanuel Charpentier wrote:
>
>> Inspired by this ask.sagemath.org question 
>> <https://ask.sagemath.org/question/78686/taylor-expansion-in-sagemath-returns-error/>
>> .
>>
>> Compare this Maxima standalone execution :
>> (%i1) display2d:false; (%o1) false (%i2) g: 
>> 1/4*((w1^2*w3^2*x1^4*x2^6*x3^8 + 2*(w1^2*w3^2*x1^4*x2^6 + 
>> w1^2*w3*x1^3*x2^5)*x3^7 + (w1^2*w3^2*x1^4*x2^6 + 2*w1^2*w3*x1^3*x2^5 + 
>> 2*w1^2*x1^2*x2^4)*x3^6)*x4^6 + 2*((w1^2*w3^2*x1^4*x2^6 + (w1^2*w3^2*x1^4 + 
>> (2*w1^2*w3 + w1*w3^2)*x1^3)*x2^5)*x3^7 + 2*(w1^2*w3^2*x1^4*x2^6 + 
>> (w1^2*w3^2*x1^4 + (3*w1^2*w3 + w1*w3^2)*x1^3)*x2^5 + (w1^2*w3*x1^3 + (w1^2 
>> + w1*w3)*x1^2)*x2^4)*x3^6 + (w1^2*w3^2*x1^4*x2^6 + (w1^2*w3^2*x1^4 + 
>> (4*w1^2*w3 + w1*w3^2)*x1^3)*x2^5 + 2*(w1^2*w3*x1^3 + (2*w1^2 + 
>> w1*w3)*x1^2)*x2^4 + 2*(w1^2*x1^2 + w1*x1)*x2^3)*x3^5)*x4^5 + 
>> ((w1^2*w3^2*x1^4*x2^6 + 2*(w1^2*w3^2*x1^4 + (3*w1^2*w3 + 
>> 2*w1*w3^2)*x1^3)*x2^5 + (w1^2*w3^2*x1^4 + 2*(3*w1^2*w3 + 2*w1*w3^2)*x1^3 + 
>> 2*(3*w1^2 + 6*w1*w3 + w3^2)*x1^2)*x2^4)*x3^6 + 2*(w1^2*w3^2*x1^4*x2^6 + 
>> (2*w1^2*w3^2*x1^4 + (7*w1^2*w3 + 4*w1*w3^2)*x1^3)*x2^5 + (w1^2*w3^2*x1^4 + 
>> 4*(2*w1^2*w3 + w1*w3^2)*x1^3 + (9*w1^2 + 16*w1*w3 + 2*w3^2)*x1^2)*x2^4 + 
>> (w1^2*w3*x1^3 + (3*w1^2 + 4*w1*w3)*x1^2 + 2*(3*w1 + w3)*x1)*x2^3)*x3^5 + 
>> (w1^2*w3^2*x1^4*x2^6 + 2*(w1^2*w3^2*x1^4 + 2*(2*w1^2*w3 + 
>> w1*w3^2)*x1^3)*x2^5 + (w1^2*w3^2*x1^4 + 2*(5*w1^2*w3 + 2*w1*w3^2)*x1^3 + 
>> 2*(7*w1^2 + 10*w1*w3 + w3^2)*x1^2)*x2^4 + 2*(w1^2*w3*x1^3 + (5*w1^2 + 
>> 4*w1*w3)*x1^2 + 2*(5*w1 + w3)*x1)*x2^3 + 2*(w1^2*x1^2 + 4*w1*x1 + 
>> 2)*x2^2)*x3^4)*x4^4 + 2*(((w1^2*w3 + w1*w3^2)*x1^3*x2^5 + (2*(w1^2*w3 + 
>> w1*w3^2)*x1^3 + (3*w1^2 + 10*w1*w3 + 2*w3^2)*x1^2)*x2^4 + ((w1^2*w3 + 
>> w1*w3^2)*x1^3 + (3*w1^2 + 10*w1*w3 + 2*w3^2)*x1^2 + 4*(3*w1 + 
>> 2*w3)*x1)*x2^3)*x3^5 + (2*(w1^2*w3 + w1*w3^2)*x1^3*x2^5 + (4*(w1^2*w3 + 
>> w1*w3^2)*x1^3 + (7*w1^2 + 22*w1*w3 + 4*w3^2)*x1^2)*x2^4 + 2*((w1^2*w3 + 
>> w1*w3^2)*x1^3 + 2*(2*w1^2 + 6*w1*w3 + w3^2)*x1^2 + (17*w1 + 10*w3)*x1)*x2^3 
>> + ((w1^2 + 2*w1*w3)*x1^2 + 2*(5*w1 + 2*w3)*x1 + 8)*x2^2)*x3^4 + ((w1^2*w3 + 
>> w1*w3^2)*x1^3*x2^5 + 2*((w1^2*w3 + w1*w3^2)*x1^

[sage-support] Possible problem with our interfaces to maxima

2024-08-22 Thread Emmanuel Charpentier


Inspired by this ask.sagemath.org question 

.

Compare this Maxima standalone execution :
(%i1) display2d:false; (%o1) false (%i2) g: 1/4*((w1^2*w3^2*x1^4*x2^6*x3^8 
+ 2*(w1^2*w3^2*x1^4*x2^6 + w1^2*w3*x1^3*x2^5)*x3^7 + (w1^2*w3^2*x1^4*x2^6 + 
2*w1^2*w3*x1^3*x2^5 + 2*w1^2*x1^2*x2^4)*x3^6)*x4^6 + 
2*((w1^2*w3^2*x1^4*x2^6 + (w1^2*w3^2*x1^4 + (2*w1^2*w3 + 
w1*w3^2)*x1^3)*x2^5)*x3^7 + 2*(w1^2*w3^2*x1^4*x2^6 + (w1^2*w3^2*x1^4 + 
(3*w1^2*w3 + w1*w3^2)*x1^3)*x2^5 + (w1^2*w3*x1^3 + (w1^2 + 
w1*w3)*x1^2)*x2^4)*x3^6 + (w1^2*w3^2*x1^4*x2^6 + (w1^2*w3^2*x1^4 + 
(4*w1^2*w3 + w1*w3^2)*x1^3)*x2^5 + 2*(w1^2*w3*x1^3 + (2*w1^2 + 
w1*w3)*x1^2)*x2^4 + 2*(w1^2*x1^2 + w1*x1)*x2^3)*x3^5)*x4^5 + 
((w1^2*w3^2*x1^4*x2^6 + 2*(w1^2*w3^2*x1^4 + (3*w1^2*w3 + 
2*w1*w3^2)*x1^3)*x2^5 + (w1^2*w3^2*x1^4 + 2*(3*w1^2*w3 + 2*w1*w3^2)*x1^3 + 
2*(3*w1^2 + 6*w1*w3 + w3^2)*x1^2)*x2^4)*x3^6 + 2*(w1^2*w3^2*x1^4*x2^6 + 
(2*w1^2*w3^2*x1^4 + (7*w1^2*w3 + 4*w1*w3^2)*x1^3)*x2^5 + (w1^2*w3^2*x1^4 + 
4*(2*w1^2*w3 + w1*w3^2)*x1^3 + (9*w1^2 + 16*w1*w3 + 2*w3^2)*x1^2)*x2^4 + 
(w1^2*w3*x1^3 + (3*w1^2 + 4*w1*w3)*x1^2 + 2*(3*w1 + w3)*x1)*x2^3)*x3^5 + 
(w1^2*w3^2*x1^4*x2^6 + 2*(w1^2*w3^2*x1^4 + 2*(2*w1^2*w3 + 
w1*w3^2)*x1^3)*x2^5 + (w1^2*w3^2*x1^4 + 2*(5*w1^2*w3 + 2*w1*w3^2)*x1^3 + 
2*(7*w1^2 + 10*w1*w3 + w3^2)*x1^2)*x2^4 + 2*(w1^2*w3*x1^3 + (5*w1^2 + 
4*w1*w3)*x1^2 + 2*(5*w1 + w3)*x1)*x2^3 + 2*(w1^2*x1^2 + 4*w1*x1 + 
2)*x2^2)*x3^4)*x4^4 + 2*(((w1^2*w3 + w1*w3^2)*x1^3*x2^5 + (2*(w1^2*w3 + 
w1*w3^2)*x1^3 + (3*w1^2 + 10*w1*w3 + 2*w3^2)*x1^2)*x2^4 + ((w1^2*w3 + 
w1*w3^2)*x1^3 + (3*w1^2 + 10*w1*w3 + 2*w3^2)*x1^2 + 4*(3*w1 + 
2*w3)*x1)*x2^3)*x3^5 + (2*(w1^2*w3 + w1*w3^2)*x1^3*x2^5 + (4*(w1^2*w3 + 
w1*w3^2)*x1^3 + (7*w1^2 + 22*w1*w3 + 4*w3^2)*x1^2)*x2^4 + 2*((w1^2*w3 + 
w1*w3^2)*x1^3 + 2*(2*w1^2 + 6*w1*w3 + w3^2)*x1^2 + (17*w1 + 10*w3)*x1)*x2^3 
+ ((w1^2 + 2*w1*w3)*x1^2 + 2*(5*w1 + 2*w3)*x1 + 8)*x2^2)*x3^4 + ((w1^2*w3 + 
w1*w3^2)*x1^3*x2^5 + 2*((w1^2*w3 + w1*w3^2)*x1^3 + (2*w1^2 + 6*w1*w3 + 
w3^2)*x1^2)*x2^4 + ((w1^2*w3 + w1*w3^2)*x1^3 + (5*w1^2 + 14*w1*w3 + 
2*w3^2)*x1^2 + 12*(2*w1 + w3)*x1)*x2^3 + ((w1^2 + 2*w1*w3)*x1^2 + 2*(7*w1 + 
2*w3)*x1 + 12)*x2^2 + 2*(w1*x1 + 2)*x2)*x3^3)*x4^3 + 24*(x2^2 + 2*x2 + 
1)*x3^2 + 2*(((w1^2 + 4*w1*w3 + w3^2)*x1^2*x2^4 + 2*((w1^2 + 4*w1*w3 + 
w3^2)*x1^2 + (8*w1 + 7*w3)*x1)*x2^3 + ((w1^2 + 4*w1*w3 + w3^2)*x1^2 + 
2*(8*w1 + 7*w3)*x1 + 20)*x2^2)*x3^4 + 2*((w1^2 + 4*w1*w3 + w3^2)*x1^2*x2^4 
+ (2*(w1^2 + 4*w1*w3 + w3^2)*x1^2 + 3*(6*w1 + 5*w3)*x1)*x2^3 + ((w1^2 + 
4*w1*w3 + w3^2)*x1^2 + 4*(5*w1 + 4*w3)*x1 + 27)*x2^2 + ((2*w1 + w3)*x1 + 
7)*x2)*x3^3 + ((w1^2 + 4*w1*w3 + w3^2)*x1^2*x2^4 + 2*((w1^2 + 4*w1*w3 + 
w3^2)*x1^2 + 2*(5*w1 + 4*w3)*x1)*x2^3 + ((w1^2 + 4*w1*w3 + w3^2)*x1^2 + 
6*(4*w1 + 3*w3)*x1 + 36)*x2^2 + 2*((2*w1 + w3)*x1 + 9)*x2 + 2)*x3^2)*x4^2 + 
24*x2^2 + 48*(x2^2 + 2*x2 + 1)*x3 + 12*(((w1 + w3)*x1*x2^3 + (2*(w1 + 
w3)*x1 + 5)*x2^2 + ((w1 + w3)*x1 + 5)*x2)*x3^3 + (2*(w1 + w3)*x1*x2^3 + 
(4*(w1 + w3)*x1 + 11)*x2^2 + 2*((w1 + w3)*x1 + 6)*x2 + 1)*x3^2 + ((w1 + 
w3)*x1*x2^3 + 2*((w1 + w3)*x1 + 3)*x2^2 + ((w1 + w3)*x1 + 7)*x2 + 1)*x3)*x4 
+ 48*x2 + 24)*e^(-w2*x1*x2*x3*x4)/((x2^3*x3^6*e^(w5*x1*x2) + 
3*x2^3*x3^5*e^(w5*x1*x2) + 3*x2^3*x3^4*e^(w5*x1*x2) + 
x2^3*x3^3*e^(w5*x1*x2))*x4^3*e^(w6*x1*x2*x3) + 3*((x2^3 + 
x2^2)*x3^5*e^(w5*x1*x2) + 3*(x2^3 + x2^2)*x3^4*e^(w5*x1*x2) + 3*(x2^3 + 
x2^2)*x3^3*e^(w5*x1*x2) + (x2^3 + 
x2^2)*x3^2*e^(w5*x1*x2))*x4^2*e^(w6*x1*x2*x3) + 3*((x2^3 + 2*x2^2 + 
x2)*x3^4*e^(w5*x1*x2) + 3*(x2^3 + 2*x2^2 + x2)*x3^3*e^(w5*x1*x2) + 3*(x2^3 
+ 2*x2^2 + x2)*x3^2*e^(w5*x1*x2) + (x2^3 + 2*x2^2 + 
x2)*x3*e^(w5*x1*x2))*x4*e^(w6*x1*x2*x3) + ((x2^3 + 3*x2^2 + 3*x2 + 
1)*x3^3*e^(w5*x1*x2) + 3*(x2^3 + 3*x2^2 + 3*x2 + 1)*x3^2*e^(w5*x1*x2) + 
3*(x2^3 + 3*x2^2 + 3*x2 + 1)*x3*e^(w5*x1*x2) + (x2^3 + 3*x2^2 + 3*x2 + 
1)*e^(w5*x1*x2))*e^(w6*x1*x2*x3))$ (%i3) foo:coeff(taylor(g, x4, 0, 8), 
x4^7)$ 

which works okay, with these Sage snippets :
sage: g.taylor(x4, 0, 7).coefficient(x4, 7) 
--- 
RuntimeError Traceback (most recent call last) File 
/usr/local/sage-10/src/sage/interfaces/interface.py:750, in 
InterfaceElement.__init__(self, parent, value, is_name, name) 749 try: --> 
750 self._name = parent._create(value, name=name) 751 except (TypeError, 
RuntimeError, ValueError) as x: File 
/usr/local/sage-10/src/sage/interfaces/maxima_lib.py:623, in 
MaximaLib._create(self, value, name) 622 else: --> 623 self.set(name, 
value) 624 except RuntimeError as error: File 
/usr/local/sage-10/src/sage/interfaces/maxima_lib.py:533, in 
MaximaLib.set(self, var, value) 532 cmd = '%s : %s$' % (var, 
value.rstrip(';')) --> 533 self.eval(cmd) File 
/usr/local/sage-10/src/sage/interfaces/maxima_lib.py:479, in 
MaximaLib._eval_line(self, line, locals, reformat, **kwds) 478 if 
statement: --> 479 maxima_eval("#$%s$" % statement) 480 if not reformat: 
File /usr/local/sage-10/src/sage/libs/ecl.pyx:8

[sage-support] Re: Problem with minimize_constrained

2024-08-19 Thread Emmanuel Charpentier


I filed this issue  for your 
question.

An analytical solution :
# Potential extrema : points where all first derivatives are zero. PE = 
[{u:d[u].n() for u in d.keys()} for d in solve([G(x, y).diff(u) for u in 
(x, y)], (x, y), solution_dict=True)] # Actual values of G var("val") 
Vals=[d|{val:G(d[x],d[y]).n()} for d in PE] # Actual maxima [d for d in 
Vals if d[val]==(Max:=max([d[val] for d in Vals]))] 

gives
[{x: 0.500, y: 0.000, val: 1.25}, {x: 
0.000, y: 0.500, val: 1.25}] 

HTH,
​
Le lundi 19 août 2024 à 12:35:29 UTC+2, Nicola Sottocornola a écrit :

> Dear all,
>
> we want to find the maximum of the function G over [0,1]x[0,1]. The code 
> below gives 0 which is clearly wrong. 
>
> Using instead
>
> sage: minimize_constrained(-G, [[0, 1], [0, 1]],[1/2, 1/2])
> seems to provide the right answer...
>
> var('x,y') c1(x,y)=x c2(x,y)=y c3(x,y)=1-x c4(x,y)=1-y G(x,y) = -(56*x^2*y
> ^2 - 4*x^2*y - 4*x*y^2 - 4*x^2 - x*y - 4*y^2 - x - y - 1)*(x - 1)*(y - 1) 
> M = minimize_constrained(-G(x,y), [c1(x,y),c2(x,y),c3(x,y),c4(x,y)],[0.5,
> 0.5]) print(G(M[0],M[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/fe15b9a2-ae63-4445-a3e8-a7b4a614314dn%40googlegroups.com.


[sage-support] Support JupyterLab debugging interface ?

2024-07-31 Thread Emmanuel Charpentier


A question 
 
on ask.sagemath.org raises an interesting issue :

   - 
   
   “Our” Jupyterlab supports the debugging interface offered to Jupyter 
   (zmq ?) kernels (e. g. one can use it with the “standard” Python kernel).
   - 
   
   Our Sage kernel does not support this interface.
   
This seems an interesting potential addition (ease-of-use-wise) but I 
haven’t the foggiest idea about the amount of work necessary.

Your thoughts ?
​

-- 
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/f31ada74-01ed-445a-9556-05ffbd0044b1n%40googlegroups.com.


[sage-support] Re: View does not work

2024-06-24 Thread Emmanuel Charpentier


The Sage wiki has a relevant section . 
I found it useful.

HTH,
​
Le dimanche 23 juin 2024 à 05:37:52 UTC+2, Trey Davis a écrit :

> I use wsl with Ubuntu 22.04.3 LTS installed. I installed sage from source 
> code (SageMath version 10.4.beta9.)  View does not work. When I try to use 
> it, it returns the error, "!  ==> Fatal error occurred, no output PDF file 
> produced!." Latex does work though.

-- 
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/c0b7b455-aa47-4a5d-9fc6-35052f75426cn%40googlegroups.com.


[sage-support] Re: A problematic dictionary update (possible Maxima problem)

2024-06-01 Thread Emmanuel Charpentier


The damn thing *can* be done in Sage … by using Sympy :
# Use of Sympy import sympy sx, sy = sympy.symbols("sx, sy") SL = 
[sympy.sin, sympy.cos, sympy.tan, sympy.csc, sympy.sec, sympy.cot, 
sympy.sinh, sympy.cosh, sympy.tanh, sympy.csch, sympy.sech, sympy.coth] SIL 
= [sympy.asin, sympy.acos, sympy.atan, sympy.acsc, sympy.asec, sympy.acot, 
sympy.asinh, sympy.acosh, sympy.atanh, sympy.acsch, sympy.asech, 
sympy.acoth] px = sympy.Wild("px") SD={sx:px} foo=[dict(list(map(lambda 
v:[v.subs(SD), u[0].subs(SD)], u[1]))) for u in zip([w(sx) for w in SIL], 
[w for w in [sympy.solve((u(sy)-sx).rewrite("exp"), sy) for u in SL]])] 
sD=dict() for d in foo:sD|=d # Conversion to Sage 
Dic2={u._sage_().subs({px:w0}):sD[u]._sage_().subs({px:w0}) for u in 
sD.keys()} 

Indeed :
sage: Dic2 {-I*log(I*$0 - I*sqrt($0^2 - 1)): arcsin($0), -I*log(I*$0 + 
I*sqrt($0^2 - 1)): arcsin($0), -I*log($0 - sqrt($0^2 - 1)): arccos($0), 
-I*log($0 + sqrt($0^2 - 1)): arccos($0), -I*log(-sqrt(-($0 - I)/($0 + I))): 
arctan($0), -I*log(sqrt(-($0 - I)/($0 + I))): arctan($0), 
-I*log(-(sqrt($0^2 - 1) - I)/$0): arccsc($0), -I*log((sqrt($0^2 - 1) + 
I)/$0): arccsc($0), -I*log(-(sqrt(-$0^2 + 1) - 1)/$0): arcsec($0), 
-I*log((sqrt(-$0^2 + 1) + 1)/$0): arcsec($0), -I*log(-sqrt(($0 + I)/($0 - 
I))): arccot($0), -I*log(sqrt(($0 + I)/($0 - I))): arccot($0), log($0 - 
sqrt($0^2 + 1)): arcsinh($0), log($0 + sqrt($0^2 + 1)): arcsinh($0), log($0 
- sqrt($0^2 - 1)): arccosh($0), log($0 + sqrt($0^2 - 1)): arccosh($0), 
log(-sqrt(-($0 + 1)/($0 - 1))): arctanh($0), log(sqrt(-($0 + 1)/($0 - 1))): 
arctanh($0), log(-(sqrt($0^2 + 1) - 1)/$0): arccsch($0), log((sqrt($0^2 + 
1) + 1)/$0): arccsch($0), log(-(sqrt(-$0^2 + 1) - 1)/$0): arcsech($0), 
log((sqrt(-$0^2 + 1) + 1)/$0): arcsech($0), log(-sqrt(($0 + 1)/($0 - 1))): 
arccoth($0), log(sqrt(($0 + 1)/($0 - 1))): arccoth($0)} 

But the need for this workaround makes me suspect thai it might not be as 
useful as I wish it would be…

Hints ? Ideas ?

[ Even lazzi are welcome… ]
​
Le samedi 1 juin 2024 à 22:11:43 UTC+2, Emmanuel Charpentier a écrit :

> Context : finding patterns of explicit forms of inverse 
> (hyperbolic|trigonometric) functions for simplification.
>
> Simple solution :
> reset() y=SR.var("y") IL = [] w0=SR.wild(0) L=[sin, cos, tan, csc, sec, 
> cot, sinh, cosh, tanh, csch, sech, coth] for f in L: 
> R=(f(y)==x).solve(y)[0].rhs() for s in (f(y)==x).exponentialize().solve(y): 
> IL += [s.rhs().subs(x==w0)==R.subs(x==w0)] # End loop 
>
> This works. But I’d like to express this list as a dictionary. Brute-force 
> solution fails with a mysterious TypeError: ECL says: THROW: The catch 
> MACSYMA-QUIT is undefined.. But calling this on *parts* of the list seems 
> to work (not shown).
>
> Try a loop :
> ID=dict() for s in IL: ID[s.lhs()]=s.rhs() # End loop 
>
> This fails again :
> --- 
> RuntimeError Traceback (most recent call last) File 
> /usr/local/sage-10/src/sage/interfaces/interface.py:749, in 
> InterfaceElement.__init__(self, parent, value, is_name, name) 748 try: --> 
> 749 self._name = parent._create(value, name=name) 750 except (TypeError, 
> RuntimeError, ValueError) as x: File 
> /usr/local/sage-10/src/sage/interfaces/maxima_lib.py:632, in 
> MaximaLib._create(self, value, name) 631 else: --> 632 self.set(name, 
> value) 633 except RuntimeError as error: File 
> /usr/local/sage-10/src/sage/interfaces/maxima_lib.py:540, in 
> MaximaLib.set(self, var, value) 539 cmd = '%s : %s$' % (var, 
> value.rstrip(';')) --> 540 self.eval(cmd) File 
> /usr/local/sage-10/src/sage/interfaces/maxima_lib.py:486, in 
> MaximaLib._eval_line(self, line, locals, reformat, **kwds) 485 if 
> statement: --> 486 maxima_eval("#$%s$" % statement) 487 if not reformat: 
> File /usr/local/sage-10/src/sage/libs/ecl.pyx:837, in 
> sage.libs.ecl.EclObject.__call__() 836 """ --> 837 lispargs = 
> EclObject(list(args)) 838 return ecl_wrap(ecl_safe_apply(self.obj, 
> (lispargs).obj)) File 
> /usr/local/sage-10/src/sage/libs/ecl.pyx:698, in 
> sage.libs.ecl.EclObject.__init__() 697 elif len(args) == 1: --> 698 
> self.set_obj(python_to_ecl(args[0], True)) 699 elif len(args) == 2: File 
> /usr/local/sage-10/src/sage/libs/ecl.pyx:481, in 
> sage.libs.ecl.python_to_ecl() 480 for i in range(len(pyobj) - 1, -1, -1): 
> --> 481 L = cl_cons(python_to_ecl(pyobj[i], read_strings), L) 482 return L 
> File /usr/local/sage-10/src/sage/libs/ecl.pyx:458, in 
> sage.libs.ecl.python_to_ecl() 457 if read_strings: --> 458 return 
> ecl_safe_funcall(read_from_string_clobj, o) 459 else: File 
> /usr/local/sage-10/src/sage/libs/ecl.pyx:342, in 
> sage.libs.ecl.ecl_safe_funcall() 341 else: --> 342 raise RuntimeError("

[sage-support] A problematic dictionary update (possible Maxima problem)

2024-06-01 Thread Emmanuel Charpentier


Context : finding patterns of explicit forms of inverse 
(hyperbolic|trigonometric) functions for simplification.

Simple solution :
reset() y=SR.var("y") IL = [] w0=SR.wild(0) L=[sin, cos, tan, csc, sec, 
cot, sinh, cosh, tanh, csch, sech, coth] for f in L: 
R=(f(y)==x).solve(y)[0].rhs() for s in (f(y)==x).exponentialize().solve(y): 
IL += [s.rhs().subs(x==w0)==R.subs(x==w0)] # End loop 

This works. But I’d like to express this list as a dictionary. Brute-force 
solution fails with a mysterious TypeError: ECL says: THROW: The catch 
MACSYMA-QUIT is undefined.. But calling this on *parts* of the list seems 
to work (not shown).

Try a loop :
ID=dict() for s in IL: ID[s.lhs()]=s.rhs() # End loop 

This fails again :
--- 
RuntimeError Traceback (most recent call last) File 
/usr/local/sage-10/src/sage/interfaces/interface.py:749, in 
InterfaceElement.__init__(self, parent, value, is_name, name) 748 try: --> 
749 self._name = parent._create(value, name=name) 750 except (TypeError, 
RuntimeError, ValueError) as x: File 
/usr/local/sage-10/src/sage/interfaces/maxima_lib.py:632, in 
MaximaLib._create(self, value, name) 631 else: --> 632 self.set(name, 
value) 633 except RuntimeError as error: File 
/usr/local/sage-10/src/sage/interfaces/maxima_lib.py:540, in 
MaximaLib.set(self, var, value) 539 cmd = '%s : %s$' % (var, 
value.rstrip(';')) --> 540 self.eval(cmd) File 
/usr/local/sage-10/src/sage/interfaces/maxima_lib.py:486, in 
MaximaLib._eval_line(self, line, locals, reformat, **kwds) 485 if 
statement: --> 486 maxima_eval("#$%s$" % statement) 487 if not reformat: 
File /usr/local/sage-10/src/sage/libs/ecl.pyx:837, in 
sage.libs.ecl.EclObject.__call__() 836 """ --> 837 lispargs = 
EclObject(list(args)) 838 return ecl_wrap(ecl_safe_apply(self.obj, 
(lispargs).obj)) File 
/usr/local/sage-10/src/sage/libs/ecl.pyx:698, in 
sage.libs.ecl.EclObject.__init__() 697 elif len(args) == 1: --> 698 
self.set_obj(python_to_ecl(args[0], True)) 699 elif len(args) == 2: File 
/usr/local/sage-10/src/sage/libs/ecl.pyx:481, in 
sage.libs.ecl.python_to_ecl() 480 for i in range(len(pyobj) - 1, -1, -1): 
--> 481 L = cl_cons(python_to_ecl(pyobj[i], read_strings), L) 482 return L 
File /usr/local/sage-10/src/sage/libs/ecl.pyx:458, in 
sage.libs.ecl.python_to_ecl() 457 if read_strings: --> 458 return 
ecl_safe_funcall(read_from_string_clobj, o) 459 else: File 
/usr/local/sage-10/src/sage/libs/ecl.pyx:342, in 
sage.libs.ecl.ecl_safe_funcall() 341 else: --> 342 raise RuntimeError("ECL 
says: {}".format(message)) 343 else: RuntimeError: ECL says: THROW: The 
catch MACSYMA-QUIT is undefined. During handling of the above exception, 
another exception occurred: TypeError Traceback (most recent call last) 
Cell In[231], line 1 > 1 
load('/tmp/sage_shell_modeSJ8pfj/sage_shell_mode_temp.sage') File 
/usr/local/sage-10/src/sage/misc/persist.pyx:175, in 
sage.misc.persist.load() 173 174 if 
sage.repl.load.is_loadable_filename(filename): --> 175 
sage.repl.load.load(filename, globals()) 176 return 177 File 
/usr/local/sage-10/src/sage/repl/load.py:277, in load(filename, globals, 
attach) 275 add_attached_file(fpath) 276 with fpath.open() as f: --> 277 
exec(preparse_file(f.read()) + "\n", globals) 278 elif ext in ['.spyx', 
'.pyx']: 279 if attach: File :5 File 
/usr/local/sage-10/src/sage/symbolic/expression.pyx:3515, in 
sage.symbolic.expression.Expression.__bool__() 3513 if res in (True, 
False): 3514 return res -> 3515 res = 
self.operator()((self.lhs()-self.rhs()).simplify_full(), 0).test_relation() 
3516 if res in (True, False): 3517 return res File 
/usr/local/sage-10/src/sage/symbolic/expression.pyx:10737, in 
sage.symbolic.expression.Expression.simplify_full() 10735 """ 10736 x = 
self > 10737 x = x.simplify_factorial() 10738 x = x.simplify_rectform() 
10739 x = x.simplify_trig() File 
/usr/local/sage-10/src/sage/symbolic/expression.pyx:11217, in 
sage.symbolic.expression.Expression.simplify_factorial() 11215 11216 """ > 
11217 return 
self.parent()(self._maxima_().makefact().factcomb().minfactorial()) 11218 
11219 factorial_simplify = simplify_factorial File 
/usr/local/sage-10/src/sage/symbolic/expression.pyx:1227, in 
sage.symbolic.expression.Expression._maxima_() 1225 # Maybe not such a 
great idea because the "default" interface is another one 1226 from 
sage.calculus.calculus import maxima -> 1227 return 
super()._interface_(maxima) 1228 else: 1229 return 
super()._interface_(session) File 
/usr/local/sage-10/src/sage/structure/sage_object.pyx:724, in 
sage.structure.sage_object.SageObject._interface_() 722 except Exception: 
723 raise NotImplementedError("coercion of object %s to %s not 
implemented:\n%s\n%s" % (repr(self), I)) --> 724 X = I(s) 725 if c: 726 
try: File /usr/local/sage-10/src/sage/interfaces/interface.py:299, in 
Interface.__call__(self, x, name) 296 pass 298 if isinstance(x, str): --> 
299 return cls(self, x, name=name) 300 try: 301 # Spec

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

2024-04-09 Thread Emmanuel Charpentier


Le mardi 9 avril 2024 à 02:24:45 UTC+2, Dima Pasechnik a écrit :

[ Snip… ]

Actually, the best way to solve this would be to get rid of Jupyter as a 
part of Sage the distribution.

Agreed. Since I “seriously” configured Sage a lng time ago, I missed 
the rise of the .configure options allowing for using the system’s Jupyter. 
As far as I understand it, I’ll have to install Ubuntu’s (=Debian’s) 
Jupyter, pipx and install Jupyterlab in a venv. Will this solve my problem 
? Stay tuned…

Then one can install these kernels in a normal Jupyter way - without it 
being a kind of
afterthought 2nd class citizen way.
No project I know, apart from Sage, vendors Jupyter. Vendoring Jupyter is 
just a needless bloat.

The important word is *“is”* (*i.e.* not *“was*“) : ISTR that a (not so) 
long time ago, Sages motto was *“batteries included”*, which implied the 
bundling of anything Sage could use in Sage-the-distribution (including 
some interesting kitchen sinks…). This “philosophy” has changed, but Sage’s 
construction still lags behind (and so does my knowledge of the 
installation system…).


Dima  

-- 
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/0d7f8312-478b-40b5-8943-57388fa22bc5n%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/d3a5118e-66a1-4868-b06f-cfa381fbbd10n%40googlegroups.com.


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

2024-04-08 Thread Emmanuel Charpentier


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/0d7f8312-478b-40b5-8943-57388fa22bc5n%40googlegroups.com.


[sage-support] Re: Successful plots (without notebook) on Windows?

2024-04-03 Thread Emmanuel Charpentier
Le mardi 2 avril 2024 à 21:13:50 UTC+2, kcrisman a écrit :

On Monday, April 1, 2024 at 3:31:44 PM UTC-4 Emmanuel Charpentier wrote:

I just had to install Sage on a Windows machine (long story…) which has to 
be connected to a corporate VPN, whose an annoying side effect is to 
deprive Linux apps of network connectivity (don’t get me started…). 
Therefore, the Linux browser couldn’t use Mathjax.

I guess I didn't know how to use the Linux browser in the first place on 
Windows.


Just run `wsl firefox`. But in my specific case (amv VPN...), using the 
Windows berwser (alse Firefox) is better. 

 

Using your utilities works perfectly. 

Haha, they are not "mine" :-) 


Huh ? You did the Wiki post, no ?
 

but I'm glad they work for someone, we would definitely want to get some 
information in the user manual and not just the wiki about that.


Suggestion : an interim solution is to leave a note in the 
(installation|user) manual with a link to the wiki...
 

I'm not sure which version of Ubuntu it uses - whatever the current default 
for WSL is.


Currently, it's 22.04LTS, probably to be replaced bu 24.04LTS when the 
latter is released.
 

I can safely guarantee my son has zero interest in Ubuntu, or Linux for 
that matter.


Condolences... ;_-)

HTH, 

-- 
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/28e852ce-05fa-47a5-ac58-56e0d7ea7d93n%40googlegroups.com.


[sage-support] Re: Successful plots (without notebook) on Windows?

2024-04-01 Thread Emmanuel Charpentier


I just had to install Sage on a Windows machine (long story…) which has to 
be connected to a corporate VPN, whose an annoying side effect is to 
deprive Linux apps of network connectivity (don’t get me started…). 
Therefore, the Linux browser couldn’t use Mathjax.

Using your utilities works perfectly. I checked that one can display both 
2D and 3D graphics from both commandine and Jupyter/Jupyterlab notebooks.

BTW, does your son run Ubuntu 22.04 ? If so, it might explain why display 
is problematic : this distribution uses a “snap” version of firefox, which 
asininely insists to run in its own sandbox, *with no access to local files 
:* (‘G…).

HTH,
​
Le lundi 4 mars 2024 à 23:23:17 UTC+1, kcrisman a écrit :

> Has anyone successfully used the instructions at 
> https://wiki.sagemath.org/SageWindows lately for plots?  I'm reviewing 
> https://github.com/sagemath/sage/pull/37184 and it would be nice to have 
> that information actually in the installation guide, but for some reason it 
> didn't work for me.  (Maybe because it's my son's computer ... some sort of 
> Murphy's Law?)
>
> Thanks for any info.
>

-- 
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/6a2a1f61-2745-4f5b-938a-3517f9af9481n%40googlegroups.com.


[sage-support] Re: init.sage not running anymore

2024-03-04 Thread Emmanuel Charpentier


FWIW, Someone going under the nickname of stillconfused posted alpost 
exactly the same problem 
 
on ask.sagemath.org. Is that you ?
​
Le dimanche 3 mars 2024 à 21:40:50 UTC+1, David Ayotte a écrit :

> Hello,
>
> Since I upgraded my SageMath to version 10.3.beta8, the init.sage script 
> located at ~/.sage/init.sage stopped running when I start sage. I also get 
> the following message right after the SageMath banner:
>
> /home/user/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/prompt_toolkit/application/application.py:988:
>  
> DeprecationWarning: There is no current event loop
>   loop = asyncio.get_event_loop()
>
> Do anybody know what happened here? I like to use this script for defining 
> some frequently used variables.
>
> Best,
>
> David 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/4a601786-fc56-482e-a2fa-d35a58258057n%40googlegroups.com.


Re: [sage-support] Issues with real precision

2024-02-24 Thread Emmanuel Charpentier


Le samedi 24 février 2024 à 18:11:25 UTC+1, Gareth Ma a écrit :

Note that you can wrap it in `Decimal` or `Fraction`, which are both 
builtin Python libraries.

I stand corrected. Python ints are bignums, *not* 32-bits integers. and 
fractions.Fractions are rationals. Ordinary integer arithmetic wroks with 
these rationals. We just need a binomial coefficient function returning an 
int (math.comb returns a float) :
>>> from math import factorial >>> from fractions import Fraction >>> def 
ibin(n, k): return Fraction(factorial(n), factorial(k)*factorial(n-k)) if 
n>=k else 0 ... >>> def g(n, k, r): return 
(-1)**k*ibin(n,k)*Fraction((n-k)**r, n**r) ... >>> def f(n, r): return 
float(sum([g(n,k,r) for k in range(n+1)])) ... >>> f(365, 2000) 
0.21611945163321844 

A tad more muscular than using Sage…

Thanks a lot ! I learned something useful today…

On Saturday 24 February 2024 at 13:54:51 UTC Emmanuel Charpentier wrote:

Le vendredi 23 février 2024 à 23:23:20 UTC+1, Dima Pasechnik a écrit :

[ Snip…]

the normal Python way, without any symbolic sum, would be like this:


sage: sage: g(n,k,r)=(-1)^(k)*binomial(n,k)*(n-k)^r/n^r
: sage: def f(n,r): return math.fsum([1.0*g(n,k,r) for k in range(n+1)])
: sage: f(365,2000)
0.21611945163321847

This works *in Sagemath*. It wouldn’t work in Python : the range of the 
magnitudes of the terms of the *alternating* sum are way too large for the 
precision of Python’s floats, necessary if you want to use math.comb. 
Programming this in Python would need some serious analytical work, or 
using a multiple-precision integer library, which Sage does for you…

[ Re-snip... ]

HTH,


​

-- 
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/4dfa86e9-d3c8-42cc-8bda-826640da9cf8n%40googlegroups.com.


Re: [sage-support] Issues with real precision

2024-02-24 Thread Emmanuel Charpentier


Le vendredi 23 février 2024 à 23:23:20 UTC+1, Dima Pasechnik a écrit :

[ Snip…]

the normal Python way, without any symbolic sum, would be like this:


sage: sage: g(n,k,r)=(-1)^(k)*binomial(n,k)*(n-k)^r/n^r
: sage: def f(n,r): return math.fsum([1.0*g(n,k,r) for k in range(n+1)])
: sage: f(365,2000)
0.21611945163321847

This works *in Sagemath*. It wouldn’t work in Python : the range of the 
magnitudes of the terms of the *alternating* sum are way too large for the 
precision of Python’s floats, necessary if you want to use math.comb. 
Programming this in Python would need some serious analytical work, or 
using a multiple-precision integer library, which Sage does for you…

[ Re-snip... ]

HTH,


-- 
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/951d18fd-1e64-4943-bc7d-d653b9035ce4n%40googlegroups.com.


[sage-support] Re: Why cant this limit be evaluated?

2024-02-19 Thread Emmanuel Charpentier


Indeed. That’s probably an oversight :
sage: elliptic_kc(x).limit(x=0) 1/2*pi sage: elliptic_ec(x).limit(x=0) 
limit(elliptic_ec(x), x, 0) 

Curioisly :
sage: elliptic_ec(0) 1/2*pi 

FWIW :
sage: D(r)._mathematica_().Limit(mathematica.Rule(r, 0)) -1/8 

HTH,
​
Le lundi 19 février 2024 à 21:25:51 UTC+1, Mark “Essa King” Sukaiti a 
écrit :

> D(r)=-1/2*((3*r^2 - 1)*elliptic_ec((4*r/(r^2 + 2*r + 1)))^2 + (r^2 - 2*r + 
> 1)*elliptic_ec((4*r/(r^2 + 2*r + 1)))*elliptic_kc((4*r/(r^2 + 2*r + 
> 1/(pi^2*r^8 - 2*pi^2*r^7 - pi^2*r^6 + 4*pi^2*r^5 - pi^2*r^4 - 
> 2*pi^2*r^3 + pi^2*r^2)
>
> D(r).limit(r=0)
>
> The limit should be -0.125 (or -1/8) but it seems maxima doesnt know the 
> limit of elliptic_ec(x) for x->0
> [image: 2024-02-20_00-22.png]
> Sympy also fails giving -5/8.
>
> The other algorithms cant evaluate it either.
>

-- 
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/25c243ea-fa2c-489e-93c8-ec9c946d3779n%40googlegroups.com.


[sage-support] Developer's guide and configure : the list of packages needs some updating

2024-01-22 Thread Emmanuel Charpentier


For installation from source on Debian, a few packages have incorrect names 
in the Developer’s guide (and possibly in the configuration process files) :
| Replace | with | 
++--| | 
beautifulsoup4 | python3-bs4 | | cython | cython3 | | hatch-vcs | 
python3-hatch-vcs | | importlib-resources | python3-importlib-resources | | 
ipykernel | python3-ipykernel | | meson-python | python3-mesonpy (?) | | 
python-fastjsonschema | python3-fastjsonschema | | 
python-hatch-fancy-pypi-readme | python3-hatch-fancy-pypi-readme | | 
python-tinycss2 | python3-tinycss2 | | rpy2 | python3-rpy2 | | 
setuptools-scm | python3-setuptools-scm | | sphinxcontrib-websupport | 
python3-sphinxcontrib.websupport | 

A question : are clang and clang-relatedpackages necessary or a “simple 
recommendation” ? In the latter case, what is the rationale ?

Another couple of questions :

   - 
   
   How to report such problems efficiently ?
   - 
   
   What to fix in the source in order to fix them ?
   
HTH,
​

-- 
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/0f62ff1c-bc7f-4dfc-9924-e357ef7cc467n%40googlegroups.com.


[sage-support] Re: Sage seems to incorrectly evaluate fractional powers of complexes

2024-01-04 Thread Emmanuel Charpentier


Indeed :
(%i29) domain:complex; (%o29) complex (%i30) Sol1C:solve(Sys1, Unks); 
(%o30) [[x = 8,y = -40/3,l = (2*25^(1/3))/(3*9^(1/3))]] (%i31) 
Sol2C:solve(Sys2, Unks); (%o31) [] (%i32) map(lambda([w], map(lambda([v], 
subst(w, v)), map(lambda([u], ratsimp(lhs(u)-rhs(u))), Sys1))), Sol1C); 
(%o32) [[((8*(-1)^(2/3)*5^(5/3))/3^(2/3)-(40*25^(1/3))/9^(1/3))/12, 
((8*(-1)^(1/3)*3^(2/3)*5^(1/3)*25^(1/3))/9^(1/3)+40) 
/(2*(-1)^(1/3)*3^(2/3)*5^(1/3)),0]] (%i33) %, numer; (%o33) 
[[0.08333*(56.22884435344994 
*(0.8660254037844387*%i-0.4998) -56.22884435344994), 
0.1405721108836249*(39.99 
*(0.8660254037844386*%i+0.5001) 
+40)*(0.5001-0.8660254037844386*%i), 0]] (%i34) map(lambda([w], 
map(lambda([v], subst(w, v)), map(lambda([u], ratsimp(lhs(u)-rhs(u))), 
Sys2))), Sol2C); (%o34) [] (%i35) %, numer; (%o35) [] 

But this does not explain whiy Sage is uneble o check (numericalmlmy or 
otherwise) the solutions given by Sympy or Mathematica, which check in 
Sympy (I didn’t yet try to check them in Mathematica, the limitations of 
the current Mathematica interface make this bothersome…).

IMHO, this would deserve a critiocal ticket (possibly a blocker one), but I 
do not know how to report this efficiently. Suggestions welcome…

HTH,
​
Le jeudi 4 janvier 2024 à 12:04:14 UTC+1, Dima Pasechnik a écrit :

> You can get the same errors from pure Maxima if you set domain to 
> "complex",
> no? 
>
> On Thursday, January 4, 2024 at 10:29:56 AM UTC Emmanuel Charpentier wrote:
>
>> The problem seems Sage-specific : the same systems solve correctly (up to 
>> numerical noise) in “pure” Maxima :
>> ;;; Loading #P"/usr/lib/x86_64-linux-gnu/ecl-21.2.1/sb-bsd-sockets.fas" 
>> ;;; Loading #P"/usr/lib/x86_64-linux-gnu/ecl-21.2.1/sockets.fas" Maxima 
>> 5.46.0 https://maxima.sourceforge.io using Lisp ECL 21.2.1 Distributed 
>> under the GNU Public License. See the file COPYING. Dedicated to the memory 
>> of William Schelter. The function bug_report() provides bug reporting 
>> information. (%i1) display2d:false; (%o1) false (%i2) Unks:[x,y,l]; (%o2) 
>> [x,y,l] (%i3) f:10*x^(1/3)*y^(2/3); (%o3) 10*x^(1/3)*y^(2/3) (%i4) g:5*x - 
>> 6*y; (%o4) 5*x-6*y (%i5) h:5*x^2 + 6*y; (%o5) 6*y+5*x^2 (%i6) fx:diff(f,x); 
>> (%o6) (10*y^(2/3))/(3*x^(2/3)) (%i7) fy:diff(f, y); (%o7) 
>> (20*x^(1/3))/(3*y^(1/3)) (%i8) gx:diff(g, x); (%o8) 5 (%i9) gy:diff(g, y); 
>> (%o9) -6 (%i10) hx:diff(h, x); (%o10) 10*x (%i11) hy:diff(h, y); (%o11) 6 
>> (%i12) Sys1:[fx=l*gx,fy=l*gy,g=120]; (%o12) [(10*y^(2/3))/(3*x^(2/3)) = 
>> 5*l,(20*x^(1/3))/(3*y^(1/3)) = -6*l, 5*x-6*y = 120] (%i13) 
>> Sys2:[fx=l*hx,fy=l*hy,h=120]; (%o13) [(10*y^(2/3))/(3*x^(2/3)) = 
>> 10*l*x,(20*x^(1/3))/(3*y^(1/3)) = 6*l, 6*y+5*x^2 = 120] (%i14) 
>> Sol1:solve(Sys1, Unks); (%o14) [[x = 8,y = -40/3,l = (2*5^(2/3))/3^(5/3)]] 
>> (%i15) Sol2:solve(Sys2, Unks); (%o15) [[x = (2*sqrt(6))/sqrt(5),y = 16,l = 
>> 18750^(1/6)/9], [x = -(2*sqrt(6))/sqrt(5),y = 16,l = -18750^(1/6)/9]] 
>> (%i16) map(lambda([w], map(lambda([v], subst(w, v)), map(lambda([u], 
>> ratsimp(lhs(u)-rhs(u))), Sys1))), Sol1); (%o16) [[0,0,0]] (%i17) 
>> map(lambda([w], map(lambda([v], subst(w, v)), map(lambda([u], 
>> ratsimp(lhs(u)-rhs(u))), Sys2))), Sol2); (%o17) 
>> [[(5^(1/3)*(5*2^(11/3)-(2^(8/3)*5^(1/6)*6^(5/6)*18750^(1/6))/3)) 
>> /(3*2^(2/3)*6^(1/3)), 
>> -(2^(7/3)*18750^(1/6)-2^(7/3)*5^(5/6)*6^(1/6))/(3*2^(4/3)),0], 
>> [(5^(1/3)*(5*2^(11/3)-(2^(8/3)*5^(1/6)*6^(5/6)*18750^(1/6))/3)) 
>> /(3*2^(2/3)*6^(1/3)), 
>> -(2^(7/3)*5^(5/6)*6^(1/6)-2^(7/3)*18750^(1/6))/(3*2^(4/3)),0]] (%i18) %, 
>> numer; (%o18) [[1.404069277432862e-15,0.0,0],[1.404069277432862e-15,0.0,0]] 
>>
>> HTH,
>> ​
>> Le jeudi 4 janvier 2024 à 10:21:31 UTC+1, Emmanuel Charpentier a écrit :
>>
>>> Motivation : see [this post], which shows a case where Sage fails to 
>>> find the roots of a three equations system.
>>>
>>> I signalled in this thread that Sympy was able to find these roots. But 
>>> I stumbled on a difficulty checking these solutions.
>>>
>>> Set up the systems :
>>> # Pretext : https://groups.google.com/g/sage-support/c/Nw12vYR0L0U 
>>> Unks=var('x,y,l 
>>> <https://groups.google.com/g/sage-support/c/Nw12vYR0L0UUnks=var('x,y,l>') 
>>> f(x, y) = 10*x^(1/3)*y^(2/3) g(x, y) = 5*x - 6*y h(x, y) = 5*x^2 + 6*y fx = 
>>> diff(f,x) fy = diff(f, y) gx = diff(g, x) gy = diff(g, y) hx = diff(h, x) 
>>> hy = diff(h, y) Sys1 = [fx(x, y)==l*gx(x, y),fy(x, y)==l*gy(x, y),g(x, 
>>> y)==120] Sys2 = [fx(x, y)==l*hx(x, y),fy(x, y)==l*hy(x, y),h(x, y)==120] 
>>>
>>> Sage’s (default

[sage-support] Re: Sage seems to incorrectly evaluate fractional powers of complexes

2024-01-04 Thread Emmanuel Charpentier


The problem seems Sage-specific : the same systems solve correctly (up to 
numerical noise) in “pure” Maxima :
;;; Loading #P"/usr/lib/x86_64-linux-gnu/ecl-21.2.1/sb-bsd-sockets.fas" ;;; 
Loading #P"/usr/lib/x86_64-linux-gnu/ecl-21.2.1/sockets.fas" Maxima 5.46.0 
https://maxima.sourceforge.io using Lisp ECL 21.2.1 Distributed under the 
GNU Public License. See the file COPYING. Dedicated to the memory of 
William Schelter. The function bug_report() provides bug reporting 
information. (%i1) display2d:false; (%o1) false (%i2) Unks:[x,y,l]; (%o2) 
[x,y,l] (%i3) f:10*x^(1/3)*y^(2/3); (%o3) 10*x^(1/3)*y^(2/3) (%i4) g:5*x - 
6*y; (%o4) 5*x-6*y (%i5) h:5*x^2 + 6*y; (%o5) 6*y+5*x^2 (%i6) fx:diff(f,x); 
(%o6) (10*y^(2/3))/(3*x^(2/3)) (%i7) fy:diff(f, y); (%o7) 
(20*x^(1/3))/(3*y^(1/3)) (%i8) gx:diff(g, x); (%o8) 5 (%i9) gy:diff(g, y); 
(%o9) -6 (%i10) hx:diff(h, x); (%o10) 10*x (%i11) hy:diff(h, y); (%o11) 6 
(%i12) Sys1:[fx=l*gx,fy=l*gy,g=120]; (%o12) [(10*y^(2/3))/(3*x^(2/3)) = 
5*l,(20*x^(1/3))/(3*y^(1/3)) = -6*l, 5*x-6*y = 120] (%i13) 
Sys2:[fx=l*hx,fy=l*hy,h=120]; (%o13) [(10*y^(2/3))/(3*x^(2/3)) = 
10*l*x,(20*x^(1/3))/(3*y^(1/3)) = 6*l, 6*y+5*x^2 = 120] (%i14) 
Sol1:solve(Sys1, Unks); (%o14) [[x = 8,y = -40/3,l = (2*5^(2/3))/3^(5/3)]] 
(%i15) Sol2:solve(Sys2, Unks); (%o15) [[x = (2*sqrt(6))/sqrt(5),y = 16,l = 
18750^(1/6)/9], [x = -(2*sqrt(6))/sqrt(5),y = 16,l = -18750^(1/6)/9]] 
(%i16) map(lambda([w], map(lambda([v], subst(w, v)), map(lambda([u], 
ratsimp(lhs(u)-rhs(u))), Sys1))), Sol1); (%o16) [[0,0,0]] (%i17) 
map(lambda([w], map(lambda([v], subst(w, v)), map(lambda([u], 
ratsimp(lhs(u)-rhs(u))), Sys2))), Sol2); (%o17) 
[[(5^(1/3)*(5*2^(11/3)-(2^(8/3)*5^(1/6)*6^(5/6)*18750^(1/6))/3)) 
/(3*2^(2/3)*6^(1/3)), 
-(2^(7/3)*18750^(1/6)-2^(7/3)*5^(5/6)*6^(1/6))/(3*2^(4/3)),0], 
[(5^(1/3)*(5*2^(11/3)-(2^(8/3)*5^(1/6)*6^(5/6)*18750^(1/6))/3)) 
/(3*2^(2/3)*6^(1/3)), 
-(2^(7/3)*5^(5/6)*6^(1/6)-2^(7/3)*18750^(1/6))/(3*2^(4/3)),0]] (%i18) %, 
numer; (%o18) [[1.404069277432862e-15,0.0,0],[1.404069277432862e-15,0.0,0]] 

HTH,
​
Le jeudi 4 janvier 2024 à 10:21:31 UTC+1, Emmanuel Charpentier a écrit :

> Motivation : see [this post], which shows a case where Sage fails to find 
> the roots of a three equations system.
>
> I signalled in this thread that Sympy was able to find these roots. But I 
> stumbled on a difficulty checking these solutions.
>
> Set up the systems :
> # Pretext : https://groups.google.com/g/sage-support/c/Nw12vYR0L0U 
> Unks=var('x,y,l 
> <https://groups.google.com/g/sage-support/c/Nw12vYR0L0UUnks=var('x,y,l>') 
> f(x, y) = 10*x^(1/3)*y^(2/3) g(x, y) = 5*x - 6*y h(x, y) = 5*x^2 + 6*y fx = 
> diff(f,x) fy = diff(f, y) gx = diff(g, x) gy = diff(g, y) hx = diff(h, x) 
> hy = diff(h, y) Sys1 = [fx(x, y)==l*gx(x, y),fy(x, y)==l*gy(x, y),g(x, 
> y)==120] Sys2 = [fx(x, y)==l*hx(x, y),fy(x, y)==l*hy(x, y),h(x, y)==120] 
>
> Sage’s (default) solution of the first system
> DSol1 = solve(Sys1, Unks, solution_dict=True) 
>
> As already shown in the original thread, Sage (slowly) fails to solve the 
> second system. Sympy can solve it (anfd the first one too…) :
> SSol1 = solve(Sys1, Unks, algorithm="sympy") SSol2 = solve(Sys2, Unks, 
> algorithm="sympy") 
>
> For what it’s worth, chech the “competition” :
> MSol1 = [{u[1].sage():u[2].sage() for u in s} for s in 
> mathematica(Sys1).Solve(Unks)] MSol2 = [{u[1].sage():u[2].sage() for u in 
> s} for s in mathematica(Sys2).Solve(Unks)] 
>
> Both Sympy and Mathematica find one solution to the first system and two 
> for the second. These solutions have different ex^pressins, but that is not 
> problematic. The fly in the ointment is that Sage has trouble checking 
> these solutions. A simple numerical check of these solutions is :
> sage: [[(e.lhs()-e.rhs()).subs(s).n(digits=3) for e in Sys1] for s in 
> DSol1] [[-0.000977, 8.44 - 4.87*I, 0.000]] sage: 
> [[(e.lhs()-e.rhs()).subs(s).n(digits=3) for e in Sys1] for s in SSol1] 
> [[7.03 - 4.06*I, 0.000488*I, 0.000]] sage: 
> [[(e.lhs()-e.rhs()).subs(s).n(digits=3) for e in Sys2] for s in SSol2] 
> [[0.000977, 0.000, 0.000], [-0.000977 + 0.00195*I, 0.000122 - 0.000244*I, 
> 0.000]] sage: [[(e.lhs()-e.rhs()).subs(s).n(digits=3) for e in Sys1] for s 
> in MSol1] [[7.03 - 4.06*I, 0.000, 0.000]] sage: 
> [[(e.lhs()-e.rhs()).subs(s).n(digits=3) for e in Sys2] for s in MSol2] 
> [[-0.00146 - 0.000977*I, 0.000122 + 0.000244*I, 0.000], [0.00195, 0.000244, 
> 0.000]] 
>
> None of these solutions seems to check. Uh oh…
>
> However, using sympy to compute the same numerical checks gives different 
> results :
> sage: [[(e.lhs()-e.rhs())._sympy_().subs(sympy.sympify(s)).simplify().n(3) 
> for e in Sys1] for s in DSol1] [[-7.03 + 4.06*I, 8.43 - 4.87*I, 0]] sage: 
> [[(e.lhs()-e.rhs())._sympy_().subs(sympy.sympify(s)).

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

2024-01-04 Thread Emmanuel Charpentier


These systems and Sage’s “solutions” exhibit some *serious* problems. See 
there <https://groups.google.com/g/sage-support/c/gGssS_15jxE>…
​
Le mardi 2 janvier 2024 à 12:30:14 UTC+1, Emmanuel Charpentier a écrit :

> FWIW, a working workaround this interesting Maxima quirk (bug ?) is to use 
> sympy, as demonstrated here 
> <https://sagecell.sagemath.org/?z=eJyNj8sKgzAQRfeC_yBunKRT6oN2l18RhDYZIWLRYjN_X2NiuyiFrnLvHHImWboJCoeMthBpomGNQlWldC1Up0ZIbqFezzQxAZ2lO14kpwm9e1sftol26tprDRqdV_He2N-OzGzM8N48o8gIMw-J9-rhTOMT5tEuNwDtwk5lpQkRNX9GIWJ8qKrqUiBsXxOYddaMU_-gQeUzD3fOxW85fcspyulf-QulymS5&lang=sage&interacts=eJyLjgUAARUAuQ==>
> .
>
> HTH,
> ​
> Le mardi 28 novembre 2023 à 16:36:30 UTC+1, Fernando Q. Gouvea a écrit :
>
>> Yesterday I was demonstrating to my calculus class Sage's ability to 
>> implement the method of Lagrange multipliers. I used a standard example, 
>> putting the following code into SageMath Cell: 
>>
>> var('x,y,l') 
>> f(x,y)=10*x^(1/3)*y^(2/3) 
>> g(x,y)=5*x-6*y 
>> fx=diff(f,x) 
>> fy=diff(f,y) 
>> gx=diff(g,x) 
>> gy=diff(g,y) 
>> solve((fx(x,y)==l*gx(x,y),fy(x,y)==l*gy(x,y),g(x,y)==120),(x,y,l)) 
>>
>> That works beautifully. Then I decided to show off Sage's powers by 
>> making a little change: 
>>
>> var('x,y,l') 
>> f(x,y)=10*x^(1/3)*y^(2/3) 
>> g(x,y)=5*x^2+6*y 
>> fx=diff(f,x) 
>> fy=diff(f,y) 
>> gx=diff(g,x) 
>> gy=diff(g,y) 
>> solve((fx(x,y)==l*gx(x,y),fy(x,y)==l*gy(x,y),g(x,y)==120),(x,y,l)) 
>>
>> SageCell now gives me a spinning symbol ("I'm working") for a while, 
>> then seems to exit without any result. On my local installation (Sage 
>> 9.2 on Windows) it returns an empty list, []. 
>>
>> What is curious is that the constraint equation 5x^2 + 6y=120 is easily 
>> solved for y... 
>>
>> Questions: 
>>
>> 1) Shouldn't SageCell output an empty list here? 
>>
>> 2) Is this a known limitation of "solve"? 
>>
>> Fernando 
>>
>> PS: It seems that if I add "algorithm='sympy'" then solutions are found. 
>>
>> -- 
>> == 
>> Fernando Q. Gouvea 
>> Carter Professor of Mathematics 
>> Colby College 
>> Mayflower Hill 5836 
>> Waterville, ME 04901 
>> fqgo...@colby.edu http://www.colby.edu/~fqgouvea 
>>
>>
>>
>>

-- 
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/7558fee6-11fa-4557-b38e-42b8267029b7n%40googlegroups.com.


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

2024-01-04 Thread Emmanuel Charpentier
These systems and Sage's "solutions" exhibit some *serious* problems. See 
[there](https://groups.google.com/g/sage-support/c/gGssS_15jxE)...

Le mardi 2 janvier 2024 à 12:30:14 UTC+1, Emmanuel Charpentier a écrit :

> FWIW, a working workaround this interesting Maxima quirk (bug ?) is to use 
> sympy, as demonstrated here 
> <https://sagecell.sagemath.org/?z=eJyNj8sKgzAQRfeC_yBunKRT6oN2l18RhDYZIWLRYjN_X2NiuyiFrnLvHHImWboJCoeMthBpomGNQlWldC1Up0ZIbqFezzQxAZ2lO14kpwm9e1sftol26tprDRqdV_He2N-OzGzM8N48o8gIMw-J9-rhTOMT5tEuNwDtwk5lpQkRNX9GIWJ8qKrqUiBsXxOYddaMU_-gQeUzD3fOxW85fcspyulf-QulymS5&lang=sage&interacts=eJyLjgUAARUAuQ==>
> .
>
> HTH,
> ​
> Le mardi 28 novembre 2023 à 16:36:30 UTC+1, Fernando Q. Gouvea a écrit :
>
>> Yesterday I was demonstrating to my calculus class Sage's ability to 
>> implement the method of Lagrange multipliers. I used a standard example, 
>> putting the following code into SageMath Cell: 
>>
>> var('x,y,l') 
>> f(x,y)=10*x^(1/3)*y^(2/3) 
>> g(x,y)=5*x-6*y 
>> fx=diff(f,x) 
>> fy=diff(f,y) 
>> gx=diff(g,x) 
>> gy=diff(g,y) 
>> solve((fx(x,y)==l*gx(x,y),fy(x,y)==l*gy(x,y),g(x,y)==120),(x,y,l)) 
>>
>> That works beautifully. Then I decided to show off Sage's powers by 
>> making a little change: 
>>
>> var('x,y,l') 
>> f(x,y)=10*x^(1/3)*y^(2/3) 
>> g(x,y)=5*x^2+6*y 
>> fx=diff(f,x) 
>> fy=diff(f,y) 
>> gx=diff(g,x) 
>> gy=diff(g,y) 
>> solve((fx(x,y)==l*gx(x,y),fy(x,y)==l*gy(x,y),g(x,y)==120),(x,y,l)) 
>>
>> SageCell now gives me a spinning symbol ("I'm working") for a while, 
>> then seems to exit without any result. On my local installation (Sage 
>> 9.2 on Windows) it returns an empty list, []. 
>>
>> What is curious is that the constraint equation 5x^2 + 6y=120 is easily 
>> solved for y... 
>>
>> Questions: 
>>
>> 1) Shouldn't SageCell output an empty list here? 
>>
>> 2) Is this a known limitation of "solve"? 
>>
>> Fernando 
>>
>> PS: It seems that if I add "algorithm='sympy'" then solutions are found. 
>>
>> -- 
>> == 
>> Fernando Q. Gouvea 
>> Carter Professor of Mathematics 
>> Colby College 
>> Mayflower Hill 5836 
>> Waterville, ME 04901 
>> fqgo...@colby.edu http://www.colby.edu/~fqgouvea 
>>
>>
>>
>>

-- 
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/633463b4-c2c9-4d8c-add0-1a691a16e948n%40googlegroups.com.


[sage-support] Sage seems to incorrectly evaluate fractional powers of complexes

2024-01-04 Thread Emmanuel Charpentier


Motivation : see [this post], which shows a case where Sage fails to find 
the roots of a three equations system.

I signalled in this thread that Sympy was able to find these roots. But I 
stumbled on a difficulty checking these solutions.

Set up the systems :
# Pretext : https://groups.google.com/g/sage-support/c/Nw12vYR0L0U 
Unks=var('x,y,l') f(x, y) = 10*x^(1/3)*y^(2/3) g(x, y) = 5*x - 6*y h(x, y) 
= 5*x^2 + 6*y fx = diff(f,x) fy = diff(f, y) gx = diff(g, x) gy = diff(g, 
y) hx = diff(h, x) hy = diff(h, y) Sys1 = [fx(x, y)==l*gx(x, y),fy(x, 
y)==l*gy(x, y),g(x, y)==120] Sys2 = [fx(x, y)==l*hx(x, y),fy(x, y)==l*hy(x, 
y),h(x, y)==120] 

Sage’s (default) solution of the first system
DSol1 = solve(Sys1, Unks, solution_dict=True) 

As already shown in the original thread, Sage (slowly) fails to solve the 
second system. Sympy can solve it (anfd the first one too…) :
SSol1 = solve(Sys1, Unks, algorithm="sympy") SSol2 = solve(Sys2, Unks, 
algorithm="sympy") 

For what it’s worth, chech the “competition” :
MSol1 = [{u[1].sage():u[2].sage() for u in s} for s in 
mathematica(Sys1).Solve(Unks)] MSol2 = [{u[1].sage():u[2].sage() for u in 
s} for s in mathematica(Sys2).Solve(Unks)] 

Both Sympy and Mathematica find one solution to the first system and two 
for the second. These solutions have different ex^pressins, but that is not 
problematic. The fly in the ointment is that Sage has trouble checking 
these solutions. A simple numerical check of these solutions is :
sage: [[(e.lhs()-e.rhs()).subs(s).n(digits=3) for e in Sys1] for s in 
DSol1] [[-0.000977, 8.44 - 4.87*I, 0.000]] sage: 
[[(e.lhs()-e.rhs()).subs(s).n(digits=3) for e in Sys1] for s in SSol1] 
[[7.03 - 4.06*I, 0.000488*I, 0.000]] sage: 
[[(e.lhs()-e.rhs()).subs(s).n(digits=3) for e in Sys2] for s in SSol2] 
[[0.000977, 0.000, 0.000], [-0.000977 + 0.00195*I, 0.000122 - 0.000244*I, 
0.000]] sage: [[(e.lhs()-e.rhs()).subs(s).n(digits=3) for e in Sys1] for s 
in MSol1] [[7.03 - 4.06*I, 0.000, 0.000]] sage: 
[[(e.lhs()-e.rhs()).subs(s).n(digits=3) for e in Sys2] for s in MSol2] 
[[-0.00146 - 0.000977*I, 0.000122 + 0.000244*I, 0.000], [0.00195, 0.000244, 
0.000]] 

None of these solutions seems to check. Uh oh…

However, using sympy to compute the same numerical checks gives different 
results :
sage: [[(e.lhs()-e.rhs())._sympy_().subs(sympy.sympify(s)).simplify().n(3) 
for e in Sys1] for s in DSol1] [[-7.03 + 4.06*I, 8.43 - 4.87*I, 0]] sage: 
[[(e.lhs()-e.rhs())._sympy_().subs(sympy.sympify(s)).simplify().n(3) for e 
in Sys1] for s in SSol1] [[0, 0, 0]] sage: 
[[(e.lhs()-e.rhs())._sympy_().subs(sympy.sympify(s)).simplify().n(3) for e 
in Sys2] for s in SSol2] [[0, 0, 0], [0, 0, 0]] sage: 
[[(e.lhs()-e.rhs())._sympy_().subs(sympy.sympify(s)).simplify().n(3) for e 
in Sys1] for s in MSol1] [[0, 0, 0]] sage: 
[[(e.lhs()-e.rhs())._sympy_().subs(sympy.sympify(s)).simplify().n(3) for e 
in Sys2] for s in MSol2] [[0, 0, 0], [0, 0, 0]] 

Sage’s solution to the first system does not check ; Both Sympy’s and 
Mathematica’s solutions of both systems check.

This tells us that 

   - 
   
   Sage’s solution of the first system is wrong, and that
   - 
   
   Sage’s computaion of the numerical checks of knows solutins is *also* 
   wrong.
   
This suggests a bug in Sage’s computations ; this problem *may* be bound to 
the use of fractional powers.

Any hint on the “right” way to report this issue eficiently welcome.
​

-- 
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/c6a7f267-dd7b-4f7b-807b-42f59374c6e0n%40googlegroups.com.


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

2024-01-02 Thread Emmanuel Charpentier


FWIW, a working workaround this interesting Maxima quirk (bug ?) is to use 
sympy, as demonstrated here 

.

HTH,
​
Le mardi 28 novembre 2023 à 16:36:30 UTC+1, Fernando Q. Gouvea a écrit :

> Yesterday I was demonstrating to my calculus class Sage's ability to 
> implement the method of Lagrange multipliers. I used a standard example, 
> putting the following code into SageMath Cell:
>
> var('x,y,l')
> f(x,y)=10*x^(1/3)*y^(2/3)
> g(x,y)=5*x-6*y
> fx=diff(f,x)
> fy=diff(f,y)
> gx=diff(g,x)
> gy=diff(g,y)
> solve((fx(x,y)==l*gx(x,y),fy(x,y)==l*gy(x,y),g(x,y)==120),(x,y,l))
>
> That works beautifully. Then I decided to show off Sage's powers by 
> making a little change:
>
> var('x,y,l')
> f(x,y)=10*x^(1/3)*y^(2/3)
> g(x,y)=5*x^2+6*y
> fx=diff(f,x)
> fy=diff(f,y)
> gx=diff(g,x)
> gy=diff(g,y)
> solve((fx(x,y)==l*gx(x,y),fy(x,y)==l*gy(x,y),g(x,y)==120),(x,y,l))
>
> SageCell now gives me a spinning symbol ("I'm working") for a while, 
> then seems to exit without any result. On my local installation (Sage 
> 9.2 on Windows) it returns an empty list, [].
>
> What is curious is that the constraint equation 5x^2 + 6y=120 is easily 
> solved for y...
>
> Questions:
>
> 1) Shouldn't SageCell output an empty list here?
>
> 2) Is this a known limitation of "solve"?
>
> Fernando
>
> PS: It seems that if I add "algorithm='sympy'" then solutions are found.
>
> -- 
> ==
> Fernando Q. Gouvea
> Carter Professor of Mathematics
> Colby College
> Mayflower Hill 5836
> Waterville, ME 04901 
> fqgo...@colby.edu http://www.colby.edu/~fqgouvea
>
>
>
>

-- 
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/5a3584b1-a59b-4b58-a8a2-86a2869a40b3n%40googlegroups.com.


[sage-support] Re: A nice (minor ?) bug ?

2023-12-24 Thread Emmanuel Charpentier


Never ming : this has been reported 
<https://github.com/sagemath/sage/issues/35489> six months ago…

Sorry for the noise…
​
Le vendredi 22 décembre 2023 à 06:51:59 UTC+1, Emmanuel Charpentier a 
écrit :

> Seen in 10.3.beta3 :
> sage: show_identifiers() :1: 
> DeprecationWarning: Importing Euler_Phi from here is deprecated; please use 
> "from sage.arith.misc import Euler_Phi" instead. See 
> https://github.com/sagemath/sage/issues/30322 for details. 
> show_identifiers() 
> --- 
> RuntimeError Traceback (most recent call last) Cell In[1], line 1 > 1 
> show_identifiers() File /usr/local/sage-10/src/sage/misc/session.pyx:232, 
> in sage.misc.session.show_identifiers() 230 return val == 
> DocTestTask.extra_globals.get(name, _none) 231 --> 232 return sorted([x for 
> x, v in state.items() if _is_new_var(x, v, hidden) 233 and not 
> _in_extra_globals(x, v)]) 234 RuntimeError: dictionary changed size during 
> iteration 
>
> How to report it efficiently ?
> ​
>

-- 
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/4d6c6d6c-12be-48c0-be90-4408061dff33n%40googlegroups.com.


[sage-support] A nice (minor ?) bug ?

2023-12-21 Thread Emmanuel Charpentier


Seen in 10.3.beta3 :
sage: show_identifiers() :1: 
DeprecationWarning: Importing Euler_Phi from here is deprecated; please use 
"from sage.arith.misc import Euler_Phi" instead. See 
https://github.com/sagemath/sage/issues/30322 for details. 
show_identifiers() 
--- 
RuntimeError Traceback (most recent call last) Cell In[1], line 1 > 1 
show_identifiers() File /usr/local/sage-10/src/sage/misc/session.pyx:232, 
in sage.misc.session.show_identifiers() 230 return val == 
DocTestTask.extra_globals.get(name, _none) 231 --> 232 return sorted([x for 
x, v in state.items() if _is_new_var(x, v, hidden) 233 and not 
_in_extra_globals(x, v)]) 234 RuntimeError: dictionary changed size during 
iteration 

How to report it efficiently ?
​

-- 
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/0709349c-43c8-4e49-9f28-0640dae7b805n%40googlegroups.com.


[sage-support] Re: Problem with plot

2023-12-16 Thread Emmanuel Charpentier


Le mercredi 13 décembre 2023 à 12:35:42 UTC+1, Philippe Delavalade a écrit :

Hi. 

I'm using sage-10.2 with linux (slint-15.0 based on slackware 15.0) on the 
console. 

When I run 
p=plot(x^2); p 
there is no graphics on the screen, just the line 
Launched png viewer for Graphics object consisting of 1 graphics primitive 

Is something missing in my configuration ?

Maybe : WorksForMe(TM) on Debian testing installed from source. How did you 
obtain your installation ?

Moreover, in help(plot), the command sphinx_plot is often used but on my 
machine I obtain 
NameError: name 'sphinx_plot' is not defined

Googling sagemath sphinx_plot leads you to the General conventions 
 chapter of 
the Sage developer Guide 
, where it appears 
that this function is part of the Sphinx system of documentation 
(especially the mechanisms extracting viewable/printable documentation from 
Python docstrings).

This function appears to trigger the output of (some relevant form of) 
graphics in the desired documentation. Since help gives you a *text* form 
of the docstring, which does not have any useful form of graphics, what you 
get in the output is the (unexecuted) function call.

A complete explanation probably exists in the Sphinx documentation, which 
I’m currently too lazy to chase on the ‘Net…

HTH,



Thanks for help. 

-- 
Philippe 

​

-- 
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/5f5cf9f2-4bf5-4558-8417-6e31c50858d7n%40googlegroups.com.


[sage-support] Re: factor((A-B)*(B-C)).list() ?

2023-10-23 Thread Emmanuel Charpentier
sage: var("a, b, c") (a, b, c) sage: foo=(a-b)*(b-c) ; foo (a - b)*(b - c) 

Note that :
sage: foo.expand() a*b - b^2 - a*c + b*c 

>From foo.list? :
Docstring: Return the coefficients of this symbolic expression as a 
polynomial in x. INPUT: * "x" -- optional variable. OUTPUT: A list of 
expressions where the "n"-th element is the coefficient of "x^n" when self 
is seen as polynomial in "x". 

Therefore :
sage: foo.list() [-b^2 + b*c, b - c] 

Is indeed the list of foo’s coefficients of powers of a.

What you seek is :
sage: foo.operands() [a - b, b - c] 

HTH,

BTW, a better forum or this kind of questions is probably ask.sagemath.org.
​
Le lundi 23 octobre 2023 à 18:23:32 UTC+2, Rolandb a écrit :

> Hi,
>
> I am surprised by  the output (9.8 and 10.1 Ubuntu):
> var('A,B,C') factor((A-B)*(B-C)).list()
> var('A,B,C') factor((A-B)*(B-C)).list()
>
> var('A,B,C')
> factor((A-B)*(B-C)).list()
> [-B^2 + B*C, B - C]
>
> I expected [B - A, B - C]. Any explanation?
>
> Kind regards,
>
> Roland
>

-- 
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/a893adfb-7a84-46e0-8c8c-b8df8b357034n%40googlegroups.com.


[sage-support] Re: factor((A-B)*(B-C)).list() ?

2023-10-23 Thread Emmanuel Charpentier
```
sage: var("a, b, c")
(a, b, c)
sage: foo=(a-b)*(b-c) ; foo
(a - b)*(b - c)
```

Note that :

```
sage: foo.expand()
a*b - b^2 - a*c + b*c
```

>From `foo.list?` :

```
Docstring: 
   Return the coefficients of this symbolic expression as a polynomial
   in x.

   INPUT:

   * "x" -- optional variable.

   OUTPUT:

   A list of expressions where the "n"-th element is the coefficient
   of "x^n" when self is seen as polynomial in "x".
```

Therefore :

```
sage: foo.list()
[-b^2 + b*c, b - c]
```

Is indeed the list of foo's coefficients of powers of `a`.

What you seek is :

```
sage: foo.operands()
[a - b, b - c]
```

HTH,
Le lundi 23 octobre 2023 à 18:23:32 UTC+2, Rolandb a écrit :

> Hi,
>
> I am surprised by  the output (9.8 and 10.1 Ubuntu):
> var('A,B,C') factor((A-B)*(B-C)).list()
> var('A,B,C') factor((A-B)*(B-C)).list()
>
> var('A,B,C')
> factor((A-B)*(B-C)).list()
> [-B^2 + B*C, B - C]
>
> I expected [B - A, B - C]. Any explanation?
>
> Kind regards,
>
> Roland
>

-- 
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/2b276448-dbf6-4b6a-83a2-01422f0e16c8n%40googlegroups.com.


[sage-support] Re: factor((A-B)*(B-C)).list() ?

2023-10-23 Thread Emmanuel Charpentier


FWIW :
sage: var("a, b, c") (a, b, c) sage: ((a-b)*(b-c)) (a - b)*(b - c) sage: 
((a-b)*(b-c)).list() [-b^2 + b*c, b - c] sage: ((a-b)*(b-c)).operands() [a 
- b, b - c] 

HTH,
​
Le lundi 23 octobre 2023 à 18:23:32 UTC+2, Rolandb a écrit :

> Hi,
>
> I am surprised by  the output (9.8 and 10.1 Ubuntu):
> var('A,B,C') factor((A-B)*(B-C)).list()
> var('A,B,C') factor((A-B)*(B-C)).list()
>
> var('A,B,C')
> factor((A-B)*(B-C)).list()
> [-B^2 + B*C, B - C]
>
> I expected [B - A, B - C]. Any explanation?
>
> Kind regards,
>
> Roland
>

-- 
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/456c9fa5-1950-4e72-8017-9dcb1fe2cde4n%40googlegroups.com.


[sage-support] (Possible) bug in solving a simple complex equation.

2023-08-06 Thread Emmanuel Charpentier


Consider :
sage: reset() sage: z=var("z") sage: Eq=(3+4*I)^2-2*(z.conjugate())==z ; Eq 
-2*conjugate(z) + 24*I - 7 == z sage: Sol=solve(Eq, z) ; Sol [z == (8*I - 
7/3)] sage: Eq.subs(Sol[0]) (40*I - 7/3) == (8*I - 7/3) sage: 
bool(Eq.subs(Sol[0])) False 

which annoys me *immensely*. It reeks of conjugate() error, which, AFAICT 
is ginac territory…

However :
sage: E2=(Eq.lhs()-Eq.rhs()).subs(z=x+I*y) ; E2 -3*x + I*y + 24*I - 7 sage: 
S2=solve([E2.real(), E2.imag()], [x, y]) ; S2 [[x == (-7/3), y == -24]] 
sage: E2.subs(S2[0]) 0 sage: Eq.subs(z==x+I*y).subs(S2[0]) (-24*I - 7/3) == 
(-24*I - 7/3) 

This failure to solve a *simple* equation on complexes is troubling. 
Re-reading myself did not led me to “obvious” problems.

Does this deserve a critical ticket ?

BTW, there is currently no *free* alternative :
sage: solve(Eq, z, algorithm="sympy") ConditionSet(z, Eq(-z - 
2*conjugate(z) - 7 + 24*I, 0), Complexes) sage: solve(Eq, z, 
algorithm="giac") Warning, the test a==b is performed by checking that the 
internal representation of regroup(a-b) is not 0. Therefore a==b may return 
false even if a and b are mathematically equal, if they have different 
internal representations. You can explicitly call a simplification function 
like simplify(a-b)==0 to avoid this. Warning, argument is not an equation, 
solving false=0 [z] sage: solve(Eq, z, algorithm="fricas") [z == (8*I - 
7/3)] sage: solve(Eq, z, algorithm="maxima") [z == (8*I - 7/3)] sage: 
[[u[1].sage()==u[2].sage() for u in s] for s in mathematica.Solve(Eq, z)] 
[[z == (-24*I - 7/3)]] 

HTH,
​

-- 
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/5f5517d4-e129-4724-b80f-68a73540fa6an%40googlegroups.com.


Re: [sage-support] Possible bug in the mathematica interface

2023-07-10 Thread Emmanuel Charpentier


Well, it’s a bit more intricate than I thought initially :
sage: reset() sage: k = var("k") sage: Ex = (1 + (-1)^k)*x^k sage: sum(Ex, 
k, 0, oo) sum(((-1)^k + 1)*x^k, k, 0, +Infinity) 

Sage (i. e. Maxima) can’t solve it.
sage: sum(Ex, k, 0, oo, algorithm="giac") 1/(x + 1) - 1/(x - 1) 

Giac does
sage: sum(Ex, k, 0, oo)._sympy_().doit() Piecewise((1/(1 - x), Abs(x) < 1), 
(Sum(x**k, (k, 0, oo)), True)) + Piecewise((1/(x + 1), Abs(x) < 1), 
(Sum((-1)**k*x**k, (k, 0, oo)), True)) 

Sympy does, gives an important precision (radius of convergence), but this 
answer can’t (yet) be (automatically) translated to Sage
sage: Ex._mathematica_().Sum(mathematica([k, 0, oo])) {(1 + (-1)^k)*k*x^k, 
0, (1 + (-1)^k)*x^k*Infinity} 

Applying the Sum (Mathematica) method to the Ex object (automatically 
translated to Mathematica) gives a nonsensical answer
sage: mathematica.Sum(*map(mathematica, (Ex, [k, 0, oo]))) {(1 + 
(-1)^k)*k*x^k, 0, (1 + (-1)^k)*x^k*Infinity} 

Ditto when calling the mathematica.Sum function to the (manually 
translated) arguments.
sage: mathematica("Sum[%s, %s]"%tuple(map(lambda u:repr(mathematica(u)), 
(Ex, [k, 0, oo] -2/(-1 + x^2) 

But passing to the interpreter a (manually built) string representting the 
function call works.

Not obvious to report…
​
Le dimanche 9 juillet 2023 à 23:45:59 UTC+2, Jan Groenewald a écrit :

> Debian 12, Sage 9.5 (debian package), Mathematica 13.3
>
> sage: mathematica("Sum[%s, %s]"%tuple(map(lambda u:repr(mathematica(u)), 
> ((1+(-1
> : )^k)*x^k, [k , 0, oo]
> -2/(-1 + x^2)
>
> sage: mathematica.Sum(*map(mathematica, ((1+(-1)^k)*x^k, [k , 0, oo])))
> {(1 + (-1)^k)*k*x^k, 0, (1 + (-1)^k)*x^k*Infinity}
>
> On Sun, 9 Jul 2023 at 23:01, Emmanuel Charpentier  
> wrote:
>
>> Inspiration : this ask.sagemath.org question 
>> <https://ask.sagemath.org/question/69855/compute-power-series/>.
>>
>> Using the Wolfram engine <https://www.wolfram.com/engine/> gives me a 
>> curious and nonsensical conversion. Compare :
>> sage: mathematica("Sum[%s, %s]"%tuple(map(lambda u:repr(mathematica(u)), 
>> ((1+(-1)^k)*x^k, [k , 0, oo] -2/(-1 + x^2) # Correct sage: 
>> mathematica.Sum(*map(mathematica, ((1+(-1)^k)*x^k, [k , 0, oo]))) {(1 + 
>> (-1)^k)*k*x^k, 0, (1 + (-1)^k)*x^k*Infinity} # Nonsensical 
>>
>> I *think* that this signs a bug in the Mathematica conversion of sum. 
>> Can someone check me with the “full blown” Mathematica interpreter before I 
>> open an new issue ?
>>
>> Thanks in advance…
>> ​
>>
>> -- 
>> 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/03eb02e5-6872-4479-8f30-ee2e92606b2an%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sage-support/03eb02e5-6872-4479-8f30-ee2e92606b2an%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/49ae8276-f134-4b7d-9fee-8d600cdbe816n%40googlegroups.com.


[sage-support] Possible bug in the mathematica interface

2023-07-09 Thread Emmanuel Charpentier


Inspiration : this ask.sagemath.org question 
.

Using the Wolfram engine  gives me a 
curious and nonsensical conversion. Compare :
sage: mathematica("Sum[%s, %s]"%tuple(map(lambda u:repr(mathematica(u)), 
((1+(-1)^k)*x^k, [k , 0, oo] -2/(-1 + x^2) # Correct sage: 
mathematica.Sum(*map(mathematica, ((1+(-1)^k)*x^k, [k , 0, oo]))) {(1 + 
(-1)^k)*k*x^k, 0, (1 + (-1)^k)*x^k*Infinity} # Nonsensical 

I *think* that this signs a bug in the Mathematica conversion of sum. Can 
someone check me with the “full blown” Mathematica interpreter before I 
open an new issue ?

Thanks in advance…
​

-- 
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/03eb02e5-6872-4479-8f30-ee2e92606b2an%40googlegroups.com.


[sage-support] A possibly serious problem in the Maxima interface.

2023-04-19 Thread Emmanuel Charpentier


The new issue #35541 , 
inspired by this `ask.sagemath.org question 
 
reports a non-insignificant discrepancy between Maxima’s behaiour of its 
solver and what our interface reports, and may be worth a look by someone 
more expert than me…

As far as I can tell, this is a new 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/53c96b0e-813f-4754-83af-cdca9bacb17cn%40googlegroups.com.


Re: [sage-support] How to convert complex_root_of to QQbar (algebraic number)

2023-04-01 Thread Emmanuel Charpentier


Le vendredi 31 mars 2023 à 15:19:51 UTC+2, William Stein a écrit :

[ Snip… ]

Meta comment -- I added this "Help me fix this..." feature to cocalc 
jupyter notebooks a week ago, and it's been extremely
popular with 1000+ uses a day.  It's exactly the sort of thing that ChatGPT 
can be very helpful with, given that Sage typical
outputs a massive scary stacktrace when anything goes wrong, and it's just 
a lot of mental effort to untangle it, especially given
the preparser.  ChatGPT is far from perfect, but it doesn't mind 
expending a lot of effort. People also often get stuck and
very frustrated with Sage due to silly little things, e.g., accidentally 
capitalizing a function name, and chatgpt instantly points
out such things. 

You can reproduce the above exactly also at https://chat.openai.com/chat by 
using the prompt:

"I ran the following SageMath 9.8 code:

(put the code)

and it produced the following error message:

(put the error)

Help me fix my code."

However, I think people find seeing and error and just clicking once then 
seeing the result right in their notebook to be easier and less
disruptive of flow than a bunch of copy/paste.

Very nice ! With the usual reservation to take chatGPT’s answers with a 
grain of salt (sometomes iceberg-sized) : chatGPT conjured out of …err.., 
thin air, a matrix log function in Sage, and a matrix log function in Sympy 
; the latter is only partially false, since Sympy’s Matrixes *do* have 
*methods* exp and log, the former is just plain wrong.

Do you think such a feature could be added to the Jupyter/Jupyterlab 
versions included in Sage ?

Or possibly to Jupyter/Juyterlab (i. e. upstream) ?
​

-- 
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/54ebf451-4b23-4f53-a29c-6b3ab1e2a790n%40googlegroups.com.


[sage-support] Re: mathematica_console() command not working

2023-01-19 Thread Emmanuel Charpentier


mathematica_console() does not indeed exist. but mathematica.console() does 
(and so does mathematica.interact(), which might be what you are really 
searching…).
​
Le jeudi 19 janvier 2023 à 11:13:28 UTC+1, pvit...@gmail.com a écrit :

> Using Sage 9.7 installed in Arch Linux over WSL2 in Windows 10.
> The interface to mathematica works, but the mathematica_console() does 
> not, with this error:
>
> NameError Traceback (most recent call last)
> Cell In[16], line 1
> > 1 mathematica_console()
>
> NameError: name 'mathematica_console' is not defined
>
> Is this command not available anymore?
>
> Thanks a lot
> Pablo
>

-- 
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/cb5cba00-b562-4969-8c77-36057751a20bn%40googlegroups.com.


[sage-support] cython_lambda not usable in practice

2023-01-18 Thread Emmanuel Charpentier


Inspired by this ask.sagemath.org question 
.
 
Let 
sage: f = x^2*sin(x) - cos(x)*e^(-x) + log(x^2 + 1) - log(sqrt(1991)) 

Then, one would may like to accelerate f evaluation via cythonization. but :
sage: cf=cython_lambda('double x', f) 
--- 
CompileError Traceback (most recent call last) File 
/usr/local/sage-9/src/sage/misc/cython.py:358, in cython(filename, verbose, 
compile_message, use_cache, create_local_c_file, annotate, sage_namespace, 
create_local_so_file) 357 with cython_namespace_package_support(): --> 358 
ext, = cythonize([ext], 359 aliases=aliases, 360 include_path=includes, 361 
compiler_directives=directives, 362 quiet=(verbose <= 0), 363 
errors_to_stderr=False, 364 use_listing_file=True) 365 finally: 366 # Read 
the "listing file" which is the file containing 367 # warning and error 
messages generated by Cython. File 
/usr/local/sage-9/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/Cython/Build/Dependencies.py:1127,
 
in cythonize(module_list, exclude, nthreads, aliases, quiet, force, 
language, exclude_failures, **options) 1126 for args in to_compile: -> 1127 
cythonize_one(*args) 1129 if exclude_failures: File 
/usr/local/sage-9/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/Cython/Build/Dependencies.py:1250,
 
in cythonize_one(pyx_file, c_file, fingerprint, quiet, options, 
raise_on_failure, embedded_metadata, full_module_name, progress) 1249 if 
raise_on_failure: -> 1250 raise CompileError(None, pyx_file) 1251 elif 
os.path.exists(c_file): CompileError: 
/tmp/tmpx6ekg9s7/spyx/_tmp_tmpgo2z5pbk_tmp_q3q1r4on_pyx/_tmp_tmpgo2z5pbk_tmp_q3q1r4on_pyx_0.pyx
 
During handling of the above exception, another exception occurred: 
RuntimeError Traceback (most recent call last) Cell In [40], line 1 > 1 
cf=cython_lambda('double x', f) File 
/usr/local/sage-9/src/sage/misc/lazy_import.pyx:402, in 
sage.misc.lazy_import.LazyImport.__call__() 400 True 401 """ --> 402 return 
self.get_object()(*args, **kwds) 403 404 def __repr__(self): File 
/usr/local/sage-9/src/sage/misc/cython.py:510, in cython_lambda(vars, expr, 
verbose, **kwds) 507 f.write(s) 509 d = {} --> 510 
cython_import_all(tmpfile, d, verbose=verbose, **kwds) 511 return d['f'] 
File /usr/local/sage-9/src/sage/misc/cython.py:563, in 
cython_import_all(filename, globals, **kwds) 548 def 
cython_import_all(filename, globals, **kwds): 549 """ 550 Imports all 
non-private (i.e., not beginning with an underscore) 551 attributes of the 
specified Cython module into the given context. (...) 561 code 562 """ --> 
563 m = cython_import(filename, **kwds) 564 for k, x in m.__dict__.items(): 
565 if k[0] != '_': File /usr/local/sage-9/src/sage/misc/cython.py:534, in 
cython_import(filename, **kwds) 517 def cython_import(filename, **kwds): 
518 """ 519 Compile a file containing Cython code, then import and return 
the 520 module. Raises an ``ImportError`` if anything goes wrong. (...) 532 
- the module that contains the compiled Cython code. 533 """ --> 534 name, 
build_dir = cython(filename, **kwds) 536 oldpath = sys.path 537 try: File 
/usr/local/sage-9/src/sage/misc/cython.py:374, in cython(filename, verbose, 
compile_message, use_cache, create_local_c_file, annotate, sage_namespace, 
create_local_so_file) 372 cython_messages = "Error compiling Cython file" 
373 except CompileError: --> 374 raise 
RuntimeError(cython_messages.strip()) 376 if verbose >= 0: 377 
sys.stderr.write(cython_messages) RuntimeError: Error compiling Cython 
file:  ... 
raise NameError("global {!r} is not defined".format(name)) sage = _s() def 
f(double x): return x^2*sin(x) - cos(x)*e^(-x) + log(x^2 + 1) - 
log(sqrt(1991)) ^ 
 
_tmp_tmpgo2z5pbk_tmp_q3q1r4on_pyx_0.pyx:18:15: undeclared name not builtin: 
sin Error compiling Cython file: 
 ... raise 
NameError("global {!r} is not defined".format(name)) sage = _s() def 
f(double x): return x^2*sin(x) - cos(x)*e^(-x) + log(x^2 + 1) - 
log(sqrt(1991)) ^ 
 
_tmp_tmpgo2z5pbk_tmp_q3q1r4on_pyx_0.pyx:18:24: undeclared name not builtin: 
cos Error compiling Cython file: 
 ... raise 
NameError("global {!r} is not defined".format(name)) sage = _s() def 
f(double x): return x^2*sin(x) - cos(x)*e^(-x) + log(x^2 + 1) - 
log(sqrt(1991)) ^ 
 
_tmp_tmpgo2z5pbk_tmp_q3q1r4on_pyx_0.pyx:18:31: undeclared name not builtin: 
e Error compiling Cython file: 
 ... raise 
NameError("global {!r} is not defined".format(name)

[sage-support] Re: gridlines in 3d ?

2023-01-17 Thread Emmanuel Charpentier
Le mardi 17 janvier 2023 à 07:21:08 UTC+1, roger...@gmail.com a écrit :
I am not sure if it is exactly what you are looking for, but a few months 
ago I wrote some lines of code to create a frame with gridlines for 3D 
plots. 

[image: plot_frame3d.png]

See the link 

.

Nice ! Would you consider a ticket adding this to Sage ?
 
The code is also included in the attachment.

Best

Rogerio

Em segunda-feira, 16 de janeiro de 2023 às 10:32:56 UTC-3, HG escreveu:

Hi,

I am looking for gridlines in 3d, is it possible with sagemath ?

anyhelp welcome

best

Henri

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/fbf34de7-ab35-47f8-8b5d-76027a817f7bn%40googlegroups.com.


Re: [sage-support] solve solution is this a bug?

2023-01-13 Thread Emmanuel Charpentier


In Google Groups, I can’t see the screenshot nor the notebook, but this is 
a FAQ, so I risk an answer :

solve, used without algorithm= uses Maxima’s solver. The latter may 
introduce new variables to denote unknown, arbitrary, quantities : “zxxx” 
denote integer arbitrary constants, “rxxx” denoting real or complex 
arbitrary constants. But…

… the Sage interface to Maxima doesn’t catch them and does not define them 
in Sage. You have to catch them and declare them yourself. A quick and 
crude way to catch undefined variables in an expression E is [u for u in 
E.variables() if str(u) not in globals()] ; declaring them may use 
var(str(u)).

HTH,
​
Le jeudi 12 janvier 2023 à 21:40:48 UTC+1, brad...@ntlworld.com a écrit :

> My mistake, here is the screenshot
>
> On Thursday, January 12, 2023 at 8:14:20 PM UTC dim...@gmail.com wrote:
>
>> On Thu, Jan 12, 2023 at 8:00 PM 'Charles Bradshaw' via sage-support 
>>  wrote: 
>> > 
>> > In the attached screenshot line 'out [113]' and 'out [98]' please 
>> observe 2*pi*z5484 
>> > the attempt to evaluate: line [114] produces the error x5484 is not 
>> defined 
>>
>> there is no attachment. 
>>
>>
>> > 
>> > is this a bug or did I not understand something? 
>> > 
>> > I am running Fedora 37 with the dnf installed 
>> > SageMath version 9.6, Release Date: 2022-05-15 
>> > Using Python 3.11.1. 
>> > 
>> > Thanks 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> Groups "sage-support" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> an email to sage-support...@googlegroups.com. 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sage-support/e870bef7-68db-49a5-b45a-5508c039caf3n%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/283777a5-40f2-4b95-ad85-f28ad3315d21n%40googlegroups.com.


Re: [sage-support] Plot doesn't respect numerical precision specification.

2022-12-06 Thread Emmanuel Charpentier


The same thing happens after :

sage: def foo(x):
: return RR(N(-1/2*pi*(tan(1/2*pi*tanh(x))^2 + 1)*(tanh(x)^2 - 
1)/tan(1/2*pi*tanh(x)), digits=30))
: 
sage: foo

sage: plot(foo, (1, 30))
Launched png viewer for Graphics object consisting of 1 graphics primitive

​


Le mardi 6 décembre 2022 à 14:23:48 UTC+1, Emmanuel Charpentier a écrit :

> Le mardi 6 décembre 2022 à 14:16:56 UTC+1, dim…@gmail.com a écrit :
>
> It's plotting via matplotlib, perhaps that's why the precision setting is 
>> ignored (or pehaps something like RDF is hardcoded in Sage plotting code)
>>
> That wouldn’t explain why the specification included in the lambda 
> expression in the third example isn’t accepted : matplotlib should see 
> the RR values returned by it (which *do* accept the precision 
> specification).
>
>
>>
>> On Tue, Dec 6, 2022 at 12:53 PM Emmanuel Charpentier <
>> emanuel.c...@gmail.com> wrote:
>>
>>> Question already asked on |`ask.sagemath.org`](
>>> https://ask.sagemath.org/question/64934/plotting-ill-conditionned-function/),
>>>  
>>> where it didn't attract a lot of attention...
>>>
>>> Let
>>>
>>> ```
>>> sage: f(x)=log(tan(pi/2*tanh(x))).diff(x) ; f
>>> x |--> -1/2*pi*(tan(1/2*pi*tanh(x))^2 + 1)*(tanh(x)^2 - 
>>> 1)/tan(1/2*pi*tanh(x))
>>> ```
>>>
>>> It can be shown (see Juanjo's answer [here](
>>> https://ask.sagemath.org/question/64794/inconsistentincorrect-value-of-limit-involving-tan-and-tanh/))
>>>  
>>> that this finction's limit at `x=oo` is 2.
>>>
>>> A couple CASes are wrong about it :
>>>
>>> ```
>>> sage: f(x).limit(x=oo)
>>> 0
>>> sage: f(x).limit(x=oo, algorithm="maxima")
>>> 0
>>> ```
>>>
>>> A couple get it right :
>>>
>>> ```
>>> sage: f(x).limit(x=oo, algorithm="giac")
>>> 2
>>> sage: f(x).limit(x=oo, algorithm="mathematica_free")
>>> 2
>>> ```
>>>
>>> And Sympy currently never returns.
>>>
>>> A "naïve" way to explore this is to assess the situation is to look for 
>>> numerical values :
>>>
>>> ```
>>> plot(f, (1, 30))
>>> ```
>>> [image: tmp_bnpx6r7n.png]
>>>
>>> This plot hints at ill-conditionong of the epression of the function. 
>>> And it turns out that this ill-conditioning can be overcome by specifying 
>>> an "absurd" precision :
>>>
>>> ```
>>> sage: f(30).n()
>>> -0.000
>>> sage: f(30).n(digits=30)
>>> 1.9483984586167962667231030
>>> ```
>>>
>>> But `plot` seems to *ignore* this specification :
>>>
>>> ```
>>> sage: plot(lambda u:f(u).n(digits=30), (1, 30))
>>> ```
>>>
>>> [image: tmp_jeq3c8ko.png]
>>>
>>> We can try to "isolate" the precision specification in a Python 
>>> function, which seems to work :
>>>
>>> ```
>>> sage: def foo(x): return RR(f(x).n(digits=30))
>>> sage: foo(30)
>>> 1.9483984586
>>> ```
>>>
>>> but is still defeated byr the inner gears of `plot` :
>>>
>>> ```
>>> sage: plot(foo, (1, 30))
>>> ```
>>>
>>> [image: tmp_dg2gelpc.png]
>>>
>>> Why, Ô why ???
>>>
>>>
>>> -- 
>>> 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/db271244-0ad7-4484-8a46-bdc4b1edd0f0n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/sage-support/db271244-0ad7-4484-8a46-bdc4b1edd0f0n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> ​
>

-- 
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/de783db9-35b4-47a4-88ba-064a1f67f532n%40googlegroups.com.


Re: [sage-support] Plot doesn't respect numerical precision specification.

2022-12-06 Thread Emmanuel Charpentier


Le mardi 6 décembre 2022 à 14:16:56 UTC+1, dim…@gmail.com a écrit :

It's plotting via matplotlib, perhaps that's why the precision setting is 
> ignored (or pehaps something like RDF is hardcoded in Sage plotting code)
>
That wouldn’t explain why the specification included in the lambda 
expression in the third example isn’t accepted : matplotlib should see the 
RR values returned by it (which *do* accept the precision specification).


>
> On Tue, Dec 6, 2022 at 12:53 PM Emmanuel Charpentier <
> emanuel.c...@gmail.com> wrote:
>
>> Question already asked on |`ask.sagemath.org`](
>> https://ask.sagemath.org/question/64934/plotting-ill-conditionned-function/),
>>  
>> where it didn't attract a lot of attention...
>>
>> Let
>>
>> ```
>> sage: f(x)=log(tan(pi/2*tanh(x))).diff(x) ; f
>> x |--> -1/2*pi*(tan(1/2*pi*tanh(x))^2 + 1)*(tanh(x)^2 - 
>> 1)/tan(1/2*pi*tanh(x))
>> ```
>>
>> It can be shown (see Juanjo's answer [here](
>> https://ask.sagemath.org/question/64794/inconsistentincorrect-value-of-limit-involving-tan-and-tanh/))
>>  
>> that this finction's limit at `x=oo` is 2.
>>
>> A couple CASes are wrong about it :
>>
>> ```
>> sage: f(x).limit(x=oo)
>> 0
>> sage: f(x).limit(x=oo, algorithm="maxima")
>> 0
>> ```
>>
>> A couple get it right :
>>
>> ```
>> sage: f(x).limit(x=oo, algorithm="giac")
>> 2
>> sage: f(x).limit(x=oo, algorithm="mathematica_free")
>> 2
>> ```
>>
>> And Sympy currently never returns.
>>
>> A "naïve" way to explore this is to assess the situation is to look for 
>> numerical values :
>>
>> ```
>> plot(f, (1, 30))
>> ```
>> [image: tmp_bnpx6r7n.png]
>>
>> This plot hints at ill-conditionong of the epression of the function. And 
>> it turns out that this ill-conditioning can be overcome by specifying an 
>> "absurd" precision :
>>
>> ```
>> sage: f(30).n()
>> -0.000
>> sage: f(30).n(digits=30)
>> 1.9483984586167962667231030
>> ```
>>
>> But `plot` seems to *ignore* this specification :
>>
>> ```
>> sage: plot(lambda u:f(u).n(digits=30), (1, 30))
>> ```
>>
>> [image: tmp_jeq3c8ko.png]
>>
>> We can try to "isolate" the precision specification in a Python function, 
>> which seems to work :
>>
>> ```
>> sage: def foo(x): return RR(f(x).n(digits=30))
>> sage: foo(30)
>> 1.9483984586
>> ```
>>
>> but is still defeated byr the inner gears of `plot` :
>>
>> ```
>> sage: plot(foo, (1, 30))
>> ```
>>
>> [image: tmp_dg2gelpc.png]
>>
>> Why, Ô why ???
>>
>>
>> -- 
>> 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/db271244-0ad7-4484-8a46-bdc4b1edd0f0n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sage-support/db271244-0ad7-4484-8a46-bdc4b1edd0f0n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> ​

-- 
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/d4815776-3bbd-44b1-bc46-cfc423cdedf4n%40googlegroups.com.


[sage-support] Plot doesn't respect numerical precision specification.

2022-12-06 Thread Emmanuel Charpentier
Question already asked on 
|`ask.sagemath.org`](https://ask.sagemath.org/question/64934/plotting-ill-conditionned-function/),
 
where it didn't attract a lot of attention...

Let

```
sage: f(x)=log(tan(pi/2*tanh(x))).diff(x) ; f
x |--> -1/2*pi*(tan(1/2*pi*tanh(x))^2 + 1)*(tanh(x)^2 - 
1)/tan(1/2*pi*tanh(x))
```

It can be shown (see Juanjo's answer 
[here](https://ask.sagemath.org/question/64794/inconsistentincorrect-value-of-limit-involving-tan-and-tanh/))
 
that this finction's limit at `x=oo` is 2.

A couple CASes are wrong about it :

```
sage: f(x).limit(x=oo)
0
sage: f(x).limit(x=oo, algorithm="maxima")
0
```

A couple get it right :

```
sage: f(x).limit(x=oo, algorithm="giac")
2
sage: f(x).limit(x=oo, algorithm="mathematica_free")
2
```

And Sympy currently never returns.

A "naïve" way to explore this is to assess the situation is to look for 
numerical values :

```
plot(f, (1, 30))
```
[image: tmp_bnpx6r7n.png]

This plot hints at ill-conditionong of the epression of the function. And 
it turns out that this ill-conditioning can be overcome by specifying an 
"absurd" precision :

```
sage: f(30).n()
-0.000
sage: f(30).n(digits=30)
1.9483984586167962667231030
```

But `plot` seems to *ignore* this specification :

```
sage: plot(lambda u:f(u).n(digits=30), (1, 30))
```

[image: tmp_jeq3c8ko.png]

We can try to "isolate" the precision specification in a Python function, 
which seems to work :

```
sage: def foo(x): return RR(f(x).n(digits=30))
sage: foo(30)
1.9483984586
```

but is still defeated byr the inner gears of `plot` :

```
sage: plot(foo, (1, 30))
```

[image: tmp_dg2gelpc.png]

Why, Ô why ???


-- 
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/db271244-0ad7-4484-8a46-bdc4b1edd0f0n%40googlegroups.com.


Re: [sage-support] Re: Sagecell : is it possible to install the Wolfram engine ?

2022-12-02 Thread Emmanuel Charpentier
William,

Le mercredi 30 novembre 2022 à 18:00:22 UTC+1, wst...@gmail.com a écrit :

> On Wed, Nov 30, 2022 at 1:26 AM Dima Pasechnik  wrote: 
> > 
> > On Sat, Nov 19, 2022 at 7:59 PM William Stein  wrote: 
> > > 
> > > On Sat, Nov 19, 2022 at 11:25 AM kcrisman  wrote: 
> > > > 
> > > > Though see this: 
> https://www.wolfram.com/engine/faq/#can-i-use-the-free-engine-in-an-open-source-project
>  
> > > 
> > > That says " However, the Free Engine license does not permit end-user 
> > > use, except when this use is for further development. For end-user 
> > > uses, users must have a separate license for the Wolfram Engine." 
> > > which seems to me to make it crystal clear that it would not be legal 
> > > to install cocalc-docker (or even Jupyter notebook) and along with 
> > > Wolfram Engine and use it for any purpose except for development of 
> > > cocalc or Jupyter itself (i.e., to make sure the UI works). 
> > > Everything in that FAQ is about "developing a product". 
> > 
> > I'm not a lawyer, but in Wolfram's mindset a scientific paper is a 
> > product, too, no ? 
> > (Especially assuming it has enough self-promotion hype in it - not 
> > sure, if this is a joke :-)) 
> > 
> > Would putting Wolfram Engine on cocalc with a warning saying "read 
> > their terms of use" be 
> > too dangerous, risking more than just being slapped with a "cease and 
> > desist" letter? 
>
> Dima, 
>
> I suspect something fairly close to what you suggest would be legal. 
> Namely, 
> you can create your own CoCalc project, then you download Wolfram 
> Engine (or any other software) to your computer, then upload it into 
> CoCalc. 
> Then use it. Our terms of service don't prevent you from uploading your 
> own binaries and using them. It's not different to you creating 
> a VM on DigitalOcean or something, and installing Wolfram Engine or any 
> other 
> software there. People have in the past done exactly the above with 
> Magma, Maple and the 
> actual full Mathematica.



Do you think that the same loophole would be applicable to Sagecelll 
(different structure...) wrt to international law, wrt american law, and 
with wrt to european law ?
 

> -- William 
>
> > 
> > Dima 
> > 
> > > This is a 
> > > license aimed at increasing the number of reasons people will buy 
> > > Mathematica, by being nice to developers who are building products 
> > > that use Mathematica. 
> > > 
> > > The discussions like this 
> > > 
> > > 
> https://mathematica.stackexchange.com/questions/274333/wolfram-engine-jupyter-stackrel-mathematica
>  
> > > 
> > > (and the corresponding reddit thread) seem to me to be wildly 
> > > optimistic in their interpretation. 
> > > 
> > > Anyway, I'm not a lawyer, though I applaud Wolfram, Inc. for posting 
> > > that very clearly worded plain language FAQ instead of just some 
> > > massive wall of legalese. 
> > > 
> > > William 
> > > 
> > > > On Saturday, November 19, 2022 at 2:24:15 PM UTC-5 kcrisman wrote: 
> > > >>> 
> > > >>> The same could also apply to Cocalc ... except that Cocalc is also 
> a commercial product, therefore excluded from Wolfram terms for the 
> *gratis* Wolfram engine... 
> > > >> 
> > > >> 
> > > >> Technically if someone ran a Cocalc instance (say, from a Docker 
> image) that was not commercial, maybe that would be okay? (IANAL as usual.) 
> > > > 
> > > > -- 
> > > > 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/58eebc97-408e-4511-bbc8-c1a61d19249en%40googlegroups.com.
>  
>
> > > 
> > > 
> > > 
> > > -- 
> > > William (http://wstein.org) 
> > > 
> > > -- 
> > > You received this message because you are subscribed to the Google 
> Groups "sage-support" group. 
> > > To unsubscribe from this group and stop receiving emails from it, send 
> an email to sage-support...@googlegroups.com. 
> > > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-support/CACLE5GBGVdaisv4SN0g2ZPZXw%3DksWWv1ZXhX8JhaCq3F02xo7w%40mail.gmail.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...@googlegroups.com. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-support/CAAWYfq02EOCja16ceAxgMxx-EycXGybPjz9j_HMd%2B%2BKo%3DBUm0g%40mail.gmail.com.
>  
>
>
>
>
> -- 
> William (http://wstein.org) 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.googl

Re: [sage-support] Re: Sagecell : is it possible to install the Wolfram engine ?

2022-11-30 Thread Emmanuel Charpentier
*Timeo advocatos a communa lege loquentes... *The relevant precedents in 
(what passes for) american law strongly hint at a very complicated 
resolution (which would enrich lawyers and nobody else...).

I do not know if William's analysis is right, but it seems to be *prudent*, 
and therefore a sound advice for preventive behavior. This is even stronger 
in his case, since his company *sells* Cocalc access/use... this point may 
be weaker for Sagecell (nothing is *sold*...), but I wouldn't bet on it : 
as far as I know, what passes for legal logic has never been proved 
complete nor consistent.

Where is Kurt Gödel when you need him ;-)...

Le mercredi 30 novembre 2022 à 10:26:17 UTC+1, dim...@gmail.com a écrit :

> On Sat, Nov 19, 2022 at 7:59 PM William Stein  wrote:
> >
> > On Sat, Nov 19, 2022 at 11:25 AM kcrisman  wrote:
> > >
> > > Though see this: 
> https://www.wolfram.com/engine/faq/#can-i-use-the-free-engine-in-an-open-source-project
> >
> > That says " However, the Free Engine license does not permit end-user
> > use, except when this use is for further development. For end-user
> > uses, users must have a separate license for the Wolfram Engine."
> > which seems to me to make it crystal clear that it would not be legal
> > to install cocalc-docker (or even Jupyter notebook) and along with
> > Wolfram Engine and use it for any purpose except for development of
> > cocalc or Jupyter itself (i.e., to make sure the UI works).
> > Everything in that FAQ is about "developing a product".
>
> I'm not a lawyer, but in Wolfram's mindset a scientific paper is a
> product, too, no ?
> (Especially assuming it has enough self-promotion hype in it - not
> sure, if this is a joke :-))
>
> Would putting Wolfram Engine on cocalc with a warning saying "read
> their terms of use" be
> too dangerous, risking more than just being slapped with a "cease and
> desist" letter?
>
> Dima
>
> > This is a
> > license aimed at increasing the number of reasons people will buy
> > Mathematica, by being nice to developers who are building products
> > that use Mathematica.
> >
> > The discussions like this
> >
> > 
> https://mathematica.stackexchange.com/questions/274333/wolfram-engine-jupyter-stackrel-mathematica
> >
> > (and the corresponding reddit thread) seem to me to be wildly
> > optimistic in their interpretation.
> >
> > Anyway, I'm not a lawyer, though I applaud Wolfram, Inc. for posting
> > that very clearly worded plain language FAQ instead of just some
> > massive wall of legalese.
> >
> > William
> >
> > > On Saturday, November 19, 2022 at 2:24:15 PM UTC-5 kcrisman wrote:
> > >>>
> > >>> The same could also apply to Cocalc ... except that Cocalc is also a 
> commercial product, therefore excluded from Wolfram terms for the *gratis* 
> Wolfram engine...
> > >>
> > >>
> > >> Technically if someone ran a Cocalc instance (say, from a Docker 
> image) that was not commercial, maybe that would be okay? (IANAL as usual.)
> > >
> > > --
> > > 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/58eebc97-408e-4511-bbc8-c1a61d19249en%40googlegroups.com
> .
> >
> >
> >
> > --
> > William (http://wstein.org)
> >
> > --
> > You received this message because you are subscribed to the Google 
> Groups "sage-support" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to sage-support...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-support/CACLE5GBGVdaisv4SN0g2ZPZXw%3DksWWv1ZXhX8JhaCq3F02xo7w%40mail.gmail.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/270e6a1d-6e00-4170-b2c1-0b2fcb8670cbn%40googlegroups.com.


Re: [sage-support] Re: Rendering tables in jupyter notebook

2022-11-20 Thread Emmanuel Charpentier

Le dimanche 20 novembre 2022 à 19:16:44 UTC+1, gauri...@gmail.com a écrit :

> Thanks! I will ask on the Jupyter mailing list. 
>
>>
>> Also is it possible for me to write [image: x^k-1] for various powers of 
>> [image: 
>> k] in latex in place of [image: x^k+2]. i.e. I want to write -1 wherever 
>> there is a 2 in the left column. Sure I can do this with print, but the 
>> output won’t be Latex rendered.
>
>
> I apologize that it was terribly worded.   It was just a dumb question 
> that occured while trying to understand how the `table` function outputs 
> data into a jupyter notebook cell. 
>
> I basically wanted the left hand-side to contain [image: x^k-1] in place 
> of [image: x^k+2] for different values of [image: k] i.e. [image: x-1] in 
> place of [image: x+2]  
>  [image: x^2-1] in place of [image: x^2+2] and so on.  I *know* of course 
> -1 and 2  are identical in Z/3Z, but I was wondering if there was a  way to 
> *display* (-1) in place of 2 while using the `table` command and working 
> Z/3Z. 
>

I doubt it : Sage is strngly opinionated (you could say asinine) about its 
presentation choices, and, for example, systematically rewrite `1/sqrt(2)` 
as `sqrt(2)/2`. Even if you sacrifice a goat ;-)...
 

> Regards
> G
>
> On Sun, Nov 20, 2022 at 3:36 PM Emmanuel Charpentier <
> emanuel.c...@gmail.com> wrote:
>
>> > How can I ask Sage to place each factorization in the right column on a 
>> single line.
>>
>> Both the display in a console and the LaTeX display given by `view` are 
>> single-lined. I can reproduce your problem in Jupyter ; therefore, I think 
>> that the question should be directed to a Jupyter-centered mailing list, 
>> newsgroup, forum or whatever...
>>
>> > Also is it possible for me to write x^k-1 for various powers of k in 
>> latex in place of x^k+2. i.e. I want to write -1 wherever there is a 2 in 
>> the left column. Sure I can do this with print, but the output won’t be 
>> Latex rendered.
>>
>> I cant't make head or tail of this gibberish. Could you rephrase ?
>>
>> HTH,
>>
>> Le dimanche 20 novembre 2022 à 07:39:27 UTC+1, gauri...@gmail.com a 
>> écrit :
>>
>>> I want to create a neat table of the factorization of several 
>>> polynomials of the form [image: x^n-1] in the ring Z/3Z [x]. 
>>>
>>> This is my code, which I am using inside of a Jupyter notebook that 
>>> works as expected:
>>>
>>> R = IntegerModRing(3) 
>>> x = PolynomialRing(R, 'x').gen()
>>>
>>> rows  = []
>>> for k in range(1,10):
>>> f = x^k - 1
>>> factor = f.factor()
>>> rows.append((f,factor))
>>>
>>> table(rows, header_row=["Polynomial ", "Factorization"], frame=True)
>>>
>>> However, the output produced is ugly and looks like the one in the 
>>> attachment; it leaves a lot of space on the right but the factorization is 
>>> spread across multiple rows. How can I ask Sage to place each factorization 
>>> in the right column on a single line. 
>>>
>>> Also is it possible for me to write [image: x^k-1] for various powers 
>>> of [image: k] in latex in place of [image: x^k+2]. i.e. I want to write 
>>> -1 wherever there is a 2 in the left column. Sure I can do this with 
>>> print, but the output won’t be Latex rendered. 
>>>
>>> ​
>>>
>> -- 
>> 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/a737f888-3397-4be7-aab6-1e9e8230b20en%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sage-support/a737f888-3397-4be7-aab6-1e9e8230b20en%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/270ea155-ea95-4b25-858e-02ed76796d90n%40googlegroups.com.


[sage-support] Re: Rendering tables in jupyter notebook

2022-11-20 Thread Emmanuel Charpentier
> How can I ask Sage to place each factorization in the right column on a 
single line.

Both the display in a console and the LaTeX display given by `view` are 
single-lined. I can reproduce your problem in Jupyter ; therefore, I think 
that the question should be directed to a Jupyter-centered mailing list, 
newsgroup, forum or whatever...

> Also is it possible for me to write x^k-1 for various powers of k in 
latex in place of x^k+2. i.e. I want to write -1 wherever there is a 2 in 
the left column. Sure I can do this with print, but the output won’t be 
Latex rendered.

I cant't make head or tail of this gibberish. Could you rephrase ?

HTH,

Le dimanche 20 novembre 2022 à 07:39:27 UTC+1, gauri...@gmail.com a écrit :

> I want to create a neat table of the factorization of several polynomials 
> of the form [image: x^n-1] in the ring Z/3Z [x]. 
>
> This is my code, which I am using inside of a Jupyter notebook that works 
> as expected:
>
> R = IntegerModRing(3) 
> x = PolynomialRing(R, 'x').gen()
>
> rows  = []
> for k in range(1,10):
> f = x^k - 1
> factor = f.factor()
> rows.append((f,factor))
>
> table(rows, header_row=["Polynomial ", "Factorization"], frame=True)
>
> However, the output produced is ugly and looks like the one in the 
> attachment; it leaves a lot of space on the right but the factorization is 
> spread across multiple rows. How can I ask Sage to place each factorization 
> in the right column on a single line. 
>
> Also is it possible for me to write [image: x^k-1] for various powers of 
> [image: 
> k] in latex in place of [image: x^k+2]. i.e. I want to write -1 wherever 
> there is a 2 in the left column. Sure I can do this with print, but the 
> output won’t be Latex rendered. 
>
> ​
>

-- 
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/a737f888-3397-4be7-aab6-1e9e8230b20en%40googlegroups.com.


[sage-support] Re: Listing elements of a finite ring.

2022-11-20 Thread Emmanuel Charpentier


No predefined method, but listing S’s elements seems easy :

sage: R1.=GF(97)[]
sage: p=lambda x:x^2+2
sage: S=R1.quotient(p(t),'a')
sage: L=[u for u in S]
sage: len(L)
9409

HTH,
​
Le dimanche 20 novembre 2022 à 07:39:27 UTC+1, gauri...@gmail.com a écrit :

> I am afraid I cannot seem to find the answer to the following question in 
> the docs. 
>
> Suppose I have finite ring? How do I list all its elements? e.g.
>
> ```
> R = PolynomialRing(GF(97),'x')
> x = R.gen()
>
> p = lambda x: x^2+2
> S = R.quotient(p(x), 'a')
> ```
>
> I would like to list all the elements of the quotient ring S. Is there a 
> function/method that allows listing elements of S?
>
>  
>

-- 
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/5288658d-8d36-454f-9f07-8a6cadf056edn%40googlegroups.com.


[sage-support] Sagecell : is it possible to install the Wolfram engine ?

2022-11-19 Thread Emmanuel Charpentier
Dear list

Now that the *gratis* (but by no means free) [Wofram 
engine](https://www.wolfram.com/engine/) can be used for "pre-production" 
projects, it seems to me that it *could* be installed on 
`sagegell.sagemath.org`, this allowing access to the 
`algorithm="mathematica"` options and, more generally, using Mathematica 
algorithms for comparison with Sage ones... This is sometimes more than 
useful...

Technically, installing it on a Debian machine, and on a WSL installation 
of Sage under Windows was a breeze. It should be possible to install it on 
whatever runs the Sagecell server

Legally, perusing the [FAQ](https://www.wolfram.com/engine/faq/) makes me 
think that this use *could* be alowed unfer Wolfram's terms, but I am by no 
means any kind of lawyer...

The same could also apply to Cocalc ... except that Cocalc is also a 
commercial product, therefore excluded from Wolfram terms for the *gratis* 
Wolfram engine...

Reactions ? Advices ?

-- 
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/2b1592d2-85ab-4d55-886e-8da460abf604n%40googlegroups.com.


[sage-support] Re: Plotting the solution returned by desolve

2022-11-15 Thread Emmanuel Charpentier


Try this :

sage: var("x, t") ## t will be used later
(x, t)
sage: y=function("y") ## Note : no default argument
sage: sol=desolve(diff(y(x),x)==(x*y(x)^2 - cos(x)*sin(x) )/(y(x)*(1 - x^2)) 
,y(x), ics=[0, 2]) ; sol  ## Note : specify y argument
1/2*(x^2 - 1)*y(x)^2 + 1/2*cos(x)^2 == (-3/2)
sage: implicit_plot((sol.lhs()-sol.rhs()).subs(y(x)==t), (x, -5, 5), (t, -5, 
5)) ## Substitute a variable to the expression...
Launched png viewer for Graphics object consisting of 1 graphics primitive

[image: tmp_y92wys2o.png]

HTH,
​

-- 
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/05f845c2-9bb7-45a9-9903-cd9b0d63f995n%40googlegroups.com.


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

2022-11-03 Thread Emmanuel Charpentier


Never mind : I reconstituted something similar :

# ** General system **
Vars = var('L1 L2 L3 L4 C1 C2 C3 C4 M23 I1 I2 I3 I4 U w p RL J')
IVars = [I1, I2, I3, I4]
Sys = [I1*(w*J*L1 + 1/(w*J*C1)) + I2*(-1/(w*J*C1) ) == U,
   I2*(w*J*L2 + 1/(w*J*C1) + 1/(w*J*C2)) + I3*(w*J*M23 - 1/(w*I*C2)) + 
I1*(- 1/(w*J*C1)) == 0,
   I3*(1/(w*J*C3) + w*J*L3 + 1/(w*J*C2)) + I2*(w*J*M23 - 1/(w*J*C2)) - 
I4/(w*J*C3) == 0,
   I4/(w*J*C3) + I4*RL - I3/(w*J*C3) == 0]
Sol = solve(Sys, IVars, solution_dict=True)
Chk = all([u.subs(Sol).simplify_full() for u in Sys])
# ** Specialization to J=I **
Sys0 = [u.subs(J=I) for u in Sys]
Sol0 = solve(Sys0, IVars, solution_dict=True)
Chk0 = all([u.subs(Sol0).simplify_full() for u in Sys0])
# ** Fricas **
Sys0f = fricas(Sys0)
Sol0ff = fricas.solve(Sys0f, fricas(IVars))
# Here, no automatic backconversion to Sage : manual conversion necessary...
Sol0f = [{fricas.lhs(u).sage():fricas.rhs(u).sage() for u in v}
  for v in Sol0ff]
Chk0f = all([u.subs(Sol0f[0]).simplify_full() for u in Sys0])

And, of course :

sage: Chk
True
sage: Chk0
False
sage: Chk0f
True

You are right….
​
Le jeudi 3 novembre 2022 à 16:51:31 UTC+1, Emmanuel Charpentier a écrit :

> Le jeudi 3 novembre 2022 à 12:59:48 UTC+1, axio…@yahoo.de a écrit :
>
> @Emmanuel, why are you saying that FriCAS returns the same as sage?
>>
> I tried solve(Sys0, IVars) and got the same result as the one given by 
> the default solver…
>
> For me, fricas.solve works as expected.
>>
> Could you give us your execution *especially* how to convert the result 
> back to Sage ?
>
> Martin
>>
>> On Sunday, 9 October 2022 at 18:43:03 UTC+2 Emmanuel Charpentier wrote:
>>
>>> It turns out that the original author has also posted this problem in 
>>> sage-devel <https://groups.google.com/g/sage-devel/c/6jIKV1hPoCQ>, wher 
>>> we should continue…
>>> ​
>>> Le dimanche 9 octobre 2022 à 18:27:54 UTC+2, Nils Bruin a écrit :
>>>
>>>> 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/0304fb31-2c5d-43b7-9136-18374174a8dbn%40googlegroups.com.


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

2022-11-03 Thread Emmanuel Charpentier


Le jeudi 3 novembre 2022 à 12:59:48 UTC+1, axio…@yahoo.de a écrit :

@Emmanuel, why are you saying that FriCAS returns the same as sage?
>
I tried solve(Sys0, IVars) and got the same result as the one given by the 
default solver…

For me, fricas.solve works as expected.
>
Could you give us your execution *especially* how to convert the result 
back to Sage ?

Martin
>
> On Sunday, 9 October 2022 at 18:43:03 UTC+2 Emmanuel Charpentier wrote:
>
>> It turns out that the original author has also posted this problem in 
>> sage-devel <https://groups.google.com/g/sage-devel/c/6jIKV1hPoCQ>, wher 
>> we should continue…
>> ​
>> Le dimanche 9 octobre 2022 à 18:27:54 UTC+2, Nils Bruin a écrit :
>>
>>> 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/0b7c11ce-5bab-4d7a-92bf-072d46dfbcb7n%40googlegroups.com.


[sage-support] Re: Plotting heat maps of scalar fields in SAGE

2022-10-19 Thread Emmanuel Charpentier


That can be done in Sage in a variety of ways . Here’s one :

var("x, y")
L = 3# Plotted function
f =lambda x,y:cos(x)-2*y# Coloring# Colormap
cm=colormaps["RdBu"]# We have to scale the colormap :# Range of values : 
possible shortcut via some analytical obviousnesses :# cmin = f(-3, 3).n()# 
cmax = f(0, -3)# Being dum and computing on grid :
foo = [u for u in (-3,-2.97..3)]
Mesh = [[f(u, v) for v in foo] for u in foo]
cmin = min(flatten(Mesh))
cmax = max(flatten(Mesh)
crange = cmax-cmin
cf = lambda x, y: f(x, y)/crange# Plot
parametric_plot3d(lambda x, y, z:[x, y, f(x, y)], (-3, 3), (-3, 3),
  color=(cf, cm), aspect_ratio=[2, 2, 1])

It turns out that plot3d(f, (-3, 3), (-3, 3), color=(cf, cm), 
aspect_ratio=[2, 2, 1]) *also* works, but the color= parameter is not 
documented as such for plot3d, only for parametric_plot3d.

You may also try to play with list_plot3d, which I do not use as often. 
Lazy me…

HTH,
​
Le mercredi 19 octobre 2022 à 11:18:37 UTC+2, gauri...@gmail.com a écrit :

> I want to create heat maps of a scalar field in SAGE. Here is equivalent 
> code in Matplotlib that does the job along with the resulting output. The 
> matplotlib code uses the .pcolormesh function. Is there an equivalent in 
> SAGE? 
>
> The closest I can see are the functions that create contour plots as 
> given here 
> ,
>  
> but I don’t want the discrete bands that are created in those plots; for 
> contour plots that is of course natural because you want to see the shapes 
> of the individual level curves. 
>
> However, I specifically want the continuous smearing as outputted by the 
> Matplotlib code below, which gives a “heat-map” of the 2D scalar function.
>
> import numpy as np
> import matplotlib.pyplot as plt
> import matplotlib.cm as cm 
>
> fig,ax = plt.subplots()
> L = 3
> x= np.linspace(-L, L, 100) 
> y= np.linspace(-L, L, 100) 
> X, Y = np.meshgrid(x, y)
> Z= np.cos(X) - 2*Y 
>
> z_min, z_max = -np.abs(Z).max(), np.abs(Z).max()
> c= ax.pcolormesh(X, Y, Z, cmap='RdBu', vmin=z_min, vmax=z_max) 
> fig.colorbar(c, ax=ax)
>
> ax.set_aspect(1.0)
> ax.set_title("Heat map of scalar field",fontsize=20)
> fig.set_size_inches((10,10))
> plt.show()
>
>
>
> Thanks!
>
> Gaurish
> ​
>

-- 
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/e137f7cc-20f2-4be2-ad78-abf616a193c4n%40googlegroups.com.


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

2022-10-09 Thread Emmanuel Charpentier


It turns out that the original author has also posted this problem in 
sage-devel <https://groups.google.com/g/sage-devel/c/6jIKV1hPoCQ>, wher we 
should continue…
​
Le dimanche 9 octobre 2022 à 18:27:54 UTC+2, Nils Bruin a écrit :

> 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/efe7ba51-13b4-417c-a08c-dd3c3813fdccn%40googlegroups.com.


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

2022-10-09 Thread Emmanuel Charpentier
... 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).

TL;DR : a linear system, perfectly solved by Sage's default solver (i. e. 
Maxima's), gets a wrong answer when one of its variables is replaced by the 
`I` (*i*, imaginary unit) constant.

The problem can be reproduced in `maxima` used standalone. (see referenced 
post).

Furthermore, the same system (with *i*) seems to confuse `sympy` to no 
extend : `solve(Sys, IVars), algorithm="sympy")`doesn't return after more 
than 15 minutes, whereas the solution of the system with a variable instead 
of *i* is solved in a matter of milliseconds...

Giac doesn't give an answer, and Fricas seems to return the same thing as 
Sage...

Advoce requested on how to file tickets/bug reports efficiently.

-- 
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/afec4c09-ad06-4bc7-81ec-8757195f756fn%40googlegroups.com.


[sage-support] Sagetex version ?

2022-08-20 Thread Emmanuel Charpentier


I do not understand my installation of sagetex. As far as I understand it, 
Sage will use the files accessible via 
$SAGE_ROOT/venv/share/texmf/tex/latex/sagetex, and that’s what I symlinked 
to my LaTeX setup (in /usr/local/share/tex/latex/ in a Debian testing 
installation).

However, this version differs sensibly from what can be cloned from the github 
repository . Even the files are 
differenty named : in the Sage installation :

$ ls /usr/local/sage/venv/share/texmf/tex/latex/sagetex
CONTRIBUTORS__pycache__  sagetex.ins
example.tex remote-sagetex.dtx   sagetexparse.py
extractsagecode.py  remote-sagetex.pysagetex.sty
makestatic.py   run-sagetex-if-necessary.py  scripts.dtx
py-and-sty.dtx  sagetex.dtx

In the cloned repository (after extraction and doc recompilation) :

$ ls
CONTRIBUTORS  sagetex-extract.py sagetexparse.py
example.tex   sagetex.glosagetex.pdf
HACKING.mdsagetex.glssagetex.py
LICENSE   sagetex.hd sagetex-remote.py
Makefile  sagetex.idxsagetex-run.py
py-and-sty.dtxsagetex.ilgsagetex.sagetex.sage
README.md sagetex.indsagetex.sty
remote-sagetex.dtxsagetex.insscripts.dtx
sagetex.aux   sagetex.logsetup.py
sagetex_doctest.sage  sagetex-makestatic.py  test.sh
sagetex.dtx   sagetex.outTODO

The Pyton scripts are named differently.

More specifically, I had issues with the path_to_sage variable, thus set by 
the curent Sagemath version :

# CHANGE THIS AS APPROPRIATE
path_to_sage = os.path.expanduser('~/bin/sage')
# or try to auto-find it:
# path_to_sage = subprocess.check_output(['which', 'sage']).strip()
# or just tell me:
# path_to_sage = '/usr/local/bin/sage'

This didn’t work for me (the path_to_sage = 
subprocess.check_output(['which', 'sage']).strip() was OK).

This became totally different in the Github version.

I suppose that’s why the Github version has not (yet) been installed in the 
Sagemath release. Hence a couple question :

   - 
   
   Is this version ready for use ?
   - 
   
   Can it replace the current version ?
   - 
   
   If so, how to install it ? (by `sage -pip install , I suppose…)
   
Advice ?
​

-- 
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/942e5f32-0aad-4136-8bba-f6e8fdb01077n%40googlegroups.com.


[sage-support] Re: Solving system of Linear Equatin over finite fields.

2022-05-11 Thread Emmanuel Charpentier


Your example has several problems :

1) You don’t define your polynomial indeterminates ; you should 
Rx.inject_variables().

2) The syntax you use to substitute values in f is questionable…

3) f(v) is a polynomial in x0..x9 over GF(7), *not* a symbolic expression. 
Therefore f(v)==1 is *not* a symbolic equation ; it just tests if f(v) is 
equal to 1, which isFalse`. Hence the “error” you get.

4) solve_modis a function working on *symbolic equations systems*. Passing 
a (list of) polynomial(s) as its first argument will fail. If you want to 
use this function, us it on *symbolic equation systems*.

5) “Solving” polynomial systems use other methods. Perusing the 
documentation and the source the latter points to is *highly* recommended.

HTH,
​
Le mardi 10 mai 2022 à 09:40:48 UTC+2, Ha a écrit :

> Hi,
> I need to solve a system of linear equations [over finite fields] which 
> are obtained from system of polynomials by l substitution   of some 
> variables.   
> For example:   If we start with F[x1,x2,x3] = x1*x2+x3+1 and let x1 = 1 
> then we get
> L[x2,x3] = F(1,x2,x3) = x2+x3+1 --> a linear equation. 
> Need to solve L == constant over a finite field Fp.
>
> I tried the following method. But no luck.
>
> ##
> n=10
> F = GF(7)
> Rx=PolynomialRing(F,n,'x')
> X=Rx.gens()
> f = x2+ x1 * x5 - 1
> print(f)
> v=list(X)
> v[1]=1
> v[2]=5
> print(f(v))
> eqns = [f(v) == 1]
> sol = solve_mod(eqns, 7)
> print(sol)
> ##--
> Getting error:
>
>- AttributeError: 'bool' object has no attribute 'lhs' 
>
>

-- 
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/eaf5db10-0e69-4fc9-8938-8475e1bebeb2n%40googlegroups.com.


Re: [sage-support] Unexpected result for cos(a)^2 + sin(a)^2, question about variables

2022-04-30 Thread Emmanuel Charpentier


Also :

sage: b.simplify_trig()
1

Using specific simplifications in a specific order is often the key to get 
interesting results that the brute-force simplify_full cannot. Such 
simplifications are :

sage: import re
sage: print(", ".join([v[0] for v in list(map(lambda 
u:re.findall(".*simplify.*", u), dir(x))) if len(v)>0]))
factorial_simplify, full_simplify, hypergeometric_simplify, log_simplify, 
rational_simplify, simplify, simplify_factorial, simplify_full, 
simplify_hypergeometric, simplify_log, simplify_rational, simplify_real, 
simplify_rectform, simplify_trig, trig_simplify

to which you should add canonicalize_radical (with caution ! See this 
 for 
example), and the x._sympy_().simplify()._sage_() idiom, extremely 
interesting alternative to full_simplify.

HTH,
​
Le vendredi 29 avril 2022 à 11:59:50 UTC+2, maxime...@inria.fr a écrit :

> On 4/29/22 09:49, erentar wrote:
> > I would expect the following expression to evaluate to 1 but it does not.
> >
> > ```
> > var("a",domain="real")
> > simplify(cos(a)^2 + sin(a)^2)
> > ```
> >
> > How can i define a variable in this fashion that will result in the 
> > code evaluating to 1?
>
> Hi,
>
> you can use the "full_simplify" method for that:
>
>
> ```
> sage: var("a", domain="real")
> a
> sage: b = cos(a)^2+sin(a)^2
> sage: b.simplify()
> cos(a)^2 + sin(a)^2
> sage: b.full_simplify()
> 1
> ```
>
> Best,
>
> -- 
> Maxime
>
>

-- 
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/51209438-c1d5-4d8f-81a1-54491b338aean%40googlegroups.com.


[sage-support] Re: \ZZ not defined

2022-04-18 Thread Emmanuel Charpentier
This means that Mathjax, which is used by Jupyter to interpret LaTeX 
expressions, has no definition of a `\ZZ` LaTeX macro.

On 9.6.rc0, I get `\Bold𝑍/6\Bold𝑍`, which is not interpreted by `mathjax` 
either. I don't know how to work around this with Mathjax.

Would you mind filing a ticket ?

Le lundi 18 avril 2022 à 13:11:22 UTC+2, list...@gmail.com a écrit :

>
> This is on SageMath 9.5, Jupyter notebook.
>
> Am I missing something?
>
> Guillermo
>
>

-- 
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/f0d17420-2dbd-4b77-bf83-b3053a668a05n%40googlegroups.com.


Re: [sage-support] Solving logarithmic equations

2022-04-09 Thread Emmanuel Charpentier


BTW :

sage: solve(1+2*log(x+1, 4)==2*log(x,2), x, to_poly_solve="force")
[x == -sqrt(3) + 1, x == sqrt(3) + 1]

HTH,
​
Le samedi 9 avril 2022 à 11:34:10 UTC+2, wdjo...@gmail.com a écrit :

> On Sat, Apr 9, 2022 at 5:18 AM Paolo Robillos  
> wrote:
> >
> > Hi,
> >
> > I am trying to solve the following equation for x, 1+2log(x+1, 
> 4)==2log(x,2)
> >
> > I entered in the input "(1+2log(x+1, 
> 4)==2log(x,2)).solve(x,algorithm='sympy', domain='all')"
> >
> > and the Output was 
> "{𝑥∣𝑥∈ℂ∧−𝑥2log(2)+𝑒(𝑥+1)1log(2)=0}∖{𝑥∣𝑥∈ℂ∧𝑥2log(2)=0}"
> >
> > The answer I am looking for is "x = 1+3^(1/2)."
> >
>
> You're right, but here is a comment to show SymPy is on the right track:
>
> The first equation is x^(2/log(2)) == e*(x + 1)^(1/log(2)). If you
> first raise both sides ro the log(2) power, SageMath can solve it:
>
> sage: solve(x^(2) == e^(log(2))*(x + 1), x)
> [x == -sqrt(3) + 1, x == sqrt(3) + 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...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-support/4f7fb72f-b292-4abd-8740-9a5f50491a2an%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/720fda97-919f-4834-8cf3-06f116e3160bn%40googlegroups.com.


[sage-support] Re: search_def(), search_src() are not working in Sage

2022-03-23 Thread Emmanuel Charpentier
How did you install Sage ? And on what platform ?

Le mercredi 23 mars 2022 à 06:37:20 UTC+1, adarsh.k...@gmail.com a écrit :

> Hello everyone,
> I was going through some of the Sage functions and I wanted to look it up 
> in the source file definitions. For this I tried search_def() and then 
> search_src(). In both cases it gave a warning "that the Sage documentation 
> is not available".
>
> [image: Screenshot from 2022-03-23 10-05-04.png]
>
> I have tried to look up the official Sage developer's manual, 
> StackOverflow questions and GitHub issues. However, it has not worked out 
> for me, unfortunately.
>
> On the other hand, the search_doc() command works fine for me. This is the 
> output for 
> search_doc("add_edges()")
> [image: Screenshot from 2022-03-23 10-07-35.png]
>
> Is there any documentation that I have to build before I can use these 
> commands? I would appreciate it if someone can give pointers to some 
> helpful links or online documentation where this issue has been addressed.
>

-- 
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/5197146a-c0f3-4ff9-9dd3-6261f368eb49n%40googlegroups.com.


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

2022-03-08 Thread Emmanuel Charpentier


even more simpler :-) :

sage: V=var("v", n=8)
sage: V
(v0, v1, v2, v3, v4, v5, v6, v7)
sage: v2
v2
sage: V[2]
v2

*“Who could ask for anything more ?”*
​
Le mardi 8 mars 2022 à 08:20:07 UTC+1, slelievre a écrit :

> Even more practical, I find, is to name the tuple of indexed variables:
> ```
> sage: v = SR.var('v', n=8)
> sage: v
> (v0, v1, v2, v3, v4, v5, v6, v7)
> ```
> and to use index notation `v[k]` instead of `vk` to use the variables.
> ```
> sage: v[0]
> v0
> sage: v[7]
> v7
> ```
>
> That does not assign the variables to the names `v0` to `v7`:
> ```
> sage: v2
> Traceback (most recent call last)=
> ...
> NameError: name 'v2' is not defined
> ```
>
> If you really want to use `v0` to `v7` instead of `v[0]` to `v[7]`,
> follow the implementation in `var` (accessed with `var??`),
> which simply amounts to:
> ```
> G = globals()
> for vk in v:
> G[repr(vk)] = vk
> ```
>
> After that:
> ```
> sage: v2
> v2
> ```
>

-- 
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/37dc1c01-6cab-41cd-b8e2-b3a06c4e4509n%40googlegroups.com.


Re: [sage-support] nonlinear equation system

2022-03-03 Thread Emmanuel Charpentier
Or (unexpectedly much simpler) :

```
sage: mathematica.Reduce(Sys, Vars)
False
```

Le jeudi 3 mars 2022 à 15:09:27 UTC+1, Emmanuel Charpentier a écrit :

> And, BTW :
>
> sage: mathematica("Sys = {%s}"%", ".join([u._mathematica_init_() for u in 
> Sys]))
> {-B^2 + A*EE + EE^2 - B*F == 1, A*II + II^2 - B*J + RR^2 == -1/2, 
>  A*RR + 2*II*RR - B*T == 0, B*II - EE*J + II*J + RR*T == 0, 
>  -(B*RR) - J*RR + EE*T - II*T == 0, EE*II - F*J + J^2 + T^2 == 1/2, 
>  -(EE*RR) + F*T - 2*J*T == 0, II^2 - J^2 - RR^2 + T^2 == -1}
> sage: mathematica("Vars = {%s}"%", ".join([u._mathematica_init_() for u in 
> Vars]))
> {A, B, EE, F, II, J, RR, T}
> sage: mathematica("Reduce[Sys, Vars]")
> False
>
> HTH,
> ​
> Le jeudi 3 mars 2022 à 15:01:46 UTC+1, Emmanuel Charpentier a écrit :
>
>> FWIW, executing :
>>
>> reset()
>> # Don't scratch Sage's predefined identifiers, for sanity's sake...
>> Vars= var('A B EE F II J RR T') 
>> eq1 = A*EE-B^2-B*F+EE^2==1 
>> eq4 = A*II-B*J+II^2+RR^2==-1/2 
>> eq5 = A*RR-B*T+2*RR*II==0 
>> eq6 = B*II-EE*J+II*J+RR*T==0 
>> eq8 = -B*RR+EE*T-RR*J-II*T==0 
>> eq9 = EE*II-F*J+J^2+T^2==1/2 
>> eq11 = -EE*RR+F*T-2*T*J==0 
>> eq12 = II^2-RR^2-J^2+T^2==-1
>> Sys = [eq1,eq4,eq5,eq6,eq8,eq9,eq11,eq12]
>> # Build an equivalent polynomial system
>> # Ring
>> R1 = PolynomialRing(QQbar, len(Vars), "u")
>> R1.inject_variables()
>> # Conversion dictionary
>> D = dict(zip(Vars, R1.gens()))
>> # Polynomial system
>> PSys = [R1((u.lhs()-u.rhs()).subs(D)) for u in Sys]
>> # Try to solve
>> J1 = R1.ideal(PSys)
>> # Check
>> print(J1.dimension())
>>
>> prints
>>
>> Defining u0, u1, u2, u3, u4, u5, u6, u7
>> -1
>>
>> According to J1.dimension? : If the ideal is the total ring, the 
>> dimension is -1 by convention.
>>
>> No bloody solution…
>> ​
>> Le mardi 1 mars 2022 à 18:23:19 UTC+1, Scott Wilson a écrit :
>>
>>> Thanks all. I believe Dima is correct. These are inconsistent.
>>>
>>> On Monday, February 28, 2022 at 1:59:58 AM UTC-8 dim...@gmail.com wrote:
>>>
>>>> On Mon, Feb 28, 2022 at 7:24 AM cyrille@univ-orleans.fr 
>>>>  wrote: 
>>>> > 
>>>> > I am not a mathematician but what seems obvious is that you have 8 
>>>> equations with 8 variables. You could conjecture there is at least a real 
>>>> solution even if there could be 8. But, your system is highly nonlinear. 
>>>>
>>>> Generically, one might expect up to 2^8 solutions here (8 variables, 8 
>>>> equations of degree 2). 
>>>> This is called Bezout theorem. 
>>>> No guarantee that any solution is real, though. 
>>>>
>>>>
>>>>
>>>> So you can not expect a solution by quadrature. You must try to solve 
>>>> you system numerically. 
>>>> > 
>>>> > 
>>>> > - Mail d’origine - 
>>>> > De: Scott Wilson  
>>>> > À: sage-support  
>>>> > Envoyé: Sun, 27 Feb 2022 20:40:43 +0100 (CET) 
>>>> > Objet: [sage-support] nonlinear equation system 
>>>> > 
>>>> > Hello, I am new to sage math and tried to get the solution to the 
>>>> following nonlinear equation system. Sage has been working on this since 
>>>> yesterday and I am wondering how long I should typically wait. All 
>>>> comments 
>>>> are appreciated. Thanks in advance. 
>>>> > 
>>>> > var('A B E F I J R T') 
>>>> > 
>>>> > eq1 = A*E-B^2-B*F+E^2==1 
>>>> > eq4 = A*I-B*J+I^2+R^2==-1/2 
>>>> > eq5 = A*R-B*T+2*R*I==0 
>>>> > eq6 = B*I-E*J+I*J+R*T==0 
>>>> > eq8 = -B*R+E*T-R*J-I*T==0 
>>>> > eq9 = E*I-F*J+J^2+T^2==1/2 
>>>> > eq11 = -E*R+F*T-2*T*J==0 
>>>> > eq12 = I^2-R^2-J^2+T^2==-1 
>>>> > 
>>>> > solve([eq1,eq4,eq5,eq6,eq8,eq9,eq11,eq12],A,B,E,F,I,J,R,T) 
>>>> > 
>>>> > 
>>>> > 
>>>> > 
>>>> > -- 
>>>> > 
>>>> > 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/47695a04-777d-4fbb-af5d-7371db01a31an%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...@googlegroups.com. 
>>>> > To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/sage-support/599338425.36980299.1646033057570.JavaMail.zimbra%40univ-orleans.fr.
>>>>  
>>>>
>>>>
>>>

-- 
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/0e17b3d3-bbc8-4046-9433-31d9a7ed37d7n%40googlegroups.com.


Re: [sage-support] nonlinear equation system

2022-03-03 Thread Emmanuel Charpentier


And, BTW :

sage: mathematica("Sys = {%s}"%", ".join([u._mathematica_init_() for u in Sys]))
{-B^2 + A*EE + EE^2 - B*F == 1, A*II + II^2 - B*J + RR^2 == -1/2, 
 A*RR + 2*II*RR - B*T == 0, B*II - EE*J + II*J + RR*T == 0, 
 -(B*RR) - J*RR + EE*T - II*T == 0, EE*II - F*J + J^2 + T^2 == 1/2, 
 -(EE*RR) + F*T - 2*J*T == 0, II^2 - J^2 - RR^2 + T^2 == -1}
sage: mathematica("Vars = {%s}"%", ".join([u._mathematica_init_() for u in 
Vars]))
{A, B, EE, F, II, J, RR, T}
sage: mathematica("Reduce[Sys, Vars]")
False

HTH,
​
Le jeudi 3 mars 2022 à 15:01:46 UTC+1, Emmanuel Charpentier a écrit :

> FWIW, executing :
>
> reset()
> # Don't scratch Sage's predefined identifiers, for sanity's sake...
> Vars= var('A B EE F II J RR T') 
> eq1 = A*EE-B^2-B*F+EE^2==1 
> eq4 = A*II-B*J+II^2+RR^2==-1/2 
> eq5 = A*RR-B*T+2*RR*II==0 
> eq6 = B*II-EE*J+II*J+RR*T==0 
> eq8 = -B*RR+EE*T-RR*J-II*T==0 
> eq9 = EE*II-F*J+J^2+T^2==1/2 
> eq11 = -EE*RR+F*T-2*T*J==0 
> eq12 = II^2-RR^2-J^2+T^2==-1
> Sys = [eq1,eq4,eq5,eq6,eq8,eq9,eq11,eq12]
> # Build an equivalent polynomial system
> # Ring
> R1 = PolynomialRing(QQbar, len(Vars), "u")
> R1.inject_variables()
> # Conversion dictionary
> D = dict(zip(Vars, R1.gens()))
> # Polynomial system
> PSys = [R1((u.lhs()-u.rhs()).subs(D)) for u in Sys]
> # Try to solve
> J1 = R1.ideal(PSys)
> # Check
> print(J1.dimension())
>
> prints
>
> Defining u0, u1, u2, u3, u4, u5, u6, u7
> -1
>
> According to J1.dimension? : If the ideal is the total ring, the 
> dimension is -1 by convention.
>
> No bloody solution…
> ​
> Le mardi 1 mars 2022 à 18:23:19 UTC+1, Scott Wilson a écrit :
>
>> Thanks all. I believe Dima is correct. These are inconsistent.
>>
>> On Monday, February 28, 2022 at 1:59:58 AM UTC-8 dim...@gmail.com wrote:
>>
>>> On Mon, Feb 28, 2022 at 7:24 AM cyrille@univ-orleans.fr 
>>>  wrote: 
>>> > 
>>> > I am not a mathematician but what seems obvious is that you have 8 
>>> equations with 8 variables. You could conjecture there is at least a real 
>>> solution even if there could be 8. But, your system is highly nonlinear. 
>>>
>>> Generically, one might expect up to 2^8 solutions here (8 variables, 8 
>>> equations of degree 2). 
>>> This is called Bezout theorem. 
>>> No guarantee that any solution is real, though. 
>>>
>>>
>>>
>>> So you can not expect a solution by quadrature. You must try to solve 
>>> you system numerically. 
>>> > 
>>> > 
>>> > - Mail d’origine - 
>>> > De: Scott Wilson  
>>> > À: sage-support  
>>> > Envoyé: Sun, 27 Feb 2022 20:40:43 +0100 (CET) 
>>> > Objet: [sage-support] nonlinear equation system 
>>> > 
>>> > Hello, I am new to sage math and tried to get the solution to the 
>>> following nonlinear equation system. Sage has been working on this since 
>>> yesterday and I am wondering how long I should typically wait. All comments 
>>> are appreciated. Thanks in advance. 
>>> > 
>>> > var('A B E F I J R T') 
>>> > 
>>> > eq1 = A*E-B^2-B*F+E^2==1 
>>> > eq4 = A*I-B*J+I^2+R^2==-1/2 
>>> > eq5 = A*R-B*T+2*R*I==0 
>>> > eq6 = B*I-E*J+I*J+R*T==0 
>>> > eq8 = -B*R+E*T-R*J-I*T==0 
>>> > eq9 = E*I-F*J+J^2+T^2==1/2 
>>> > eq11 = -E*R+F*T-2*T*J==0 
>>> > eq12 = I^2-R^2-J^2+T^2==-1 
>>> > 
>>> > solve([eq1,eq4,eq5,eq6,eq8,eq9,eq11,eq12],A,B,E,F,I,J,R,T) 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > -- 
>>> > 
>>> > 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/47695a04-777d-4fbb-af5d-7371db01a31an%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...@googlegroups.com. 
>>> > To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/sage-support/599338425.36980299.1646033057570.JavaMail.zimbra%40univ-orleans.fr.
>>>  
>>>
>>>
>>

-- 
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/9c816455-bd1b-437e-a856-4656a81aa258n%40googlegroups.com.


Re: [sage-support] nonlinear equation system

2022-03-03 Thread Emmanuel Charpentier


FWIW, executing :

reset()
# Don't scratch Sage's predefined identifiers, for sanity's sake...
Vars= var('A B EE F II J RR T') 
eq1 = A*EE-B^2-B*F+EE^2==1 
eq4 = A*II-B*J+II^2+RR^2==-1/2 
eq5 = A*RR-B*T+2*RR*II==0 
eq6 = B*II-EE*J+II*J+RR*T==0 
eq8 = -B*RR+EE*T-RR*J-II*T==0 
eq9 = EE*II-F*J+J^2+T^2==1/2 
eq11 = -EE*RR+F*T-2*T*J==0 
eq12 = II^2-RR^2-J^2+T^2==-1
Sys = [eq1,eq4,eq5,eq6,eq8,eq9,eq11,eq12]
# Build an equivalent polynomial system
# Ring
R1 = PolynomialRing(QQbar, len(Vars), "u")
R1.inject_variables()
# Conversion dictionary
D = dict(zip(Vars, R1.gens()))
# Polynomial system
PSys = [R1((u.lhs()-u.rhs()).subs(D)) for u in Sys]
# Try to solve
J1 = R1.ideal(PSys)
# Check
print(J1.dimension())

prints

Defining u0, u1, u2, u3, u4, u5, u6, u7
-1

According to J1.dimension? : If the ideal is the total ring, the dimension 
is -1 by convention.

No bloody solution…
​
Le mardi 1 mars 2022 à 18:23:19 UTC+1, Scott Wilson a écrit :

> Thanks all. I believe Dima is correct. These are inconsistent.
>
> On Monday, February 28, 2022 at 1:59:58 AM UTC-8 dim...@gmail.com wrote:
>
>> On Mon, Feb 28, 2022 at 7:24 AM cyrille@univ-orleans.fr 
>>  wrote: 
>> > 
>> > I am not a mathematician but what seems obvious is that you have 8 
>> equations with 8 variables. You could conjecture there is at least a real 
>> solution even if there could be 8. But, your system is highly nonlinear. 
>>
>> Generically, one might expect up to 2^8 solutions here (8 variables, 8 
>> equations of degree 2). 
>> This is called Bezout theorem. 
>> No guarantee that any solution is real, though. 
>>
>>
>>
>> So you can not expect a solution by quadrature. You must try to solve 
>> you system numerically. 
>> > 
>> > 
>> > - Mail d’origine - 
>> > De: Scott Wilson  
>> > À: sage-support  
>> > Envoyé: Sun, 27 Feb 2022 20:40:43 +0100 (CET) 
>> > Objet: [sage-support] nonlinear equation system 
>> > 
>> > Hello, I am new to sage math and tried to get the solution to the 
>> following nonlinear equation system. Sage has been working on this since 
>> yesterday and I am wondering how long I should typically wait. All comments 
>> are appreciated. Thanks in advance. 
>> > 
>> > var('A B E F I J R T') 
>> > 
>> > eq1 = A*E-B^2-B*F+E^2==1 
>> > eq4 = A*I-B*J+I^2+R^2==-1/2 
>> > eq5 = A*R-B*T+2*R*I==0 
>> > eq6 = B*I-E*J+I*J+R*T==0 
>> > eq8 = -B*R+E*T-R*J-I*T==0 
>> > eq9 = E*I-F*J+J^2+T^2==1/2 
>> > eq11 = -E*R+F*T-2*T*J==0 
>> > eq12 = I^2-R^2-J^2+T^2==-1 
>> > 
>> > solve([eq1,eq4,eq5,eq6,eq8,eq9,eq11,eq12],A,B,E,F,I,J,R,T) 
>> > 
>> > 
>> > 
>> > 
>> > -- 
>> > 
>> > 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/47695a04-777d-4fbb-af5d-7371db01a31an%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...@googlegroups.com. 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sage-support/599338425.36980299.1646033057570.JavaMail.zimbra%40univ-orleans.fr.
>>  
>>
>>
>

-- 
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/23988c14-d498-4ec4-a4e4-e3d63d8c8eb6n%40googlegroups.com.


[sage-support] Re: mathematica_free error

2022-02-19 Thread Emmanuel Charpentier
I have had similar problems. Wolfram may have changed (again !) something 
in their output format... Since I know zilch about HTML mysteries and 
miseries, I can't offer anything but my warmest condolences...

Le lundi 14 février 2022 à 17:17:20 UTC+1, rodrigos...@gmail.com a écrit :

> Good afternoon,
>
> In this worksheet 
> ,
>  
> the algorithm mathematica_free of integrate returns the following error:
>
> Error in lines 2-2 Traceback (most recent call last): File 
> "/cocalc/lib/python3.9/site-packages/smc_sagews/sage_server.py", line 1230, 
> in execute exec( File "", line 1, in  File 
> "sage/symbolic/expression.pyx", line 13138, in 
> sage.symbolic.expression.Expression.integral 
> (build/cythonized/sage/symbolic/expression.cpp:95197) return integral(self, 
> *args, **kwds) File 
> "/ext/sage/9.5/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/symbolic/integration/integral.py",
>  
> line 1047, in integrate return integrator(expression, v, a, b) File 
> "/ext/sage/9.5/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/symbolic/integration/external.py",
>  
> line 127, in mma_free_integrator all_outputs = 
> parse_moutput_from_json(json_page_data) File 
> "/ext/sage/9.5/local/var/lib/sage/venv-python3.9.9/lib/python3.9/site-packages/sage/interfaces/mathematica.py",
>  
> line 1235, in parse_moutput_from_json raise ValueError('json object 
> contains no pods') ValueError: json object contains no pods
>
> Why is this happening?
>

-- 
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/06a0ded3-42e2-4e76-b2e1-db466b3c5fean%40googlegroups.com.


[sage-support] Re: Inter-versions reproducibility problem of random elements.

2022-02-06 Thread Emmanuel Charpentier
Also : coud you report the results on as many platforms and/or versions as 
possible ?

Le dimanche 6 février 2022 à 20:23:39 UTC+1, Emmanuel Charpentier a écrit :

> Seen in this thread 
> <https://groups.google.com/g/sage-support/c/IvjMhqryRQs> :
>
> On Sagecell <https://sagecell.sagemath.org/> :
>
> print(sage.version.version)
> with seed(0): M = matrix(AA, 3, 3, lambda u,v: AA.random_element())
> M.apply_map(lambda u:u.radical_expression())
>
> prints
>
> 9.4
> [-2  2 -2]
> [-2  0  2]
> [-1  2  2]
>
> On Sage 9.5 compiled from source on Debian testing running on core i7 :
>
> sage: with seed(0): M = matrix(AA, 3, 3, lambda u,v: AA.random_element())
> sage: M.apply_map(lambda u:u.radical_expression())
> [   -sqrt(2) - 1-1/4  -2*sqrt(3)]
> [1/2  1/8*sqrt(33) + 1/8 -1/5*sqrt(29) + 3/5]
> [  0 1/4 1/2]
>
> Advice required on how to file an efficient ticket.
> ​
>

-- 
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/617f077f-17d0-439f-a1e2-40c6ca1ff361n%40googlegroups.com.


[sage-support] Inter-versions reproducibility problem of random elements.

2022-02-06 Thread Emmanuel Charpentier


Seen in this thread  
:

On Sagecell  :

print(sage.version.version)
with seed(0): M = matrix(AA, 3, 3, lambda u,v: AA.random_element())
M.apply_map(lambda u:u.radical_expression())

prints

9.4
[-2  2 -2]
[-2  0  2]
[-1  2  2]

On Sage 9.5 compiled from source on Debian testing running on core i7 :

sage: with seed(0): M = matrix(AA, 3, 3, lambda u,v: AA.random_element())
sage: M.apply_map(lambda u:u.radical_expression())
[   -sqrt(2) - 1-1/4  -2*sqrt(3)]
[1/2  1/8*sqrt(33) + 1/8 -1/5*sqrt(29) + 3/5]
[  0 1/4 1/2]

Advice required on how to file an efficient ticket.
​

-- 
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/9544f43a-d9ff-4547-afba-74bf8ec172e1n%40googlegroups.com.


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

2022-02-06 Thread Emmanuel Charpentier


Nins and me got *different* random matrices : his was composed of integers 
in (-2..2), and Sage could compute its eigenspaces ; mine was :

sage: with seed(0): M = matrix(AA, 3, 3, lambda u,v: AA.random_element())
sage: M.apply_map(lambda u:u.radical_expression())
[   -sqrt(2) - 1-1/4  -2*sqrt(3)]
[1/2  1/8*sqrt(33) + 1/8 -1/5*sqrt(29) + 3/5]
[  0 1/4 1/2]

which, BTW, shows a problem about the reproducibility of random elements 
between Sage versions and/or platforms…

Could you post *your* random matrix ? And could you try :

M.95 = matrix(AA,3,3,[-sqrt(2) - 1, -1/4, -2*sqrt(3), 1/2, 1/8*sqrt(33) + 1/8, 
-1/5*sqrt(29) + 3/5, 0, 1/4, 1/2])
ES = M95.eigenspaces_left()

and report if you get a result ?
​
Le dimanche 6 février 2022 à 17:35:20 UTC+1, alan_thoma...@yahoo.co.uk a 
écrit :

> No, it works with the 9.4 kernel but not with the 9.5 beta.
>

-- 
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/550c9eea-fe35-4cec-a026-9fc9301a3fb6n%40googlegroups.com.


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

2022-02-06 Thread Emmanuel Charpentier
That was my initial complaint... ;-)

Le samedi 5 février 2022 à 18:05:42 UTC+1, alan_thoma...@yahoo.co.uk a 
écrit :

> M.eigenvalues() never returns.
> On Saturday, February 5, 2022 at 11:48:47 AM UTC Emmanuel Charpentier 
> wrote:
>
>> What exactly fails in the example ?
>>
>> Le vendredi 4 février 2022 à 13:20:26 UTC+1, alan_thoma...@yahoo.co.uk a 
>> écrit :
>>
>>>
>>> On Apple Mac the example above runs on the 9.4 kernel using either the 
>>> 9.4 or 9.5  interface but not on the 9.5 kernel from either Interface.
>>> On Thursday, February 3, 2022 at 6:44:47 AM UTC Emmanuel Charpentier 
>>> wrote:
>>>
>>>> Le mercredi 2 février 2022 à 22:15:00 UTC+1, Nils Bruin a écrit :
>>>>
>>>> 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.
>>>>>
>>>> Hmmm… You may have obtained a “less pathological” M than I did, due to 
>>>> possible differences in random numbers generation (notwithstanding my 
>>>> attempt at reproducibility…). 
>>>>
>>>> What do you get for M ? I have :
>>>>
>>>> sage: with seed(0): M = matrix(AA, 3, 3, lambda u,v: AA.random_element())
>>>> sage: M.apply_map(lambda u:u.radical_expression())
>>>> [   -sqrt(2) - 1-1/4  -2*sqrt(3)]
>>>> [1/2  1/8*sqrt(33) + 1/8 -1/5*sqrt(29) + 3/5]
>>>> [  0 1/4 1/2]
>>>>
>>>> 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})
>>>>>
>>>> Okay. We have a problem in reproducibility : with seed(0): should 
>>>> entail a reproducible, platform-independent result. It did not. BTW, what 
>>>> is your platform ?
>>>>
>>>> Suggestions on how to document this and file a ticket ?
>>>>
>>>> I agree with the rest of your conclusions, but going to numerical 
>>>> approximations then trying to somehow “recognize” the algebraics they are 
>>>> approximations of somehow denies the whole point of working in QQbar…
>>>>
>>>> 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/81cbc5c0-c7b0-4e82-9ba7-e0fca48dc598n%40googlegroups.com.


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

2022-02-05 Thread Emmanuel Charpentier
What exactly fails in the example ?

Le vendredi 4 février 2022 à 13:20:26 UTC+1, alan_thoma...@yahoo.co.uk a 
écrit :

>
> On Apple Mac the example above runs on the 9.4 kernel using either the 9.4 
> or 9.5  interface but not on the 9.5 kernel from either Interface.
> On Thursday, February 3, 2022 at 6:44:47 AM UTC Emmanuel Charpentier wrote:
>
>> Le mercredi 2 février 2022 à 22:15:00 UTC+1, Nils Bruin a écrit :
>>
>> 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.
>>>
>> Hmmm… You may have obtained a “less pathological” M than I did, due to 
>> possible differences in random numbers generation (notwithstanding my 
>> attempt at reproducibility…). 
>>
>> What do you get for M ? I have :
>>
>> sage: with seed(0): M = matrix(AA, 3, 3, lambda u,v: AA.random_element())
>> sage: M.apply_map(lambda u:u.radical_expression())
>> [   -sqrt(2) - 1-1/4  -2*sqrt(3)]
>> [1/2  1/8*sqrt(33) + 1/8 -1/5*sqrt(29) + 3/5]
>> [  0 1/4 1/2]
>>
>> 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})
>>>
>> Okay. We have a problem in reproducibility : with seed(0): should entail 
>> a reproducible, platform-independent result. It did not. BTW, what is your 
>> platform ?
>>
>> Suggestions on how to document this and file a ticket ?
>>
>> I agree with the rest of your conclusions, but going to numerical 
>> approximations then trying to somehow “recognize” the algebraics they are 
>> approximations of somehow denies the whole point of working in QQbar…
>>
>> 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/1371b6cf-4ae6-4a69-b178-b9ee0a4e8761n%40googlegroups.com.


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

2022-02-02 Thread Emmanuel Charpentier


Le mercredi 2 février 2022 à 22:15:00 UTC+1, Nils Bruin a écrit :

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.
>
Hmmm… You may have obtained a “less pathological” M than I did, due to 
possible differences in random numbers generation (notwithstanding my 
attempt at reproducibility…). 

What do you get for M ? I have :

sage: with seed(0): M = matrix(AA, 3, 3, lambda u,v: AA.random_element())
sage: M.apply_map(lambda u:u.radical_expression())
[   -sqrt(2) - 1-1/4  -2*sqrt(3)]
[1/2  1/8*sqrt(33) + 1/8 -1/5*sqrt(29) + 3/5]
[  0 1/4 1/2]

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})
>
Okay. We have a problem in reproducibility : with seed(0): should entail a 
reproducible, platform-independent result. It did not. BTW, what is your 
platform ?

Suggestions on how to document this and file a ticket ?

I agree with the rest of your conclusions, but going to numerical 
approximations then trying to somehow “recognize” the algebraics they are 
approximations of somehow denies the whole point of working in QQbar…

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/ca1fb071-5e07-45b6-a4e4-dd6f63cd98d5n%40googlegroups.com.


[sage-support] Re: init_printing from sympy is no longer working in SageCell

2022-02-02 Thread Emmanuel Charpentier
WorksForMe(TM) in Sage 9.5, in both Jupyter and Jupyterlab...

HTH,
Le mercredi 2 février 2022 à 18:42:48 UTC+1, dsfitz...@gmail.com a écrit :

> I'm teaching a linear algebra course where we use the Sympy Python package 
> for a lot of the computations. This includes a PreTeXt textbook where there 
> are Sage Cells throughout, with sample code supplied.
>
> Until today (I think it was working yesterday), I've had no trouble 
> running code like the following:
>
> from sympy import Matrix, init_printing
> init_printing()
> A = Matrix([[1,2,3,4],[5,6,7,8],[9,0,1,2]])
> display(A.rref())
>
> The init_printing function from Sympy renders the output in MathJax rather 
> than pretty-printed plain text, which is nice for teaching. I can run this 
> with the language set to either Sage or Python. (the 'display' command is 
> only needed for Python, which is funny, because it is not needed in Jupyter 
> with a Python kernel.)
>
> Right now this code throws about 50 lines of error messages; the main 
> error is a Type Error:
>
> TypeError: Object of type  with value of '(a very, very 
> long string that I won't reproduce here)' is not JSON serializable
>
> Was there a change made today that would cause this error? Maybe in the 
> Sympy library? If I remove the init_printing() line, everything works, 
> except that there's no longer nice display for the output.
>
> The reason for using Python syntax is that we also do labs in Jupyter 
> notebooks. Our institution has a Jupyter hub with Python and R kernels, but 
> no Sage kernel. (We do not have a CoCalc subscription.)
>
> I know there is a Sage equivalent to init_printing (although I forget what 
> it is) but that won't work on the Jupyter side.
>

-- 
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/9c7e9ce1-b339-4cd2-a7e8-84e1581596ccn%40googlegroups.com.


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

2022-02-02 Thread Emmanuel Charpentier
See lines #7-8 of the "Minimal example" :

Le mercredi 2 février 2022 à 11:57:41 UTC+1, alan_thoma...@yahoo.co.uk a 
écrit :

>
> What is v0? When I run the above it isn't defined.
> On Monday, January 31, 2022 at 11:19:49 PM UTC 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")
>>
>>
Here is the definition you seek : 

>
>> # Vector of unknowns for the eigenvectors
>> V =vector(list(var("v", n=2))+[SR(1)])
>>
>>
Is that clearer ?
 

>
>> # M.eigenvalues does not return. Get them by hand
>> # Equation determining the eigenspace
>> ESE = M-l*identity_matrix(WR, 3)
>> # Eigenvalues
>> EVa = ESE.det().roots(ring=WR)
>> # M.eigenvectors_left() doesn't return.
>> # Set up a system of equations whose roots define the eigenvectors.
>> Sys = ESE*V
>> # Solve for each eigenvalue
>> # solve([u.subs(l==EVa[0][0]) for u in Sys],list(V[:2])) fails.
>> # Try to solve manually by substitution
>> # First equation, first variable.
>> # solve(Sys[0].subs(l==EVa[0][0]), v0) fails.
>> # Try to solve by explicit algebraic manipulation
>> E00 = Sys[0].subs(l==EVa[0][0])
>> # Isolate v0
>> V00=E0/E00.coefficient(v0) # fast
>>
>> At this point, tryoing to proint V00‘s value “never returns”. However, a 
>> forst interruption (C-C) prints :
>>
>> sage: V00
>>   C-c 
>> C-c---
>> AttributeErrorTraceback (most recent call last)
>> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py
>>  in minpoly(self)
>>4492 try:
>> -> 4493 return self._minimal_polynomial
>>4494 except AttributeError:
>>
>> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/element.pyx
>>  in sage.structure.element.Element.__getattr__ 
>> (build/cythonized/sage/structure/element.c:4754)()
>> 493 """
>> --> 494 return self.getattr_from_category(name)
>> 495 
>>
>> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/element.pyx
>>  in sage.structure.element.Element.getattr_from_category 
>> (build/cythonized/sage/structure/element.c:4866)()
>> 506 cls = P._abstract_element_class
>> --> 507 return getattr_from_other_class(self, cls, name)
>> 508 
>>
>> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/cpython/getattr.pyx
>>  in sage.cpython.getattr.getattr_from_other_class 
>> (build/cythonized/sage/cpython/getattr.c:2633)()
>> 360 dummy_error_message.name = name
>> --> 361 raise AttributeError(dummy_error_message)
>> 362 attribute = attr
>>
>> AttributeError: 'AlgebraicNumber' object has no attribute 
>> '_minimal_polynomial'
>>
>> During handling of the above exception, another exception occurred:
>>
>> KeyboardInterrupt Traceback (most recent call last)
>> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/element.pyx
>>  in sage.structure.element.Element.__richcmp__ 
>> (build/cythonized/sage/structure/element.c:10418)()
>>1110 return (self)._richcmp_(other, op)
>> else:
>> -> 1112 return coercion_model.richcmp(self, other, op)
>>1113 
>>1114 cpdef _richcmp_(left, right, int op):
>>
>> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/coerce.pyx
>>  in sage.structure.coerce.CoercionModel.richcmp 
>> (build/cythonized/sage/structure/coerce.c:20625)()
>>1979 assert not (isinstance(x, Element) and
>>1980 
>> (x)._parent.get_flag(Parent_richcmp_element_without_coercion))
>> -> 1981 return PyObject_RichCompare(x, y, op)
>>1982 
>>1983 # Comparing with coercion didn't work, try something else.
>>
>> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/element.pyx
>>  in sage.structur

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

2022-01-31 Thread Emmanuel Charpentier
ib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py",
 line 4365, in exactify
self._set_descr(self._descr.exactify())
  File 
"/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py",
 line 8431, in exactify
left.exactify()
  File 
"/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py",
 line 4365, in exactify
self._set_descr(self._descr.exactify())
  File 
"/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py",
 line 8433, in exactify
gen = left._exact_field().union(right._exact_field())
  File 
"/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py",
 line 3232, in union
pari_nf = self.pari_field()
  File 
"/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py",
 line 3136, in pari_field
self._pari_field = pari_pol.nfinit(1)
  File "cypari2/auto_gen.pxi", line 23641, in cypari2.gen.Gen_base.nfinit
KeyboardInterrupt: 
1.000?*v0 - 35.57125011095806?*v1 - 492.8896998473554?

Similarly, V00.coefficient(v0).is_one() “never returns”.
The current aritmetic on algebraics is therefore problematic for this kind 
of problems.
Suggestions ?
​
Le lundi 31 janvier 2022 à 17:59:34 UTC+1, Emmanuel Charpentier a écrit :

> Thank you, Nils !
> Trying to pinpoint things by running a manual solution step by step, it 
> seems that the stumbling oint is the division on two algebraics. I'll try 
> to make a clear minimal example and report it.
> Le lundi 31 janvier 2022 à 00:49:22 UTC+1, Nils Bruin a écrit :
>
>> 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/3201fd01-beb2-4afe-8057-d14c7e4c4bc9n%40googlegroups.com.


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

2022-01-31 Thread Emmanuel Charpentier
Thank you, Nils !
Trying to pinpoint things by running a manual solution step by step, it 
seems that the stumbling oint is the division on two algebraics. I'll try 
to make a clear minimal example and report it.
Le lundi 31 janvier 2022 à 00:49:22 UTC+1, Nils Bruin a écrit :

> 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/b74e28b5-1c59-40ad-b284-107fe6a1aa2dn%40googlegroups.com.


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

2022-01-29 Thread Emmanuel Charpentier


FWIW, upgrading to 9.5.rc4 *and disabling the use of system’s pari and 
singular* gives the same symptoms. Possible suspect :

charpent@zen-book-flip:~$ sage -pip list | grep pari
cypari2   2.1.2

I’m way out of my depth here…

HTH,
​
Le samedi 29 janvier 2022 à 22:51:14 UTC+1, Emmanuel Charpentier a écrit :

> The promlem seems tolie wit (my use of) polynomial rings to compute the 
> eigenvectors. Manually, after executing
>
> dims = M.dimensions()
> if dims[0] != dims[1]: raise DomainError("Not a square matrix !")
> dim = dims[0]
> BR = M.base_ring()
> try:
> WR = BR.algebraic_closure()
> except AttributeError:
> WR = BR
> WPR = WR["t"]
> t = WPR.gens()[0]
> # CP = WPR(M.charpoly(var="t"))
> # Eigenvalues
> CP = M.charpoly(var="t")
> lambdas = CP.roots(ring=WR)
> # Eigenvectors
> Id = identity_matrix(WR,dim)
> WM = M.apply_map(lambda u:WR(u))
> PR = PolynomialRing(WR,list(("v%d"%u for u in range(dim
> J=PR.ideal(*(WM-Id*lambdas[0][0])*vector(PR.gens()))
>
> neither J.dimension() nor J.variety() returns ; the interruption gives :
>
> sage: J.dimension()
>   C-c 
> C-c---
> KeyboardInterrupt Traceback (most recent call last)
>  in 
> > 1 J.dimension()
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/polynomial/multi_polynomial_ideal.py
>  in __call__(self, *args, **kwds)
> 295 if not R.base_ring().is_field():
> 296 raise ValueError("Coefficient ring must be a field for 
> function '%s'."%(self.f.__name__))
> --> 297 return self.f(self._instance, *args, **kwds)
> 298 
> 299 require_field = RequireField
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar_decorators.py
>  in wrapper(*args, **kwds)
> 111 # same_field=True might trigger an exception otherwise.
> 112 
> --> 113 numfield, new_elems, morphism = 
> number_field_elements_from_algebraics(orig_elems, same_field=True, 
> minimal=True)
> 114 
> 115 elem_dict = dict(zip(orig_elems, new_elems))
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py
>  in number_field_elements_from_algebraics(numbers, minimal, same_field, 
> embedded, prec)
>2759 real_numbers = []
>2760 for v in numbers:
> -> 2761 if v._exact_field().is_complex() and real_case:
>2762 # the number comes from a complex algebraic number field
>2763 embedded_rt = v.interval_fast(RealIntervalField(prec))
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py
>  in _exact_field(self)
>4428 if isinstance(sd, (ANRational, ANExtensionElement)):
>4429 return sd.generator()
> -> 4430 self.exactify()
>4431 return self._exact_field()
>4432 
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py
>  in exactify(self)
>4363 if isinstance(od, (ANRational, ANExtensionElement)):
>4364 return
> -> 4365 self._set_descr(self._descr.exactify())
>4366 
>4367 def _set_descr(self, new_descr):
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py
>  in exactify(self)
>8180 
>8181 if op == 'real':
> -> 8182 arg.exactify()
>8183 rv = (arg + arg.conjugate()) / 2
>8184 rv.exactify()
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py
>  in exactify(self)
>4363 if isinstance(od, (ANRational, ANExtensionElement)):
>4364 return
> -> 4365 self._set_descr(self._descr.exactify())
>4366 
>4367 def _set_descr(self, new_descr):
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py
>  in exactify(self)
>8429 left = self._left
>8430 right = self._right
> -> 8431 left.exactify()
>8432 right.exactify()
>8433 gen = left._exact_field().union(right._exact_field())
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py
>  in exactify(self)
>4363 if isinstance(od, (ANRational, ANExtensionElement)):
>4364

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

2022-01-29 Thread Emmanuel Charpentier
QQxy.gens()

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

Suggestions ?
​
Le samedi 29 janvier 2022 à 15:34:05 UTC+1, Emmanuel Charpentier a écrit :

> Setup : Sage 9.5.rc1 running in Debian testing on core i7 + 16 GB RAM.
>
> def test(Size=2, Ring=QQ):
> from time import time as stime
> with seed(0):
> M = matrix(Ring, Size, Size, lambda u, v:Ring.random_element())
> t0 = stime()
> SL = M.eigenspaces_left(algebraic_multiplicity=True)
> t1 = stime()
> VL = M.eigenvectors_left()
> t2 = stime()
> return t1-t0, SL, t2-t1, VL
>
> test() runs as expected, as well as test(Size=5) and test(Ring=AA), with 
> very reasonable runtimes (under a second, IIRC). But test(Size=3, Ring=AA) 
> “never returns” (meaning that it hadn’t returned when I interrupted it 
> after tens of minutes). Further exploration showec that neither 
> M.eigenspaces_left(algebraic_multiplicity=True) nor M.eigenvectors_left() 
> return.
>
> Is that an expected behaviour ?
>
> FWIW, stack trace at interruption :
>
> sage: AA3=test(Size=3, Ring=AA)
> AA3=test(Size=3, Ring=AA)  C-c 
> C-c---
> AttributeErrorTraceback (most recent call last)
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py
>  in minpoly(self)
>4492 try:
> -> 4493 return self._minimal_polynomial
>4494 except AttributeError:
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/element.pyx
>  in sage.structure.element.Element.__getattr__ 
> (build/cythonized/sage/structure/element.c:4754)()
> 493 """
> --> 494 return self.getattr_from_category(name)
> 495 
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/element.pyx
>  in sage.structure.element.Element.getattr_from_category 
> (build/cythonized/sage/structure/element.c:4866)()
> 506 cls = P._abstract_element_class
> --> 507 return getattr_from_other_class(self, cls, name)
> 508 
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/cpython/getattr.pyx
>  in sage.cpython.getattr.getattr_from_other_class 
> (build/cythonized/sage/cpython/getattr.c:2633)()
> 360 dummy_error_message.name = name
> --> 361 raise AttributeError(dummy_error_message)
> 362 attribute = attr
>
> AttributeError: 'sage.rings.real_mpfi.RealIntervalFieldElement' object has no 
> attribute '_evaluate_polynomial'
>
> During handling of the above exception, another exception occurred:
>
> KeyboardInterrupt Traceback (most recent call last)
>  in 
> > 1 AA3=test(Size=Integer(3), Ring=AA)
>
>  in test(Size, Ring)
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/matrix/matrix2.pyx
>  in sage.matrix.matrix2.Matrix.eigenspaces_left 
> (build/cythonized/sage/matrix/matrix2.c:43588)()
>6270 self = self.change_ring(F)
>6271 A = self - alpha
> -> 6272 W = A.kernel()
>6273 V.append((alpha, 
> W.ambient_module().span_of_basis(W.basis()), e))
>6274 else:
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/matrix/matrix2.pyx
>  in sage.matrix.matrix2.Matrix.left_kernel 
> (build/cythonized/sage/matrix/matrix2.c:32440)()
>4947 
>4948 tm = verbose("computing left kernel for %sx%s matrix" % 
> (self.nrows(), self.ncols()),level=1)
> -> 4949 K = self.transpose().right_kernel(*args, **kwds)
>4950 self.cache('left_kernel', K)
>4951 verbose("done computing left kernel for %sx%s matrix" % 
> (self.nrows(), self.ncols()),level=1,t=tm)
>
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/matrix/matrix2.pyx
>  in sage.matrix.matrix2.Matrix.right_kernel 
> (build/cythonized/sage/matrix/matrix2.c:31909)()
>4785 
>4786 # Go get the kernel matrix, this is where it all happens
> -> 4787 M = self.right_kernel_matrix(*args, **kwds)
> 

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

2022-01-29 Thread Emmanuel Charpentier


Setup : Sage 9.5.rc1 running in Debian testing on core i7 + 16 GB RAM.

def test(Size=2, Ring=QQ):
from time import time as stime
with seed(0):
M = matrix(Ring, Size, Size, lambda u, v:Ring.random_element())
t0 = stime()
SL = M.eigenspaces_left(algebraic_multiplicity=True)
t1 = stime()
VL = M.eigenvectors_left()
t2 = stime()
return t1-t0, SL, t2-t1, VL

test() runs as expected, as well as test(Size=5) and test(Ring=AA), with 
very reasonable runtimes (under a second, IIRC). But test(Size=3, Ring=AA) 
“never returns” (meaning that it hadn’t returned when I interrupted it 
after tens of minutes). Further exploration showec that neither 
M.eigenspaces_left(algebraic_multiplicity=True) nor M.eigenvectors_left() 
return.

Is that an expected behaviour ?

FWIW, stack trace at interruption :

sage: AA3=test(Size=3, Ring=AA)
AA3=test(Size=3, Ring=AA)  C-c 
C-c---
AttributeErrorTraceback (most recent call last)
/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/rings/qqbar.py
 in minpoly(self)
   4492 try:
-> 4493 return self._minimal_polynomial
   4494 except AttributeError:

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/element.pyx
 in sage.structure.element.Element.__getattr__ 
(build/cythonized/sage/structure/element.c:4754)()
493 """
--> 494 return self.getattr_from_category(name)
495 

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/structure/element.pyx
 in sage.structure.element.Element.getattr_from_category 
(build/cythonized/sage/structure/element.c:4866)()
506 cls = P._abstract_element_class
--> 507 return getattr_from_other_class(self, cls, name)
508 

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/cpython/getattr.pyx
 in sage.cpython.getattr.getattr_from_other_class 
(build/cythonized/sage/cpython/getattr.c:2633)()
360 dummy_error_message.name = name
--> 361 raise AttributeError(dummy_error_message)
362 attribute = attr

AttributeError: 'sage.rings.real_mpfi.RealIntervalFieldElement' object has no 
attribute '_evaluate_polynomial'

During handling of the above exception, another exception occurred:

KeyboardInterrupt Traceback (most recent call last)
 in 
> 1 AA3=test(Size=Integer(3), Ring=AA)

 in test(Size, Ring)

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/matrix/matrix2.pyx
 in sage.matrix.matrix2.Matrix.eigenspaces_left 
(build/cythonized/sage/matrix/matrix2.c:43588)()
   6270 self = self.change_ring(F)
   6271 A = self - alpha
-> 6272 W = A.kernel()
   6273 V.append((alpha, 
W.ambient_module().span_of_basis(W.basis()), e))
   6274 else:

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/matrix/matrix2.pyx
 in sage.matrix.matrix2.Matrix.left_kernel 
(build/cythonized/sage/matrix/matrix2.c:32440)()
   4947 
   4948 tm = verbose("computing left kernel for %sx%s matrix" % 
(self.nrows(), self.ncols()),level=1)
-> 4949 K = self.transpose().right_kernel(*args, **kwds)
   4950 self.cache('left_kernel', K)
   4951 verbose("done computing left kernel for %sx%s matrix" % 
(self.nrows(), self.ncols()),level=1,t=tm)

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/matrix/matrix2.pyx
 in sage.matrix.matrix2.Matrix.right_kernel 
(build/cythonized/sage/matrix/matrix2.c:31909)()
   4785 
   4786 # Go get the kernel matrix, this is where it all happens
-> 4787 M = self.right_kernel_matrix(*args, **kwds)
   4788 
   4789 ambient = R**self.ncols()

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/matrix/matrix2.pyx
 in sage.matrix.matrix2.Matrix.right_kernel_matrix 
(build/cythonized/sage/matrix/matrix2.c:30829)()
   4394 
   4395 if M is None and R in _Fields:
-> 4396 format, M = self._right_kernel_matrix_over_field()
   4397 
   4398 if M is None and R.is_integral_domain():

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/matrix/matrix2.pyx
 in sage.matrix.matrix2.Matrix._right_kernel_matrix_over_field 
(build/cythonized/sage/matrix/matrix2.c:27969)()
   3686 from sage.matrix.matrix_space import MatrixSpace
   3687 tm = verbose("computing right kernel matrix over an arbitrary 
field for %sx%s matrix" % (self.nrows(), self.ncols()),level=1)
-> 3688 E = self.echelon_form(*args, **kwds)
   3689 pivots = E.pivots()
   3690 pivots_set = set(pivots)

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/pyt

Re: [sage-support] Problem in running SageMath application

2022-01-15 Thread Emmanuel Charpentier
Le samedi 15 janvier 2022 à 10:52:52 UTC+1, slelievre a écrit :

> 2022-01-15 09:05:10 UTC, Dima Pasechnik:
> >
> > what is "Gilbert Source"?
>
> I would bet some auto-respelling software thought
> that was a nice way to reinterpret "GitHub releases"
> to make the conversation interesting.  --Samuel
>

"Hell is paved with good intentions"...
 

-- 
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/c660b99f-a846-4eae-8cdc-b6895382b99dn%40googlegroups.com.


Re: [sage-support] Re: Snowman

2022-01-15 Thread Emmanuel Charpentier
Homework ?

Le vendredi 14 janvier 2022 à 19:41:05 UTC+1, iva.po...@gmail.com a écrit :

> Sorry, here is the picture how snowman has to look like..I started drawing 
> with a Sphere, but I can't get it like in the picture. 
>
>

-- 
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/44c8d1b6-292d-41f2-bd7e-646e0fd9bca2n%40googlegroups.com.


[sage-support] Re: Problem iniciating sage

2022-01-10 Thread Emmanuel Charpentier
You are trying to run Sage on a virtual machine. This Linix virtual machine 
requires you to log in.

I note that this virtual machine runs Linux 2.6.32 on a 32-bit virtual 
machine, which is downright paleontologic...

Are you trying to run a pre-packaged "appliance" ? Those weren't updated 
for a long time...

A better solution would be to compile from source on your host platform. 
This is (semi-) trivial on Linux, a tad more involved on Mac OS or Windows, 
but is well-documented in the installation guide 
.

What is your (host) platform ?

Le lundi 10 janvier 2022 à 10:10:32 UTC+1, albacar...@gmail.com a écrit :

> Hello I tried to enter to sage as usually, opening the virtual machine and 
> then through google chrome using localhost, but yesterday this popped and I 
> don´t know how to solve because it doesn´t let me get to my notebook.

-- 
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/9fb4e92d-e9f3-4f5c-b0e8-d8fc7fe01460n%40googlegroups.com.


[sage-support] Re: Sage Crash report (again...)

2021-12-18 Thread Emmanuel Charpentier


I’m in trouble:

The previous steps (make giac-clean && make fricas-clean && make 
sagelib-clean && make) failed ; I reverted to (make distclean && make) … 
which failed.

Repeatedly…

I’ll report and post logs in sage-release, which seems te “right place” for 
an installation problem occurring on a previously-working system.

Thank you for your attention.
​
Le samedi 18 décembre 2021 à 10:44:07 UTC+1, Emmanuel Charpentier a écrit :

> Same circumstances as in the previous case : on Debian testing running on 
> core i7 + 16 GB RAM, after upgrading Sage 9.5.beta7 compiled from a git 
> tree  to 9.5.beta8, Sage crashes at startup. Crash report enclosed
>
> I'll try the same steps as in the last occurrence...
>
> --
> Emmanuel Charpentier
>
>

-- 
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/a44974fb-75c1-4afa-a315-e90531c3f7edn%40googlegroups.com.


[sage-support] Sage Crash report (again...)

2021-12-18 Thread Emmanuel Charpentier
Same circumstances as in the previous case : on Debian testing running
on core i7 + 16 GB RAM, after upgrading Sage 9.5.beta7 compiled from a
git tree  to 9.5.beta8, Sage crashes at startup. Crash report enclosed

I'll try the same steps as in the last occurrence...

--
Emmanuel Charpentier

-- 
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/14e68240fe2d60a5c5e1b718b0c3d1d1e6eb13a1.camel%40free.fr.
***

IPython post-mortem report

{'commit_hash': 'd6d0edce10',
 'commit_source': 'installation',
 'default_encoding': 'utf-8',
 'ipython_path': 
'/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/IPython',
 'ipython_version': '7.27.0',
 'os_name': 'posix',
 'platform': 'Linux-5.15.0-2-amd64-x86_64-with-glibc2.33',
 'sys_executable': 
'/usr/local/sage-9/local/var/lib/sage/venv-python3.9/bin/python3',
 'sys_platform': 'linux',
 'sys_version': '3.9.9 (main, Nov 16 2021, 10:24:31) \n[GCC 11.2.0]'}

***



***

Crash traceback:

---
---
ImportErrorPython 3.9.9: 
/usr/local/sage-9/local/var/lib/sage/venv-python3.9/bin/python3
   Sat Dec 18 10:31:33 2021
A problem occurred executing Python code.  Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
/usr/local/sage-9/src/bin/sage-ipython in 
  1 #!/usr/bin/env sage-python
  2 # -*- coding: utf-8 -*-
  3 """
  4 Sage IPython startup script.
  5 """
  6 
  7 # Display startup banner. Do this before anything else to give the user
  8 # early feedback that Sage is starting.
  9 from sage.misc.banner import banner
 10 banner()
 11 
 12 from sage.repl.interpreter import SageTerminalApp
 13 
 14 app = SageTerminalApp.instance()
---> 15 app.initialize()
global app.initialize = >
 16 app.start()

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/traitlets/config/application.py
 in inner(app=, *args=(), 
**kwargs={})
 73 else:
 74 raise ValueError("Unsupported value for environment variable: 
'TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR' is set to '%s' which is none of 
 {'0', '1', 'false', 'true', ''}."% _envvar )
 75 
 76 
 77 def catch_config_error(method):
 78 """Method decorator for catching invalid config 
(Trait/ArgumentErrors) during init.
 79 
 80 On a TraitError (generally caused by bad config), this will print 
the trait's
 81 message, and exit the app.
 82 
 83 For use on init methods, to prevent invoking excepthook on invalid 
input.
 84 """
 85 @functools.wraps(method)
 86 def inner(app, *args, **kwargs):
 87 try:
---> 88 return method(app, *args, **kwargs)
global method = undefined
app = 
args = ()
kwargs = {}
 89 except (TraitError, ArgumentError) as e:
 90 app.log.fatal("Bad config encountered during 
initialization: %s", e)
 91 app.log.debug("Config at the time: %s", app.config)
 92 app.exit(1)
 93 
 94 return inner
 95 
 96 class ApplicationError(Exception):
 97 pass
 98 
 99 
100 class LevelFormatter(logging.Formatter):
101 """Formatter with additional `highlevel` record
102 
103 This field is empty if log level is less than highlevel_limit,

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/IPython/terminal/ipapp.py
 in initialize(self=, argv=None)
302 
303 return super(TerminalIPythonApp, self).parse_command_line(argv)
304 
305 @catch_config_error
306 def initialize(self, argv=None):
307 """Do actions after construct, but before starting the app."""
308 super(TerminalIPythonApp, self).initialize(argv)
309 if self.subapp is 

[sage-support] Re: Bug in integrals

2021-12-16 Thread Emmanuel Charpentier


A nice one, indeed. Here, Sage seems to use Maxima’s integrator :

sage: table([[u,(f(x)-g(x)).integrate(x,algorithm=u)] for u in ["maxima", 
"sympy", "giac", "fricas", "mathematica_free"]], header_row=["Algorithm", 
"Indefinite integral"])
  Algorithm  Indefinite integral
+--+--+
  maxima -1/9*(-3*I*x - 1)*cos(3*x) - 1/9*(3*I*x + 1)*e^(-3*I*x) + 
1/9*(3*x - I)*sin(3*x) - 1/12*cos(6*x) + 1/12*e^(-6*I*x) + 1/12*I*sin(6*x)
  sympy  0
  giac   0
  fricas 0
  mathematica_free   0

Note that :

sage: (f(x)-g(x)).integrate(x).simplify()
-1/9*(-3*I*x - 1)*cos(3*x) - 1/9*(3*I*x + 1)*e^(-3*I*x) + 1/9*(3*x - 
I)*sin(3*x) - 1/12*cos(6*x) + 1/12*e^(-6*I*x) + 1/12*I*sin(6*x)

but :

sage: (f(x)-g(x)).integrate(x).simplify_full()
0

and :

sage: (f(x)-g(x)).expand()
0

There are already some reports of incorrect/surprising Maxima definite and 
indefinite integral errors, often related to choice of branchs or branch 
cuts not accounted for. Would you care to check them and file a ticket if 
yours isn’t already known?
​
Le mercredi 15 décembre 2021 à 20:43:07 UTC+1, juanlui...@gmail.com a 
écrit :

> See this example:
>
> f(x)=(x+sin(3*x))*exp(-3*x*I)
> g(x)=f(x).expand()
> integral(f(x)-g(x),(x,0,2*pi))
>
> The answer is I*pi, but it should be 0.
>
> Many other examples (related to Fourier coefficients) give similar errors. 
> For instance:
>
> f(x)=(x+cos(x))*exp(-x*I)
> g(x)=f(x).expand()
> integral(f(x)-g(x),(x,0,2*pi))
>
> The answer is -pi, and it should be 0.
>
> It can be easily with sagemath 9.4 in https://sagecell.sagemath.org
>
> Thanks in advance,
>
> Yours,
>
> Juan Luis Varona
>
>
>
>

-- 
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/ec5574d3-21c4-41d2-b6d7-83c8a2189d41n%40googlegroups.com.


[sage-support] Re: Bug in integrals

2021-12-16 Thread Emmanuel Charpentier
Le mercredi 15 décembre 2021 à 20:43:07 UTC+1, juanlui...@gmail.com a 
écrit :

> See this example:
>
> f(x)=(x+sin(3*x))*exp(-3*x*I)
> g(x)=f(x).expand()
> integral(f(x)-g(x),(x,0,2*pi))
>
> The answer is I*pi, but it should be 0.
>

Huh ?

f has no poles ; therefore, the value of the integrate beteen two given 
points is independent of the integration path. In particular, 
f(x).integrate(x,a,b)==real(f(x)).integrate(x,a,b)+I*imag(x).integrate(x,a,b)). 
You can therefor check your affirmation by executing :

sage: numerical_integral(lambda 
u:f(u).real(),0,2*pi)[0]+I*numerical_integral(lambda u:f(u).imag(),0,2*pi)[0]
-3.2262783606579845e-15 - 1.0471975511966007*I

which raises some doubts about your affirmation….
​

>
> Many other examples (related to Fourier coefficients) give similar errors. 
> For instance:
>
> f(x)=(x+cos(x))*exp(-x*I)
> g(x)=f(x).expand()
> integral(f(x)-g(x),(x,0,2*pi))
>
> The answer is -pi, and it should be 0.
>

The previous reasoning also applies here :

```
sage: g(x)=(x+cos(x))*exp(-x*I)
sage: numerical_integral(lambda 
u:g(u).real(),0,2*pi)[0]+I*numerical_integral(lambda 
u:g(u).imag(),0,2*pi)[0]
3.1415926535897913 + 6.283185307179586*I
 ```
However, the answers given by the various available algorithms may still be 
questioned :

sage: table([[alg,f(x).integrate(x,0,2*pi, algorithm=alg)] for alg in 
("maxima", "giac", "sympy", "fricas", "mathematica_free")])
  maxima 2/3*I*pi
  giac   -1/3*I*pi
  sympy  -1/3*I*pi
  fricas -1/3*I*pi
  mathematica_free   -1.047200*I
sage: table([[alg,g(x).integrate(x,0,2*pi, algorithm=alg)] for alg in 
("maxima", "giac", "sympy", "fricas", "mathematica_free")])
  maxima 2*I*pi
  giac   (2*I + 1)*pi
  sympy  (2*I + 1)*pi
  fricas (2*I + 1)*pi
  mathematica_free   3.141590 + 6.283190*I

​
HTH,

It can be easily with sagemath 9.4 in https://sagecell.sagemath.org
>
> Thanks in advance,
>
> Yours,
>
> Juan Luis Varona
>
>
>
>

-- 
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/19143436-d58f-4830-bb77-daab8674d823n%40googlegroups.com.


[sage-support] Re: Deprecation warning when calling certain symbolic commands on Ubuntu 21.10 but not on 20.04 (SageMath 9.4)

2021-12-13 Thread Emmanuel Charpentier
Hmmm... Hypothesis : the tarball you used depends on some system library 
that got updated in Ubuntu 21.10. You might try to compile yourself from 
source, or wait for a tarball compiled for your version of Ubuntu.
My preference would go to the first solution, which makes you independent 
of further tarballs, and haves other advantages, such as being able to 
install optional packages. It's not *that* hard, just a bit long, and well 
explained in the installation guide 
<https://doc.sagemath.org/html/en/installation/>.

HTH,

Le lundi 13 décembre 2021 à 23:40:39 UTC+1, Marcus Aichmayr a écrit :

> It happens in command line and in jupyter notebook (firefox).
>
> On Monday, December 13, 2021 at 11:36:24 PM UTC+1 Emmanuel Charpentier 
> wrote:
>
>> Smells of an interface problem...
>>
>> Are you using a notebook, the command line or another interface (e. g. 
>> sage_shell_mode in emacs) ? If notebook, which browser do you use ?
>>
>> Le lundi 13 décembre 2021 à 20:31:48 UTC+1, Marcus Aichmayr a écrit :
>>
>>> Hi,
>>>
>>> I'm using SageMath 9.4 on both Ubuntu 20.04 and 21.10. In Ubuntu 21.10, 
>>> certain symbolic commands trigger a deprecation warning. This is not the 
>>> case in Ubuntu 20.04.
>>>
>>> Example 1:
>>> sage: assume(x > 0) 
>>> 
>>> /opt/SageMath/local/lib/python3.9/site-packages/sage/symbolic/expression_conversions.py:972:
>>>  
>>> DeprecationWarning: invalid escape sequence \|
>>>   """
>>>
>>> Example 2:
>>> sage: bool(SR(2) < 0)   
>>> 
>>> /opt/SageMath/local/lib/python3.9/site-packages/sage/symbolic/expression_conversions.py:972:
>>>  
>>> DeprecationWarning: invalid escape sequence \|
>>>   """
>>> False
>>>
>>> Note that SR(2) < 0 alone does not trigger the deprecation warning.
>>>
>>> I am not sure, what causes this deprecation warning on Ubuntu 21.10.
>>> Note that I have used the* sage-9.4-Ubuntu_20.04-x86_64.tar.bz2* 
>>> binaries to install SageMath 9.4 on both computers. The deprecation warning 
>>> might not occur if SageMath is built from source code on Ubuntu 21.10. I 
>>> have not tried 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/13299a14-3c7d-4a5d-bccb-ede4ea649f7an%40googlegroups.com.


[sage-support] Re: Deprecation warning when calling certain symbolic commands on Ubuntu 21.10 but not on 20.04 (SageMath 9.4)

2021-12-13 Thread Emmanuel Charpentier
Smells of an interface problem...

Are you using a notebook, the command line or another interface (e. g. 
sage_shell_mode in emacs) ? If notebook, which browser do you use ?

Le lundi 13 décembre 2021 à 20:31:48 UTC+1, Marcus Aichmayr a écrit :

> Hi,
>
> I'm using SageMath 9.4 on both Ubuntu 20.04 and 21.10. In Ubuntu 21.10, 
> certain symbolic commands trigger a deprecation warning. This is not the 
> case in Ubuntu 20.04.
>
> Example 1:
> sage: assume(x > 0)   
>   
> /opt/SageMath/local/lib/python3.9/site-packages/sage/symbolic/expression_conversions.py:972:
>  
> DeprecationWarning: invalid escape sequence \|
>   """
>
> Example 2:
> sage: bool(SR(2) < 0) 
>   
> /opt/SageMath/local/lib/python3.9/site-packages/sage/symbolic/expression_conversions.py:972:
>  
> DeprecationWarning: invalid escape sequence \|
>   """
> False
>
> Note that SR(2) < 0 alone does not trigger the deprecation warning.
>
> I am not sure, what causes this deprecation warning on Ubuntu 21.10.
> Note that I have used the* sage-9.4-Ubuntu_20.04-x86_64.tar.bz2* binaries 
> to install SageMath 9.4 on both computers. The deprecation warning might 
> not occur if SageMath is built from source code on Ubuntu 21.10. I have not 
> tried 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/b725ef30-226a-4236-ac93-396979960d7an%40googlegroups.com.


Re: [sage-support] Re: Sage crash report

2021-12-10 Thread Emmanuel Charpentier


Now, at the *end* of a Sage session, I get :

sage: quit
Exiting Sage (CPU time 0m5.63s, Wall time 97m53.10s).

/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/cysignals/signals.cpython-39-x86_64-linux-gnu.so(+0x7e1b)[0x7fe106cabe1b]
/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/cysignals/signals.cpython-39-x86_64-linux-gnu.so(+0x7ec9)[0x7fe106cabec9]
/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/cysignals/signals.cpython-39-x86_64-linux-gnu.so(+0xafa3)[0x7fe106caefa3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x138e0)[0x7fe1099888e0]
/usr/lib/x86_64-linux-gnu/libflint-2.8.2.so(_fmpz_cleanup_mpz_content+0x6a)[0x7fe0b651279a]
/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/libs/flint/flint.cpython-39-x86_64-linux-gnu.so(+0x2e29)[0x7fe0a2a71e29]
python3[0x52326b]
python3(_PyEval_EvalFrameDefault+0x53d1)[0x5149c1]
python3[0x50e2d1]
python3(_PyFunction_Vectorcall+0x3db)[0x525f3b]
python3(_PyEval_EvalFrameDefault+0x53d1)[0x5149c1]
python3[0x50e2d1]
python3(_PyFunction_Vectorcall+0x3db)[0x525f3b]
python3[0x63a580]
python3[0x6287ad]
python3(Py_FinalizeEx+0x4d)[0x62841d]
python3(Py_RunMain+0x170)[0x61eff0]
python3(Py_BytesMain+0x29)[0x606df9]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea)[0x7fe1097d5e4a]
python3(_start+0x2a)[0x606cfa]

Attaching gdb to process id 174166.
Cannot find gdb installed
GDB is not installed.
Install gdb for enhanced tracebacks.

Unhandled SIGSEGV: A segmentation fault occurred.
This probably occurred because a *compiled* module has a bug
in it and is not properly wrapped with sig_on(), sig_off().
Python will now terminate.

Segmentation fault

Both from a terminal session and from emacs‘s sage_shell_mode. I don’t see 
anything when I stop-and-close a Jupyter notebook.

Thoughts ?
​
Le vendredi 10 décembre 2021 à 16:39:53 UTC+1, Emmanuel Charpentier a 
écrit :

> make giac-clean && make did it !
>
> (*Alla cinese*) 10^4 thanks !
> ​
> Le vendredi 10 décembre 2021 à 11:56:00 UTC+1, dim...@gmail.com a écrit :
>
>> Everything that depends on updated Debian libs has to be rebuilt - looks 
>> like 
>>
>> make giac-clean 
>>
>> is needed too, for sure. 
>>
>> On Fri, Dec 10, 2021 at 10:36 AM Emmanuel Charpentier 
>>  wrote: 
>> > 
>> > 
>> > 
>> > Le vendredi 10 décembre 2021 à 01:04:33 UTC+1, Matthias Koeppe a écrit 
>> : 
>> >> 
>> >> "make sagelib-clean" will fix this 
>> > 
>> > 
>> > Nope. `make sagelib-clean` succeeds, but the following `make` fails at 
>> documentation ; attempting `make doc-clean && make also fails, *with the 
>> very same error*... : 
>> > 
>> > ``` 
>> > [sagemath_doc_html-none] cd /usr/local/sage-9 && ./sage --docbuild 
>> --no-pdf-links reference/libs inventory --no-prune-empty-dirs 
>> > [sagemath_doc_html-none] Warning: Could not import sage.libs.giac 
>> libgsl.so.25: cannot open shared object file: No such file or directory 
>> > [sagemath_doc_html-none] 
>> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/__init__.py:1066:
>>  
>> DeprecationWarning: the module sage.libs.ratpoints is deprecated; use 
>> pari.ellratpoints or pari.hyperellratpoints instead 
>> > [sagemath_doc_html-none] See http://trac.sagemath.org/24531 for 
>> details. 
>> > [sagemath_doc_html-none] __import__(module_name) 
>> > [sagemath_doc_html-none] [libs ] building [inventory]: targets for 39 
>> source files that are out of date 
>> > [sagemath_doc_html-none] [libs ] updating environment: [new config] 39 
>> added, 0 changed, 0 removed 
>> > [sagemath_doc_html-none] [libs ] WARNING: autodoc: failed to import 
>> module 'giac' from module 'sage.libs'; the following exception was raised: 
>> > [sagemath_doc_html-none] [libs ] libgsl.so.25: cannot open shared 
>> object file: No such file or directory 
>> > [sagemath_doc_html-none] [libs ] The inventory files are in 
>> local/share/doc/sage/inventory/en/reference/libs. 
>> > [sagemath_doc_html-none] Error building the documentation. 
>> > [sagemath_doc_html-none] Traceback (most recent call last): 
>> > [sagemath_doc_html-none] File "/usr/lib/python3.9/runpy.py", line 197, 
>> in _run_module_as_main 
>> > [sagemath_d

Re: [sage-support] Re: Sage crash report

2021-12-10 Thread Emmanuel Charpentier


make giac-clean && make did it !

(*Alla cinese*) 10^4 thanks !
​
Le vendredi 10 décembre 2021 à 11:56:00 UTC+1, dim...@gmail.com a écrit :

> Everything that depends on updated Debian libs has to be rebuilt - looks 
> like
>
> make giac-clean
>
> is needed too, for sure.
>
> On Fri, Dec 10, 2021 at 10:36 AM Emmanuel Charpentier
>  wrote:
> >
> >
> >
> > Le vendredi 10 décembre 2021 à 01:04:33 UTC+1, Matthias Koeppe a écrit :
> >>
> >> "make sagelib-clean" will fix this
> >
> >
> > Nope. `make sagelib-clean` succeeds, but the following `make` fails at 
> documentation ; attempting `make doc-clean && make also fails, *with the 
> very same error*... :
> >
> > ```
> > [sagemath_doc_html-none] cd /usr/local/sage-9 && ./sage --docbuild 
> --no-pdf-links reference/libs inventory --no-prune-empty-dirs
> > [sagemath_doc_html-none] Warning: Could not import sage.libs.giac 
> libgsl.so.25: cannot open shared object file: No such file or directory
> > [sagemath_doc_html-none] 
> /usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/__init__.py:1066:
>  
> DeprecationWarning: the module sage.libs.ratpoints is deprecated; use 
> pari.ellratpoints or pari.hyperellratpoints instead
> > [sagemath_doc_html-none] See http://trac.sagemath.org/24531 for details.
> > [sagemath_doc_html-none] __import__(module_name)
> > [sagemath_doc_html-none] [libs ] building [inventory]: targets for 39 
> source files that are out of date
> > [sagemath_doc_html-none] [libs ] updating environment: [new config] 39 
> added, 0 changed, 0 removed
> > [sagemath_doc_html-none] [libs ] WARNING: autodoc: failed to import 
> module 'giac' from module 'sage.libs'; the following exception was raised:
> > [sagemath_doc_html-none] [libs ] libgsl.so.25: cannot open shared object 
> file: No such file or directory
> > [sagemath_doc_html-none] [libs ] The inventory files are in 
> local/share/doc/sage/inventory/en/reference/libs.
> > [sagemath_doc_html-none] Error building the documentation.
> > [sagemath_doc_html-none] Traceback (most recent call last):
> > [sagemath_doc_html-none] File "/usr/lib/python3.9/runpy.py", line 197, 
> in _run_module_as_main
> > [sagemath_doc_html-none] return _run_code(code, main_globals, None,
> > [sagemath_doc_html-none] File "/usr/lib/python3.9/runpy.py", line 87, in 
> _run_code
> > [sagemath_doc_html-none] exec(code, run_globals)
> > [sagemath_doc_html-none] File 
> "/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/__main__.py",
>  
> line 2, in 
> > [sagemath_doc_html-none] main()
> > [sagemath_doc_html-none] File 
> "/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/__init__.py",
>  
> line 1815, in main
> > [sagemath_doc_html-none] builder()
> > [sagemath_doc_html-none] File 
> "/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/__init__.py",
>  
> line 822, in _wrapper
> > [sagemath_doc_html-none] getattr(DocBuilder, build_type)(self, *args, 
> **kwds)
> > [sagemath_doc_html-none] File 
> "/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/__init__.py",
>  
> line 133, in f
> > [sagemath_doc_html-none] runsphinx()
> > [sagemath_doc_html-none] File 
> "/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/sphinxbuild.py",
>  
> line 323, in runsphinx
> > [sagemath_doc_html-none] sys.stderr.raise_errors()
> > [sagemath_doc_html-none] File 
> "/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/sphinxbuild.py",
>  
> line 258, in raise_errors
> > [sagemath_doc_html-none] raise OSError(self._error)
> > [sagemath_doc_html-none] OSError: WARNING: autodoc: failed to import 
> module 'giac' from module 'sage.libs'; the following exception was raised:
> > [sagemath_doc_html-none]
> > [sagemath_doc_html-none] Note: incremental documentation builds 
> sometimes cause spurious
> > [sagemath_doc_html-none] error messages. To be certain that these are 
> real errors, run
> > [sagemath_doc_html-none] "make doc-clean" first and try again.
> > [sagemath_doc_html-none] make[6]: *** [Makefile:20 : 
> doc-inventory--reference-libs] Erreur 1
> > [sagemath_doc_html-none] make[5]: *** [Makefile:37 : 
> doc-inventory-reference] Erreur 2
> > make[4]: *** [Makefi

[sage-support] Re: Sage crash report

2021-12-10 Thread Emmanuel Charpentier


Le vendredi 10 décembre 2021 à 01:04:33 UTC+1, Matthias Koeppe a écrit :

> "make sagelib-clean" will fix this
>

Nope. `make sagelib-clean` succeeds, but the following `make` fails at 
documentation ; attempting `make doc-clean && make also fails, *with the 
very same error*... :

```
[sagemath_doc_html-none] cd /usr/local/sage-9 && ./sage --docbuild 
--no-pdf-links reference/libs inventory --no-prune-empty-dirs
[sagemath_doc_html-none] Warning: Could not import sage.libs.giac 
libgsl.so.25: cannot open shared object file: No such file or directory
[sagemath_doc_html-none] 
/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/__init__.py:1066:
 
DeprecationWarning: the module sage.libs.ratpoints is deprecated; use 
pari.ellratpoints or pari.hyperellratpoints instead
[sagemath_doc_html-none] See http://trac.sagemath.org/24531 for details.
[sagemath_doc_html-none]   __import__(module_name)
[sagemath_doc_html-none] [libs ] building [inventory]: targets for 39 
source files that are out of date
[sagemath_doc_html-none] [libs ] updating environment: [new config] 39 
added, 0 changed, 0 removed
[sagemath_doc_html-none] [libs ] WARNING: autodoc: failed to import 
module 'giac' from module 'sage.libs'; the following exception was raised:
[sagemath_doc_html-none] [libs ] libgsl.so.25: cannot open shared 
object file: No such file or directory
[sagemath_doc_html-none] [libs ] The inventory files are in 
local/share/doc/sage/inventory/en/reference/libs.
[sagemath_doc_html-none] Error building the documentation.
[sagemath_doc_html-none] Traceback (most recent call last):
[sagemath_doc_html-none]   File "/usr/lib/python3.9/runpy.py", line 197, in 
_run_module_as_main
[sagemath_doc_html-none] return _run_code(code, main_globals, None,
[sagemath_doc_html-none]   File "/usr/lib/python3.9/runpy.py", line 87, in 
_run_code
[sagemath_doc_html-none] exec(code, run_globals)
[sagemath_doc_html-none]   File 
"/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/__main__.py",
 
line 2, in 
[sagemath_doc_html-none] main()
[sagemath_doc_html-none]   File 
"/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/__init__.py",
 
line 1815, in main
[sagemath_doc_html-none] builder()
[sagemath_doc_html-none]   File 
"/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/__init__.py",
 
line 822, in _wrapper
[sagemath_doc_html-none] getattr(DocBuilder, build_type)(self, *args, 
**kwds)
[sagemath_doc_html-none]   File 
"/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/__init__.py",
 
line 133, in f
[sagemath_doc_html-none] runsphinx()
[sagemath_doc_html-none]   File 
"/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/sphinxbuild.py",
 
line 323, in runsphinx
[sagemath_doc_html-none] sys.stderr.raise_errors()
[sagemath_doc_html-none]   File 
"/usr/local/sage-9/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage_docbuild/sphinxbuild.py",
 
line 258, in raise_errors
[sagemath_doc_html-none] raise OSError(self._error)
[sagemath_doc_html-none] OSError: WARNING: autodoc: failed to import module 
'giac' from module 'sage.libs'; the following exception was raised:
[sagemath_doc_html-none] 
[sagemath_doc_html-none] Note: incremental documentation builds 
sometimes cause spurious
[sagemath_doc_html-none] error messages. To be certain that these are 
real errors, run
[sagemath_doc_html-none] "make doc-clean" first and try again.
[sagemath_doc_html-none] make[6]: *** [Makefile:20 : 
doc-inventory--reference-libs] Erreur 1
[sagemath_doc_html-none] make[5]: *** [Makefile:37 : 
doc-inventory-reference] Erreur 2
make[4]: *** [Makefile:2789 : sagemath_doc_html-SAGE_DOCS-no-deps] Erreur 2
make[3]: *** [Makefile:2789 : 
/usr/local/sage-9/local/var/lib/sage/installed/sagemath_doc_html-none] 
Erreur 2
make[2]: *** [Makefile:2332 : all-start] Erreur 2
make[2] : on quitte le répertoire « /usr/local/sage-9/build/make »

real18m33,136s
user29m24,260s
sys1m6,712s
***
Error building Sage.

The following package(s) may have failed to build (not necessarily
during this run of 'make all-start'):

It is safe to delete any log files and build directories, but they
contain information that is helpful for debugging build problems.
WARNING: If you now run 'make' again, the build directory of the
same version of the package will, by default, be deleted. Set the
environment variable SAGE_KEEP_BUILT_SPKGS=yes to prevent this.

make[1]: *** [Makefile:39 : all-start] Erreur 1
make[1] :

Re: [sage-support] another "how to simplify" question

2021-12-09 Thread Emmanuel Charpentier


In Sage, this can be written wrong.maxima_methods().trigrat().expand().

HTH,
​
Le jeudi 9 décembre 2021 à 10:37:11 UTC+1, Daniel Volinski a écrit :

> Hi All,
>
> In Maxima (embedded in SageMath) you can use:
>
> expand(trigrat(integrate(integrate(sin(x^2),x,y,1),y,0,1)));
>
> in order to get exactly the same result in both cases.
>
> Daniel
>
>
>
> En miércoles, 8 de diciembre de 2021 23:02:00 GMT+2, Fernando Q. Gouvea <
> fqgo...@colby.edu> escribió: 
>
>
> I see. So the difference between this and, say, 1+1==2 (which returns 
> True) is that 1+1 and 2 are numbers, not symbolic things.
>
> Fernando
> On 12/8/2021 3:37 PM, William Stein wrote:
>
>
>
> On Wed, Dec 8, 2021 at 12:22 PM Fernando Q. Gouvea  
> wrote:
>
> Thank you, that works. What is strange is that this does not:
>
> sage: right=integrate(integrate(sin(x^2),y,0,x),x,0,1)
> sage: wrong=integrate(integrate(sin(x^2),x,y,1),y,0,1)
> sage: real(wrong)==right
> -1/2*cos(1) + 1/2 == -1/2*cos(1) + 1/2
>
> Is Sage seeing a difference there that I don't? 
>
>
> I think I don't understand the difference between real(wrong)==right and 
> bool(real(wrong)==right).
>
> In Sage "[symbol thing] == [symbolic thing]" is a constructor for a 
> symbolic equation.
>
> sage: SR(2) == SR(2)
> 2 == 2
> sage: parent(SR(2) == SR(2))
> Symbolic Ring
> sage: bool(SR(2) == SR(2))
> True # only because Sage can *prove* they are equal -- it's false if it 
> can't prove they are equal, even if they are equal...
>
>
> https://cocalc.com/wstein/support/gouvea-equals
>
>
>  
>
> Fernando
> On 12/8/2021 1:23 PM, William Stein wrote:
>
> You can compare the real and imaginary parts directly. 
>
> https://cocalc.com/wstein/support/2021-12-08-gouvea
>
> sage: bool(wrong.real() == right)
> True
> sage: wrong.imag()
> 0
>
> On Wed, Dec 8, 2021 at 10:07 AM Fernando Q. Gouvea  
> wrote:
>
> I was showing my students a famous calculus example of an integral that 
> can be computed in one order of the variables but not in the other. Knowing 
> that SageMath can compute anything, the students suggested trying the 
> integral the "wrong" way.
>
> The "right" way is
>
> sage: integrate(integrate(sin(x^2),y,0,x),x,0,1)
>
> -1/2*cos(1) + 1/2
>
> The "wrong" way is
>
> sage: integrate(integrate(sin(x^2),x,y,1),y,0,1)
>
> -1/16*(-1)^(3/4)*((sqrt(2) + 4*(-1)^(1/4))*e^I - sqrt(-I)*((I + 
> 1)*sqrt(2)*(-1)^(1/4)*e^(2*I) - (I + 1)*sqrt(2)*(-1)^(1/4)*e^I) + 
> I*sqrt(2)*e^I - 2*(-1)^(1/4)*e^(2*I) - (I + 1)*sqrt(2) - 
> 2*(-1)^(1/4))*e^(-I)
>
> Is there any way to get Sage to check that these are equal? 
>
> The obvious thing does not seem to work:
>
> sage: -1/16*(-1)^(3/4)*((sqrt(2) + 4*(-1)^(1/4))*e^I - sqrt(-I)*((I + 
> 1)*sqrt(2)
> : *(-1)^(1/4)*e^(2*I) - (I + 1)*sqrt(2)*(-1)^(1/4)*e^I) + I*sqrt(2)*e^I - 
> 2*
> : (-1)^(1/4)*e^(2*I) - (I + 1)*sqrt(2) - 2*(-1)^(1/4))*e^(-I) == 
> -1/2*cos(1)
> : +1/2
>
> -1/16*(-1)^(3/4)*((sqrt(2) + 4*(-1)^(1/4))*e^I - sqrt(-I)*((I + 
> 1)*sqrt(2)*(-1)^(1/4)*e^(2*I) 
> - (I + 1)*sqrt(2)*(-1)^(1/4)*e^I) + I*sqrt(2)*e^I - 2*(-1)^(1/4)*e^(2*I) - (I 
> + 1)*sqrt(2) 
> - 2*(-1)^(1/4))*e^(-I) == -1/2*cos(1) + 1/2
>
> Thanks,
>
> Fernando
>
> -- 
> ==
> Fernando Q. Gouvea
> Carter Professor of Mathematics  
> Colby College
> Mayflower Hill 5836
> Waterville, ME 04901 fqgo...@colby.edu   
> http://www.colby.edu/~fqgouvea
>
> I have had a perfectly wonderful evening, but this wasn't it.
>   --Groucho Marx
>
>
> -- 
> 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/9557c1a9-bd1c-69e1-358f-4ab02a058c3a%40colby.edu
>  
> 
> .
>
>
>
> -- 
> William (http://wstein.org)
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-support...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-support/CACLE5GC6SNZuSsJ13iRFbO72Udn80Yy5OavR1SFwv03gjaQxvw%40mail.gmail.com
>  
> 
> .
>
> -- 
> ==
> Fernando Q. Gouvea
> Carter Professor of Mathematics  
> Colby College
> Mayflower Hill 5836
> Waterville, ME 04901 fqgo...@colby.edu   
> http://www.colby.edu/~fqgouvea
>
> What is socialism?
>
> The painful transition

[sage-support] Transformations/functions of equalities (and possibly inequalities)

2021-12-08 Thread Emmanuel Charpentier


Sage can “distribute” many operations on equalities operands, such as :

sage: var("a, b")
(a, b)
sage: (a==b)+3
a + 3 == b + 3
sage: 3*(a==b)
3*a == 3*b
sage: (a==b)^3
a^3 == b^3

But not common functions :

sage: log(a==b)
log(a == b)
sage: sin(a==b)
sin(a == b)

In both cases above, “distributing” the function would have been either 
right ((a==b)==> sin(a)==sin(b)) or at least possible (a==b implies that 
any value log(a) has an equal value of log(b)).

The case of inequalities is more questionable :

sage: 3*(a0 and b>0), log(a)==log(b)), (True, log(a==b))])
sage: (-3)*(a-3*b
sage: c*(a0),ab)),((c==0), True),(True,c*(a-b))])

etc…

Would work in this direction be useful to Sage ?

Advice ?
​

-- 
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/4b71608b-27d8-4ed3-9fdd-7ff6394c83e1n%40googlegroups.com.


[sage-support] Re: A problem with the Sage solvers

2021-12-06 Thread Emmanuel Charpentier


On the Sympy list, Cris Smith points out 
<https://groups.google.com/g/sympy/c/EB_Z6h3ZRDg/m/DuAIQkquBAAJ> that 
factoring the orignal equations is enough to allow Sympy’s solve go get a 
correct solution. It turns out that he’s right for Sympy 1.9 (current), but 
not for Sympy 1.8 (current in Sage 9.5.beta7).

Sorry for the noise…
​
Le dimanche 5 décembre 2021 à 20:55:32 UTC+1, Emmanuel Charpentier a écrit :

> ask.sagemat.org question 
> <https://ask.sagemath.org/question/59063/weird-c-values-from-solving-system-of-equations/>
>  
> demonstrating a problem common to all free equation solvers : solve
>
> $$
> \begin{align
>
>
>
>
> *}-a{1}^{3} a{2} + a{1} a{2}^{2} \ -3 \, a{1}^{2} a{2} b{1} + 2 \, a{1} 
> a{2} b{2} + a{2}^{2} b{2} - a{1} b{2} \ -a{1}^{2} a{2}^{2} + a{2}^{3} \ -2 
> \, a{1}^{2} a{2} b{2} - 2 \, a{2}^{2} b{1} + 3 \, a{2}^{2} b{2}\end{align*
> }
> $$
>
> Unk = var('a1 a2 b1 b2')   
> eq1 = a1 * a2^2 - a2 * a1^3
> eq2 = 2*a1*a2*b2 + b2*a2^2 - 3*a2*a1^2*b1 - a1*b2   
> eq3 = a2^3 - a2^2*a1^2 
> eq4 = 3*a2^2*b2 - 2*a2*a1^2*b2 - 2*a2^2*b1
> Sys = [eq1, eq2, eq3, eq4]
>
> Solving eq1 for a2 :
>
> S1 = eq1.factor().solve(a2, solution_dict=True) ;print ("S1 = ", S1)
>
> S1 =  [{a2: a1^2}, {a2: 0}]
>
> gives us a set of solutions which are *also* solutions of eq3 :
>
> [eq3.subs(s) for s in S1]
>
> [0, 0]
>
> It easy to check that there are no ther roots to eq3:
>
> flatten([eq3.solve(v, algorithm="sympy") for v in eq3.variables()])
>
> [a1 == sqrt(a2), a1 == -sqrt(a2), a2 == 0, a2 == a1^2]
>
> S1[1] turns out to be *also* a solution of eq4:
>
> eq4.subs(S1[1])
>
> 0
>
> As above, we can substitute S1[0] in eq4 and merge the resulting 
> solutions of eq4 to S1[0] suitably updated:
>
> E4=eq4.subs(S1[0])
> S4=flatten([E4.solve(v, solution_dict=True) for v in E4.variables()])
> S134t=S1[1:]for s in S4:
> S0={u:S1[0][u].subs(s) if "subs" in dir(S1[0][u]) else S1[0][u] for u in 
> S1[0].keys()}
> S134t+=[S0.copy()|s]
> S134t
>
> [{a2: 0}, {a2: 0, a1: 0}, {a2: a1^2, b1: 1/2*b2}, {a2: a1^2, b2: 2*b1}]
>
> This set being redundant, we trim it manually :
>
> S134=[S134t[u] for u in (0, 3)]
> S134
>
> [{a2: 0}, {a2: a1^2, b2: 2*b1}]
>
> Substituting these solutions in eq2 gives us a set of equations, whose 
> solutions for their variables complete the partial solutions of S134, thus 
> giving the set of solutions of the complete system :
>
> S1234=[]for s in S134:
> E=eq2.subs(s)
> S=flatten([E.solve(v, solution_dict=True) for v in E.variables()])
> for s1 in S:
> s0={u:s[u].subs(s1) if "subs" in  dir(s[u]) else s[u] for u in 
> s.keys()}
> S1234+=[s0.copy()|s1]
> S1234
>
> [{a2: 0, a1: 0},
>  {a2: 0, b2: 0},
>  {a2: 1/324*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(I*sqrt(3) + 1) + 
> 16*(-I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)^2,
>   b2: 2*b1,
>   a1: -1/2*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(I*sqrt(3) + 1) - 
> 8/9*(-I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 4/3},
>  {a2: 1/324*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(-I*sqrt(3) + 1) + 
> 16*(I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)^2,
>   b2: 2*b1,
>   a1: -1/2*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(-I*sqrt(3) + 1) - 
> 8/9*(I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 4/3},
>  {a2: 1/81*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 
> 16/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 12)^2,
>   b2: 2*b1,
>   a1: (1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 16/9/(1/9*I*sqrt(101)*sqrt(3) 
> + 37/27)^(1/3) + 4/3},
>  {a2: 0, b2: 2*b1, a1: 0},
>  {a2: a1^2, b2: 0, b1: 0}]
>
> Let’s check these solution by substitution in the original system:
>
> Chk=[[e.subs(s) for e in Sys] for s in S1234] ; Chk
>
> [[0, 0, 0, 0],
>  [0, 0, 0, 0],
>  [0,
>   -1/104976*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(I*sqrt(3) + 1) + 
> 16*(-I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)^4*b1 - 
> 1/1458*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(I*sqrt(3) + 1) + 
> 16*(-I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)^3*b1 + 
> 1/9*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(I*sqrt(3) + 1) + 
> 16*(-I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)*b1,
>   0,
>   0],
>  [0,
>   -1/104976*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(-I*sqrt(3) + 1) + 
> 16*(I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)^4*b1 - 
> 1/1458*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(-I*sqrt(3) + 1) + 
> 16*(I*sqrt(3) + 1)/(1/9*I*sqrt(101)*

[sage-support] A problem with the Sage solvers

2021-12-05 Thread Emmanuel Charpentier


ask.sagemat.org question 

 
demonstrating a problem common to all free equation solvers : solve

$$
\begin{align




*}-a{1}^{3} a{2} + a{1} a{2}^{2} \ -3 \, a{1}^{2} a{2} b{1} + 2 \, a{1} 
a{2} b{2} + a{2}^{2} b{2} - a{1} b{2} \ -a{1}^{2} a{2}^{2} + a{2}^{3} \ -2 
\, a{1}^{2} a{2} b{2} - 2 \, a{2}^{2} b{1} + 3 \, a{2}^{2} b{2}\end{align*}
$$

Unk = var('a1 a2 b1 b2')   
eq1 = a1 * a2^2 - a2 * a1^3
eq2 = 2*a1*a2*b2 + b2*a2^2 - 3*a2*a1^2*b1 - a1*b2   
eq3 = a2^3 - a2^2*a1^2 
eq4 = 3*a2^2*b2 - 2*a2*a1^2*b2 - 2*a2^2*b1
Sys = [eq1, eq2, eq3, eq4]

Solving eq1 for a2 :

S1 = eq1.factor().solve(a2, solution_dict=True) ;print ("S1 = ", S1)

S1 =  [{a2: a1^2}, {a2: 0}]

gives us a set of solutions which are *also* solutions of eq3 :

[eq3.subs(s) for s in S1]

[0, 0]

It easy to check that there are no ther roots to eq3:

flatten([eq3.solve(v, algorithm="sympy") for v in eq3.variables()])

[a1 == sqrt(a2), a1 == -sqrt(a2), a2 == 0, a2 == a1^2]

S1[1] turns out to be *also* a solution of eq4:

eq4.subs(S1[1])

0

As above, we can substitute S1[0] in eq4 and merge the resulting solutions 
of eq4 to S1[0] suitably updated:

E4=eq4.subs(S1[0])
S4=flatten([E4.solve(v, solution_dict=True) for v in E4.variables()])
S134t=S1[1:]for s in S4:
S0={u:S1[0][u].subs(s) if "subs" in dir(S1[0][u]) else S1[0][u] for u in 
S1[0].keys()}
S134t+=[S0.copy()|s]
S134t

[{a2: 0}, {a2: 0, a1: 0}, {a2: a1^2, b1: 1/2*b2}, {a2: a1^2, b2: 2*b1}]

This set being redundant, we trim it manually :

S134=[S134t[u] for u in (0, 3)]
S134

[{a2: 0}, {a2: a1^2, b2: 2*b1}]

Substituting these solutions in eq2 gives us a set of equations, whose 
solutions for their variables complete the partial solutions of S134, thus 
giving the set of solutions of the complete system :

S1234=[]for s in S134:
E=eq2.subs(s)
S=flatten([E.solve(v, solution_dict=True) for v in E.variables()])
for s1 in S:
s0={u:s[u].subs(s1) if "subs" in  dir(s[u]) else s[u] for u in s.keys()}
S1234+=[s0.copy()|s1]
S1234

[{a2: 0, a1: 0},
 {a2: 0, b2: 0},
 {a2: 1/324*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(I*sqrt(3) + 1) + 
16*(-I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)^2,
  b2: 2*b1,
  a1: -1/2*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(I*sqrt(3) + 1) - 
8/9*(-I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 4/3},
 {a2: 1/324*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(-I*sqrt(3) + 1) + 
16*(I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)^2,
  b2: 2*b1,
  a1: -1/2*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(-I*sqrt(3) + 1) - 
8/9*(I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 4/3},
 {a2: 1/81*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 
16/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 12)^2,
  b2: 2*b1,
  a1: (1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 16/9/(1/9*I*sqrt(101)*sqrt(3) + 
37/27)^(1/3) + 4/3},
 {a2: 0, b2: 2*b1, a1: 0},
 {a2: a1^2, b2: 0, b1: 0}]

Let’s check these solution by substitution in the original system:

Chk=[[e.subs(s) for e in Sys] for s in S1234] ; Chk

[[0, 0, 0, 0],
 [0, 0, 0, 0],
 [0,
  -1/104976*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(I*sqrt(3) + 1) + 
16*(-I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)^4*b1 - 
1/1458*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(I*sqrt(3) + 1) + 
16*(-I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)^3*b1 + 
1/9*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(I*sqrt(3) + 1) + 16*(-I*sqrt(3) 
+ 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)*b1,
  0,
  0],
 [0,
  -1/104976*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(-I*sqrt(3) + 1) + 
16*(I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)^4*b1 - 
1/1458*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(-I*sqrt(3) + 1) + 
16*(I*sqrt(3) + 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)^3*b1 + 
1/9*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3)*(-I*sqrt(3) + 1) + 16*(I*sqrt(3) 
+ 1)/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) - 24)*b1,
  0,
  0],
 [0,
  -1/6561*b1*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 
16/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 12)^4 + 
4/729*b1*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 
16/(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 12)^3 - 
2/9*b1*(9*(1/9*I*sqrt(101)*sqrt(3) + 37/27)^(1/3) + 16/(1/9*I*sqrt(101)*sqrt(3) 
+ 37/27)^(1/3) + 12),
  0,
  0],
 [0, 0, 0, 0],
 [0, 0, 0, 0]]

The fly in the ointment is that once substituted, for some solutions, eq2 
is a first-degree monomial in b1, whose coefficient is in each case 
numerically quite close to 0 :

K=[Chk[u][1].coefficient(b1) for u in range(2,5)]
[u.n() for u in K]

[6.66133814775094e-16 + 4.44089209850063e-16*I,
 -8.88178419700125e-16 - 4.44089209850063e-16*I,
 -2.84217094304040e-14]

but cannot be proven to be 0 ([u.is_zero() for u in K] never returns).

Furthermore [u.factor().n() for u in K] aborts (on Sage 9.

Re: [sage-support] Re: Constrained optimization with strange result.

2021-11-30 Thread Emmanuel Charpentier


Le mardi 30 novembre 2021 à 18:18:35 UTC+1, cyrille piatecki a écrit :

> Thanks Emmanuel for your so precious answer. But obviously the doc must be 
> upgraded. From
>
> "maxima", "fricas", "sympy", "giac"
>
> only "sympy" has a reference.
>

(Almost) right : the documentation I pointed to doesn’t list anything but 
maxima. The up to date documentation 
<https://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/relation.html>
 
is similar, but gives example of algorithm="sympy" uses…

Would you care to file a ticket against that ? A further problem being that 
the documentatin mentions the use of algorithm for single-equation solving, 
whereas your current example shows success for (an) equation *system*. This 
should be clarified…
​
 

> I wonder If one could add a parameter asking, in all cases, only for Real 
> solutions.
>

Beware : There Might Be Tygers ! (Hint : I left you an exercise... ;-)
 

>
> - Mail d’origine -
> De: Emmanuel Charpentier 
> À: sage-support 
> Envoyé: Tue, 30 Nov 2021 14:54:31 +0100 (CET)
> Objet: Re: [sage-support] Re: Constrained optimization with strange result.
>
> Le lundi 29 novembre 2021 à 16:33:41 UTC+1, cyrille piatecki a écrit :
>
>
>
> Thanks Emmanuel for your precious answer. But It generates some few new 
>> questions :
>> - is there a place in the documentation where I can find the information 
>> on `solve()` and mainly its options ?
>>
>
>
> The documentation 
> <https://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/relation.html>,
>  
> of course…
>
>
>
>
>> - if I understand clearly z_{6497} is an integer but how to fix it to 
>> zero --- when the number change at each iteration
>>
>
>
> That’s why I used a methods sequence to designate it, rather than using 
> its name…
>
>
>
>
>> - sympy seems to be the good approach
>>
>
>
> Beware : see below…
>
>
>
> but it is not self evident that to call y one must typpeset sol2[0][x]
>>
>
>
> It is, because algorithm="sympy" will cause the results to be expressed 
> as dictionaries and D[x] is the canonical way to get the value of the 
> entry of dictionary D indexed by x. Basic Python…
>
>
>
>
>> - the giac way is certainly the better but it keeps no track of the 
>> variable's order.
>>
>
>
> Again, ask for a solution dictionary. As for algorithm="giac", I have 
> seen it go pear-shaped a couple times…
>
> Now for the various expression of solutions : consider :
>
> print(table([[u,solve(FOC,[x,y,l], solution_dict=True, algorithm=u)] for u in 
> ["maxima", "fricas", "sympy", "giac"]]))
>   maxima   [{l: 1/p_y, x: (p_x/p_y)^(1/a)*e^(2*I*pi*z3541/a), y: 
> -(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3541/a) - R)/p_y}]
>   fricas   [{l: 1/p_y, x: (p_x/p_y)^(1/a)*e^(2*I*pi*z3892/a), y: 
> -(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3892/a) - R)/p_y}]
>   sympy[{x: (p_x/p_y)^(1/a), l: 1/p_y, y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y}]
>   giac [{x: (p_x/p_y)^(1/a), y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y, l: 1/p_y}]
>
> Both maxima and fricas try to explicitly express the set of solutions of 
> the equation z^a==p_x/p_y, which is a set of a complexes if a is a 
> positive integer. (I leave to you (as en exercise ;-) to determine what it 
> means (if any…) if a is rational, algebraic or transcendental, real or 
> complex…).
>
> OTOH, both sympy and giac use the notation (p_x/p_y)^(1/a) to *implicitly* 
> denote *the very same set of solutions to the very same equation. One could 
> say that tey are glossing over whatever maxima and fricas insist on. 
> Choose your poison…
>
> HTH,
> ​
>
>  
>
>>
>> I have tried my solution assuming l>0 on the 3 conditions but it changes 
>> nothing.
>>
>>
>>
>> - Mail d’origine -
>> De: Emmanuel Charpentier 
>> À: sage-support 
>> Envoyé: Mon, 29 Nov 2021 11:03:37 +0100 (CET)
>> Objet: [sage-support] Re: Constrained optimization with strange result.
>>
>> Variables of the form z_ are *integer* variables created by Maxima, 
>> which attempts to give you *also* the complex roots, if any, thus 
>> ignoring the assumptions on x, y and l. Note that :
>>
>> sage: solve(FOC[0], x)
>> ---
>>
>> [ Snip… ]
>>
>> TypeError: Computation failed since Maxima requested additional constraints; 
>> using the 'assume' command before evaluation *may* help (example of legal 
>> syntax is 'assum

Re: [sage-support] Re: Constrained optimization with strange result.

2021-11-30 Thread Emmanuel Charpentier


Le lundi 29 novembre 2021 à 16:33:41 UTC+1, cyrille piatecki a écrit :

Thanks Emmanuel for your precious answer. But It generates some few new 
> questions :
> - is there a place in the documentation where I can find the information 
> on `solve()` and mainly its options ?
>
The documentation 
<https://doc.sagemath.org/html/en/reference/calculus/sage/symbolic/relation.html>,
 
of course…

- if I understand clearly z_{6497} is an integer but how to fix it to zero 
> --- when the number change at each iteration
>
That’s why I used a methods sequence to designate it, rather than using its 
name…

- sympy seems to be the good approach
>
Beware : see below…

but it is not self evident that to call y one must typpeset sol2[0][x]
>
It is, because algorithm="sympy" will cause the results to be expressed as 
dictionaries and D[x] is the canonical way to get the value of the entry of 
dictionary D indexed by x. Basic Python…

- the giac way is certainly the better but it keeps no track of the 
> variable's order.
>
Again, ask for a solution dictionary. As for algorithm="giac", I have seen 
it go pear-shaped a couple times…

Now for the various expression of solutions : consider :

print(table([[u,solve(FOC,[x,y,l], solution_dict=True, algorithm=u)] for u in 
["maxima", "fricas", "sympy", "giac"]]))
  maxima   [{l: 1/p_y, x: (p_x/p_y)^(1/a)*e^(2*I*pi*z3541/a), y: 
-(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3541/a) - R)/p_y}]
  fricas   [{l: 1/p_y, x: (p_x/p_y)^(1/a)*e^(2*I*pi*z3892/a), y: 
-(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3892/a) - R)/p_y}]
  sympy[{x: (p_x/p_y)^(1/a), l: 1/p_y, y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y}]
  giac [{x: (p_x/p_y)^(1/a), y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y, l: 1/p_y}]

Both maxima and fricas try to explicitly express the set of solutions of 
the equation z^a==p_x/p_y, which is a set of a complexes if a is a positive 
integer. (I leave to you (as en exercise ;-) to determine what it means (if 
any…) if a is rational, algebraic or transcendental, real or complex…).

OTOH, both sympy and giac use the notation (p_x/p_y)^(1/a) to *implicitly* 
denote *the very same set of solutions to the very same equation. One could 
say that tey are glossing over whatever maxima and fricas insist on. Choose 
your poison…

HTH,
​
 

> I have tried my solution assuming l>0 on the 3 conditions but it changes 
> nothing.
>
>
>
> - Mail d’origine -
> De: Emmanuel Charpentier 
> À: sage-support 
> Envoyé: Mon, 29 Nov 2021 11:03:37 +0100 (CET)
> Objet: [sage-support] Re: Constrained optimization with strange result.
>
> Variables of the form z_ are *integer* variables created by Maxima, 
> which attempts to give you *also* the complex roots, if any, thus 
> ignoring the assumptions on x, y and l. Note that :
>
> sage: solve(FOC[0], x)
> ---
>
> [ Snip… ]
>
> TypeError: Computation failed since Maxima requested additional constraints; 
> using the 'assume' command before evaluation *may* help (example of legal 
> syntax is 'assume(l>0)', see `assume?` for more details)
> Is l positive, negative or zero?
> sage: with assuming(l>0): print(solve(FOC[0], x))
> [
> x == (l*p_x)^(1/a)
> ]
> sage: with assuming(l<0): print(solve(FOC[0], x))
> [
> x^a == l*p_x
> ]
> sage: with assuming(l<0): print(solve(FOC[0], x, to_poly_solve=True))
> [x == (l*p_x)^(1/a)*e^(2*I*pi*z4353/a)]
>
> Interestingly:
>
> sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l)
> [[l == (1/p_y), x == (p_x/p_y)^(1/a)*e^(2*I*pi*z3540/a), y == 
> -(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3540/a) - R)/p_y]]
> sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l, algorithm="sympy")
> [{x: (p_x/p_y)^(1/a), l: 1/p_y, y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y}]
> sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l, algorithm="fricas")
> [[l == (1/p_y), x == (p_x/p_y)^(1/a)*e^(2*I*pi*z3891/a), y == 
> -(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3891/a) - R)/p_y]]
> sage: giac.solve(giac(FOC),giac([x,y,l])).sage()
> [[(p_x/p_y)^(1/a), -(p_x*(p_x/p_y)^(1/a) - R)/p_y, 1/p_y]]
>
> HTH,
> ​
> Le dimanche 28 novembre 2021 à 22:13:12 UTC+1, cyrille piatecki a écrit :
>
>> On my computer the solution of
>>
>> var('a x y p_x p_y D Rev R l')
>> assume(a,'real')
>> assume(x,'real')
>> assume(y,'real')
>> assume(p_x,'real')
>> assume(p_y,'real')
>> assume(D,'real')
>> assume(Rev,'real')
>> assume(R,'real')
>> assume(l,'real')
>> assume(a<1)
>> assume(a>0)
>> assume(p_x>0)
>> assume(p_y>0)
>> assume(R>0)
&

[sage-support] Re: Constrained optimization with strange result.

2021-11-29 Thread Emmanuel Charpentier


Variables of the form z_ are *integer* variables created by Maxima, 
which attempts to give you *also* the complex roots, if any, thus ignoring 
the assumptions on x, y and l. Note that :

sage: solve(FOC[0], x)
---

[ Snip… ]

TypeError: Computation failed since Maxima requested additional constraints; 
using the 'assume' command before evaluation *may* help (example of legal 
syntax is 'assume(l>0)', see `assume?` for more details)
Is l positive, negative or zero?
sage: with assuming(l>0): print(solve(FOC[0], x))
[
x == (l*p_x)^(1/a)
]
sage: with assuming(l<0): print(solve(FOC[0], x))
[
x^a == l*p_x
]
sage: with assuming(l<0): print(solve(FOC[0], x, to_poly_solve=True))
[x == (l*p_x)^(1/a)*e^(2*I*pi*z4353/a)]

Interestingly:

sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l)
[[l == (1/p_y), x == (p_x/p_y)^(1/a)*e^(2*I*pi*z3540/a), y == 
-(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3540/a) - R)/p_y]]
sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l, algorithm="sympy")
[{x: (p_x/p_y)^(1/a), l: 1/p_y, y: -(p_x*(p_x/p_y)^(1/a) - R)/p_y}]
sage: solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l, algorithm="fricas")
[[l == (1/p_y), x == (p_x/p_y)^(1/a)*e^(2*I*pi*z3891/a), y == 
-(p_x*(p_x/p_y)^(1/a)*e^(2*I*pi*z3891/a) - R)/p_y]]
sage: giac.solve(giac(FOC),giac([x,y,l])).sage()
[[(p_x/p_y)^(1/a), -(p_x*(p_x/p_y)^(1/a) - R)/p_y, 1/p_y]]

HTH,
​
Le dimanche 28 novembre 2021 à 22:13:12 UTC+1, cyrille piatecki a écrit :

> On my computer the solution of
>
> var('a x y p_x p_y D Rev R l')
> assume(a,'real')
> assume(x,'real')
> assume(y,'real')
> assume(p_x,'real')
> assume(p_y,'real')
> assume(D,'real')
> assume(Rev,'real')
> assume(R,'real')
> assume(l,'real')
> assume(a<1)
> assume(a>0)
> assume(p_x>0)
> assume(p_y>0)
> assume(R>0)
> U =(1/(a+1))*x^(a+1)+y
> show(LatexExpr(r'\text{La fonction d}^\prime\text{utilité est }U(x,y) = 
> '),U)
> D= x*p_x + y*p_y
> show(LatexExpr(r'\text{La Dépense } D = '),D)
> Rev= R
> show(LatexExpr(r'\text{Le Revenu } Rev = '),R)
> L=U+l*(Rev-D)
> show(LatexExpr(r'\text{Le lagrangien est } \mathcal{L}(x, y, λ) = '),L)
> FOC = [diff(L,x),diff(L,y),diff(L,l)]
> show(LatexExpr(r'\text{Les condition du premier ordre sont } 
> \left\{\begin{array}{c}\mathcal{L}_x= 0\\\mathcal{L}_y= 0\\\mathcal{L}_λ= 
> 0\end{array}\right. '))
> show(LatexExpr(r'\text{soit }'))
> show(LatexExpr(r'\mathcal{L}_x= 0 \Longleftrightarrow '),FOC[0]==0)
> show(LatexExpr(r'\mathcal{L}_y= 0 \Longleftrightarrow '),FOC[1]==0)
> show(LatexExpr(r'\mathcal{L}_λ= 0 \Longleftrightarrow '),FOC[2]==0)
> sol=solve([FOC[0]==0,FOC[1]==0,FOC[2]==0],x,y,l)
> show(sol)
>
> Is nearly correct, but an extra complex exponential term multiplies $x$ 
> and then modifies $y$. Even as an element I do not understand its form :
>
> $e^{(2iπz_{5797}a)}$
>
> Could some one explain why ?
>
>

-- 
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/e745f8a7-df76-4def-b3b9-09ac7684e9a3n%40googlegroups.com.


Re: [sage-support] I'm confused with symbolic fractions

2021-11-27 Thread Emmanuel Charpentier


Alternatives :

sage: var("a, b, c")
(a, b, c)
sage: f=1/(a-b)+2/(b-c)+3/(c-a)
sage: g=f*(a-b)*(b-c)*(c-a)
sage: f
1/(a - b) - 3/(a - c) + 2/(b - c)
sage: f.factor()
(2*a^2 - 4*a*b + 3*b^2 - 2*b*c + c^2)/((a - b)*(a - c)*(b - c))
sage: g
-(a - b)*(a - c)*(b - c)*(1/(a - b) - 3/(a - c) + 2/(b - c))
sage: g.expand()
-a^2*b/(a - b) + 3*a^2*b/(a - c) - 2*a^2*b/(b - c) + a*b^2/(a - b) - 3*a*b^2/(a 
- c) + 2*a*b^2/(b - c) + a^2*c/(a - b) - 3*a^2*c/(a - c) + 2*a^2*c/(b - c) - 
b^2*c/(a - b) + 3*b^2*c/(a - c) - 2*b^2*c/(b - c) - a*c^2/(a - b) + 3*a*c^2/(a 
- c) - 2*a*c^2/(b - c) + b*c^2/(a - b) - 3*b*c^2/(a - c) + 2*b*c^2/(b - c)
sage: g.expand().factor()
-2*a^2 + 4*a*b - 3*b^2 + 2*b*c - c^2

And, indeed :

sage: R1.=QQ[]
sage: fp = FractionField(R1)(f.subs(dict(zip((a,b,c),(t,u,v).numerator() ; 
fp
2*t^2 - 4*t*u + 3*u^2 - 2*u*v + v^2
sage: SR(fp).subs(dict(zip((t,u,v), (a,b,c
2*a^2 - 4*a*b + 3*b^2 - 2*b*c + c^2

HTH,
​
Le vendredi 26 novembre 2021 à 20:25:08 UTC+1, dim...@gmail.com a écrit :

> On Fri, Nov 26, 2021 at 7:19 PM Ricardo Fodra  wrote:
> >
> > So I tried to do:
> >
> > var('a b c')
> > f = 1/(a-b) + 2/(b-c) + 3/(c-a)
> > # get rid of the denominators
> > g = f*(a-b)*(b-c)*(c-a)
> > g.expand()
> >
> > And I was hoping to get something like:
> >
> > -a*b + a*c + b*c - c^2 - 2*a - 2*b - c
> >
> > and instead I got:
> >
> > -a^2*b/(a - b) + 3*a^2*b/(a - c) - 2*a^2*b/(b - c) + a*b^2/(a - b) - 
> 3*a*b^2/(a - c) + 2*a*b^2/(b - c) + a^2*c/(a - b) - 3*a^2*c/(a - c) + 
> 2*a^2*c/(b - c) - b^2*c/(a - b) + 3*b^2*c/(a - c) - 2*b^2*c/(b - c) - 
> a*c^2/(a - b) + 3*a*c^2/(a - c) - 2*a*c^2/(b - c) + b*c^2/(a - b) - 
> 3*b*c^2/(a - c) + 2*b*c^2/(b - c)
> >
> > Are those equivalent? Am I doing something wrong?
>
> do the following:
>
> sage: g.simplify_rational()
> -2*a^2 + 4*a*b - 3*b^2 + 2*b*c - c^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/5d5f136d-637b-4dd9-9c9b-eb00b7609401n%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/c1edfa06-311f-458f-818b-e0e3fd3eed76n%40googlegroups.com.


[sage-support] Re: why does this not work? i am trying to create a pattern 1 2 3 4 5 6 which will repeat 6 times. i got this method from my lecturer but it is not working

2021-11-25 Thread Emmanuel Charpentier


Sage (i. e. Python) solution : list(range(1,9))*6

HTH,
​
Le samedi 13 novembre 2021 à 17:09:54 UTC+1, abdulra...@gmail.com a écrit :

>

-- 
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/6a088d8e-756e-414e-a3d4-7d8f1768549dn%40googlegroups.com.


[sage-support] Re: subs

2021-11-24 Thread Emmanuel Charpentier


Also :

sage: import sympy
sage: ex._sympy_().subs({(5^x)._sympy_():t._sympy_()})._sage_()
t^2 - 7*t + 4

HTH,
​
Le mercredi 24 novembre 2021 à 17:20:10 UTC+1, Emmanuel Charpentier a 
écrit :

> FWIW :
>
> sage: var("x, t")
> (x, t)
> sage: maxima_calculus.ratsubst(t,5^x, ex).sage()
> t^2 - 7*t + 4
> sage: maxima_calculus.lratsubst([5^x==t], ex).sage()
> t^2 - 7*t + 4
>
> See also this ask.sagemath.org question 
> <https://ask.sagemath.org/question/59881/substitute-multiplication-of-sine-and-cosine-for-a-symbolic-function/>
> .
>
> I think that wrapping Maximas [l]ratsubst might be interesting…
> ​
> Le mardi 23 novembre 2021 à 20:42:12 UTC+1, juanlui...@gmail.com a écrit :
>
>> In the expression (5^x)^2-7*5^x+4, I want to substitute x^5 by t.
>>
>> With sagemath 7.2 (or another old versions), I can do
>> ((5^x)^2-7*5^x+4).subs(5^x==t)
>> and I get t^2 - 5*t + 4
>>
>> But sagemath 9.4 does not change the first 5^x and he gives
>> 5^(2*x) - 7*t + 4
>>
>> Why?
>>
>> (In both cases, var("t") has been previously used)
>>
>> Yours,
>>
>> Juan Luis Varona
>>
>>

-- 
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/8f1ee0c8-ecbe-4def-8980-b6cf112de8aan%40googlegroups.com.


[sage-support] Re: subs

2021-11-24 Thread Emmanuel Charpentier


FWIW :

sage: var("x, t")
(x, t)
sage: maxima_calculus.ratsubst(t,5^x, ex).sage()
t^2 - 7*t + 4
sage: maxima_calculus.lratsubst([5^x==t], ex).sage()
t^2 - 7*t + 4

See also this ask.sagemath.org question 

.

I think that wrapping Maximas [l]ratsubst might be interesting…
​
Le mardi 23 novembre 2021 à 20:42:12 UTC+1, juanlui...@gmail.com a écrit :

> In the expression (5^x)^2-7*5^x+4, I want to substitute x^5 by t.
>
> With sagemath 7.2 (or another old versions), I can do
> ((5^x)^2-7*5^x+4).subs(5^x==t)
> and I get t^2 - 5*t + 4
>
> But sagemath 9.4 does not change the first 5^x and he gives
> 5^(2*x) - 7*t + 4
>
> Why?
>
> (In both cases, var("t") has been previously used)
>
> Yours,
>
> Juan Luis Varona
>
>

-- 
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/fd360243-56e1-4586-bd50-1e912019f3a8n%40googlegroups.com.


  1   2   3   4   5   >