Ask Your Question

Galedon's profile - activity

2020-04-03 21:12:51 +0200 received badge  Student (source)
2020-03-31 15:19:29 +0200 asked a question Hypergeometric function does not accept a numpy array element

Hello. I am dealing with a very elementary problem. I need to compute an array of complex legendre function value, using a definition by hypergeometric function. My code is following:

N=1000
xmin=-1
xmax=1

l=2
m=0

x=np.linspace(xmin,xmax,N)

f=np.zeros(N)

for i in range(N):
    f[i]=P(l,m,x[i])

But when I run it an error message appears reading:

NotImplementedError: The Function hypergeometric does not support numpy arrays as arguments

2020-03-31 15:19:29 +0200 asked a question The bessel_K function does not accept an element of a numpy array

I had a problem with classical sage ploting of Bessel K function in classical way, so I tried to manage through python matplotlib.pyplot and numpy library.

My code looks like this (for some reasons the formating put lines together, co I had to add a free line every time - just here, there are not present in original code):

import numpy as np 
import matplotlib.pyplot as plt

def P(l,m,x):
    return (-1)^m*gamma(l+m+1)*(1-x^2)^(m/2)/2^m/gamma(l-m+1)/gamma(m+1)*hypergeometric([m-l,m+l+1],[1+m],(1-x)/2)


N=1000
l1=-0.01996
romin=0
romax=1

a=sqrt(3).n()
R=1
m=0

roDD=R*a/sqrt(1+a^2).n()
nu=a*i/2
xDD=a*sqrt(abs(l1*(l1+1)))
ccD=1/sqrt(1+a^2)
A=P(l1,m,ccD)/bessel_K(nu,xDD)

f2=np.zeros(N)
ro2=np.linspace(roDD,romax,N)

for i in range(N):
     f2[i]=A*bessel_K(nu,(1/R)*sqrt(1+a^2)*sqrt(abs(l1*(l1+1)))*ro2[i])

But it gives me the following error message:

NotImplementedError: The Function bessel_K does not support numpy arrays as arguments

If I delete " *ro2[i] ", everything works just fine. If I print for example r2[100] I get a real number, not an array.

Any ideas what could it be?

2020-03-31 15:19:29 +0200 asked a question bessel_K does not accept an element of a numpy array

I had a problem with classical sage ploting of Bessel K function in classical way, so I tried to manage through python matplotlib.pyplot and numpy library.

My code looks like this (for some reasons the formating put lines together, co I had to add a free line every time - just here, there are not present in original code):

import numpy as np

import matplotlib.pyplot as plt

def P(l,m,x): return (-1)^mgamma(l+m+1)(1-x^2)^(m/2)/2^m/gamma(l-m+1)/gamma(m+1)*hypergeometric([m-l,m+l+1],[1+m],(1-x)/2)

N=1000

l1=-0.01996

romin=0

romax=1

a=sqrt(3).n()

R=1

m=0

roDD=R*a/sqrt(1+a^2).n()

nu=a*i/2

xDD=asqrt(abs(l1(l1+1)))

ccD=1/sqrt(1+a^2)

A=P(l1,m,ccD)/bessel_K(nu,xDD)

f2=np.zeros(N)

ro2=np.linspace(roDD,romax,N)

for i in range(N):

 f2[i]=A*bessel_K(nu,(1/R)*sqrt(1+a^2)*sqrt(abs(l1*(l1+1)))*ro2[i])

But it gives me the following error message:

NotImplementedError: The Function bessel_K does not support numpy arrays as arguments

If I delete " *ro2[i] ", everything works just fine. If I print for example r2[100] I get a real number, not an array.

Any ideas what could it be?