[sage-support] Re: Adding new attribute to Poset
Thanks Eric. It works! I figured out the FinitePoset part after reading the manual. But I know test that it works for X = FinitePoset(...) I didn't think of trying it with X = Poset(...). On Monday, September 28, 2020 at 11:38:15 AM UTC-7 egourg...@gmail.com wrote: > Poset is a function, which constructs a finite poset, not the poset class, > as you can check: > sage: type(Poset) > > You can also check it by having a look at the source code: > sage: Poset?? > > So when you write > Poset.upper_bounds = upper_bounds > you are attaching upper_bounds to the function, not to the class of > posets. The latter is FinitePoset (actually a subclass of it, name > FinitePoset_with_category, which is constructed dynamically via Sage > category mechanism). So you should do > > sage: from sage.combinat.posets.posets import FinitePoset > sage: FinitePoset.upper_bounds = upper_bounds > > Then > sage: X = Poset(...) > sage: X.upper_bounds(...) > shoud work. > > > Le lundi 28 septembre 2020 à 18:29:43 UTC+2, pong a écrit : > >> For convenient, I would like to add an attribute, upper_bounds, to Poset >> objects >> >> However, after writing the method and issue >> Poset.upper_bounds = upper_bounds >> >> X.upper_bounds(S) complains >> >> 'FinitePoset_with_category' object has no attribute 'upper_bounds' >> >> When I try >> FinitePoset_with_category.upper_bounds = upper_bounds >> >> I got >> name 'FinitePoset_with_category' is not defined >> >> So how can one add an attribute to FinitePoset_with_category? >> > -- You received this message because you are subscribed to the Google Groups "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/3b134e30-a1a5-4e63-afd3-3a14380df654n%40googlegroups.com.
Re: [sage-support] integrating sin(t)/t
On Mon, Sep 28, 2020 at 04:03:48PM -0400, Fernando Q. Gouvea wrote: > I am trying to see how to do a standard calculus exercise in Sage. I want a > power series for the integral of sin(x)/x. I tried: > > sage: var('t') > t > sage: assume(x>0) > sage: f(x)=integrate(sin(t)/t,t,0,x) > sage: f > x |--> sin_integral(x) > sage: taylor(f(x),x,0,10) > 73/466560*x^9 - 127/35280*x^7 + 31/600*x^5 - 7/18*x^3 + x That's odd. I get the same behavior in sage8.9 and my current develop branch of sage. Annoyingly, I notice that if you get the Taylor series as you might in a calculus class, by first getting the Taylor series and then integrating it term by term, it comes out differently (and correctly). var('t') littlef(t) = taylor(sin(t)/t, t, 0, 10) bigf(x) = integrate(littlef(t), t, 0, x) x |--> -1/439084800*x^11 + 1/3265920*x^9 - 1/35280*x^7 + 1/600*x^5 - 1/18*x^3 + x I don't know why what you tried fails. This seems to be a bug. On the trac, this seems closely related to 1. https://trac.sagemath.org/ticket/11164 2. https://trac.sagemath.org/ticket/30389 - DLD -- David Lowry-Duda -- You received this message because you are subscribed to the Google Groups "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/20200928204921.GA13285%40icerm-dld.
[sage-support] integrating sin(t)/t
I am trying to see how to do a standard calculus exercise in Sage. I want a power series for the integral of sin(x)/x. I tried: sage: var('t') t sage: assume(x>0) sage: f(x)=integrate(sin(t)/t,t,0,x) sage: f x |--> sin_integral(x) sage: taylor(f(x),x,0,10) 73/466560*x^9 - 127/35280*x^7 + 31/600*x^5 - 7/18*x^3 + x The first weirdness is that Sage can't compute the integral unless I add the "assume(x>0)"; I'm not sure why. The second weirdness is that the Taylor series is wrong! Taylor(Si(x),x,0,10) gives the same answer. Fernando -- == Fernando Q. Gouvea Carter Professor of Mathematics Colby College Mayflower Hill 5836 Waterville, ME 04901 fqgou...@colby.edu http://www.colby.edu/~fqgouvea The object of opening the mind, as of opening the mouth, is to shut it again on something solid. -- G. K. Chesterton, Autobiography. -- You received this message because you are subscribed to the Google Groups "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/5624ba1e-9194-6d00-864a-8fa2a83d1698%40colby.edu.
[sage-support] Re: Adding new attribute to Poset
Poset is a function, which constructs a finite poset, not the poset class, as you can check: sage: type(Poset) You can also check it by having a look at the source code: sage: Poset?? So when you write Poset.upper_bounds = upper_bounds you are attaching upper_bounds to the function, not to the class of posets. The latter is FinitePoset (actually a subclass of it, name FinitePoset_with_category, which is constructed dynamically via Sage category mechanism). So you should do sage: from sage.combinat.posets.posets import FinitePoset sage: FinitePoset.upper_bounds = upper_bounds Then sage: X = Poset(...) sage: X.upper_bounds(...) shoud work. Le lundi 28 septembre 2020 à 18:29:43 UTC+2, pong a écrit : > For convenient, I would like to add an attribute, upper_bounds, to Poset > objects > > However, after writing the method and issue > Poset.upper_bounds = upper_bounds > > X.upper_bounds(S) complains > > 'FinitePoset_with_category' object has no attribute 'upper_bounds' > > When I try > FinitePoset_with_category.upper_bounds = upper_bounds > > I got > name 'FinitePoset_with_category' is not defined > > So how can one add an attribute to FinitePoset_with_category? > -- You received this message because you are subscribed to the Google Groups "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/7b4691ad-9bab-4f71-818d-371b8011a42dn%40googlegroups.com.
[sage-support] Adding new attribute to Poset
For convenient, I would like to add an attribute, upper_bounds, to Poset objects However, after writing the method and issue Poset.upper_bounds = upper_bounds X.upper_bounds(S) complains 'FinitePoset_with_category' object has no attribute 'upper_bounds' When I try FinitePoset_with_category.upper_bounds = upper_bounds I got name 'FinitePoset_with_category' is not defined So how can one add an attribute to FinitePoset_with_category? -- You received this message because you are subscribed to the Google Groups "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/d4c4a7b3-4f77-4cce-9174-accec70011a5n%40googlegroups.com.