On 08/09/2017 09:12 AM, Vladimir V. Kisil wrote:
On Tue, 8 Aug 2017 20:15:07 +0200, Jan Rheinländer <jrheinlaender@gmx.de> said:
JR> Hi, what is the logic here (example from ginsh)?
>> real_part(sqrt(-3)); JR> sqrt(-3) >> imag_part(sqrt(-3)); JR> 0
>> real_part(sqrt(-1)); JR> 0 >> imag_part(sqrt(-1)); JR> 1
The problems seems to be in CLN library, since for the GiNaC::numeric object sqrt(-3), real_part() and imag_part() are simply calling cln::realpart() and cln::imagpart().
sqrt(-1) straightly evaluates to I, which works. But sqrt(-3) isn't a numeric object. Rather, it is a power(-3,1/2). Seems to me like the logic in power::real_part() and power::imag_part() can be improved: https://www.ginac.de/ginac.git/?p=ginac.git;a=blob;f=ginac/power.cpp;h=26194... -richy. -- Richard B. Kreckel <https://in.terlu.de/~kreckel/>