# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Representations of the Wave Equation and its Solutions
#
# *This Jupyter notebook is part of a [collection of notebooks](../index.ipynb) in the masters course Selected Topics in Audio Signal Processing, Communications Engineering, Universität Rostock. Please direct questions and suggestions to [<EMAIL>](mailto:<EMAIL>).*

# ## Time-Domain
#
# The inhomogeneous wave equation in the time-domain is given as
#
# \begin{equation}
# \Delta p(\mathbf{x}, t) - \frac{1}{c^2} \frac{\partial^2}{\partial t^2} p(\mathbf{x}, t) = - q(\mathbf{x}, t) .
# \end{equation}
#
# The wave equation is a linear partial differential equation (PDE) with constant coefficients.

# ## Monochromatic
#
# Let's assume a monochromatic real-valued excitation $q(\mathbf{x}, t) = Q(\mathbf{x}, \omega_0) \cos(\omega_0 t)$ with angular frequency $\omega_0 = 2 \pi f_0$. Due to the linearity of the wave equation, the following Ansatz is chosen for the sound pressure $p(\mathbf{x}, t) = P(\mathbf{x}, \omega_0) \cos(\omega_0 t)$. It is common to use complex calculus for PDEs, hence 
#
# \begin{eqnarray}
# q(\mathbf{x}, t) &= \Re \{ Q(\mathbf{x}, \omega_0) e^{j \omega_0 t} \} \\
# p(\mathbf{x}, t) &= \Re \{ P(\mathbf{x}, \omega_0) e^{j \omega_0 t} \} .
# \end{eqnarray}
#
# Introducing the complex quantities into the wave equation yields
#
# \begin{equation}
# \Delta P(\mathbf{x}, \omega_0) e^{j \omega_0 t} + \left( \frac{\omega_0}{c} \right)^2 P(\mathbf{x}, \omega_0) e^{j \omega_0 t} = - Q(\mathbf{x}, \omega_0) e^{j \omega_0 t} .
# \end{equation}
#
# The complex exponential function can be canceled resulting in
#
# \begin{equation}
# \Delta P(\mathbf{x}, \omega_0) + \left( \frac{\omega_0}{c} \right)^2 P(\mathbf{x}, \omega_0) = - Q(\mathbf{x}, \omega_0) .
# \end{equation}
#
# For $t=0$ the time-domain solution of the wave equation for $\omega_0$ is given as $p(\mathbf{x}, 0) = \Re \{ P(\mathbf{x}, \omega_0) \}$. It is common to discard the index 0 in the angular frequency. The index was however introduced for the sake of comparison with the temporal Fourier transform of the wave equation discussed in the following.

# ## Temporal Fourier Domain
#
# Temporal Fourier transform of the inhomogeneity and the pressure yields the Helmholtz equation
#
# \begin{equation}
# \Delta P(\mathbf{x}, \omega) + \left( \frac{\omega}{c} \right)^2 P(\mathbf{x}, \omega) = - Q(\mathbf{x}, \omega) ,
# \end{equation}
#
# where the differentiation theorem of the Fourier transform has been applied. The link to the monochromatic case can be found by considering a monochromatic excitation 
#
# \begin{equation}
# Q(\mathbf{x}, \omega_0) = Q(\mathbf{x}, \omega) \delta(\omega - \omega_0) .
# \end{equation}
#
# Due to the linearity of the wave equation the following Ansatz is chosen
#
# \begin{equation}
# P(\mathbf{x}, \omega_0) = P(\mathbf{x}, \omega) \delta(\omega - \omega_0) .
# \end{equation}
#
# Introducing the right-hand-sides of the latter two equations into the Helmholtz equation yields the same result as for the monochromatic case
#
# \begin{equation}
# \Delta P(\mathbf{x}, \omega_0) + \left( \frac{\omega_0}{c} \right)^2 P(\mathbf{x}, \omega_0) = - Q(\mathbf{x}, \omega_0)
# \end{equation}
#
# Hence, the time-domain solution for a monochromatic excitation for $t=0$ may also be derived from the temporal Fourier transform of the problem by evaluation of $p(\mathbf{x}, \omega) = \Re \{ P(\mathbf{x}, \omega) \}$ for one particular frequency $\omega_0$.

# ## Temporal Excitation
#
# Let's consider the solution $P_\delta(\mathbf{x}, \omega)$ of the Helmholtz equation for the excitation with a temporal Dirac impulse $q(\mathbf{x}, t) = q(\mathbf{x}) \delta(t)$
#
# \begin{equation}
# \Delta P_\delta(\mathbf{x}, \omega) + \left( \frac{\omega}{c} \right)^2 P_\delta(\mathbf{x}, \omega) = - Q(\mathbf{x})
# \end{equation}
#
# Due to the linearity of the wave equation the pressure field for a generic time-domain excitation $q(\mathbf{x}, t) = q(\mathbf{x}) \hat{q}(t)$ is given as
#
# \begin{equation}
# P(\mathbf{x}, \omega) = P_\delta(\mathbf{x}, \omega) \hat{Q}(\omega)
# \end{equation}
#
# or
#
# \begin{equation}
# p(\mathbf{x},t) = p_\delta(\mathbf{x}, t) * \hat{q}(t)
# \end{equation}

# **Copyright**
#
# This notebook is provided as [Open Educational Resources](https://en.wikipedia.org/wiki/Open_educational_resources). Feel free to use the notebook for your own purposes. The text/images/data are licensed under [Creative Commons Attribution 4.0](https://creativecommons.org/licenses/by/4.0/), the code of the IPython examples under the [MIT license](https://opensource.org/licenses/MIT). Please attribute the work as follows: *<NAME>, Selected Topics in Audio Signal Processing - Supplementary Material*.

StarcoderdataJupyterScriptsDedupFiltered