# Getting incorrect results for non integer Bessel Functions

1. ## Getting incorrect results for non integer Bessel Functions

I found that when I tried putting non integer Bessel Functions into excel I got the same answer as the Bessel function of the largest integer smaller than that number. I have attached a file to demonstrate what I mean

Non integer bessel functions in general don't have the same values as integer Bessel functions. Is there a way to calculate the correct value for a non integer Bessel function in Excel?

2. ## Re: Getting incorrect results for non integer Bessel Functions

You seem to be referring to the second parameter ("n").

What's the mystery? From any of the BESSEL function help pages: ``If n is not an integer, it is truncated``.

3. ## Re: Getting incorrect results for non integer Bessel Functions

Well is there a way to get it to not truncate n besides putting in the taylor series for the function?

4. ## Re: Getting incorrect results for non integer Bessel Functions

As near as I can tell, Excel does not have a built in bessel type function that allows non-integer "n". Excel is not open source and MSFT keeps its source code pretty tightly wrapped up, so I don't see an easy way to implement this in using native Excel functions (except, as you note, developing the formula from the GAM() and other functions).

What are your restrictions and limitations? Excel only? Any spreadsheet? Any programming language?

If you are not limited to Excel only, I quickly browsed help files for other spreadsheets and noticed that Gnumeric's documentation for its bessel functions specifically mentions Excel's limitation to integer alpha in a way that implies that their implementation is not so restricted: https://help.gnome.org/users/gnumeri...nction-BESSELI I cannot test this now, but will be able to test later. However, I mention it now because you might be able to test before I can. Using a spreadsheet other than Excel that is not limited to integer alpha is probably the easiest solution that I see.

If you are not limited to spreadsheets, you can obviously look to other programming languages. I obviously did not do an exhaustive search, but I see that Python has built in bessel functions (in the scipy library) that are not limited to integer arguments. If you still want the Excel experience, there are ways to write user-defined functions in other programming languages and then link them to Excel (through dlls or add-ins like xlwings). You could write a simple function in another programming language that utilizes a more robust bessel algorithm. Then figure out how to link those functions to Excel (I haven't had to do this myself, so I'm not sure all that is involved. I know of xlwings for python, and I have an add-in where the dll was written in either Fortran or C that has a bunch of VBA "wrapper" functions that call the dll and return results to the spreadsheet rather seemlessly, so I know it can work well).

A couple of thoughts. A lot depends on whether or not you require a spreadsheet (and/or Excel specifically) for this task or not.

5. ## Re: Getting incorrect results for non integer Bessel Functions

I cannot verify the absolute accuracy, but I can verify that Gnumeric's bessel functions return different values for real n.
X -- n -- bessely(x,n)
0.5 -- 0 -- -0.4445
0.5 -- 0.5 -- -0.9902
0.5 -- 1 -- -1.4715

Not sure if that helps at all.

There are currently 1 users browsing this thread. (0 members and 1 guests)