forked from schormans/CuCCo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resonance.m
45 lines (41 loc) · 27.3 KB
/
resonance.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function [rootfreqs] = resonance(config,L1,L2,C1,C2,R1,R2,M,Zout)
%RESONANCES Calculates peak and trough frequencies for a given link
% By providing the config and appropriate link parameters, the peak and
% trough frequencies will be computed in Hz. In general there will be 3
% solutions, peak-trough-peak. The calculation is performed by taking the
% polynomial resulting from d(Zlink)/d(omega) = 0, f(omega), then solving
% for f(omega) = 0.
syms omega
switch config
case 'SS'
%
%polycoeffs = flip(coeffs((L1^2*L2^4 + 2*L1*L2^3*M^2 + L2^2*M^4)*C1^2*C2^4*omega^12 + (L2^3*M^2*R1 + 4*L1^2*L2^3*(R2 + Zout) + 3*L2*M^4*(R2 + Zout) + (L2^4*R1 + 7*L2^2*M^2*(R2 + Zout))*L1)*C1^2*C2^4*omega^11 + 2*(2*L2^2*M^2*R1*(R2 + Zout) + 3*(R2^2 + 2*R2*Zout + Zout^2)*L1^2*L2^2 + (R2^2 + 2*R2*Zout + Zout^2)*M^4 + 2*(L2^3*R1*(R2 + Zout) + 2*(R2^2 + 2*R2*Zout + Zout^2)*L2*M^2)*L1)*C1^2*C2^4*omega^10 + (5*(R2^2 + 2*R2*Zout + Zout^2)*L2*M^2*R1 + 4*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*L1^2*L2 + 3*(2*(R2^2 + 2*R2*Zout + Zout^2)*L2^2*R1 + (R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*M^2)*L1)*C1^2*C2^4*omega^9 - (C2^4*L2^4 - 2*C1*C2^3*L2^2*M^2 - ((4*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*L1*L2*R1 + 2*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*M^2*R1 + (R2^4 + 4*R2^3*Zout + 6*R2^2*Zout^2 + 4*R2*Zout^3 + Zout^4)*L1^2)*C2^4 + (2*L1^2*L2^2 + 6*L1*L2*M^2 + 3*M^4)*C2^2)*C1^2)*omega^8 - (4*C2^4*L2^3*(R2 + Zout) - 2*C1*C2^3*L2*M^2*(R2 + Zout) - ((R2^4 + 4*R2^3*Zout + 6*R2^2*Zout^2 + 4*R2*Zout^3 + Zout^4)*C2^4*L1*R1 + (5*L2*M^2*R1 + 4*L1^2*L2*(R2 + Zout) + (2*L2^2*R1 + 5*M^2*(R2 + Zout))*L1)*C2^2)*C1^2)*omega^7 - 2*(3*(R2^2 + 2*R2*Zout + Zout^2)*C2^4*L2^2 - (2*L1*L2*R1*(R2 + Zout) + 2*M^2*R1*(R2 + Zout) + (R2^2 + 2*R2*Zout + Zout^2)*L1^2)*C1^2*C2^2)*omega^6 + 2*((R2^2 + 2*R2*Zout + Zout^2)*C1^2*C2^2*L1*R1 - 2*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*C2^4*L2)*omega^5 - 2*(R2^2 + 2*R2*Zout + Zout^2)*C2^2*omega^2 - ((R2^4 + 4*R2^3*Zout + 6*R2^2*Zout^2 + 4*R2*Zout^3 + Zout^4)*C2^4 - C1^2*L1^2 + 2*C2^2*L2^2 + 2*C1*C2*M^2)*omega^4 + (C1^2*L1*R1 - 4*C2^2*L2*(R2 + Zout))*omega^3 - 1,omega));
polycoeffs = coeffs(((C1^2*C2^4*L1^2*L2^4 - 2*C1^2*C2^4*L1*L2^3*M^2 + C1^2*C2^4*L2^2*M^4)*omega^12 - 2*(2*C1^2*C2^3*L1^2*L2^3 - 4*C1^2*C2^3*L1*L2^2*M^2 + 2*C1^2*C2^3*L2*M^4 - (C1^2*C2^4*L1^2*L2^2 - 2*C1^2*C2^4*L1*L2*M^2 + C1^2*C2^4*M^4)*R2^2 - 2*(C1^2*C2^4*L1^2*L2^2 - 2*C1^2*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C2^3*L2)*Zout^2 + 4*(C2^4*R2^3 - 2*C2^3*L2*R2)*Zout)*omega^4 - 2*(C2^2*R2^2 + 2*C2^2*R2*Zout + C2^2*Zout^2 - 2*C2*L2)*omega^2 - 1),omega,'All');
solns = double(roots(polycoeffs));
PRR = solns( imag(solns) == 0 & real(solns) > 0 );
rootfreqs = PRR/(2*pi);
case 'SP'
%
%polycoeffs = flip(coeffs((L1^2*L2^4*Zout^4 + 2*L1*L2^3*M^2*Zout^4 + L2^2*M^4*Zout^4)*C1^2*C2^4*omega^12 + (L2^3*M^2*R1*Zout^4 + 4*L1^2*L2^3*R2*Zout^4 + 3*L2*M^4*R2*Zout^4 + (L2^4*R1*Zout^4 + 7*L2^2*M^2*R2*Zout^4)*L1)*C1^2*C2^4*omega^11 + 2*((2*L2^2*M^2*R1*R2*Zout^4 + 3*L1^2*L2^2*R2^2*Zout^4 + M^4*R2^2*Zout^4 + 2*(L2^3*R1*R2*Zout^4 + 2*L2*M^2*R2^2*Zout^4)*L1)*C2^4 + (L1^2*L2^4*Zout^2 + 2*L1*L2^3*M^2*Zout^2 + L2^2*M^4*Zout^2)*C2^2)*C1^2*omega^10 + ((5*L2*M^2*R1*R2^2*Zout^4 + 4*L1^2*L2*R2^3*Zout^4 + 3*(2*L2^2*R1*R2^2*Zout^4 + M^2*R2^3*Zout^4)*L1)*C2^4 + (2*L2^3*M^2*R1*Zout^2 + 4*(2*R2*Zout^2 + Zout^3)*L1^2*L2^3 + (6*R2*Zout^2 + 5*Zout^3)*L2*M^4 + (2*L2^4*R1*Zout^2 + (14*R2*Zout^2 + 9*Zout^3)*L2^2*M^2)*L1)*C2^2)*C1^2*omega^9 - (C2^4*L2^4*Zout^4 - 2*C1*C2^3*L2^2*M^2*Zout^4 - (L1^2*L2^4 + 2*L1*L2^3*M^2 + L2^2*M^4 + (4*L1*L2*R1*R2^3*Zout^4 + 2*M^2*R1*R2^3*Zout^4 + L1^2*R2^4*Zout^4)*C2^4 + (2*(4*R2*Zout^2 + 3*Zout^3)*L2^2*M^2*R1 + 2*(6*R2^2*Zout^2 + 6*R2*Zout^3 + Zout^4)*L1^2*L2^2 + (4*R2^2*Zout^2 + 6*R2*Zout^3 + 3*Zout^4)*M^4 + 2*(2*(2*R2*Zout^2 + Zout^3)*L2^3*R1 + (8*R2^2*Zout^2 + 10*R2*Zout^3 + 3*Zout^4)*L2*M^2)*L1)*C2^2)*C1^2)*omega^8 - (4*C2^4*L2^3*R2*Zout^4 - 2*C1*C2^3*L2*M^2*R2*Zout^4 - (C2^4*L1*R1*R2^4*Zout^4 + L2^3*M^2*R1 + 4*L1^2*L2^3*(R2 + Zout) + 3*L2*M^4*(R2 + Zout) + ((10*R2^2*Zout^2 + 14*R2*Zout^3 + 5*Zout^4)*L2*M^2*R1 + 4*(2*R2^3*Zout^2 + 3*R2^2*Zout^3 + R2*Zout^4)*L1^2*L2 + (2*(6*R2^2*Zout^2 + 6*R2*Zout^3 + Zout^4)*L2^2*R1 + (6*R2^3*Zout^2 + 11*R2^2*Zout^3 + 5*R2*Zout^4)*M^2)*L1)*C2^2 + (L2^4*R1 + 7*L2^2*M^2*(R2 + Zout))*L1)*C1^2)*omega^7 - 2*(3*C2^4*L2^2*R2^2*Zout^4 + C2^2*L2^4*Zout^2 - (2*L2^2*M^2*R1*(R2 + Zout) + 3*(R2^2 + 2*R2*Zout + Zout^2)*L1^2*L2^2 + (R2^2 + 2*R2*Zout + Zout^2)*M^4 + (2*(2*R2^3*Zout^2 + 3*R2^2*Zout^3 + R2*Zout^4)*L1*L2*R1 + 2*(R2^3*Zout^2 + 2*R2^2*Zout^3 + R2*Zout^4)*M^2*R1 + (R2^4*Zout^2 + 2*R2^3*Zout^3 + R2^2*Zout^4)*L1^2)*C2^2 + 2*(L2^3*R1*(R2 + Zout) + 2*(R2^2 + 2*R2*Zout + Zout^2)*L2*M^2)*L1)*C1^2)*omega^6 - (4*C2^4*L2*R2^3*Zout^4 + 4*(2*R2*Zout^2 + Zout^3)*C2^2*L2^3 + 2*(R2*Zout^2 + Zout^3)*C1*C2*L2*M^2 - (2*(R2^4*Zout^2 + 2*R2^3*Zout^3 + R2^2*Zout^4)*C2^2*L1*R1 + 5*(R2^2 + 2*R2*Zout + Zout^2)*L2*M^2*R1 + 4*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*L1^2*L2 + 3*(2*(R2^2 + 2*R2*Zout + Zout^2)*L2^2*R1 + (R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*M^2)*L1)*C1^2)*omega^5 - (C2^4*R2^4*Zout^4 + 2*(6*R2^2*Zout^2 + 6*R2*Zout^3 + Zout^4)*C2^2*L2^2 + 2*(R2^2*Zout^2 + 2*R2*Zout^3 + Zout^4)*C1*C2*M^2 + L2^4 - (4*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*L1*L2*R1 + 2*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*M^2*R1 + (R2^4 + 4*R2^3*Zout + 6*R2^2*Zout^2 + 4*R2*Zout^3 + Zout^4)*L1^2)*C1^2)*omega^4 - R2^4 - 4*R2^3*Zout - 6*R2^2*Zout^2 - 4*R2*Zout^3 - Zout^4 + ((R2^4 + 4*R2^3*Zout + 6*R2^2*Zout^2 + 4*R2*Zout^3 + Zout^4)*C1^2*L1*R1 - 4*(2*R2^3*Zout^2 + 3*R2^2*Zout^3 + R2*Zout^4)*C2^2*L2 - 4*L2^3*(R2 + Zout))*omega^3 - 4*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*L2*omega - 2*((R2^4*Zout^2 + 2*R2^3*Zout^3 + R2^2*Zout^4)*C2^2 + 3*(R2^2 + 2*R2*Zout + Zout^2)*L2^2)*omega^2,omega));
polycoeffs = coeffs(((C1^2*C2^4*L1^2*L2^4 - 2*C1^2*C2^4*L1*L2^3*M^2 + C1^2*C2^4*L2^2*M^4)*Zout^4*omega^12 - 2*((2*C1^2*C2^3*L1^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2*L1*L2*M^2 + C1^2*M^4)*R2^2 + 2*(C1^2*L1^2*L2^2 - 2*C1^2*L1*L2*M^2 + C1^2*M^4)*R2*Zout + (2*C1^2*C2^2*M^2*R1*R2^3 + C1^2*C2^2*L1^2*R2^4 + C1^2*L1^2*L2^2 - C2^2*L2^4 - 2*C1^2*L1*L2*M^2 + C1^2*M^4 - 2*(C1^2*C2*L1^2*L2 - (C1^2*C2*L1 + C1*C2^2*L2)*M^2)*R2^2)*Zout^2)*omega^6 + (2*C1^2*M^2*R1*R2^3 + C1^2*L1^2*R2^4 + 2*C1*L2*M^2*R2^2 - (C2^4*R2^4 - 4*C2^3*L2*R2^2 - C1^2*L1^2 + 6*C2^2*L2^2 + 2*C1*C2*M^2)*Zout^4 - L2^4 + 2*(C1^2*M^2*R1 + 2*(C1^2*L1^2 - C2^2*L2^2 - C1*C2*M^2)*R2)*Zout^3 + 2*(3*C1^2*M^2*R1*R2 + 2*C2*L2^3 + C1*L2*M^2 + (3*C1^2*L1^2 - 2*C2^2*L2^2 - C1*C2*M^2)*R2^2)*Zout^2 + 2*(3*C1^2*M^2*R1*R2^2 + 2*C1^2*L1^2*R2^3 + 2*C1*L2*M^2*R2)*Zout)*omega^4 - R2^4 - 4*R2^3*Zout - 6*R2^2*Zout^2 - 4*R2*Zout^3 - Zout^4 - 2*((C2^2*R2^2 - 2*C2*L2)*Zout^4 + L2^2*R2^2 + 2*L2^2*R2*Zout + 2*(C2^2*R2^3 - 2*C2*L2*R2)*Zout^3 + (C2^2*R2^4 - 2*C2*L2*R2^2 + L2^2)*Zout^2)*omega^2),omega,'All');
solns = double(roots(polycoeffs));
PRR = solns( imag(solns) == 0 & real(solns) > 0 );
rootfreqs = PRR/(2*pi);
case 'PS'
%
%polycoeffs = flip(coeffs((L1^4*L2^4 + 4*L1^3*L2^3*M^2 + 6*L1^2*L2^2*M^4 + 4*L1*L2*M^6 + M^8)*C1^2*C2^4*omega^13 + 4*(L2*M^6*R1 + L1^4*L2^3*(R2 + Zout) + (L2^4*R1 + 3*L2^2*M^2*(R2 + Zout))*L1^3 + 3*(L2^3*M^2*R1 + L2*M^4*(R2 + Zout))*L1^2 + (3*L2^2*M^4*R1 + M^6*(R2 + Zout))*L1)*C1^2*C2^4*omega^12 + 2*(3*L2^2*M^4*R1^2 + 2*M^6*R1*(R2 + Zout) + 3*(R2^2 + 2*R2*Zout + Zout^2)*L1^4*L2^2 + 2*(4*L2^3*R1*(R2 + Zout) + 3*(R2^2 + 2*R2*Zout + Zout^2)*L2*M^2)*L1^3 + 3*(L2^4*R1^2 + 6*L2^2*M^2*R1*(R2 + Zout) + (R2^2 + 2*R2*Zout + Zout^2)*M^4)*L1^2 + 6*(L2^3*M^2*R1^2 + 2*L2*M^4*R1*(R2 + Zout))*L1)*C1^2*C2^4*omega^11 + 4*(L2^3*M^2*R1^3 + 3*L2*M^4*R1^2*(R2 + Zout) + (R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*L1^4*L2 + (6*(R2^2 + 2*R2*Zout + Zout^2)*L2^2*R1 + (R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*M^2)*L1^3 + 3*(2*L2^3*R1^2*(R2 + Zout) + 3*(R2^2 + 2*R2*Zout + Zout^2)*L2*M^2*R1)*L1^2 + (L2^4*R1^3 + 9*L2^2*M^2*R1^2*(R2 + Zout) + 3*(R2^2 + 2*R2*Zout + Zout^2)*M^4*R1)*L1)*C1^2*C2^4*omega^10 + (2*(L1^2*L2^2*M^2 + 2*L1*L2*M^4 + M^6)*C1*C2^3 - (L1^2*L2^4 + 2*L1*L2^3*M^2 + L2^2*M^4)*C2^4 + ((L2^4*R1^4 + 12*L2^2*M^2*R1^3*(R2 + Zout) + 6*(R2^2 + 2*R2*Zout + Zout^2)*M^4*R1^2 + 16*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*L1^3*L2*R1 + (R2^4 + 4*R2^3*Zout + 6*R2^2*Zout^2 + 4*R2*Zout^3 + Zout^4)*L1^4 + 12*(3*(R2^2 + 2*R2*Zout + Zout^2)*L2^2*R1^2 + (R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*M^2*R1)*L1^2 + 4*(4*L2^3*R1^3*(R2 + Zout) + 9*(R2^2 + 2*R2*Zout + Zout^2)*L2*M^2*R1^2)*L1)*C2^4 + 2*(L1^4*L2^2 + 2*L1^3*L2*M^2 + L1^2*M^4)*C2^2)*C1^2)*omega^9 + (2*(L2*M^4*R1 + L1^2*L2*M^2*(R2 + Zout) + (L2^2*M^2*R1 + M^4*(R2 + Zout))*L1)*C1*C2^3 - (L2^3*M^2*R1 + 4*L1^2*L2^3*(R2 + Zout) + 3*L2*M^4*(R2 + Zout) + (L2^4*R1 + 7*L2^2*M^2*(R2 + Zout))*L1)*C2^4 + 4*((L2^3*R1^4*(R2 + Zout) + 3*(R2^2 + 2*R2*Zout + Zout^2)*L2*M^2*R1^3 + 6*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*L1^2*L2*R1^2 + (R2^4 + 4*R2^3*Zout + 6*R2^2*Zout^2 + 4*R2*Zout^3 + Zout^4)*L1^3*R1 + 3*(2*(R2^2 + 2*R2*Zout + Zout^2)*L2^2*R1^3 + (R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*M^2*R1^2)*L1)*C2^4 + (3*L1^2*L2*M^2*R1 + L1*M^4*R1 + L1^4*L2*(R2 + Zout) + (2*L2^2*R1 + M^2*(R2 + Zout))*L1^3)*C2^2)*C1^2)*omega^8 - 2*((2*L2^2*M^2*R1*(R2 + Zout) + 3*(R2^2 + 2*R2*Zout + Zout^2)*L1^2*L2^2 + (R2^2 + 2*R2*Zout + Zout^2)*M^4 + 2*(L2^3*R1*(R2 + Zout) + 2*(R2^2 + 2*R2*Zout + Zout^2)*L2*M^2)*L1)*C2^4 - ((3*(R2^2 + 2*R2*Zout + Zout^2)*L2^2*R1^4 + 8*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*L1*L2*R1^3 + 2*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*M^2*R1^3 + 3*(R2^4 + 4*R2^3*Zout + 6*R2^2*Zout^2 + 4*R2*Zout^3 + Zout^4)*L1^2*R1^2)*C2^4 + (6*L1*L2*M^2*R1^2 + M^4*R1^2 + 8*L1^3*L2*R1*(R2 + Zout) + (R2^2 + 2*R2*Zout + Zout^2)*L1^4 + 6*(L2^2*R1^2 + M^2*R1*(R2 + Zout))*L1^2)*C2^2)*C1^2)*omega^7 - (2*(L2*M^2*R1^2*(R2 + Zout) + (R2^2 + 2*R2*Zout + Zout^2)*L1*M^2*R1)*C1*C2^3 + (5*(R2^2 + 2*R2*Zout + Zout^2)*L2*M^2*R1 + 4*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*L1^2*L2 + 3*(2*(R2^2 + 2*R2*Zout + Zout^2)*L2^2*R1 + (R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*M^2)*L1)*C2^4 - 4*(((R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*L2*R1^4 + (R2^4 + 4*R2^3*Zout + 6*R2^2*Zout^2 + 4*R2*Zout^3 + Zout^4)*L1*R1^3)*C2^4 + (L2*M^2*R1^3 + 6*L1^2*L2*R1^2*(R2 + Zout) + 2*(R2^2 + 2*R2*Zout + Zout^2)*L1^3*R1 + (2*L2^2*R1^3 + 3*M^2*R1^2*(R2 + Zout))*L1)*C2^2)*C1^2)*omega^6 - ((4*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*L1*L2*R1 + 2*(R2^3 + 3*R2^2*Zout + 3*R2*Zout^2 + Zout^3)*M^2*R1 + (R2^4 + 4*R2^3*Zout + 6*R2^2*Zout^2 + 4*R2*Zout^3 + Zout^4)*L1^2)*C2^4 - ((R2^4 + 4*R2^3*Zout + 6*R2^2*Zout^2 + 4*R2*Zout^3 + Zout^4)*C2^4*R1^4 + L1^4 + 2*(L2^2*R1^4 + 8*L1*L2*R1^3*(R2 + Zout) + 2*M^2*R1^3*(R2 + Zout) + 6*(R2^2 + 2*R2*Zout + Zout^2)*L1^2*R1^2)*C2^2)*C1^2 + (2*L1^2*L2^2 + 6*L1*L2*M^2 + 3*M^4)*C2^2 + 2*((R2^2 + 2*R2*Zout + Zout^2)*C2^3*M^2*R1^2 + C2*L1^2*M^2)*C1)*omega^5 - ((R2^4 + 4*R2^3*Zout + 6*R2^2*Zout^2 + 4*R2*Zout^3 + Zout^4)*C2^4*L1*R1 + 6*C1*C2*L1*M^2*R1 - 4*(L1^3*R1 + (L2*R1^4*(R2 + Zout) + 2*(R2^2 + 2*R2*Zout + Zout^2)*L1*R1^3)*C2^2)*C1^2 + (5*L2*M^2*R1 + 4*L1^2*L2*(R2 + Zout) + (2*L2^2*R1 + 5*M^2*(R2 + Zout))*L1)*C2^2)*omega^4 - 2*(2*C1*C2*M^2*R1^2 - ((R2^2 + 2*R2*Zout + Zout^2)*C2^2*R1^4 + 3*L1^2*R1^2)*C1^2 + (2*L1*L2*R1*(R2 + Zout) + 2*M^2*R1*(R2 + Zout) + (R2^2 + 2*R2*Zout + Zout^2)*L1^2)*C2^2)*omega^3 + 2*(2*C1^2*L1*R1^3 - (R2^2 + 2*R2*Zout + Zout^2)*C2^2*L1*R1)*omega^2 - L1*R1 + (C1^2*R1^4 - L1^2)*omega,omega));
polycoeffs = coeffs(((C1^2*C2^4*L1^4*L2^4 - 4*C1^2*C2^4*L1^3*L2^3*M^2 + 6*C1^2*C2^4*L1^2*L2^2*M^4 - 4*C1^2*C2^4*L1*L2*M^6 + C1^2*C2^4*M^8)*omega^12 - 2*(2*C1^2*C2^3*L1^4*L2^3 - 6*C1^2*C2^3*L1^3*L2^2*M^2 + 6*C1^2*C2^3*L1^2*L2*M^4 - 2*C1^2*C2^3*L1*M^6 - (C1^2*C2^4*L1^2*L2^4 - 2*C1^2*C2^4*L1*L2^3*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