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

Mathematica Bessel function derivative in sum

  1. Jul 27, 2017 #1

    joshmccraney

    User Avatar
    Gold Member

    Hi PF!

    I'm trying to put the first derivative of the modified Bessel function of the first kind evaluated at some point say ##\alpha## in a sum where the ##ith## function is part of the index. What I have so far is
    Code (Text):

    n=3;
    alpha = 2;
    DBesselI[L_, x_] := D[BesselI[L, x], {x, 1}]
    Sum[BesselI[L, alpha], {L, 1, n}]
     
    But I don't think this is working. Any help would be awesome!
     
  2. jcsd
  3. Jul 27, 2017 #2

    Orodruin

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Gold Member

    You are using the modified Bessel function, not its derivative that you defined in the previous line, in the sum ...
     
  4. Jul 27, 2017 #3

    joshmccraney

    User Avatar
    Gold Member

    Ahh shoot,
    Shoot, this is a typo on my part copying into PF. Instead if I use
    Code (Text):

    n=3;
    alpha = 2;
    DBesselI[L_, x_] := D[BesselI[L, x], {x, 1}]
    Sum[DBesselI[L, alpha], {L, 1, n}]
     
    I still get an error. In fact, even if I simply try evaluating
    Code (Text):
    DBesselI[1, alpha]
    I receive an error. Any ideas?
     
  5. Jul 27, 2017 #4

    Orodruin

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Gold Member

    It might help if you quote the error message.
     
  6. Jul 27, 2017 #5

    joshmccraney

    User Avatar
    Gold Member

    It reads "2 is not a valid variable." and then iterates "##\partial_{\{2,1\}}BesselI[1,3]##". Any ideas?
     
  7. Jul 28, 2017 #6

    Orodruin

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Gold Member

    Try
    Code (Text):

    DBesselI[L_, x_] = D[BesselI[L, x], {x, 1}]
     
    instead. When you use := it is a delayed definition. The RHS will be evaluated only once the function is called. Since you were calling it with x = 2, it thinks you want to differentiate with respect to 2, i.e., it executes
    Code (Text):

    D[BesselI[L,2],{2,1}]
     
    Edit: See also http://reference.wolfram.com/language/tutorial/ImmediateAndDelayedDefinitions.html.en
     
    Last edited: Jul 28, 2017
  8. Jul 30, 2017 #7

    joshmccraney

    User Avatar
    Gold Member

    Thanks so much! This actually makes a lot of sense!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Bessel function derivative in sum
  1. Sum function (MATLAB) (Replies: 1)

Loading...