I am using the inbuilt function of matlab to calculate the bessel function of second order, following is the code
format long
z = (-5:1:5)';
y = bessely(1,z)
plot (y)
The output is as follows
y =
-0.147863143391227 + 0.655158275182930i
-0.397925710557100 + 0.132086656047098i
-0.324674424791800 - 0.678117917051873i
0.107032431540937 - 1.153449615513747i
0.781212821300289 - 0.880101171489867i
-Inf
-0.781212821300289
-0.107032431540937
0.324674424791800
0.397925710557100
0.147863143391227
What i don't understand is why am i getting two values when the value of z is negative ?
This
-0.147863143391227 + 0.655158275182930i
is not two values, it's a single complex number. See the i
at the right of the second part ? That's Matlab's way of telling you that that second number is the imaginary part of the number, the one which is multiplied by i
, the square root of -1.
Matlab is telling you, and I concur with Matlab on this, that that function returns complex values for negative inputs.