Ask Your Question
1

ATAN2 AssertionError while plotting complex squareroot function

asked 2016-09-05 21:59:22 +0100

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')
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)
edit retag flag offensive close merge delete

Comments

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

slelievre gravatar imageslelievre ( 2016-09-06 22:22:39 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-09-05 22:38:17 +0100

updated 2017-01-23 00:58:26 +0100

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 https://trac.sagemath.org/ticket/21428

EDIT: Fixed in Sage 7.5!

edit flag offensive delete link more

Comments

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-06 00:17:12 +0100 )edit

Right you are. This error is now https://trac.sagemath.org/ticket/21428

paulmasson gravatar imagepaulmasson ( 2016-09-06 04:14:23 +0100 )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

Stats

Asked: 2016-09-05 21:59:22 +0100

Seen: 778 times

Last updated: Jan 23 '17