Re: [sage-devel] Re: (abs(sin(x))^2).simplify_full()
> But the example in my original message works -- this really confuses me. > Clearly, simplify_trig invokes maxima to do the simplification, so why does > setting this flag in pynac make it work? Are functions of real variables > treated differently from functions taking a complex argument? > > OK, I understand this now -- when defining a function of a real argument the abs is simply not taken into account because of the square following it, so that the trig simplification can take its course as before. I still think it would be a good idea to have the simplify_* methods take into account the domain of definition to avoid problems like this. Presumably I'm missing a whole lot of context here, feel free to point me to tickets where the opposite point has been made. J. -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-devel] Re: (abs(sin(x))^2).simplify_full()
Hi Michael, Thanks for your message. I'm still a little confused about the way Sage handles assumptions, can you maybe shine your light on this? On Monday, July 1, 2013 8:55:43 PM UTC+1, Michael Orlitzky wrote: > > > > sage: u = var('u') > > sage: assume(u, 'real') > > This makes an assumption in Maxima, where most of the symbolic algebra > takes place. > As far as I can tell, setting domain to complex in maxima has the effect that sin, cos, etc are now seen as de facto complex-valued functions, even when the input x is assumed to be real. This is probably why maxima refuses to simplify abs(cos(x))^2 + abs(sin(x))^2 to 1. > sage: u = var('u', domain='real') > > This sets a flag in pynac, which does nothing as far as I can tell. > But the example in my original message works -- this really confuses me. Clearly, simplify_trig invokes maxima to do the simplification, so why does setting this flag in pynac make it work? Are functions of real variables treated differently from functions taking a complex argument? Thanks! Joris -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/groups/opt_out.
[sage-devel] Re: (abs(sin(x))^2).simplify_full()
There is certainly an opportunity to write a program that works like this: to simplify abs(f(x)) test to see if f(x) is real for all possible values of x. then find some g(x) such that g(x)^2=f(x). That is, f(x) is a perfect square. In such a case abs(f(x)) is equal to f(x). It has rather little to do with sin(x) --- just that sin(x) is real for real x. and hence sin(x)^2 is real. So it is an issue with abs, hardly much to do with trig simplification in particular. In many cases the appearance of abs() is bogus in the first place, being inserted in places such assqrt(x^2)) --> abs(x), which replaces an algebraic function with a non-algebraic one with a discontinuous derivative. RJF On Monday, July 1, 2013 12:37:00 PM UTC-7, Joris Vankerschaver wrote: > > > > On Friday, February 15, 2013 11:31:41 AM UTC, Julius wrote: >> >> >> With sage 5.6 >> sage: assume(x, 'real') >> sage: (abs(sin(x))^2).simplify_full() >> abs(sin(x))^2 >> >> For trigonometric simplifications, this is very inconvenient. For example >> sage: (abs(sin(x))^2 + abs(cos(x))^2).simplify_full().simplify_trig() >> abs(sin(x))^2 + abs(cos(x))^2 >> >> > I totally agree that this is very inconvenient. When faced with a trig > problem it doesn't take a lot of symbolic manipulations to arrive at > something which is full of these expressions, and if we have no way of > doing these obvious simplifications then that limits the usefulness of > doing symbolic manipulations. For instance, the majority of the docstrings > in trac #10132 now fail, for no good mathematical reason. > > The behavior is also inconsistent, for reasons that I don't fully get. For > instance, this will fail: > > sage: u = var('u') > sage: assume(u, 'real') > sage: (abs(cos(u))^2 + abs(sin(u))^2).simplify_trig() > abs(sin(u))^2 + abs(cos(u))^2 > > but this will work: > > sage: u = var('u', domain='real') > sage: (abs(cos(u))^2 + abs(sin(u))^2).simplify_trig() > 1 > > I don't know enough about the Maxima interface and the assumptions that > went into changing this behavior from sage 5.5 to 5.6, but is there maybe a > way we can set domain to real for symbolic functions over the reals before > passing the whole thing to maxima for the simplification? > > J. > -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-devel] Re: (abs(sin(x))^2).simplify_full()
On 07/01/2013 03:55 PM, Michael Orlitzky wrote: > On 07/01/2013 03:37 PM, Joris Vankerschaver wrote: >> >> sage: u = var('u') >> sage: assume(u, 'real') > > This makes an assumption in Maxima, where most of the symbolic algebra > takes place. > > >> sage: u = var('u', domain='real') > > This sets a flag in pynac, which does nothing as far as I can tell. > The flag, not pynac =) -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sage-devel] Re: (abs(sin(x))^2).simplify_full()
On 07/01/2013 03:37 PM, Joris Vankerschaver wrote: > > sage: u = var('u') > sage: assume(u, 'real') This makes an assumption in Maxima, where most of the symbolic algebra takes place. > sage: u = var('u', domain='real') This sets a flag in pynac, which does nothing as far as I can tell. -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/groups/opt_out.
[sage-devel] Re: (abs(sin(x))^2).simplify_full()
On Friday, February 15, 2013 11:31:41 AM UTC, Julius wrote: > > > With sage 5.6 > sage: assume(x, 'real') > sage: (abs(sin(x))^2).simplify_full() > abs(sin(x))^2 > > For trigonometric simplifications, this is very inconvenient. For example > sage: (abs(sin(x))^2 + abs(cos(x))^2).simplify_full().simplify_trig() > abs(sin(x))^2 + abs(cos(x))^2 > > I totally agree that this is very inconvenient. When faced with a trig problem it doesn't take a lot of symbolic manipulations to arrive at something which is full of these expressions, and if we have no way of doing these obvious simplifications then that limits the usefulness of doing symbolic manipulations. For instance, the majority of the docstrings in trac #10132 now fail, for no good mathematical reason. The behavior is also inconsistent, for reasons that I don't fully get. For instance, this will fail: sage: u = var('u') sage: assume(u, 'real') sage: (abs(cos(u))^2 + abs(sin(u))^2).simplify_trig() abs(sin(u))^2 + abs(cos(u))^2 but this will work: sage: u = var('u', domain='real') sage: (abs(cos(u))^2 + abs(sin(u))^2).simplify_trig() 1 I don't know enough about the Maxima interface and the assumptions that went into changing this behavior from sage 5.5 to 5.6, but is there maybe a way we can set domain to real for symbolic functions over the reals before passing the whole thing to maxima for the simplification? J. -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/groups/opt_out.
[sage-devel] Re: (abs(sin(x))^2).simplify_full()
With sage 5.5: sage: (abs(sin(x))^2).simplify_full() sin(x)^2 Maybe not completely correct because, as you said, x could be a complex number. However, I found it convenient. With sage 5.6 sage: assume(x, 'real') sage: (abs(sin(x))^2).simplify_full() abs(sin(x))^2 For trigonometric simplifications, this is very inconvenient. For example sage: (abs(sin(x))^2 + abs(cos(x))^2).simplify_full().simplify_trig() abs(sin(x))^2 + abs(cos(x))^2 On Thursday, February 14, 2013 10:10:04 PM UTC+1, Frédéric Chapoton wrote: > > This is not a bug, because x can be any complex number : > > sage: x=CDF(4+2*I) > sage: abs(sin(x))**2 > 13.7268664349 > sage: sin(x)**2 > 2.48667440045 + 13.4997523143*I > > > Le jeudi 14 février 2013 16:21:29 UTC+1, Julius a écrit : >> >> I think (abs(sin(x))^2).simplify_full() should render sin(x)^2. This is >> not the case in sage 5.6 even with the assumption assume(x, 'real'). Is >> this a [known] bug? > > -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sage-devel] Re: (abs(sin(x))^2).simplify_full()
This is not a bug, because x can be any complex number : sage: x=CDF(4+2*I) sage: abs(sin(x))**2 13.7268664349 sage: sin(x)**2 2.48667440045 + 13.4997523143*I Le jeudi 14 février 2013 16:21:29 UTC+1, Julius a écrit : > > I think (abs(sin(x))^2).simplify_full() should render sin(x)^2. This is > not the case in sage 5.6 even with the assumption assume(x, 'real'). Is > this a [known] bug? -- 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 post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.