# How to simplify this expression?

here is a transfer function tf, the ω has been subsituded with a specific solve. I want to calculate its phase margin and simplify it.

tf=-((I Sqrt[2])/(Sqrt[-k^2 + k Sqrt[4 + k^2]] (1 + (I Sqrt[-k^2 + k Sqrt[4 + k^2]])/(Sqrt[2] k))))
phaseMargin = Arg[tf] + \[Pi] // FullSimplify


the MMA didn't give out a satisfying result, well my friend who is good at math simplify it in hand, give out a pretty result of

ArcCos[Sqrt[1 + k^2/4] - k/2]


I believe MMA is capable of handling this, could anyone help me?

I still have a litte wish. I'm for engineering (IC Design) insted of theoretical reserach, hoping to use MMA to make up for my mathematical shortcomings. Is there any common methodology to process these sort of expression (symbolic expression in s/z domain, solve equation, integrate the spectrum...)? I would be very grateful if anyone could help me！

Ps. the initial transfer function is tfInitial = 1/s*(1/(s/k + 1)) /. s -> I*ω, solve Abs[tfInitial ]==1, then ToRadicals, substidute the ω with the solve, then get the tf in my post above.

Update:

The tf above is revised now. Here is the complete code:

when I try to solve this equation, I got Root[-k^2 + k^2 #1^2 + #1^4 &, 2]

ClearAll["Global*"]
tf = 1/s*(1/(s/k + 1)) /. s -> I*\[Omega];
eq = Abs[tf] == 1;
sol = Assuming[{k < 0 && \[Omega] > 0}, SolveValues[eq, \[Omega]]]


Actually, the answer should be the 3rd Root

sol = ToRadicals[Root[sol[[1, 1]], 3]]
tf = tf /. \[Omega] -> sol;
phaseMargin=[Arg[tf] + \[Pi]]


Why I got the 2nd Root? is my Assuming wrong?

• I am guessing some domain information about k is likely needed. With no information about k the result is complicated, with FullSimplify[Arg[tf] + \[Pi],k>0] the result is simply Pi What do you know, or are assuming, about the domain of k?
– Bill
Commented Apr 6, 2023 at 4:57
• k represents the second pole of this system, k‘s value is supposed to be located in the right complex plane. Or simplify, a real k>0 is fine. I noticed that when k>0, result in Pi. I don't know why, while I dont think this is right.
– Ring
Commented Apr 6, 2023 at 5:09
• when a real k>0the result is Pi... it's right. How about when k is complex number?
– Ring
Commented Apr 6, 2023 at 5:20
• To address your general question: Yes, Mma is (in principle) capable of doing all that. However, one has to learn its parts indicated as "Algebraic manipulations" "Calculus" and maybe something else. There is no easy way of doing all you wish without investing time. But there is good news: investing pays off. Commented Apr 6, 2023 at 10:43

For positive real k, the complex expressions contains no non-real term, but is located in the branch cut of the square root

tf = (I*Sqrt[2])/  (Sqrt[-k^2 - Sqrt[k^2 + 4]*k]*(1 - (I*Sqrt[-k^2 - Sqrt[k^2 + 4]*k])/ (Sqrt[2]*k)))//FullSimplify

phaseMargin = FullSimplify[Arg[tf] + Pi]/.
{ Sqrt[(-1)*a_ b___]:> {I Sqrt[a b],-I Sqrt[a b]}}

Out=1/2 (k + Sqrt[4 + k^2] + I Sqrt[2] Sqrt[-k (k + Sqrt[4 + k^2])])

{\[Pi] +  Arg[k + Sqrt[4 + k^2] - Sqrt[2] Sqrt[k (k + Sqrt[4 + k^2])]],
\[Pi] +  Arg[k + Sqrt[4 + k^2] + Sqrt[2] Sqrt[k (k + Sqrt[4 + k^2])]]}


So the Arg is undefined. As always in these Fourier inversion problems, k has to be shifted away from the cut with small imaginary part in order to get well defined integrals with sensible limit on the cut for real k.

• Thank you for you reply! You are right, in that situation k couldn't be a real number. Now I revised my post. I converted the solve ToRadicals without considering the order, which caused the problem. Now I post the complete code.
– Ring
Commented Apr 6, 2023 at 8:08

Here is what I tried, I got a simplified result of ArcTan[]

ClearAll["Global*"]
(*solve the ω when Abs[tf]==1*)
tf = 1/s*(1/(s/k + 1)) /. s -> I*ω;
eq = Abs[tf] == 1;
sol = Assuming[{k < 0, ω > 0}, SolveValues[eq, ω]];
(*the order of Root and ToRadicals is not match (BUG?)*)
(*calculate the Phase when Abs[tf]=1*)
tfs = tf /. ω -> solRoot3;
reim = ComplexExpand[ReIm[tfs]] // Simplify;
(*phaseMargin = phase@(mag=1)+π*)
pm = Assuming[{k > 0}, FullSimplify[ArcTan[reim[[2]]/reim[[1]]] + π]]


Result is

π + ArcTan[Sqrt[k] (1 + 1/2 k (k + Sqrt[4 + k^2]))^(1/4)]


But this is not perfect result, the perfect Result is

pmPrettyResult = ArcCos[Sqrt[1 + k^2/4] - k/2];


I tried to verify if these 2 phaseMargins are equal

N[pm - pmPrettyResult /. k -> {0.1, 0.2, 1 , 2}, 12]


Result, 2π diffrence is resonable, they are not that accurate because of irrational calculation?

{3.14159, 3.14159, 3.14159265359, 3.14159265359}


I still have no clue to get this pretty result, sad