On Thu, Dec 13, 2012 at 5:50 PM, Raymond Toy <toy.raymond at gmail.com> wrote:
> >>>>> "Stavros" == Stavros Macrakis <macrakis at alum.mit.edu> writes:
>
> Stavros> Currently,
>
> Stavros> realpart(sqrt(a)) =>
> Stavros> cos(atan2(0,a)/2)*sqrt(abs(a))
>
> Stavros> This is of course correct, but not very useful.
>
> Stavros> For one thing, it gives an error for a=0.
>
> But limit(cos(atan2(0,a)/2)*sqrt(abs(a)),a,0) -> 0.
>
Yes, of course.
>
> Stavros> For another, it doesn't simplify to sqrt(-a) with
> Stavros> assume(a<=0). (Though it does simplify to sqrt(a) for
>
> Why should it simplify to sqrt(-a)? Shouldn't the realpart simplify
> to 0 in that case?
>
You're right of course. I meant to say it should simplify to 0. But it
doesn't:
(%i1) qq: realpart(sqrt(a));
(%o1) cos(atan2(0,a)/2)*sqrt(abs(a))
(%i2) assume(a<=0);
(%o2) [a<=0]
(%i3) expand(qq); << resimplify with a<=0
(%o3) cos(atan2(0,a)/2)*sqrt(-a) << yuck
(%i4) assume(a<0);
(%o4) [a<0] << resimplify with a<0
(%i5) expand(qq);
(%o5) 0