Curve fit, bound by reality

I am fitting the following equation:
F(x) = (Si - (Si - S0)*exp(-x/Tch))*exp(-x/Trho) - S0

The equation can be broken into two components:
Frho(x) = S0*exp(-x/Trho)
Fch(x) = exp(-x/Tch) + S0

In short, at no x can F(x) > Frho(x) or F(x) > Fch(x) (excluding error of observation of course).

I am new to Igor, and mostly obtaining help through a colleague, but neither of us had a good idea of how to approach the solution to this problem. Thank you for your assistance.
In Igor you can put linear constraints on the fit coefficients (or linear combinations of them) but you can't put constraints on the result. I suppose you could test it for that condition and return NaN if it happens. When Igor gets a NaN, it goes into a loop that tries backing away from the latest guess in order to try to get back into good territory. But it is not guaranteed to work.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Hi John,

I'm Don's Igor-using colleague. I don't have any experience with trying to return values to the CurveFit algorithm. Do you have any advice as to how to do this?

Thanks,

-Jeremy
>I don't have any experience with trying to return values to the CurveFit algorithm.
>Do you have any advice as to how to do this?

I think John was referring to returning a NaN as the curve-fitting function result. I'm referring to your user-defined curve-fitting function whose name you pass to FuncFit.
Yes, Howard is right- have your fitting function return NAN (Not a Number) which means an invalid result. FuncFit can't handle a model with NaNs so it will try to recover from an error by reducing the size of the jump from the last iteration. You would have to add code in your fitting function that tests to see if your condition is violated.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com