Question: Result is different everytime

Hello,

I'm in the process of making a resonant LLC calculator to define Lr,Lm and Cr. In short, to do this I need to define the fonction of the Gain for different Qualifty factor at a given m value m. My issue is that the below code returns different results everytime. I'm trying to get the value at the top of the Q curve using the maximise fonction and trying to solve wx for that maximum value. Anybody can see what am I doing wrong. Sometime it outpiuts an imaginary number where sometime it doesn't. The expression seems correct as its producing the correct plot/curve.

Thank you for the help.

> restart:with(plots):
> m:=6.3:
> Q1:=1:
> GainQ1:=(8/(Pi^2))*((wx^2)*(m-1))/(sqrt((((m*wx^2)-1)^2)+(Q1^2*wx^2)*((wx^2-1)^2)*((m-1)^2))):
> semilogplot({GainQ1},wx=0.2...2,Gain,axes=boxed,thickness=5,title=`Gain (w, Q, m)`):
> Top_of_Q1:=eval(maximize(GainQ1),wx=0.1..2);wx:=solve(GainQ1=Top_of_Q1);
 

Please Wait...