Clearing variables and functions in Mathematica

matoma28
Messages
2
Reaction score
0
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!
 
Physics news on Phys.org
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 wouldn't overall.
 
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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K