% TODO: factor 2 nog uitleggen met:
% 1/evalf(subs({B=2.5e3*2*Pi,m=100e3*2*Pi,omega0=455e3*2000*Pi},Re(evalf(rhs(SL)/(2.5*2000*Pi)))));
% 1/evalf(subs({B=2.5e3*2*Pi,m=100e3*2*Pi,omega0=455e3*2000*Pi},Re(evalf(rhs(SR)/(2.5*2000*Pi)))));

\section{Maple-worksheet voor IF-filter}
\label{app:iffilter}

%\begin{maplegroup}
%\begin{mapleinput}
%\mapleinline{active}{1d}{restart;}{%
%}
%\end{mapleinput}
%
%\end{maplegroup}
%\begin{maplegroup}
%\begin{mapleinput}
%\mapleinline{active}{1d}{with(plots):}{%
%}
%\end{mapleinput}
%
%\mapleresult
%\begin{maplettyout}
%Warning, the name changecoords has been redefined
%\end{maplettyout}
%
%\end{maplegroup}
\begin{maplegroup}
h is de overdracht van een enkele filter.

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{h := (omega) -> (I*omega/omega0^2*B)/(1+(I*omega/omega0^2*B)-(omega/omega0)^2);}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{h := proc (omega) options operator, arrow;
omega/omega0^2*B/(1+omega/omega0^2*B*I-omega^2/omega0^2)*I end
proc;}{%
\[
h := \omega \rightarrow {\displaystyle \frac {\omega \,B\,I}{
\omega 0^{2}\,(1 + {\displaystyle \frac {\omega \,B\,I}{\omega 0
^{2}}}  - {\displaystyle \frac {\omega ^{2}}{\omega 0^{2}}} )}} 
\]
%
}
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
Het linker, middelste en rechter filter.

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{L := unapply(subs(\{omega0=omega0-m,B=BL\},h(omega)),omega);}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{L := proc (omega) options operator, arrow;
omega/(omega0-m)^2*BL/(1+omega/(omega0-m)^2*BL*I-omega^2/(omega0-m)^2)
*I end proc;}{%
\[
L := \omega \rightarrow {\displaystyle \frac {\omega \,\mathit{BL
}\,I}{(\omega 0 - m)^{2}\,(1 + {\displaystyle \frac {\omega \,
\mathit{BL}\,I}{(\omega 0 - m)^{2}}}  - {\displaystyle \frac {
\omega ^{2}}{(\omega 0 - m)^{2}}} )}} 
\]
%
}
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{M := unapply(subs(\{B=BM\},h(omega)),omega);}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{M := proc (omega) options operator, arrow;
omega/omega0^2*BM/(1+omega/omega0^2*BM*I-omega^2/omega0^2)*I end
proc;}{%
\[
M := \omega \rightarrow {\displaystyle \frac {\omega \,\mathit{BM
}\,I}{\omega 0^{2}\,(1 + {\displaystyle \frac {\omega \,\mathit{
BM}\,I}{\omega 0^{2}}}  - {\displaystyle \frac {\omega ^{2}}{
\omega 0^{2}}} )}} 
\]
%
}
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{R := unapply(subs(\{omega0=omega0+m,B=BR\},h(omega)),omega);}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{R := proc (omega) options operator, arrow;
omega/(omega0+m)^2*BR/(1+omega/(omega0+m)^2*BR*I-omega^2/(omega0+m)^2)
*I end proc;}{%
\[
R := \omega \rightarrow {\displaystyle \frac {\omega \,\mathit{BR
}\,I}{(\omega 0 + m)^{2}\,(1 + {\displaystyle \frac {\omega \,
\mathit{BR}\,I}{(\omega 0 + m)^{2}}}  - {\displaystyle \frac {
\omega ^{2}}{(\omega 0 + m)^{2}}} )}} 
\]
%
}
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
De linker, middelste en rechter piek. Dit is niet helemaal waar, maar
klopt wel ongeveer.

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{poolL := simplify(L(omega0-m)*M(omega0-m)*R(omega0-m)):}{%
}
\end{mapleinput}

%\mapleresult
%\begin{maplelatex}
%\mapleinline{inert}{2d}{poolL :=
%BR*BM*(-omega0+m)^2/(4*omega0*m+BR*omega0*I-I*BR*m)/(-I*BM*omega0+BM*m
%*I-2*omega0*m+m^2);}{%
%\[
%\mathit{poolL} := {\displaystyle \frac {\mathit{BR}\,\mathit{BM}
%\,( - \omega 0 + m)^{2}}{(4\,\omega 0\,m + \mathit{BR}\,\omega 0
%\,I - \mathit{BR}\,m\,I)\,( - \mathit{BM}\,\omega 0\,I + \mathit{
%BM}\,m\,I - 2\,\omega 0\,m + m^{2})}} 
%\]
%%
%}
%\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{poolM := simplify(L(omega0)*M(omega0)*R(omega0)):}{%
}
\end{mapleinput}

%\mapleresult
%\begin{maplelatex}
%\mapleinline{inert}{2d}{poolM :=
%-BR*BL*omega0^2/(2*omega0*m+m^2+BR*omega0*I)/(-2*omega0*m+m^2+omega0*B
%L*I);}{%
%\[
%\mathit{poolM} :=  - {\displaystyle \frac {\mathit{BR}\,\mathit{
%BL}\,\omega 0^{2}}{(2\,\omega 0\,m + m^{2} + \mathit{BR}\,\omega 
%0\,I)\,( - 2\,\omega 0\,m + m^{2} + \omega 0\,\mathit{BL}\,I)}} 
%\]
%%
%}
%\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{poolR := simplify(L(omega0+m)*M(omega0+m)*R(omega0+m)):}{%
}
\end{mapleinput}

%\mapleresult
%\begin{maplelatex}
%\mapleinline{inert}{2d}{poolR :=
%-BM*BL*(omega0+m)^2/(-I*BM*omega0-I*BM*m+2*omega0*m+m^2)/(4*omega0*m-I
%*omega0*BL-I*BL*m);}{%
%\[
%\mathit{poolR} :=  - {\displaystyle \frac {\mathit{BM}\,\mathit{
%BL}\,(\omega 0 + m)^{2}}{( - \mathit{BM}\,\omega 0\,I - \mathit{
%BM}\,m\,I + 2\,\omega 0\,m + m^{2})\,(4\,\omega 0\,m - \omega 0\,
%\mathit{BL}\,I - \mathit{BL}\,m\,I)}} 
%\]
%%
%}
%\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
Stel de polen aan elkaar gelijk en geef dit als voorwaarden voor de
waarden van BL en BR.
We laten de voorwaarden niet zien omdat ze vrij complex en
onoverzichtelijk zijn.
We gebruiken enkel numerieke uitkomsten ervan bij invullen van BM,
omega0 en m.

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{result := solve(\{poolL=poolM,poolR=poolM\},\{BL,BR\}):}{%
}
\end{mapleinput}

\end{maplegroup}
\begin{maplegroup}
Kijk bij de volgende twee regels uit in welke volgorde in BL en BR in
result staan.
Deze volgorde lijkt willekeurig en kan verschillen per keer dat je de
worksheet uitvoert.
Indien BL eerst komt, verwissel result[2][1] en result[2][2] dan.

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{voorwaardeBL := Re(rhs(allvalues(result[2][2])[1])):}{%
}
\end{mapleinput}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{voorwaardeBR := Re(rhs(allvalues(result[2][1])[1])):}{%
}
\end{mapleinput}

\end{maplegroup}
\begin{maplegroup}
We krijgen een vrij mooi vlak plateau en een bandbreedte die nagenoeg
klopt bij een BM van 7.8 kHz en m de helft daarvan. Deze waarden zijn
door proberen bepaald.

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{R_omega0 := 455e3*2*Pi:
R_BM := 7.8e3*2*Pi:
R_m := R_BM/2:}{%
}
\end{mapleinput}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{plot(abs(subs(\{BM=R_BM, m=R_m, omega0=R_omega0\},subs(\{BL=voorwaardeBL,
BR=voorwaardeBR\}, L(f*1e3*2*Pi)*M(f*1e3*2*Pi)*R(f*1e3*2*Pi)))),
f=450.5..459.5, 0.14..0.205);}{%
}
\end{mapleinput}

\mapleresult
\begin{center}
%\mapleplot{iffilter01}
\includegraphics[width=6.8cm]{../img/iffilter01}
%9.05cm
\end{center}

\end{maplegroup}
\begin{maplegroup}
We controleren hier hoe goed de voorwaarden voor BL en BR kloppen. We
berekenen hiertoe de verhouding tussen de hoogte van de
linker en middelste en de  rechter en middelste piek. De verhouding
is niet precies 1 en wijkt meer af naarmate m kleiner is.
\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{evalf(subs(\{BM=R_BM, m=10e3*2*Pi, omega0=R_omega0\},
[abs(subs(\{BL=voorwaardeBL,BR=voorwaardeBR\},poolL)/
subs(\{BL=voorwaardeBL,BR=voorwaardeBR\},poolM)),
abs(subs(\{BL=voorwaardeBL,BR=voorwaardeBR\},poolR)/
subs(\{BL=voorwaardeBL,BR=voorwaardeBR\},poolM))]));}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{[.9632941822, .9618024354];}{%
\[
[0.9632941822, \,0.9618024354]
\]
%
}
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{evalf(subs(\{BM=R_BM, m=R_m, omega0=R_omega0\},
[abs(subs(\{BL=voorwaardeBL,BR=voorwaardeBR\},poolL)/
subs(\{BL=voorwaardeBL,BR=voorwaardeBR\},poolM)),
abs(subs(\{BL=voorwaardeBL,BR=voorwaardeBR\},poolR)/
subs(\{BL=voorwaardeBL,BR=voorwaardeBR\},poolM))]));}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{[.8582853338, .8567310536];}{%
\[
[0.8582853338, \,0.8567310536]
\]
%
}
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
We kunnen dit zien als we het plateau ver uitvergroten.

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{plot(abs(subs(\{BM=R_BM, m=R_m, omega0=R_omega0\}, subs(\{BL=voorwaardeBL,
BR=voorwaardeBR\}, L(f*1e3*2*Pi)*M(f*1e3*2*Pi)*R(f*1e3*2*Pi)))),
f=450.5..459.5, 0.1996..0.2001);}{%
}
\end{mapleinput}

\mapleresult
\begin{center}
\includegraphics[width=8.2cm]{../img/iffilter02}
% 10.97cm
\end{center}

\end{maplegroup}
\begin{maplegroup}
We zijn tevreden met dit minieme verschil tussen de pieken. We
berekenen de benodigde waarden voor de onderdelen van de filters.
Daarvoor bepalen we eerst de eigenfrequenties, Q-factoren en voor
de volledigheid ook de bandbreedtes. De eigenfrequenties en bandbreedtes
moeten door $2\pi$ gedeeld worden om er Hertz van te maken.

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{FREQs := evalf(subs(\{m=R_m, omega0=R_omega0\},
[omega0-m,omega0,omega0+m]));}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{FREQs := [2834344.892, 2858849.315, 2883353.738];}{%
\[
\mathit{FREQs} := [0.2834344892\,10^{7}, \,0.2858849315\,10^{7}, 
\,0.2883353738\,10^{7}]
\]
%
}
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{BWDs := evalf(subs(\{BM=R_BM, m=R_m, omega0=R_omega0\},
[abs(voorwaardeBL),BM,abs(voorwaardeBR)]) );}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{BWDs := [24214.21186, 49008.84540, 24793.03166];}{%
\[
\mathit{BWDs} := [24214.21186, \,49008.84540, \,24793.03166]
\]
%
}
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{Qs := [ FREQs[1]/BWDs[1], FREQs[2]/BWDs[2], FREQs[3]/BWDs[3] ];}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{Qs := [117.0529484, 58.33333333, 116.2969409];}{%
\[
\mathit{Qs} := [117.0529484, \,58.33333333, \,116.2969409]
\]
%
}
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
We kiezen de waarden van de spoelen.

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{Ls := [ 8e-6,16e-6,8e-6 ];}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{Ls := [.8e-5, .16e-4, .8e-5];}{%
\[
\mathit{Ls} := [0.8\,10^{-5}, \,0.000016, \,0.8\,10^{-5}]
\]
%
}
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{Cs := [ 1/(FREQs[1]^2*Ls[1]), 1/(FREQs[2]^2*Ls[2]),
1/(FREQs[3]^2*Ls[3]) ];}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{Cs := [.1555982191e-7, .7647112638e-8, .1503537141e-7];}{%
\[
\mathit{Cs} := [0.1555982191\,10^{-7}, \,0.7647112638\,10^{-8}, 
\,0.1503537141\,10^{-7}]
\]
%
}
\end{maplelatex}

\end{maplegroup}
\begin{maplegroup}
\begin{mapleinput}
\mapleinline{active}{1d}{Rs := [ Qs[1]/sqrt(Cs[1]/Ls[1]), Qs[2]/sqrt(Cs[2]/Ls[2]),
Qs[3]/sqrt(Cs[3]/Ls[3]) ];}{%
}
\end{mapleinput}

\mapleresult
\begin{maplelatex}
\mapleinline{inert}{2d}{Rs := [2654.147412, 2668.259361, 2682.601754];}{%
\[
\mathit{Rs} := [2654.147412, \,2668.259361, \,2682.601754]
\]
%
}
\end{maplelatex}

\end{maplegroup}
