# Absolute value of big complex expression

I am designing a filter and doing calculations in mathematica. I have final form, and I now need to calculate magnitude and phase characteristics of this system. Problem that I have run into is that mathematica doesent seem to want to calculate absolute value. My function is stored in variable HHHI ve found solution on this stackexchange via Simplify@ComplexExpand[Abs@HHH] $$HHH=\frac{s^2+\frac{(\text{C3} \text{R4} \text{R5} \text{R6b}-\text{C2} (\text{K1}\text{R4} (\text{R5}\text{R6a}+(\text{R5}+\text{R6a})\text{R6b})-(\text{R1}+\text{R4})\text{R5} \text{R6b})) s}{\text{C2}\text{C3} \text{R1} \text{R4} \text{R5}\text{R6b}}+\frac{1}{\text{C2} \text{C3}\text{R1}\text{R4}}}{s^2+\frac{((\text{C2}\text{R1}+\text{C3} \text{R4})(\text{R5}+\text{R6a})\text{R6b}-\text{C2} \text{R4} \text{R5}\text{R6a}) s}{\text{C2} \text{C3}\text{R1} \text{R4}(\text{R5}+\text{R6a})\text{R6b}}+\frac{1}{\text{C2} \text{C3}\text{R1} \text{R4}}}$$

Z1 = R1 + 1/(s*C2); Z2 = (1/R4 + s*C3)^-1; (*K1 = R1b/(R1a+R1b);*)
aaa = Solve[U1*(1/Z1 + 1/Z2) - Uul*K1*(1/Z1) - U3*(1/Z2) == 0 &&
U2*(1/R6a + 1/R6b + 1/R5) - Uul*(1/R6a) - U3*(1/R6b) == 0 &&
U1 == U2 &&
H == U3/Uul, {H, U1, U2, U3}];
Simplify[Collect[Expand[aaa], s, Together]];
solut = FullSimplify[ExpandAll[aaa]][[1]][[1]][[2]];
d = Collect[Denominator [solut], s] //
n = Collect[Numerator [solut], s] //
HH = n/d;
(* Muka oko svođenja na pravi oblik *)
a2 = Coefficient[Denominator [solut], s, 2];
a1 = Coefficient[Denominator [solut], s, 1];
a0 = Coefficient[Denominator [solut], s, 0];
a2nov = FullSimplify[a2/a2];
a1nov = FullSimplify[a1/a2];
a0nov = FullSimplify[a0/a2];
b2 = Coefficient[Numerator [solut], s, 2];
b1 = Coefficient[Numerator [solut], s, 1];
b0 = Coefficient[Numerator [solut], s, 0];
b2nov = FullSimplify[b2/b2];
b1nov = FullSimplify[b1/b2];
b0nov = FullSimplify[b0/b2];
K = Simplify[b2/a2]
HHH = ((s^2*b2nov + s*b1nov + b0nov //
PolynomialForm[#, TraditionalOrder -> True] &)/(s^2*a2nov +
s*a1nov + a0nov //
s = I*w
ComplexExpand[Abs[HHH], w, TargetFunctions -> {Abs, Arg}]

This is my function that i get after a lot of hassle to display exactly like that. Next thing i need to do is introduce substitution $s=iw$ (complex i times omega). Then to calculate magnitude depended on w, I need to calculate Abs[HHH] and Arg[HHH]. As i mentioned I've had problems with abs and people suggested either the form suggested above or ComplexExpand@ Abs @HHH. But both forms return this mess under, and I still have complex i in expression.

$$\frac{\sqrt{\left(-w^2+\frac{i (\text{C3}\text{R4} \text{R5} \text{R6b}-\text{C2}(\text{K1} \text{R4} (\text{R5}\text{R6a}+(\text{R5}+\text{R6a})\text{R6b})-(\text{R1}+\text{R4})\text{R5} \text{R6b})) w}{\text{C2}\text{C3} \text{R1} \text{R4} \text{R5}\text{R6b}}+\frac{1}{\text{C2} \text{C3}\text{R1}\text{R4}}\right)^2}}{\sqrt{\left(-w^2+\frac{i ((\text{C2} \text{R1}+\text{C3}\text{R4}) (\text{R5}+\text{R6a})\text{R6b}-\text{C2} \text{R4} \text{R5}\text{R6a}) w}{\text{C2} \text{C3}\text{R1} \text{R4}(\text{R5}+\text{R6a})\text{R6b}}+\frac{1}{\text{C2} \text{C3}\text{R1} \text{R4}}\right)^2}}$$

So how would I tell mathematica to calculate absolute value, and later argument/angle? P.S. Sory if I forgot any info or messed up formatig, first time posting here.

• Enter your expressions in Mathematica code blocks rather than images. Have you tried the TargetFunctions option with ComplexExpand? – Bob Hanlon Jan 21 '17 at 20:55
• @BobHanlon I added the code. The target function doesn't seem to do anything, i always get that solution on the bottom of the post. – dantex47 Jan 22 '17 at 11:56

If you look at the FullForm of your output you will see that you have included the wrapper PolynomialForm in the definitions. Such wrappers are intended for display purposes and should be isolated from the definition of the expressions to be displayed, e.g., by using parentheses.

Z1 = R1 + 1/(s*C2);
Z2 = (1/R4 + s*C3)^-1;
(*K1=R1b/(R1a+R1b);*)
aaa =
Solve[U1*(1/Z1 + 1/Z2) - Uul*K1*(1/Z1) - U3*(1/Z2) == 0 &&
U2*(1/R6a + 1/R6b + 1/R5) - Uul*(1/R6a) - U3*(1/R6b) == 0 &&
U1 == U2 && H == U3/Uul,
{H, U1, U2, U3}][[1]];

solut = FullSimplify[aaa][[1, 2]];

d = Collect[Denominator[solut], s];

n = Collect[Numerator[solut], s];

HH = n/d;

(*Muka oko svođenja na pravi oblik*)
{a0, a1, a2} =
CoefficientList[Denominator[solut], s];
{a0nov, a1nov, a2nov} = FullSimplify[{a0, a1, a2}/a2];
{b0, b1, b2} = CoefficientList[Numerator[solut], s];
{b0nov, b1nov, b2nov} = FullSimplify[{b0, b1, b2}/b2];
K = Simplify[b2/a2];

HHH = ((s^2*b2nov + s*b1nov + b0nov)/(s^2*a2nov + s*a1nov + a0nov));

s = I*w;

ComplexExpand[Abs[HHH], TargetFunctions -> {Re, Im}] // Simplify