Re: [sage-support] Matrix logarithm
On Mon, 18 Apr 2022 at 14:30, GUSTAVO TERRA BASTOS wrote: > > Hi guys. > > Given two n x n matrices M, N, we know it is a big problem to find the > positive integer "i" such that M^i = N (There are other hypothesis involved). > In my particular case, I would like to do the same for 3 x 3 matrices M , N > over F_{11^2} (finite field with 121 elements). Note that finding this integer i here is something different from what is usually referred to as the "matrix logarithm" (the inverse of the matrix exponential) which gives a matrix rather than an integer as the result. Is it prohibitive to just compute powers of M until you find that M^i = N? Any i would need to satisfy det(M)^i = det(N) which should be faster to solve for large i unless det(M) and det(N) are both zero or one. Otherwise I think you can generalise the approach to other coefficients in the characteristic polynomial. Oscar -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CAHVvXxSX2maPwn2Q9De-C7Jheb8NTqeAVAvenkmLxL5e%3DON2Fg%40mail.gmail.com.
Re: [sage-support] Plot doesn't respect numerical precision specification.
On Tue, 6 Dec 2022 at 12:53, Emmanuel Charpentier wrote: > > > And Sympy currently never returns. With current SymPy master it takes 6 seconds: In [1]: %time log(tan(pi/2*tanh(x))).diff(x).limit(x, oo) CPU times: user 5.73 s, sys: 24 ms, total: 5.75 s Wall time: 5.75 s Out[1]: 2 The fix was part of a GSOC project this summer and will be in SymPy 1.12: https://github.com/sympy/sympy/pull/23844 -- Oscar -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CAHVvXxSvaiH1mKt4kNgfs%2Bndhf22B2Hsvyav0tTHwpFC6Oq9Uw%40mail.gmail.com.
Re: [sage-support] Integral result differ from Wolfram|Alpha
On Mon, 13 Nov 2023 at 21:32, Bùi Gia Nghĩa wrote: > > Hi! > I have used Sage Cell Server to integrate the function (ln(x)^2 - 1) / (x * > ln(x)). It should resulted in (ln(x)^2) / 2 - |ln(ln(x))| + C, as noted by my > textbook and Wolfram|Alpha, but instead resulted in 1/2*log(x)^2 - > 1/2*log(log(x)^2). Your textbook assumes that you are only interested in real antiderivatives and so describes the antiderivative with abs that is not complex-differentiable (i.e. not valid for non-real values of x). The result from Sage is valid for e.g. x = 1+i whereas your textbook result would be incorrect in that case. -- Oscar -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CAHVvXxTrpcPGrhTnfVfNkKvyf-dJBr-BCzT_NEqVonKRDEt8bQ%40mail.gmail.com.
Re: [sage-support] Re: limitations of "solve"?
On Tue, 28 Nov 2023 at 17:25, kcrisman wrote: > > Answering part of my question: it seems that sympy and maxima have > different attitudes towards fractional powers of negative numbers, which > may be the source of the problem. > > Yes. Maxima's attitude is that the square root of negative one is an > expression which might have multiple values, rather than just picking one you > hope might be consistent over branch points. (There are very long > discussions on this list about this from years ago, which I will spare you by > not linking to any of them.) I would not be surprised if that came up here. I wouldn't mind seeing those discussions if you have a link to send (perhaps only to me). -- Oscar -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CAHVvXxQKe1HvcD%2BYL3CHTpyH7s2K_LeEEq6Z-wJKjAmYjw5jGQ%40mail.gmail.com.
Re: [sage-support] Re: limitations of "solve"?
On Wed, 29 Nov 2023 at 12:40, Eric Gourgoulhon wrote: > > Le mardi 28 novembre 2023 à 18:25:04 UTC+1, kcrisman a écrit : > > Yes. Maxima's attitude is that the square root of negative one is an > expression which might have multiple values, rather than just picking one you > hope might be consistent over branch points. > > To enforce Maxima to work in the real domain, avoiding to play too much with > complex square roots, one can add at the beginning of the Sage session: > > maxima_calculus.eval("domain: real;") > > Then the second example in the initial message of this thread yields > > [[x == 2/5*sqrt(6)*sqrt(5), y == 16, l == 1/9*18750^(1/6)], [x == > -2/5*sqrt(6)*sqrt(5), y == 16, l == -1/9*18750^(1/6)]] > > instead of an empty list. When using Maxima (5.45.1) directly I get this result with default settings: (%i1) f: 10*x^(1/3)*y^(2/3)$ (%i2) g: 5*x^2 + 6*y$ (%i3) solve([diff(f,x)=l*diff(g,x), diff(f,y)=l*diff(g,y), g=120], [x,y,l]); 1/6 2 sqrt(6) 18750 (%o3) [[x = -, y = 16, l = ], sqrt(5) 9 1/6 2 sqrt(6)18750 [x = - -, y = 16, l = - ]] sqrt(5)9 Does Sage modify some Maxima settings related to this or does it call something other than solve? -- Oscar -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CAHVvXxToSwyc4iY3tnrXaMd1T8mp%3D5%2BOFW95kyAe5YEkM-PGrA%40mail.gmail.com.
Re: [sage-support] Re: limitations of "solve"?
What does "set domain to complex" mean in terms of Maxima's settings? Maxima's solve seems to compute complex solutions by default: (%i21) solve(x^2 + 1); (%o21)[x = - %i, x = %i] On Sun, 3 Dec 2023 at 13:37, Dima Pasechnik wrote: > > Yes, Sage modifies the defaults of Maxima, in particular we set domain to > complex. > > On 3 December 2023 12:28:45 GMT, Oscar Benjamin > wrote: > >On Wed, 29 Nov 2023 at 12:40, Eric Gourgoulhon > >wrote: > >> > >> Le mardi 28 novembre 2023 à 18:25:04 UTC+1, kcrisman a écrit : > >> > >> Yes. Maxima's attitude is that the square root of negative one is an > >> expression which might have multiple values, rather than just picking one > >> you hope might be consistent over branch points. > >> > >> To enforce Maxima to work in the real domain, avoiding to play too much > >> with complex square roots, one can add at the beginning of the Sage > >> session: > >> > >> maxima_calculus.eval("domain: real;") > >> > >> Then the second example in the initial message of this thread yields > >> > >> [[x == 2/5*sqrt(6)*sqrt(5), y == 16, l == 1/9*18750^(1/6)], [x == > >> -2/5*sqrt(6)*sqrt(5), y == 16, l == -1/9*18750^(1/6)]] > >> > >> instead of an empty list. > > > >When using Maxima (5.45.1) directly I get this result with default settings: > > > >(%i1) f: 10*x^(1/3)*y^(2/3)$ > > > >(%i2) g: 5*x^2 + 6*y$ > > > >(%i3) solve([diff(f,x)=l*diff(g,x), diff(f,y)=l*diff(g,y), g=120], [x,y,l]); > >1/6 > >2 sqrt(6) 18750 > >(%o3) [[x = -, y = 16, l = ], > > sqrt(5) 9 > > 1/6 > >2 sqrt(6)18750 > > [x = - -, y = 16, l = - > > ]] > > sqrt(5)9 > > > >Does Sage modify some Maxima settings related to this or does it call > >something other than solve? > > > >-- > >Oscar > > > > -- > You received this message because you are subscribed to the Google Groups > "sage-support" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-support+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sage-support/6F4839F2-38B6-40F2-B080-EFCC1C0C3B65%40gmail.com. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CAHVvXxQpSk-UpbgHEZ0dVaPFRcZ79SV0_vgC1Y%3DdGM_32T2KgA%40mail.gmail.com.
Re: [sage-support] Re: limitations of "solve"?
Oh, I see: (%i23) domain: complex ; (%o23) complex (%i24) f: 10*x^(1/3)*y^(2/3)$ (%i25) g: 5*x^2 + 6*y$ (%i26) solve([diff(f,x)=l*diff(g,x), diff(f,y)=l*diff(g,y), g=120], [x,y,l]); (%o26)[] On Sun, 3 Dec 2023 at 14:20, Oscar Benjamin wrote: > > What does "set domain to complex" mean in terms of Maxima's settings? > > Maxima's solve seems to compute complex solutions by default: > > (%i21) solve(x^2 + 1); > (%o21)[x = - %i, x = %i] > > On Sun, 3 Dec 2023 at 13:37, Dima Pasechnik wrote: > > > > Yes, Sage modifies the defaults of Maxima, in particular we set domain to > > complex. > > > > On 3 December 2023 12:28:45 GMT, Oscar Benjamin > > wrote: > > >On Wed, 29 Nov 2023 at 12:40, Eric Gourgoulhon > > >wrote: > > >> > > >> Le mardi 28 novembre 2023 à 18:25:04 UTC+1, kcrisman a écrit : > > >> > > >> Yes. Maxima's attitude is that the square root of negative one is an > > >> expression which might have multiple values, rather than just picking > > >> one you hope might be consistent over branch points. > > >> > > >> To enforce Maxima to work in the real domain, avoiding to play too much > > >> with complex square roots, one can add at the beginning of the Sage > > >> session: > > >> > > >> maxima_calculus.eval("domain: real;") > > >> > > >> Then the second example in the initial message of this thread yields > > >> > > >> [[x == 2/5*sqrt(6)*sqrt(5), y == 16, l == 1/9*18750^(1/6)], [x == > > >> -2/5*sqrt(6)*sqrt(5), y == 16, l == -1/9*18750^(1/6)]] > > >> > > >> instead of an empty list. > > > > > >When using Maxima (5.45.1) directly I get this result with default > > >settings: > > > > > >(%i1) f: 10*x^(1/3)*y^(2/3)$ > > > > > >(%i2) g: 5*x^2 + 6*y$ > > > > > >(%i3) solve([diff(f,x)=l*diff(g,x), diff(f,y)=l*diff(g,y), g=120], > > >[x,y,l]); > > >1/6 > > >2 sqrt(6) 18750 > > >(%o3) [[x = -, y = 16, l = ], > > > sqrt(5) 9 > > > > > > 1/6 > > >2 sqrt(6)18750 > > > [x = - -, y = 16, l = - > > > ]] > > > sqrt(5)9 > > > > > >Does Sage modify some Maxima settings related to this or does it call > > >something other than solve? > > > > > >-- > > >Oscar > > > > > > > -- > > You received this message because you are subscribed to the Google Groups > > "sage-support" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to sage-support+unsubscr...@googlegroups.com. > > To view this discussion on the web visit > > https://groups.google.com/d/msgid/sage-support/6F4839F2-38B6-40F2-B080-EFCC1C0C3B65%40gmail.com. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CAHVvXxRL812Rsnw-OnOH8n%2B5tDJXy8%3DsuOepRar9tBUnEtm27A%40mail.gmail.com.
Re: [sage-support] Re: limitations of "solve"?
I did go on to discuss this on the Maxima mailing list: https://sourceforge.net/p/maxima/mailman/maxima-discuss/thread/CADB8Zm56axVDFXRLbJnxm7xnnbQiixBzg4VX1T91ucj%2B-tuGvA%40mail.gmail.com/#msg58347791 Apparently domain:complex as used by Sage is not a very well tested configuration of Maxima. There are most likely other effects besides the documented one about sqrt(x^2) not simplifying to abs(x): $ git grep domain src/simp.lisp src/simp.lisp:(defmvar $limitdomain '$complex) src/simp.lisp: (cond ((or (and $logexpand (eq $domain '$real)) src/simp.lisp:(cond ((or $numer_pbranch (eq $domain '$complex)) src/simp.lisp: (or (and (eq $domain '$real) (not (apparently-complex-to-judge-by-$csign-p (cadr gr src/simp.lisp: (and (eq $domain '$complex) (apparently-real-to-judge-by-$csign-p (cadr gr) src/simp.lisp: (or (and (eq $domain '$real) (not (apparently-complex-to-judge-by-$csign-p (cadr gr src/simp.lisp: (and (eq $domain '$complex) (apparently-real-to-judge-by-$csign-p (cadr gr) src/simp.lisp: (and (eq $domain '$real) $radexpand)) src/simp.lisp: ((or (eq $domain '$complex) (not $radexpand)) (go up))) src/simp.lisp:(and (eq $domain '$complex) src/simp.lisp:(and (eq $domain '$real) src/simp.lisp: (eq $domain '$real)) src/simp.lisp: (eq $domain '$real) src/simp.lisp: ((and (eq $domain '$real) src/simp.lisp: (eq $domain '$real) src/simp.lisp: (and (eq $domain '$real) (ratnump e) (oddp (caddr e) src/simp.lisp: ((eq $domain '$real) -- Oscar On Mon, 1 Jan 2024 at 21:55, Nils Bruin wrote: > > The documented effect is usually of most impact: > > https://maxima.sourceforge.io/docs/manual/maxima_46.html#index-domain > > there may be other undocumented effects, but the one above tends to explain a > lot already. > > On Sunday 3 December 2023 at 06:26:20 UTC-8 Oscar Benjamin wrote: >> >> What does "set domain to complex" mean in terms of Maxima's settings? >> >> Maxima's solve seems to compute complex solutions by default: >> >> (%i21) solve(x^2 + 1); >> (%o21) [x = - %i, x = %i] >> >> On Sun, 3 Dec 2023 at 13:37, Dima Pasechnik wrote: >> > >> > Yes, Sage modifies the defaults of Maxima, in particular we set domain to >> > complex. >> > >> > On 3 December 2023 12:28:45 GMT, Oscar Benjamin >> > wrote: >> > >On Wed, 29 Nov 2023 at 12:40, Eric Gourgoulhon >> > >wrote: >> > >> >> > >> Le mardi 28 novembre 2023 à 18:25:04 UTC+1, kcrisman a écrit : >> > >> >> > >> Yes. Maxima's attitude is that the square root of negative one is an >> > >> expression which might have multiple values, rather than just picking >> > >> one you hope might be consistent over branch points. >> > >> >> > >> To enforce Maxima to work in the real domain, avoiding to play too much >> > >> with complex square roots, one can add at the beginning of the Sage >> > >> session: >> > >> >> > >> maxima_calculus.eval("domain: real;") >> > >> >> > >> Then the second example in the initial message of this thread yields >> > >> >> > >> [[x == 2/5*sqrt(6)*sqrt(5), y == 16, l == 1/9*18750^(1/6)], [x == >> > >> -2/5*sqrt(6)*sqrt(5), y == 16, l == -1/9*18750^(1/6)]] >> > >> >> > >> instead of an empty list. >> > > >> > >When using Maxima (5.45.1) directly I get this result with default >> > >settings: >> > > >> > >(%i1) f: 10*x^(1/3)*y^(2/3)$ >> > > >> > >(%i2) g: 5*x^2 + 6*y$ >> > > >> > >(%i3) solve([diff(f,x)=l*diff(g,x), diff(f,y)=l*diff(g,y), g=120], >> > >[x,y,l]); >> > > 1/6 >> > > 2 sqrt(6) 18750 >> > >(%o3) [[x = -, y = 16, l = ], >> > > sqrt(5) 9 >> > > 1/6 >> > > 2 sqrt(6) 18750 >> > > [x = - -, y = 16, l = - ]] >> > > sqrt(5) 9 >> > > >> > >Does Sage modify some Maxima settings related to this or does it call >> > >something other than solve? >> > > >> > >-- >> > >Oscar >> > > >> > >> > -- >> > You received this message because you are subscribed to the Google Groups >> &
Re: [sage-support] Re: Sage seems to incorrectly evaluate fractional powers of complexes
On Thu, 4 Jan 2024 at 12:15, Emmanuel Charpentier wrote: > > 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…). The problem is with Sage's subs method: sage: e1 = (-40/3)**(2/3) sage: e2 = (y**(2/3)).subs({y:-40/3}) sage: e1 4*(-5/3)^(2/3) sage: e2 4*(5/3)^(2/3) sage: e1.n() -2.81144221767250 + 4.86956076355288*I sage: e2.n() 5.62288443534499 When the number to be substituted has an exact cube factor subs loses the sign under the radical: sage: (y^(2/3)).subs({y:-12}) (-12)^(2/3) sage: (y^(2/3)).subs({y:-24}) 4*3^(2/3) This is most likely due to confusing y^(n/m) as (y^n)^(1/m) when it should be (y^(1/m))^n. These are not equivalent if y^(1/m) means the principal mth root. -- Oscar -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CAHVvXxQg7XDM93_ZWf26kWfxWY3D1RorGewiG33T77TfGPS-Ng%40mail.gmail.com.
Re: [sage-support] Why cant this limit be evaluated?
On Mon, 19 Feb 2024 at 20:25, Mark “Essa King” Sukaiti < xzark.suk...@gmail.com> wrote: > 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 > > Sympy also fails giving -5/8. > To follow up on this the SymPy bug is now fixed in master: https://github.com/sympy/sympy/pull/26264 In [1]: e = ((1 - 3*x**2)*elliptic_e(4*x/(x**2 + 2*x + 1))**2/2 - (x**2 - 2*x + 1)*elliptic_e(4*x/(x* ...: *2 + 2*x + 1))*elliptic_k(4*x/(x**2 + 2*x + 1))/2)/(pi**2*x**8 - 2*pi**2*x**7 - pi**2*x**6 + ...: 4*pi**2*x**5 - pi**2*x**4 - 2*pi**2*x**3 + pi**2*x**2) In [2]: e.limit(x, 0) Out[2]: -1/8 Oscar -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CAHVvXxQst7%3DUUOYd%3DcRAGaMfahH_6LtvV73kwKPvzaC1Dy_Rtw%40mail.gmail.com.