[sage-support] Re: Unexpected behaviour of derivatives on power series

2017-01-15 Thread Ralf Stephan
I would have expected that with Laurent series but
they don't do the expected, either:
sage: R.=LaurentSeriesRing(SR)
sage: f = 1 + O(x^2)
sage: f.derivative(1)
O(x^1)
sage: f.derivative(2)
0
sage: f.derivative(3)
0


-- 
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 post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: simplifying radicals of trigonometric expressions

2017-01-15 Thread Ralf Stephan
We need documentation on symbolic simplification...

sage: sin(x/(x^2 + x)).normalize()
sin(1/(x + 1))

sage: factor(cos(x)^3 - 3*cos(x)^2 - cos(x) + 6)
(cos(x)^2 - cos(x) - 3)*(cos(x) - 2)
sage: factor(sqrt(cos(x)^3 - 3*cos(x)^2 - cos(x) + 6))
sqrt(cos(x)^3 - 3*cos(x)^2 - cos(x) + 6)

sage: from sympy import factor as sfactor
sage: sfactor(sqrt(cos(x)^3 - 3*cos(x)^2 - cos(x) + 6))
sqrt((cos(x) - 2)*(cos(x)**2 - cos(x) - 3))


On Friday, January 13, 2017 at 11:12:26 AM UTC+1, Enrique Artal wrote:
>
> I would like to know how to handle with this issue. Consider a function 
> f=sqrt(cos(x)^3 - 3*cos(x)^2 - cos(x) + 6). It is possible to deal with 
> this function for standard procedures like numerical_integral in (-1,1). If 
> one considers f.canonicalize_radical() it is presented as sqrt(cos(x)^2 - 
> cos(x) - 3)*sqrt(cos(x) - 2), which avoids numerical integration in 
> particular since each factor is complex in (-1,1). It is not solved if x is 
> declared as a real variable (with domain='real'). For this particular 
> function, it is not hard to avoid the issue, but if it appears in more 
> complex expressions, it is less obvious.
>

-- 
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 post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] simplifying radicals of trigonometric expressions

2017-01-15 Thread Enrique Artal
Thanks! I did not expect a particular simplification of the function; the 
problem is that the given simplification caused problems. This function 
appeared as a factor in the computation of the curvature of some spatial 
curve.

El domingo, 15 de enero de 2017, 15:50:06 (UTC+1), Michael Orlitzky 
escribió:
>
> On 01/14/2017 03:42 AM, Enrique Artal wrote: 
> > This is true. The problem is that if not used, simple expressions keep 
> to 
> > be too much complicated. Is there any compromise? 
> > 
>
> There is simplify_full() which should be safe for all expressions, and 
> simplify_real() that assumes everything is real. Those two methods use 
> our Maxima backend. 
>
> The sympy backend has improved a lot, too. There's no easy way to get 
> access to it, but something like this should work: 
>
>   sage: import sympy 
>   sage: f = sin(x/(x^2 + x)) 
>   sage: sympy.simplify(sympy.sympify(f)) 
>   sin(1/(x + 1)) 
>
> In the case of f = sqrt(cos(x)^3 - 3*cos(x)^2 - cos(x) + 6), did you 
> have any particular simplification in mind? I don't see anything obvious 
> that can be done. 
>
>

-- 
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 post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Unexpected behaviour of derivatives on power series

2017-01-15 Thread Alex Thorne
When differentiating elements of power series rings, I do not get the 
expected result. Below is a minimal example:

R. = PowerSeriesRing(SR)
f = 1 + O(x^2)
f.derivative(1)
f.derivative(2)
f.derivative(3)

The first derivative gives `O(x^1)` as expected and similarly the second 
gives `O(x^0)`. However, the third derivative, rather than giving `O(x^0)` 
again as expected, gives `O(x^{-1})`. Is this a bug or is this the desired 
behaviour for some reason?

Note: as well as my local installation, I was able to reproduce this bug on 
SageMath Cloud.

(I apologise if I'm doing something stupid as I'm only newly trying to 
switch to Sage from Mathematica.)

-- 
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 post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] simplifying radicals of trigonometric expressions

2017-01-15 Thread Michael Orlitzky
On 01/14/2017 03:42 AM, Enrique Artal wrote:
> This is true. The problem is that if not used, simple expressions keep to 
> be too much complicated. Is there any compromise?
> 

There is simplify_full() which should be safe for all expressions, and
simplify_real() that assumes everything is real. Those two methods use
our Maxima backend.

The sympy backend has improved a lot, too. There's no easy way to get
access to it, but something like this should work:

  sage: import sympy
  sage: f = sin(x/(x^2 + x))
  sage: sympy.simplify(sympy.sympify(f))
  sin(1/(x + 1))

In the case of f = sqrt(cos(x)^3 - 3*cos(x)^2 - cos(x) + 6), did you
have any particular simplification in mind? I don't see anything obvious
that can be done.

-- 
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 post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.