Mathematica Bessel Function Evaluation Problem in Mathematica

Click For Summary
To evaluate Bessel functions numerically in Mathematica, the N function is essential. Users can apply N[BesselK[1, 2]] or use floating-point arguments like BesselK[1., 2] to achieve a numerical output. Mathematica typically only evaluates functions for specific arguments with known exact values, leaving others in symbolic form. If issues persist, checking for typos is recommended, as correct syntax is crucial for proper evaluation. The discussion confirms that using the N function is the correct approach for obtaining numerical results.
EngWiPy
Messages
1,361
Reaction score
61
Hello,

When I write:
Code:
BesselK[1,2]

in the Mathematica editor, the output is the same as the input. But I want to evaluate it numerically. In other words, I want the output be a number. How can I do that?

Regards
 
Physics news on Phys.org
Did you try the N function?

Code:
N[BesselK[1,2]]
BesselK[1,2] // N

In general, Mathematica only "evaluates" such functions for special arguments for which it knows exact values. In all other cases, it leaves the answer exact. You can force it to give a decimal representation using
N[expr]
or
N[expr, # of decimals]Another way that often works is to give the arguments as floating numbers rather than exact values:
Code:
BesselK[1., 2]
BesselK[1, 2.]
BesselK[1., 2.]
 
CompuChip said:
Did you try the N function?

Code:
N[BesselK[1,2]]
BesselK[1,2] // N

In general, Mathematica only "evaluates" such functions for special arguments for which it knows exact values. In all other cases, it leaves the answer exact. You can force it to give a decimal representation using
N[expr]
or
N[expr, # of decimals]


Another way that often works is to give the arguments as floating numbers rather than exact values:
Code:
BesselK[1., 2]
BesselK[1, 2.]
BesselK[1., 2.]

Thank you CompuChip, but it didn't work, I still get the same expression. Why?

Regards
 
try again, the N method is correct.

In[30]:= N[BesselK[1, 2]]

Out[30]= 0.139866

make sure its not misspelled.
 
Hepth said:
try again, the N method is correct.

In[30]:= N[BesselK[1, 2]]

Out[30]= 0.139866

make sure its not misspelled.

Now it is working, but believe me, I wrote it correctly, and the result was not produced numerically, I don't know why. Anyway, thank you Hepth very much to confirm the N[] numerical evaluation method.

Regards
 

Similar threads

Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K