Create Amortization_function.R

Hi Adam,

Please review the amortization function. 

Thanks,

Nan
Why did you pick this specific solver?  What happens if the solver fails to converge? You need to catch all possible errors.