Mathematica Clearing variables and functions in Mathematica

AI Thread Summary
The discussion centers on troubleshooting an issue with calculating magnetic susceptibility in Mathematica, specifically encountering a "1/0 complexinfinity" error. The user experiences inconsistent results when changing parameter values, particularly with the variable θ, leading to confusion about the underlying cause. It is suggested that the problem may stem from parts of the function diverging, even if the overall function appears to cancel out. An example is provided where a function yields a division by zero error, yet the limit approaches a finite value. Ultimately, it is concluded that the function was not analytical at the point of interest, which explains Mathematica's inability to compute the directional derivative correctly. This highlights the importance of ensuring functions are well-defined and analytical at the evaluation points to avoid such errors.
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
4
Views
2K
Replies
2
Views
3K
Replies
2
Views
2K
Replies
6
Views
4K
Replies
5
Views
3K
Replies
9
Views
3K
Back
Top