Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Bessel Function Evaluation Problem in Mathematica

  1. Jul 17, 2009 #1

    When I write:
    Code (Text):
    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?

  2. jcsd
  3. Jul 17, 2009 #2


    User Avatar
    Science Advisor
    Homework Helper

    Did you try the N function?

    Code (Text):

    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, # of decimals]

    Another way that often works is to give the arguments as floating numbers rather than exact values:
    Code (Text):

    BesselK[1., 2]
    BesselK[1, 2.]
    BesselK[1., 2.]
  4. Jul 17, 2009 #3
    Thank you CompuChip, but it didn't work, I still get the same expression. Why?

  5. Jul 17, 2009 #4


    User Avatar
    Gold Member

    try again, the N method is correct.

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

    Out[30]= 0.139866

    make sure its not misspelled.
  6. Jul 18, 2009 #5
    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.

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook