Ask Your Question

ATAN2 AssertionError while plotting complex squareroot function

asked 2016-09-05 14:59:22 -0500

bekalph gravatar image

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')
def f_exampl(xx):
    return sqrt(xx-I*delta)
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='+')
    # 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='+')
edit retag flag offensive close merge delete


@bekalph, please write Sage and not SAGE. Thank you!

slelievre gravatar imageslelievre ( 2016-09-06 15:22:39 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-09-05 15:38:17 -0500

updated 2017-01-22 17:58:26 -0500

Here's a live example on SageMathCell with delta=1. This sever is currently running version 7.3, and there doesn't appear to be a problem.

Looks like this got fixed in the current version. How about upgrading?

EDIT: Error reported as

EDIT: Fixed in Sage 7.5!

edit flag offensive delete link more


I have checked this in the cloud and also in my private 7.3 version. I made additional checks: An integer delta=1 is ok, but unfortunately a real delta=1.0 results in the same error. Also delta=real(1) is ok, but not delta=real(1.0). Thus, the problem persists, which obviously is caused by a wrong type conversation.

bekalph gravatar imagebekalph ( 2016-09-05 17:17:12 -0500 )edit

Right you are. This error is now

paulmasson gravatar imagepaulmasson ( 2016-09-05 21:14:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2016-09-05 14:59:22 -0500

Seen: 144 times

Last updated: Jan 22