Roots of unity

Bob McElrath mcelrath at
Fri Jan 18 21:04:03 CET 2002

Hans Peter Würmli [wurmli at] wrote:
> Why don't you define a simple function like:
>  numeric qrt(numeric n){
>     if (n>=0) return pow(n,numeric(1)/numeric(3)); 
>     else return -pow(-n,numeric(1)/numeric(3)); 
>  }
> and use that in your particular problem.

Because it's the symbolic expression I'm interested in, and I can't test if
n >= 0.

I suppose I could make a:
    class nthroot : public function  {
            nthroot(numeric n, ex arg);
    // ...
and override the evalf function for it (I'm not sure how to do this).  But I
was hoping this could be incorporated into pow() since the problem crops up for
any pow() with a fractional exponent.

-- Bob

Bob McElrath (rsmcelrath at 
Univ. of Wisconsin at Madison, Department of Physics
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
Url :

More information about the GiNaC-list mailing list