<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Defining decaying sin wave
Function accepts dictionary of parameters and array of x-points, returns array of y-points. Represents fit model.
Step1:  Plotting function for default parameters
Define 100 points on x-axis. Constructing dictionary with initial parameter values for decaying_sin.
Step2:  Defining objective function
Objective function requires array of errors eps. Will return array of residuals using data array defined earlier.
<ASSISTANT_TASK:>
Python Code:
def decaying_sin(params, x):
    amp = params['amp']
    phaseshift = params['phase']
    freq = params['frequency']
    decay = params['decay']
    return amp * np.sin(x*freq + phaseshift) * np.exp(-x*x*decay)
Explanation: Defining decaying sin wave
Function accepts dictionary of parameters and array of x-points, returns array of y-points. Represents fit model.
End of explanation
x = np.linspace(0.0, 10.0, 100)
default_params = {"amp" : 10.0, "decay" : 0.05, "phase" : 1.0, "frequency" : 4.0}
data = decaying_sin(default_params, x)
eps = np.linspace(0.0, 10.0, 100)
eps.fill(0.01)
a = plt.plot(x, data)
Explanation: Plotting function for default parameters
Define 100 points on x-axis. Constructing dictionary with initial parameter values for decaying_sin.
End of explanation
def objective_function(params):
    model = decaying_sin(params, x)
    return (data - model) / eps
params = lmfit.Parameters()
params.add('amp', value=1)
params.add('decay', value=0.1)
params.add('phase', value=0.1)
params.add('frequency', value=1.0)
fig, ax = plt.subplots()
a = ax.plot(x, data)
b = ax.plot(x, decaying_sin(params, x))
fig, ax2 = plt.subplots()
def plotter(params, a, b):
    current_data = decaying_sin(params, x)
    ax2.plot(x, data)
    ax2.plot(x, current_data)
    axes = plt.gca()
    axes.set_ylim(-10.0, 10.0)    
out = lmfit.minimize(objective_function, params, iter_cb=plotter)
out.params.pretty_print()
Explanation: Defining objective function
Objective function requires array of errors eps. Will return array of residuals using data array defined earlier.
End of explanation
<END_TASK>