Ask Your Question
0

how to plot Riemann surface

asked 2021-11-03 17:02:13 +0100

ortollj gravatar image

Hi

I would like to plot this Riemann surface with SageMath:

Riemann surface

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-11-12 10:56:50 +0100

ortollj gravatar image

I tinkered with this code below (far from being optimized!) Does it looks ok ? on SageCell

from sage.plot.plot3d.parametric_surface import ParametricSurface

var('x,y',domain='real')
var('k',domain='integer')

N=10 # approximation precision
xyBound=1.1

def condition(x,y,z):
    return (x*x + y*y <=1)

cm = colormaps.jet
#cm = colormaps.autumn
def c(x,y):
    if abs(x) >0 or abs(y)>0 :
        argf=acos(x/sqrt((x**2 + y**2)))/3.15      
    else :
        argf=0.5
    return argf
def fr0(x,y):
    z = CDF(x, y)
    #return x, y, real_part((sum((factorial(2*k) *  z^(2*k))/(4^k *(2*k - 1) *factorial(k)^2) ,k,0,N))^(1/2))
    return x, y, real_part(sqrt(1-z^2))

def fr1(x,y):
    z = CDF(x, y)
    return x, y, -real_part(sqrt(1-z^2))

def fi0(x,y):
    z = CDF(x, y)
    return x, y, imag_part(sqrt(1-z^2))       
def fi1(x,y):
    z = CDF(x, y)
    return x, y, -imag_part(sqrt(1-z^2)) 

pltr0=ParametricSurface(fr0, (srange(-1,1,0.1), srange(-1,1,0.1)), color=(c,cm), mesh=True)
pltr0.add_condition(condition)
pltr1=ParametricSurface(fr1, (srange(-1,1,0.1), srange(-1,1,0.1)), color=(c,cm), mesh=True)
pltr1.add_condition(condition)
pltr=pltr0+pltr1


pltr += arrow3d((0, 0, 0), (xyBound, 0, 0), color='green')
pltr += text3d("X", (xyBound, 0, 0), color='green')
pltr += arrow3d((0, 0, 0), (0, xyBound, 0), color='blue')
pltr += text3d("Y", (0, xyBound, 0), color='blue')
pltr += arrow3d((0, 0, 0), (0, 0, xyBound), color='red')
pltr += text3d("Z", (0,0, xyBound), color='red')

pltr.show(viewer='threejs')

plti0=ParametricSurface(fi0, (srange(-xyBound,xyBound,0.1), srange(-xyBound,xyBound,0.1)), color=(c,cm), mesh=True)
plti0.add_condition(condition)
plti1=ParametricSurface(fi1, (srange(-xyBound,xyBound,0.1), srange(-xyBound,xyBound,0.1)), color=(c,cm), mesh=True)
plti1.add_condition(condition)
plti=plti0+plti1


plti += arrow3d((0, 0, 0), (xyBound, 0, 0), color='green')
plti += text3d("X", (xyBound, 0, 0), color='green')
plti += arrow3d((0, 0, 0), (0, xyBound, 0), color='blue')
plti += text3d("Y", (0, xyBound, 0), color='blue')
plti += arrow3d((0, 0, 0), (0, 0, xyBound), color='red')
plti += text3d("Z", (0,0, xyBound), color='red')
plti.show(viewer='threejs')
edit flag offensive delete link more

Comments

I don't know why condition does not work

ortollj gravatar imageortollj ( 2021-11-12 12:27:13 +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

1 follower

Stats

Asked: 2021-11-03 17:02:13 +0100

Seen: 66 times

Last updated: Nov 12 '21