Re: [sage-devel] How to make call to latex() not evaluate its content again?
" I think it would be reasonable for Sage to do what the original poster suggested, and turn integrals into \int in latex rather than trying to evaluate them." Yes, this is what I am asking. If there is a way to prevent evaluation of an expression being passed to latex() command. In Mathematica for example, this is done by wrapping the expression in HoldForm, like this TeXForm[Integrate[Sin[x], x]] -\cos (x) TeXForm[HoldForm[Integrate[Sin[x], x]]] \int \sin (x) \, dx In Maple this is done by wrapping the expression by ' ' like this latex(int(sin(x),x)) -\cos \! \left(x \right) latex('int(sin(x),x)') \int \sin \! \left(x \right)d x I just wanted to know how to do the same in sagemath. Many times there is a need to obtain the latex of an expression without it being evaluated, --Nasser On Wednesday, July 26, 2023 at 9:34:34 AM UTC-5 David Roe wrote: > Even if adding some assumptions makes this particular integral evaluate > fully, the underlying problem may still show up in other cases. I haven't > tracked it down fully (and probably won't spend more time on this), but the > error messages are coming from Sage's interface to Giac, via this function > in expression.pyx: > > cpdef _latex_Expression(x): > return char_to_str(GEx_to_str_latex(&(x)._gobj)) > > I think it would be reasonable for Sage to do what the original poster > suggested, and turn integrals into \int in latex rather than trying to > evaluate them. > David > > On Wed, Jul 26, 2023 at 7:14 AM Dima Pasechnik wrote: > >> On Wed, Jul 26, 2023 at 6:17 AM 'Nasser M. Abbasi' via sage-devel >> wrote: >> > >> > Sometimes when calling integrate using algorithm such as maxima, it >> returns result which is not fully resolved but still have an integrate >> inside it. >> > >> > Next, when calling latex() on the anti-derivative this cause problems, >> because sage tried to calls maxima again on the integrate command inside >> the result. >> > >> > Is there a way to make latex() just convert the result without calling >> integrate again? >> > This results in problems like the following >> > >> > sage: latex(anti) >> > Not invertible Error: Bad Argument Value >> > Undef/Unsigned Inf encountered in limit >> > Undef/Unsigned Inf encountered in limit >> > >> > Here is an example >> >> for this integral, I think you'd like to add >> >> assume(n,"integer") >> assume(n>0) >> >> Do you really want to work in the complex domain, not also >> >> assume(x>0) >> assume(c>0) >> >> ? >> >> Anyhow, this looks like a Maxima bug to me. >> >> Dima >> >> >> > >> > >sage >> > │ SageMath version 10.0, Release Date: 2023-05-20│ >> > │ Using Python 3.11.3. Type "help()" for help. │ >> > sage: var('f x e n a p h g b c d q') >> > sage: anti=integrate(x*sec(a+b*log(c*x^n))^2,x, algorithm="maxima"); >> > sage: latex(anti) >> > >> > Not invertible Error: Bad Argument Value >> > Undef/Unsigned Inf encountered in limit >> > Undef/Unsigned Inf encountered in limit >> > Undef/Unsigned Inf encountered in limit >> > Undef/Unsigned Inf encountered in limit >> > Undef/Unsigned Inf encountered in limit >> > Undef/Unsigned Inf encountered in limit >> > Undef/Unsigned Inf encountered in limit >> > Undef/Unsigned Inf encountered in limit >> > >> > The result of maxima in this case has unresolved integrate inside it. >> This is the actual antiderivative >> > >> > sage: integrate(x*sec(a+b*log(c*x^n))^2,x, algorithm="maxima") >> > 2*(x^2*cos(2*b*log(x^n) + 2*a)*sin(2*b*log(c)) + >> x^2*cos(2*b*log(c))*sin(2*b*log(x^n) + 2*a) - >> 2*(2*b^2*n^2*cos(2*b*log(c))*cos(2*b*log(x^n) + 2*a) - >> 2*b^2*n^2*sin(2*b*log(c))*sin(2*b*log(x^n) + 2*a) + (b^2*cos(2*b*log(c))^2 >> + b^2*sin(2*b*log(c))^2)*n^2*cos(2*b*log(x^n) + 2*a)^2 + >> (b^2*cos(2*b*log(c))^2 + b^2*sin(2*b*log(c))^2)*n^2*sin(2*b*log(x^n) + >> 2*a)^2 + b^2*n^2)*integrate((x*cos(2*b*log(x^n) + 2*a)*sin(2*b*log(c)) + >> x*cos(2*b*log(c))*sin(2*b*log(x^n) + >> 2*a))/(2*b^2*n^2*cos(2*b*log(c))*cos(2*b*log(x^n) + 2*a) - >> 2*b^2*n^2*sin(2*b*log(c))*sin(2*b*log(x^n) + 2*a) + (b^2*cos(2*b*log(c))^2 >> + b^2*sin(2*b*log(c))^2)*n^2*cos(2*b*log(x^n) + 2*a)^2 + >> (b^2*cos(2*b*log(c))^2 + b^2*sin(2*b*log(c))^2)*n^2*sin(2*b*log(x^n) + >> 2*a)^2 + b^2*n^2), x))/(2*b*n*cos(2*b*log(c))*cos(2*b*log(x^n) + 2*a) + >> (b*cos(2*b*log(c))^2 + b*sin(2*b*log(c))^2)*n*cos(2*b*log(x^n) + 2*a)^2 - >> 2*b*n*sin(2*b*log(c))*sin(2*b*log(x^n) + 2*a) + (b*cos(2*b*log(c))^2 + >> b*sin(2*b*log(c))^2)*n*sin(2*b*log(x^n) + 2*a)^2 + b*n) >> > >> > Notice there is an integrate(...) command inside the above output. So >> maxima found it can't integrate that part and left the integrate command >> there. So I do not want this to be evaluated. I just need the latex >> conversion done keeping integrate as "\int{.}" without evaluating. >> > >> > This happens because sage was calling >> > >> > integrate((x*cos(2*b*log(x^n) + 2*a)*sin(2*b*log(c)) + >> x*cos(
Re: [sage-devel] How to make call to latex() not evaluate its content again?
Even if adding some assumptions makes this particular integral evaluate fully, the underlying problem may still show up in other cases. I haven't tracked it down fully (and probably won't spend more time on this), but the error messages are coming from Sage's interface to Giac, via this function in expression.pyx: cpdef _latex_Expression(x): return char_to_str(GEx_to_str_latex(&(x)._gobj)) I think it would be reasonable for Sage to do what the original poster suggested, and turn integrals into \int in latex rather than trying to evaluate them. David On Wed, Jul 26, 2023 at 7:14 AM Dima Pasechnik wrote: > On Wed, Jul 26, 2023 at 6:17 AM 'Nasser M. Abbasi' via sage-devel > wrote: > > > > Sometimes when calling integrate using algorithm such as maxima, it > returns result which is not fully resolved but still have an integrate > inside it. > > > > Next, when calling latex() on the anti-derivative this cause problems, > because sage tried to calls maxima again on the integrate command inside > the result. > > > > Is there a way to make latex() just convert the result without calling > integrate again? > > This results in problems like the following > > > > sage: latex(anti) > > Not invertible Error: Bad Argument Value > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > > > Here is an example > > for this integral, I think you'd like to add > > assume(n,"integer") > assume(n>0) > > Do you really want to work in the complex domain, not also > > assume(x>0) > assume(c>0) > > ? > > Anyhow, this looks like a Maxima bug to me. > > Dima > > > > > > >sage > > │ SageMath version 10.0, Release Date: 2023-05-20│ > > │ Using Python 3.11.3. Type "help()" for help. │ > > sage: var('f x e n a p h g b c d q') > > sage: anti=integrate(x*sec(a+b*log(c*x^n))^2,x, algorithm="maxima"); > > sage: latex(anti) > > > > Not invertible Error: Bad Argument Value > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > > > The result of maxima in this case has unresolved integrate inside it. > This is the actual antiderivative > > > > sage: integrate(x*sec(a+b*log(c*x^n))^2,x, algorithm="maxima") > > 2*(x^2*cos(2*b*log(x^n) + 2*a)*sin(2*b*log(c)) + > x^2*cos(2*b*log(c))*sin(2*b*log(x^n) + 2*a) - > 2*(2*b^2*n^2*cos(2*b*log(c))*cos(2*b*log(x^n) + 2*a) - > 2*b^2*n^2*sin(2*b*log(c))*sin(2*b*log(x^n) + 2*a) + (b^2*cos(2*b*log(c))^2 > + b^2*sin(2*b*log(c))^2)*n^2*cos(2*b*log(x^n) + 2*a)^2 + > (b^2*cos(2*b*log(c))^2 + b^2*sin(2*b*log(c))^2)*n^2*sin(2*b*log(x^n) + > 2*a)^2 + b^2*n^2)*integrate((x*cos(2*b*log(x^n) + 2*a)*sin(2*b*log(c)) + > x*cos(2*b*log(c))*sin(2*b*log(x^n) + > 2*a))/(2*b^2*n^2*cos(2*b*log(c))*cos(2*b*log(x^n) + 2*a) - > 2*b^2*n^2*sin(2*b*log(c))*sin(2*b*log(x^n) + 2*a) + (b^2*cos(2*b*log(c))^2 > + b^2*sin(2*b*log(c))^2)*n^2*cos(2*b*log(x^n) + 2*a)^2 + > (b^2*cos(2*b*log(c))^2 + b^2*sin(2*b*log(c))^2)*n^2*sin(2*b*log(x^n) + > 2*a)^2 + b^2*n^2), x))/(2*b*n*cos(2*b*log(c))*cos(2*b*log(x^n) + 2*a) + > (b*cos(2*b*log(c))^2 + b*sin(2*b*log(c))^2)*n*cos(2*b*log(x^n) + 2*a)^2 - > 2*b*n*sin(2*b*log(c))*sin(2*b*log(x^n) + 2*a) + (b*cos(2*b*log(c))^2 + > b*sin(2*b*log(c))^2)*n*sin(2*b*log(x^n) + 2*a)^2 + b*n) > > > > Notice there is an integrate(...) command inside the above output. So > maxima found it can't integrate that part and left the integrate command > there. So I do not want this to be evaluated. I just need the latex > conversion done keeping integrate as "\int{.}" without evaluating. > > > > This happens because sage was calling > > > > integrate((x*cos(2*b*log(x^n) + 2*a)*sin(2*b*log(c)) + > x*cos(2*b*log(c))*sin(2*b*log(x^n) + > 2*a))/(2*b^2*n^2*cos(2*b*log(c))*cos(2*b*log(x^n) + 2*a) - > 2*b^2*n^2*sin(2*b*log(c))*sin(2*b*log(x^n) + 2*a) + (b^2*cos(2*b*log(c))^2 > + b^2*sin(2*b*log(c))^2)*n^2*cos(2*b*log(x^n) + 2*a)^2 + > (b^2*cos(2*b*log(c))^2 + b^2*sin(2*b*log(c))^2)*n^2*sin(2*b*log(x^n) + > 2*a)^2 + b^2*n^2), x) > > Not invertible Error: Bad Argument Value > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Not invertible Error: Bad Argument Value > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > Undef/Unsigned Inf encountered in limit > > and these go on forever it seems > > > > And getting these error. The
Re: [sage-devel] How to make call to latex() not evaluate its content again?
On Wed, Jul 26, 2023 at 6:17 AM 'Nasser M. Abbasi' via sage-devel wrote: > > Sometimes when calling integrate using algorithm such as maxima, it returns > result which is not fully resolved but still have an integrate inside it. > > Next, when calling latex() on the anti-derivative this cause problems, > because sage tried to calls maxima again on the integrate command inside the > result. > > Is there a way to make latex() just convert the result without calling > integrate again? > This results in problems like the following > > sage: latex(anti) > Not invertible Error: Bad Argument Value > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > > Here is an example for this integral, I think you'd like to add assume(n,"integer") assume(n>0) Do you really want to work in the complex domain, not also assume(x>0) assume(c>0) ? Anyhow, this looks like a Maxima bug to me. Dima > > >sage > │ SageMath version 10.0, Release Date: 2023-05-20│ > │ Using Python 3.11.3. Type "help()" for help. │ > sage: var('f x e n a p h g b c d q') > sage: anti=integrate(x*sec(a+b*log(c*x^n))^2,x, algorithm="maxima"); > sage: latex(anti) > > Not invertible Error: Bad Argument Value > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > > The result of maxima in this case has unresolved integrate inside it. This is > the actual antiderivative > > sage: integrate(x*sec(a+b*log(c*x^n))^2,x, algorithm="maxima") > 2*(x^2*cos(2*b*log(x^n) + 2*a)*sin(2*b*log(c)) + > x^2*cos(2*b*log(c))*sin(2*b*log(x^n) + 2*a) - > 2*(2*b^2*n^2*cos(2*b*log(c))*cos(2*b*log(x^n) + 2*a) - > 2*b^2*n^2*sin(2*b*log(c))*sin(2*b*log(x^n) + 2*a) + (b^2*cos(2*b*log(c))^2 + > b^2*sin(2*b*log(c))^2)*n^2*cos(2*b*log(x^n) + 2*a)^2 + (b^2*cos(2*b*log(c))^2 > + b^2*sin(2*b*log(c))^2)*n^2*sin(2*b*log(x^n) + 2*a)^2 + > b^2*n^2)*integrate((x*cos(2*b*log(x^n) + 2*a)*sin(2*b*log(c)) + > x*cos(2*b*log(c))*sin(2*b*log(x^n) + > 2*a))/(2*b^2*n^2*cos(2*b*log(c))*cos(2*b*log(x^n) + 2*a) - > 2*b^2*n^2*sin(2*b*log(c))*sin(2*b*log(x^n) + 2*a) + (b^2*cos(2*b*log(c))^2 + > b^2*sin(2*b*log(c))^2)*n^2*cos(2*b*log(x^n) + 2*a)^2 + (b^2*cos(2*b*log(c))^2 > + b^2*sin(2*b*log(c))^2)*n^2*sin(2*b*log(x^n) + 2*a)^2 + b^2*n^2), > x))/(2*b*n*cos(2*b*log(c))*cos(2*b*log(x^n) + 2*a) + (b*cos(2*b*log(c))^2 + > b*sin(2*b*log(c))^2)*n*cos(2*b*log(x^n) + 2*a)^2 - > 2*b*n*sin(2*b*log(c))*sin(2*b*log(x^n) + 2*a) + (b*cos(2*b*log(c))^2 + > b*sin(2*b*log(c))^2)*n*sin(2*b*log(x^n) + 2*a)^2 + b*n) > > Notice there is an integrate(...) command inside the above output. So maxima > found it can't integrate that part and left the integrate command there. So I > do not want this to be evaluated. I just need the latex conversion done > keeping integrate as "\int{.}" without evaluating. > > This happens because sage was calling > > integrate((x*cos(2*b*log(x^n) + 2*a)*sin(2*b*log(c)) + > x*cos(2*b*log(c))*sin(2*b*log(x^n) + > 2*a))/(2*b^2*n^2*cos(2*b*log(c))*cos(2*b*log(x^n) + 2*a) - > 2*b^2*n^2*sin(2*b*log(c))*sin(2*b*log(x^n) + 2*a) + (b^2*cos(2*b*log(c))^2 + > b^2*sin(2*b*log(c))^2)*n^2*cos(2*b*log(x^n) + 2*a)^2 + (b^2*cos(2*b*log(c))^2 > + b^2*sin(2*b*log(c))^2)*n^2*sin(2*b*log(x^n) + 2*a)^2 + b^2*n^2), x) > Not invertible Error: Bad Argument Value > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Not invertible Error: Bad Argument Value > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > Undef/Unsigned Inf encountered in limit > and these go on forever it seems > > And getting these error. The strange thing, is calling the above exact > command inside Maxima just returns the input back, without these errors! > > So these errors are generated by sagemath and not by maxima from the latex() > command. > > I am using Maxima 5.47 with sagemath 10.0 > > >which maxima > /usr/bin/maxima > >maxima --version > ;;; Loading #P"/usr/lib/ecl-21.2.1/sb-bsd-sockets.fas" > ;;; Loading #P"/usr/lib/ecl-21.2.1/sockets.fas" > Maxima 5.47.0 > > > And > > >which sage > /home/me/TMP/sage-10.0/sage > >sage --version > SageMath version 10.0, Release Date: 2023-05-20 > > > > Thanks > --Nasser > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving ema
[sage-devel] ANN: FLINT workshop October 9-13 in Kaiserslautern
Hi all, There will be a FLINT development meeting in Kaiserslautern, Germany, the week October 9-13, 2023. More details will be available on the following website: https://flintlib.github.io/workshop2023.html The workshop will focus on coding sprints to improve FLINT and its integration in other software. If you want to participate, please send me an email as soon as possible. Fredrik -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAJdUXTL%3DRg9evLmM3-zzCX00rMTgg9eONQ1Ct3bUUB8nDKHCqQ%40mail.gmail.com.