.. _harmonic_oscillator_fit: Optimization of resonant system based on Gaussian fit ========================================================================================== :Driver: :ref:`ActiveLearning` **Download script**: :download:`harmonic_oscillator_fit.m` The target of the study is to tune a resonant system. For simplicity, the resonant system is a harmonic oscillator with eigenfrequency :math:`\omega_0` and damping :math:`\gamma` driven with force :math:`F` at frequency :math:`\omega`. The amplitude of the oscillator is .. math:: a_{\rm harm}(\omega) = \frac{F}{\sqrt{(2\omega\omega_0\gamma)^2 + (\omega_0^2 - \omega)^2}} . We assume the system as a black box with unknown resonant behavior. To capture the resonant feature, it is fitted against a Gaussian plus a linear function .. math:: a_{\rm fit}(\omega) = A \exp\left(-\frac{1}{2}\frac{(\omega-\tau)^2}{\sigma^2}\right) + B\omega + C . The target is to tune :math:`F, \omega_0, \gamma` such that the fitted amplitude is :math:`A = 10`, the resonance frequency is :math:`\tau = 2` and the resonance width :math:`\sigma` is as small as possible. .. literalinclude:: ./harmonic_oscillator_fit.m :language: matlab :linenos: