Bessel Function Evaluation Problem in Mathematica

In summary, the conversation is about how to evaluate a function numerically in Mathematica, specifically the function BesselK[1,2]. The suggested methods are using the N function or giving the arguments as floating numbers. The conversation ends with the confirmation from Hepth that the N method works.
  • #1
EngWiPy
1,368
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
  • #2
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.]
 
  • #3
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
 
  • #4
try again, the N method is correct.

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

Out[30]= 0.139866

make sure its not misspelled.
 
  • #5
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
 

1. What is a Bessel function?

A Bessel function is a special type of mathematical function that is used to solve certain types of differential equations. It is named after the mathematician Friedrich Bessel and is commonly denoted by the symbol Jn, where n is a positive integer.

2. What is the Bessel function evaluation problem in Mathematica?

The Bessel function evaluation problem in Mathematica refers to the challenge of accurately computing the values of Bessel functions at different points. Since Bessel functions involve complex numbers and infinite series, it can be difficult to calculate their values without encountering issues such as numerical instability or round-off errors.

3. How does Mathematica handle Bessel function evaluation?

Mathematica uses a combination of algorithms and special functions to handle Bessel function evaluation. These include the built-in functions BesselJ, BesselY, BesselI, and BesselK, as well as various numerical methods such as series expansions, asymptotic approximations, and continued fractions.

4. Can the Bessel function evaluation problem be solved analytically?

Yes, the Bessel function evaluation problem can be solved analytically for some specific values of n and for certain types of Bessel functions. However, for most cases, an analytical solution is not possible and numerical methods must be used.

5. Are there any special considerations when using Mathematica for Bessel function evaluation?

Yes, there are a few things to keep in mind when using Mathematica for Bessel function evaluation. One is that the precision of the results can vary depending on the input values and the chosen algorithm. It is also important to check for convergence and accuracy, especially when dealing with large or complex numbers. Additionally, if using symbolic inputs, Mathematica may return exact values instead of numerical approximations, which may not be desirable in some cases.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
394
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
238
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
Back
Top