Hello. 
I need a root finder of a real function which work with a initial guess. 
That can be done by scipy fsolve, but if I try to aply it on a gamma (or 
Bessel) function in Sage, I recieve following error message:

NotImplementedError: The Function gamma does not support numpy arrays as 
arguments
>
>
I have encoutered this before - then the solution was replacing  x[i]  by  
x.item(i). I am however not skilled enough to do this chenge inside scipy 
library. Any sugestions?

Here is my code:

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)
> dx=1e-10
> def dP(l,m,x):
>     return (P(l,m,x+dx) - P(l,m,x-dx))/(2*dx)
> def K(nu,x):
>     return bessel_K(nu,x)
> def dK(nu,x):
>     return (K(nu,x+dx)-K(nu,x-dx))/(2*dx)

 

import matplotlib.pyplot as plt
> import numpy as np
> import sympy
> from scipy import optimize as opt
>
> def Rce(KR):
>     a=3
>     m=0
>     nu=sqrt(abs((1+a^2)*m^2-(a^2/4)))*I
>     xD=a*KR
>     ccD=1/sqrt(1+a^2)
>     l=-0.5+sqrt(abs((1/4)-KR^2))
>     return sqrt(1+a^2)*KR*P(l,m,ccD)*dK(nu,xD)+a*K(nu,xD)*dP(l,m,ccD)
>     
>     
>
> ktip=0.2
> k0=opt.fsolve(Rce,ktip)



Thanks for any advice.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/2d0dbdc4-7a7e-4e71-aac1-a59e46bc6637%40googlegroups.com.

Reply via email to