[Scilab-users] Bessel functions
Claus Futtrup
cfuttrup at gmail.com
Sat Jan 24 18:21:12 CET 2015
Hi Nikolay, et al.
You're right, I should have checked Scilab help for Bessel functions
before trying to do my own.
I executed besselj(0,x_array) as well as besselj(1,x_array) ... it seems
that this function works exactly like what I made myself. And the output
is indistinguishable (for the range I'm interested in).
Trying to find the Scilab code for besselj, I see that it's an
uneditable and hard coded. Is there anywhere I can study in detail how
besselj was coded?
Best regards,
Claus
On 24-01-2015 18:01, Nikolay Strelkov wrote:
> Dear Claus!
>
> For me it seems that using standard functions is always better, than
> writing them from scratch.
>
> So I recommend to use built-in Scilab functions besseli, besselj,
> besselk, bessely, besselh
> <http://help.scilab.org/docs/5.5.1/en_US/bessel.html>.
>
> With best regards,
> maintainer ofMathieu functions toolbox for Scilab
> <http://atoms.scilab.org/toolboxes/Mathieu>,
> IEEE member, Ph.D.,
> Nikolay Strelkov.
>
>
> 2015-01-24 19:53 GMT+03:00 Claus Futtrup <cfuttrup at gmail.com
> <mailto:cfuttrup at gmail.com>>:
>
> Hi
>
> I've made a small script to play around with Bessel functions of
> the first kind... but this is very basic and I'm wondering if
> there's a smarter way.
>
> Below is the script I made (the function + a small test which
> plots the result).
>
> Best regards,
> Claus
>
> // bessel_test.sce
>
> function z=Jn(n,x)
> // The following power series approximates the nth Bessel
> // function of the first kind for each input x
> // In acoustics x = 2ka, defines the iput frequency k = omega / c and size
> // of the piston radiator
> powerseries = 0;
> for m=0:19 // actually it should be infinity, but 10 approximates OK ...
> powerseries_m = ((-1)^m / (factorial(m) * factorial(m + n))) * (x/2)^(2*m);
> powerseries = powerseries + powerseries_m; // sum the powerseries
> end
> z = ((x/2)^n) .* powerseries;
> endfunction
>
> x_array = 0:0.1:9.9; // define 100 points on the x-axis
> // with 2ka (x) from 0 to 10, and with m = 0-19,
> // this approximation is reasonably good for 2ka< 10
>
> z_0_array = Jn(0,x_array); // Calculate J0
>
> z_1_array = Jn(1,x_array); // Calculate J1
>
> scf();
> a = gca();
> plot(x_array,z_0_array,'-b');
> plot(x_array,z_1_array,'-r');
> xtitle("Bessel functions","x (2ka)","output (z)");
> legend("J0","J1");
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org <mailto:users at lists.scilab.org>
> http://lists.scilab.org/mailman/listinfo/users
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20150124/ec7bb762/attachment.htm>
More information about the users
mailing list