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

Clearing variables and functions in Mathematica

  1. Apr 2, 2012 #1
    Can anyone help on this?

    I am calculating the magnetic susceptibility, essentially a second derivative evaluated at zero magnetic field. The problem is that sometimes Mathematica works perfectly, and sometimes it gives me a "1/0 complexinfinity" error message, with no obvious reason. The problem can arise simply by changing the value of a parameter, but once I return to the parameter values for which it worked fine, Mathematica no longer gives me back the results (it still gives me the same error message). I suspect that it might be an internal problem, i.e. perhaps I need to clear my (user-defined) functions some way.

    Chi[Δ_, λ_, θ_, β_] = -D[F, {h, 2}] /. {h -> 0}; (* This works fine *)
    Chi[0.4, 0.6, 0.2, β_] (* The problem is here; in particular, when I change the value of θ. Last time the problem occurred because I gave θ a value outside the function (so that I could use in other functions too);

    Any help will be greatly appreciated!
     
  2. jcsd
  3. Apr 4, 2012 #2

    Hepth

    User Avatar
    Gold Member

    Some problems arise in mathematica with evaulation of functions where parts of the function diverge, though overall it may cancel. An example:

    Clear[f]
    f[x_] = x/(2 - x) + 2/(x - 2)
    f[2]
    Limit[f[x], x -> 2]

    f[2] will give you 1/0 div by zero error, but this function actually goes to -1 at x=2.

    Perhaps there is something in your function that diverges at those specific values (at least in part of the equation), but wouldnt overall.
     
  4. Apr 6, 2012 #3
    Thanks a lot! It turns out that my function was not analytical at the point of interest, that is why Mathematica did not know which (directional) derivative to give me. Thanks for your response.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook