On Wed, 9 Aug 2017 10:30:09 +0200, "Richard B. Kreckel" <kreckel@in.terlu.de> said: RK> sqrt(-1) straightly evaluates to I, which works. But sqrt(-3) RK> isn't a numeric object. Rather, it is a power(-3,1/2).
On my computer I have: sqrt(numeric(-3)).dbgprinttree(); pow(numeric(-3),numeric(1,2)).dbgprinttree(); both returning 1.7320508075688772936L0i (numeric) @0xbfcc45f0, hash=0x800d7056, flags=0x6 and power(numeric(-3),numeric(1,2)).dbgprinttree(); returning power @0xbfc551dc, hash=0x800cf188, flags=0x0, nops=2 -3 (numeric) @0x81748b38, hash=0x1, flags=0x7 1/2 (numeric) @0x81748bb8, hash=0x1, flags=0x7 RK> Seems to me like the logic in power::real_part() and RK> power::imag_part() can be improved: You are right, the power did it wrongly cout << power(numeric(-3),numeric(1,2)).real_part() << endl; // -> sqrt(-3) cout << power(numeric(-3),numeric(1,2)).imag_part() << endl; // -> 0 I will look into it. -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/