How to improve exponential decay fit

You should just convert your script to C++ :wink:

  • use const char *, not fixed-size char arrays
  • use std::vector, not fixed-size double arrays
  • and most crucially, fix the ifstream reading loop.

Your issue was that you had 50 elements but only read 49 lines. That meant one bogus number, and that meant the fit didn’t converge. The attached version fit.C (1.8 KB) fixes that! It also makes the code simpler, more readable, and more stable: less magic buffer-size number etc. So there’s plenty of motivation to try out some more advanced C++ :slight_smile:

Cheers, Axel.