MATLAB: What does “z” stands for in “solve” function

rootsolve

Hi everyone, I've been struggling trying to clear f in the next equation using the "solve" function:
syms f G m Q;
eqn = ((f^2)*(m-1))/(sqrt(((m*(f^2)-1)^2)+((f^2)*(((f^2)-1)^2)*((m-1)^2)*(Q^2))))==G;
x = solve(eqn,f)
The answer I get is the following:
x =
root(2*G^2*Q^2*m*z^3 - G^2*Q^2*m^2*z^3 - G^2*Q^2*z^3 - 4*G^2*Q^2*m*z^2 + 2*G^2*Q^2*m^2*z^2 + 2*G^2*Q^2*z^2 - G^2*m^2*z^2 - 2*m*z^2 + m^2*z^2 + z^2 + 2*G^2*Q^2*m*z - G^2*Q^2*m^2*z + 2*G^2*m*z - G^2*Q^2*z - G^2, z, 1)^(1/2)
root(2*G^2*Q^2*m*z^3 - G^2*Q^2*m^2*z^3 - G^2*Q^2*z^3 - 4*G^2*Q^2*m*z^2 + 2*G^2*Q^2*m^2*z^2 + 2*G^2*Q^2*z^2 - G^2*m^2*z^2 - 2*m*z^2 + m^2*z^2 + z^2 + 2*G^2*Q^2*m*z - G^2*Q^2*m^2*z + 2*G^2*m*z - G^2*Q^2*z - G^2, z, 2)^(1/2)
root(2*G^2*Q^2*m*z^3 - G^2*Q^2*m^2*z^3 - G^2*Q^2*z^3 - 4*G^2*Q^2*m*z^2 + 2*G^2*Q^2*m^2*z^2 + 2*G^2*Q^2*z^2 - G^2*m^2*z^2 - 2*m*z^2 + m^2*z^2 + z^2 + 2*G^2*Q^2*m*z - G^2*Q^2*m^2*z + 2*G^2*m*z - G^2*Q^2*z - G^2, z, 3)^(1/2)
-root(2*G^2*Q^2*m*z^3 - G^2*Q^2*m^2*z^3 - G^2*Q^2*z^3 - 4*G^2*Q^2*m*z^2 + 2*G^2*Q^2*m^2*z^2 + 2*G^2*Q^2*z^2 - G^2*m^2*z^2 - 2*m*z^2 + m^2*z^2 + z^2 + 2*G^2*Q^2*m*z - G^2*Q^2*m^2*z + 2*G^2*m*z - G^2*Q^2*z - G^2, z, 1)^(1/2)
-root(2*G^2*Q^2*m*z^3 - G^2*Q^2*m^2*z^3 - G^2*Q^2*z^3 - 4*G^2*Q^2*m*z^2 + 2*G^2*Q^2*m^2*z^2 + 2*G^2*Q^2*z^2 - G^2*m^2*z^2 - 2*m*z^2 + m^2*z^2 + z^2 + 2*G^2*Q^2*m*z - G^2*Q^2*m^2*z + 2*G^2*m*z - G^2*Q^2*z - G^2, z, 2)^(1/2)
-root(2*G^2*Q^2*m*z^3 - G^2*Q^2*m^2*z^3 - G^2*Q^2*z^3 - 4*G^2*Q^2*m*z^2 + 2*G^2*Q^2*m^2*z^2 + 2*G^2*Q^2*z^2 - G^2*m^2*z^2 - 2*m*z^2 + m^2*z^2 + z^2 + 2*G^2*Q^2*m*z - G^2*Q^2*m^2*z + 2*G^2*m*z - G^2*Q^2*z - G^2, z, 3)^(1/2)
But I just don't understand where does the "z" come from or what does it mean. Can anyone please help me out here? Thanks!

Best Answer

root(2*G^2*Q^2*m*z^3 - G^2*Q^2*m^2*z^3 - G^2*Q^2*z^3 - 4*G^2*Q^2*m*z^2 + 2*G^2*Q^2*m^2*z^2 + 2*G^2*Q^2*z^2 - G^2*m^2*z^2 - 2*m*z^2 + m^2*z^2 + z^2 + 2*G^2*Q^2*m*z - G^2*Q^2*m^2*z + 2*G^2*m*z - G^2*Q^2*z - G^2, z, 1)
stands for the "first" (#1) value, z, such that 2*G^2*Q^2*m*z^3 - G^2*Q^2*m^2*z^3 - G^2*Q^2*z^3 - 4*G^2*Q^2*m*z^2 + 2*G^2*Q^2*m^2*z^2 + 2*G^2*Q^2*z^2 - G^2*m^2*z^2 - 2*m*z^2 + m^2*z^2 + z^2 + 2*G^2*Q^2*m*z - G^2*Q^2*m^2*z + 2*G^2*m*z - G^2*Q^2*z - G^2 is 0.
Notice that expression is a cubic in z, so there are up to three solutions. Exactly what is meant by the "first" root(EXPRESSION,z,1) , or "second" root(EXPRESSION,z,2) or "third" root(EXPRESSION,z,3) is not really defined for user purposes. Whatever the indexing means, it is used consistently by MATLAB: if you were to fill in all of the variables with numerics, then #1 would always refer to the same root for those coefficients. On the other hand, if you start changing the coefficients, the identities of the roots can appear to change places from our perspective -- if you were to plot changing a parameter but using a constant root number, then you might see an apparent discontinuity, which is not an actual discontinuity in the roots and is only a discontinuity in whatever scheme is used internally to number the roots.
If you were to change your code to
x = solve(eqn, f, 'MaxDegree', 3)
then solve() would construct explicit equations instead of using root() placeholders. This can take some time. This can be used for up to 'MaxDegree', 4 -- that is, you can ask for explicit solutions up to quartics. It isn't usually a good idea, though.