display all results of sqrt()



I'm afraid this approach works only in the simplest of cases, where
there is just one square root in the formula.  If there are two
independent square roots, it won't work.  For example, the four roots
of x^4-10*x^2+1 are (+/-) sqrt(2) + (+/-) sqrt(3), but sqt(2)+sqt(3)
gives only the two results [sqrt(2)+sqrt(3), -sqrt(2)-sqrt(3)].

               -s

On Wed, Aug 19, 2009 at 9:50 AM, Leo Butler<l.butler at ed.ac.uk> wrote:
>
>
> On Wed, 19 Aug 2009, Grasemann, Karsten wrote:
>
> < Hello to all maximaniacs,
> <
> < I am using wxMaxima 0.8.2 and I am a newbie to maxima. Here's my prob:
> <
> < I want to display all results of the function sqrt():
> <
> < %i1 2+sqrt(4);
> < %o1 4
> <
> < I want to display also the result 0, because sqrt(4) can be 2 or -2. I
> < have searched the help and the web but I found nothing about it.
> < Probably you have the answer.
>
> I think you want something like the following:
>
> (%i2) sqt(x) := block([], if listp(x) then map(sqt,x) else
> [-sqrt(x),sqrt(x)]);
>
> (%o2) sqt(x):=block([],if listp(x) then map(sqt,x) else
> [-sqrt(x),sqrt(x)])
> (%i3) 2+sqt(4);
>
> (%o3) [0,4]
>
> Leo
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>