Ask Your Question
1

Plotting Bessel function

asked 2012-09-30 04:07:31 -0500

R C gravatar image
plot(Bessel(0,'J'),0,10)

gives me a plot of the Bessel function. However:

plot(Bessel(0,'J'),0,10,color='red')

gives me an error:

TypeError: plot() got an unexpected keyword argument 'rgbcolor'

even though:

plot(sin,0,10,color='red')

works.

I am using the developmental version of sage. Any help to resolve this is appreciated.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2012-09-30 06:50:53 -0500

achrzesz gravatar image

updated 2012-09-30 08:09:40 -0500

plot(lambda x:bessel_J(0,x),(x,0,10),color='red')
#or 
plot(lambda x:Bessel(0,'J')(x),(x,0,10),color='red')
edit flag offensive delete link more

Comments

Thanks, this works well. By defining the lambda function outside the plot command, I can use it also in find_local_maximum and find_root. I will check the documentation to better understand why a lambda function is needed for the Bessel functions.

R C gravatar imageR C ( 2012-09-30 09:51:32 -0500 )edit
1

I think this is because the in the current implementation the Bessel functions define their own `plot` method and the options supported aren't the same as the top-level plot function. hopefully this can be improved sometime soon. It looks like it would be very easy to pass along a dictionary of options through the Bessel class's plot method: http://hg.sagemath.org/sage-main/file/d06cf4b2215d/sage/functions/special.py#l1176

benjaminfjones gravatar imagebenjaminfjones ( 2012-09-30 11:22:40 -0500 )edit

Thanks for clarifying this. So using a lambda function in the plot call allows for the standard options to be passed to the plot method.

R C gravatar imageR C ( 2012-09-30 23:18:49 -0500 )edit

@benjaminfjones - as you are certainly aware, making Bessel functions symbolic would also fix this - e.g. http://trac.sagemath.org/sage_trac/ticket/4102 for Bessel J.

kcrisman gravatar imagekcrisman ( 2012-10-01 02:18:52 -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

Stats

Asked: 2012-09-30 04:07:31 -0500

Seen: 387 times

Last updated: Sep 30 '12