Bessel Function Evaluation Problem in Mathematica

Click For Summary

Discussion Overview

The discussion revolves around evaluating the Bessel function BesselK[1,2] numerically in Mathematica. Participants explore methods to obtain a numerical output rather than the symbolic expression.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant seeks to evaluate BesselK[1,2] numerically in Mathematica.
  • Another participant suggests using the N function to force numerical evaluation, providing examples of its usage.
  • Some participants mention that Mathematica typically evaluates functions for specific arguments but leaves others in symbolic form unless instructed otherwise.
  • There is a suggestion to input arguments as floating-point numbers to achieve numerical results.
  • Despite following the advice, one participant reports that the N function did not yield a numerical result, prompting further inquiry into potential issues.
  • Another participant confirms that the N method is correct and provides an example of the expected output.
  • There is acknowledgment of the confusion experienced by one participant regarding the numerical evaluation despite correct usage of the N function.

Areas of Agreement / Disagreement

Participants generally agree on the use of the N function for numerical evaluation, but there is disagreement regarding its effectiveness in this specific case, as one participant reports it did not work for them.

Contextual Notes

There are indications of potential issues such as misspellings or input formats that may affect the evaluation outcome, but these remain unresolved.

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 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K