# Revision history [back]

### ATAN2 AssertionError while plotting complex squareroot function

I want to plot the real part of a a squareroot function with complex argument by using the SAGE plot method.
This plot method combines function evaluation and plotting within one single python statement.
It fails with the error message :ATAN2 Assertion error.
However, doing the job in two separate consecutive steps , i.e., evaluating the needed function values first and plotting them afterwards with SAGE's line method is successful without error.
The following example code demonstrates this behaviour.
Meaning of variables:
f_exampl: test function calling the real part of a square-root function;
exx=1 uses the method "plot" ;
exx=2 uses the method "line" to plot a pre-calculated list of values.
delta =0: the argument of the square-root is real
delta /= 0 : I*delta is the imaginary part of the squareroot argument.

The result:
testcase exx=2 is successful for delta=0 and delta != 0.
testcase exx=1 is successful for delta=0.
testcase exx=1 aborts with ATAN2 Assertion error if the squareroot must evaluate complex numbers.

Apparently there is a conflict between the evaluation of complex sqareroots during SAGE's plot method.
Evaluating the complex sqareroots without plotting them can be done without problems.
However, In my case it is more convenient to use SAGE's plot instead of SAGE's line method.
Is it possible to avoid the assertion error in the preferred plot method?

I used SAGE Version 7.1 within a Linux opensuse 42.1 OS.

x,delta,exx=var('x', 'delta', 'exx')
delta=0.0
exx=1
def f_exampl(xx):
return sqrt(xx-I*delta)
xmin=1.0
plotpts=2
plotpts_1=plotpts+1
xmax=3.0
ym=2.0
if exx==2:
# exampl_2: no assertion error, if delta != 0:
list_exampl=[[xmin+(xmax-xmin)*i/plotpts,real_part(f_exampl(xmin+(xmax-xmin)*i/plotpts))]for i in range(plotpts_1)]
exampl_2=line(list_exampl,thickness= 2,color='red',marker='+')
show(exampl_2)
else:
# exampl_1: assertion error, if delta != 0:
exampl_1=plot (real_part(f_exampl(x)),(x,xmin,xmax),ymin=1.0,ymax=+ym,plot_points=plotpts,color='blue',marker='+')
show(exampl_1)