Hacky handling of exponential and linear cases.
Swithced to optimize.minimize for flexibility.
Using minimize instead of fmin for more solving methods.