Analytical example of simple FMPC computation (executable with Wolfram Mathematica).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* define parameters *) | |
p = 0.5; | |
t2 = Pi/(4*l); | |
t4 = (3*Pi)/(4*l); | |
s2 = t4; | |
s4 = t2; | |
(* define mask functions *) | |
phiT[x_] := t1*Sin[t2*x] + t3*Cos[t4*x]; | |
psiS[x_] := s1*Sin[s2*x] + s3*Cos[s4*x]; | |
(* compute normalization coefficients *) | |
norm1 = (1/l*Integrate[phiT[x]*psiS[x], {x, -l, l}])^(-p); | |
norm2 = (1/l*Integrate[phiT[x]*psiS[x], {x, -l, l}])^(p - 1); | |
(* compute normalized mask functions *) | |
normPhiT[x_] := norm1 * phiT[x]; | |
normPsiS[x_] := norm2 * psiS[x]; | |
(* compute f and g *) | |
f[x_] := a * normPhiT[x]; | |
g[x_] := b * normPsiS[x]; | |
(* compute fourier coefficients *) | |
a0 = (1/l) * Integrate[f[x], {x, -l, l}]; | |
an = (1/l) * Integrate[f[x] * Cos[(n* Pi *x)/l], {x, -l, l}]; | |
bn = (1/l) * Integrate[f[x] * Sin[(n* Pi *x)/l], {x, -l, l}]; | |
alpha0 = (1/l) * Integrate[g[x], {x, -l, l}]; | |
alphan = (1/l) * Integrate[g[x] * Cos[(n* Pi *x)/l], {x, -l, l}]; | |
betan = (1/l) * Integrate[g[x] * Sin[(n* Pi *x)/l], {x, -l, l}]; | |
(* compute the product ab *) | |
node1 = a0*alpha0/2 + Sum[an*alphan, {n, 1, Infinity}]; | |
node2 = Sum[bn*betan, {n, 1, Infinity}]; | |
ab = node1 + node2; | |
(* print out *) | |
FullSimplify[a0, Element[n, Integers]] | |
FullSimplify[an, Element[n, Integers]] | |
FullSimplify[bn, Element[n, Integers]] | |
FullSimplify[alpha0, Element[n, Integers]] | |
FullSimplify[alphan, Element[n, Integers]] | |
FullSimplify[betan, Element[n, Integers]] | |
FullSimplify[ab] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment