Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to see how well some curves fit a data set. If a curve doesn't fit after 100 iterations, I get the error cvmit. How do I test for and handle this error within my code?

share|improve this question

I think Check will do it, e.g.:

    (* function that may throw error *) 
    Fit[ data, funs, vars ],
    (* what to do if error is thrown *)
    Print["No convergence within 100 iterations!"]; 
    (* limit to only this error *)

Of course, you could be using other functions to do the fitting (instead of Fit). You could also do things like Quiet the error message, in case you want to handle the convergence problem gracefully.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.