Get symbolic expression from root function

9 views (last 30 days)
%I have simbolic variables
syms R_c Ro_c X_c w_c Lm_c Vp_c Vs_c alpha_c
Xm_c = w_c*Lm_c;
%then I have a set of equations that I need to solve
a_1 =Vp_c*(R_c+Ro_c);
b_1 =-Vp_c*(X_c+Xm_c);
c_1 =2*X_c*Xm_c-R_c*Ro_c-R_c^2+X_c^2;
d_1 =R_c*X_c^2+R_c*Xm_c*2+Ro_c*X_c+Ro_c*Xm_c;
a_2 =Vs_c*Xm_c*cos(alpha_c);
b_2 =-Vs_c*Xm_c*sin(alpha_c);
c_2 =2*R_c*X_c+2*R_c*Xm_c+Ro_c*X_c+Ro_c*Xm_c;
d_2 =R_c*Ro_c-X_c*Xm_c*2+R_c^2-X_c^2;
F_Pp = simplify(expand(-Vp_c*((a_1*c_1+b_1*d_1)/(c_1^2+d_1^2) + (a_2*c_2+b_2*d_2)/(c_2^2+d_2^2))));
F_Qp = simplify(expand(-Vp_c*((b_1*c_1-a_1*d_1)/(c_1^2+d_1^2) + (b_2*c_2-a_2*d_2)/(c_2^2+d_2^2))));
%I derivate
d_Pp = diff(F_Pp,Lm_c); %deR_civative active poweR_c
d_Qp = diff(F_Qp,Lm_c); %deR_civative R_ceactive poweR_c
%and calculate equaling 0, to find the expression of the maximum and minimum points of my function
s_dPp = solve(d_Pp==0,Lm_c,'MaxDegree',3); %Lm active poweR_c R_cight(1) y left(2)
s_dQp = solve(d_Qp==0,Lm_c,'MaxDegree',3); %Lm R_ceactive poweR_c top(1) y bot(2)
%but the result is expressed through the root function, like this
root(80*R_c^4*Ro_c^3*Vs_c*X_c*w_c^7*z^6*sin(alpha_c)+ ......... +32*R_c^4*Ro_c^5*Vs_c*X_c^5*w_c^3*z^2*sin(alpha_c) ... Output truncated. Text exceeds maximum line length for Command Window display.
% How can i solve this problem?

Answers (1)

Jaynik
Jaynik on 4 Oct 2023
Hi Ivan,
I understand that you want the symbolic expression instead of root function in the output. If you want the complete root function expression, you can open the variable from the “workspace” and obtain its value.
For obtaining symbolic expression directly, it might not always be possible using the “solve” function. When the solver cannot find a symbolic solution, it represents the result using the root function, which indicates that the equation cannot be expressed in a simpler form with symbolic constants. You can use numeric approximation by substituting some of the values and then using "vpa" or "double" functions.
On directly using "vpa" on the equation also gives a root function means that the symbolic expressions cannot be directly converted to numeric values without substituting specific values for the symbolic variables. To obtain numeric approximations of the results, you will need to substitute numerical values for the symbolic variables before using the vpa or double functions using the "subs" function.
You can read more about these functions here:
Hope this helps!

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!