import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import warnings
# Ignore all warnings
warnings.simplefilter('ignore')
Bestimme die Fourierreihe der periodischen Funktion $f(t)$, welche im Bereich $[0, 2\pi]$ folgende Gleichung hat: $$f(t) = t(2\pi - t) \qquad 0 \le t \le 2\pi$$ Stelle die Funktion und die Annäherung mittels der Fourierreihe grafisch dar.
# Lösung
# Umformung auf f(t) = 2 \pi t - t^2
# a0 = 4/3 \pi^2
# an = -4/n^2
# bn = 0
fig, axs = plt.subplots(1,3,figsize=(15,4))
# originale funktion
t = np.linspace(0,2*np.pi,200)
f = 2*np.pi*t - t**2
cax = axs[0]
cax.plot(t,f)
cax.set_xlabel('$t$')
cax.set_ylabel('$f(t)$')
cax.set_title('Funktion im Zeitbereich')
cax.grid()
cax = axs[1]
cax.plot(t,f, label='original', linewidth=8, alpha=0.5)
for degree in [1,5,10]:
a0 = 2/3*np.pi**2 # Konstante ist a0/2
fr = a0*np.ones_like(t)
for d in range(1,degree+1):
an = -4/d**2
fr += an*np.cos(d*t)
cax.plot(t,fr,label=f'n = {degree}', linestyle='--')
cax.set_xlabel('$t$')
cax.set_ylabel('$f(t)$')
cax.set_title('Fourierreihe')
cax.legend()
cax.grid()
cax = axs[2]
degree = np.linspace(0,10,11)
coeff = np.zeros_like(degree)
coeff[0] = 1/2 * 4/3*np.pi**2
for i in range(1,11):
coeff[i] = -4/i**2
cax.bar(degree, np.abs(coeff))
cax.grid(True)
cax.set_xlabel('$n \omega_0$')
cax.set_ylabel('$|A|$')
cax.set_title('Fourier Koeffizienten')
plt.show()
Bestimme die komplexe Fourierreihe von $f(t)$, welche im Bereich $[0,T]$ folgende Gleichung hat:$$f(t) = \dfrac{y_0}{T}t \qquad 0 \le t \le T, \; y_0 = \mathrm{konstant}$$ Bestimme die Koeffizienten der reellwertigen Darstellung aus den ermittelten Koeffizienten.
# Lösung
# c0 = y0/2
# cn = j y0/(2 \pi n)
# a0 = y0
# an = 0
# bn = - y0/(n \pi)
y0 = 10
T = 4
w0 = 2*np.pi/T
fig, axs = plt.subplots(1,3,figsize=(15,4))
# originale funktion
t = np.linspace(0,T,200)
f = y0/T*t
cax = axs[0]
cax.plot(t,f)
cax.set_xlabel('$t$')
cax.set_ylabel('$f(t)$')
cax.set_title('Funktion im Zeitbereich')
cax.grid()
cax = axs[1]
cax.plot(t,f, label='original', linewidth=8, alpha=0.5)
for degree in [1,5,50]:
c0 = y0/2
cmn = sum([1j*y0/(2*np.pi*n)*np.exp(1j*n*w0*t) for n in range(-degree,0)])
cpn = sum([1j*y0/(2*np.pi*n)*np.exp(1j*n*w0*t) for n in range(1,degree+1)])
fr = cmn + c0 + cpn
cax.plot(t,fr,label=f'n = {degree}', linestyle='--')
cax.set_xlabel('$t$')
cax.set_ylabel('$f(t)$')
cax.set_title('Fourierreihe (komplex)')
cax.legend()
cax.grid()
cax = axs[2]
degree = np.linspace(-10,10,21)
coeff = np.zeros_like(degree)
coeff[:10] = [np.abs(1j*y0/(2*np.pi*n)) for n in range(-10,0)]
coeff[10] = y0/2
coeff[11:] = [np.abs(1j*y0/(2*np.pi*n)) for n in range(1,11)]
cax.bar(degree, np.abs(coeff))
cax.grid(True)
cax.set_xlabel('$n$')
cax.set_ylabel('$|c_n|$')
cax.set_title('Fourier Koeffizienten (komplex)')
plt.show()
Bestimme die Fourier-Transformation durch Auswertung des entsprechenden Integrals. Stelle die ursprüngliche Funktion und die Fourier-Transformierte grafisch dar.
- $f(t) = \begin{cases} t^2 \mathrm{e}^{-t} & \quad t \geq 0 \\ 0 & \quad t < 0 \end{cases}$
- $f(t) = \begin{cases} 1 + \frac{t}{T} & \quad -T \leq t \leq 0 \\ 1 - \frac{t}{T} & \quad 0 \leq t \leq T \\ 0 & \quad \mathrm{sonst} \end{cases}$
# erste Funktion
# Lösung F(w) = 2/(1+jw)^3
t = np.linspace(0,10,200)
w = np.linspace(-5,5,200)
fig, axs = plt.subplots(1,2,figsize=(15,4))
cax = axs[0]
f = t**2*np.exp(-t)
cax.plot(t,f)
cax.set_xlabel('$t$')
cax.set_ylabel('$f(t)$')
cax.set_title('Funktion im Zeitbereich')
cax.grid()
cax = axs[1]
F = 2/(1+1j*w)**3
cax.plot(w,np.abs(F))
cax.set_xlabel('$\omega$')
cax.set_ylabel('$F(\omega)$')
cax.set_title('Funktion im Frequenzbereich')
cax.grid()
plt.show()
# zweite Funktion
# Lösung F(w) = 2(1 - cos(wT))/(w^2 T)
t = np.linspace(-4,4,201)
w = np.linspace(-5,5,200)
T = 2
fig, axs = plt.subplots(1,2,figsize=(15,4))
cax = axs[0]
f = (1+t/T)*(np.heaviside(t + T,1) - np.heaviside(t,1)) + (1-t/T)*(np.heaviside(t,1) - np.heaviside(t-T,1))
cax.plot(t,f)
cax.set_xlabel('$t$')
cax.set_ylabel('$f(t)$')
cax.set_title('Funktion im Zeitbereich')
cax.grid()
cax = axs[1]
F = 2*(1-np.cos(w*T))/(w**2*T)
cax.plot(w,np.abs(F))
cax.set_xlabel('$\omega$')
cax.set_ylabel('$F(\omega)$')
cax.set_title('Funktion im Frequenzbereich')
cax.grid()
plt.show()
Bestimme die Laplace-Transformation durch Auswertung des entsprechenden Integrals. Stelle die ursprüngliche Funktion und die Laplace-Transformierte grafisch dar.
- $f(t) = t^3 \sigma(t)$
- $f(t) = \begin{cases} A \sin\left(\frac{\pi}{a}t\right) & \quad 0 \leq t \leq a \\ 0 & \quad \mathrm{sonst} \end{cases}$
# erste Funktion
# Lösung L(s) = 6/s^4 mit s > 0
t = np.linspace(0,10,200)
s = np.linspace(1,4,200)
fig, axs = plt.subplots(1,2,figsize=(15,4))
cax = axs[0]
f = t**3
cax.plot(t,f)
cax.set_xlabel('$t$')
cax.set_ylabel('$f(t)$')
cax.set_title('Funktion im Zeitbereich')
cax.grid()
cax = axs[1]
L = 6/s**4
cax.plot(s,L)
cax.set_xlabel('$s$')
cax.set_ylabel('$L(s)$')
cax.set_title('Funktion im Bildbereich')
cax.grid()
plt.show()
# zweite Funktion
# Lösung L(s) = \pi a A (1+exp(-as)) / (a^2 s^2 + \pi^2)
t = np.linspace(-1,5,200)
s = np.linspace(0,4,200)
A = 2
a = 4
fig, axs = plt.subplots(1,2,figsize=(15,4))
cax = axs[0]
f = A*np.sin(np.pi/a*t)*(np.heaviside(t,1) - np.heaviside(t-a,1))
cax.plot(t,f)
cax.set_xlabel('$t$')
cax.set_ylabel('$f(t)$')
cax.set_title('Funktion im Zeitbereich')
cax.grid()
cax = axs[1]
L = a*A*np.pi*(1+np.exp(-a*s))/(a**2*s**2 + np.pi**2)
cax.plot(s,L)
cax.set_xlabel('$s$')
cax.set_ylabel('$L(s)$')
cax.set_title('Funktion im Bildbereich')
cax.grid()
plt.show()
Ausgehend von der Sinusfunktion $\sin(t)$ im Intervall $[-\pi, 2\pi]$, stelle folgende Funktionen mit Hilfe der Sprungfunktion mathematisch und grafisch dar.
- Sinusfunktion die ab $t \geq 2$ verschieden von null ist
- Sinusfunktion die bis $t \geq 2$ verschieden von null ist
- Sinusfunktion die im Intervall $[1,2]$ verschieden von null ist
t = np.linspace(-np.pi, 2*np.pi, 200)
f = np.sin(t)
fig, axs = plt.subplots(1,3,figsize=(15,4), sharex=True, sharey=True)
cax = axs[0]
# erste Fall
f1 = f*(np.heaviside(t-2,1))
cax.plot(t,f1)
cax.set_xlabel('$t$')
cax.set_ylabel('$f(t)$')
cax.set_title('ab $t \geq 2$ verschieden von null')
cax.grid()
cax = axs[1]
# zweite Fall
f2 = f*(1 - np.heaviside(t-2,1))
cax.plot(t,f2)
cax.set_xlabel('$t$')
cax.set_ylabel('$f(t)$')
cax.set_title('bis $t \geq 2$ verschieden von null')
cax.grid()
cax = axs[2]
# dritte Fall
f3 = f*(np.heaviside(t-1,1) - np.heaviside(t-2,1))
cax.plot(t,f3)
cax.set_xlabel('$t$')
cax.set_ylabel('$f(t)$')
cax.set_title('nur im Intervall $[1,2]$')
cax.grid()
plt.show()
Bestimme die Funktion im Zeitbereich durch die Auswertung des Integrals der inversen Fourier-Transformation. $$F(\omega) = \begin{cases} \pi & \quad |\omega| \leq \omega_0 \\ 0 & \quad |\omega| > \omega_0 \end{cases}$$
# Lösung: f(t) = sin(w0 t)/t für t verschieden von null
# f(0) = w0
w0 = 7.5
w = np.linspace(-10,10,200)
fig, axs = plt.subplots(1,2,figsize=(15,4))
cax = axs[0]
F = np.pi*(np.heaviside(w+w0,1) - np.heaviside(w-w0,1))
cax.plot(w,F)
cax.set_xlabel('$\omega$')
cax.set_ylabel('$F(\omega)$')
cax.set_title('Funktion im Frequenzbereich')
cax.grid()
cax = axs[1]
t = np.linspace(-2,2,101)
f = [np.sin(w0*tt)/tt if tt != 0 else w0 for tt in t]
cax.plot(t,f)
cax.set_xlabel('$t$')
cax.set_ylabel('$f(t)$')
cax.set_title('Funktion im Zeitbereich')
cax.grid()
plt.show()