vpasolve accuracy in two equations with two variables

I got two massive equations with two variables, and vpasolve can not find the solution because that commend search for an accurate answer, which does not exist. I want to get the nearest value of the variables that solve the equations. For example, I am satisfied with 90% accurate solutions.
can I add an accurate aspect in the commend vpasolve?
if not, what command or simple method can I use?

2 commentaires

The enhanced accuracy in contrast to other methods is never the reason why vpasolve fails to find a solution.
To get a useful answer from the forum, we have to see your equations.
Hey! here's the code I used.
The abs_sqr_S11_Zin_1 and abs_sqr_S11_Zin_2 are measured values.
Also,x1,2 and y1,2 are measured values
clear all;close all;clc
%%
syms Z_0
Z_0 = 50
x1 = 0.000365
y1 = 0.51
x2 = 3.51
y2 = 0.8
%%
syms I_L R_L
R_1 = ((Z_0^3)*x1+(Z_0^2)*R_L*x1^2+(Z_0)^2*R_L*y1^2+(Z_0)^2*R_L+Z_0*R_L^2*x1+Z_0*I_L^2*x1)/((Z_0+R_L*x1-I_L*y1)^2+(R_L*y1+I_L*x1)^2 )
pretty(R_1)
I_1 = ((Z_0)^3*y1-(Z_0)^2*I_L*x1^2-(Z_0)^2*I_L*y1^2+(Z_0)^2*I_L-Z_0*R_L^2*y1-Z_0*I_L^2*y1)/(((Z_0+R_L*x1-I_L*y1)^2+(R_L*y1+I_L*x1)^2 ))
pretty(I_1)
%%
R_2 = ((Z_0^3)*x2+(Z_0^2)*R_L*x2^2+(Z_0)^2*R_L*y2^2+(Z_0)^2*R_L+Z_0*R_L^2*x2+Z_0*I_L^2*x2)/((Z_0+R_L*x2-I_L*y2)^2+(R_L*y2+I_L*x2)^2)
pretty(R_2)
I_2 = ((Z_0)^3*y2-(Z_0)^2*I_L*x2^2-(Z_0)^2*I_L*y2^2+(Z_0)^2*I_L-Z_0*R_L^2*y2-Z_0*I_L^2*y2)/(((Z_0+R_L*x2-I_L*y2)^2+(R_L*y2+I_L*x2)^2 ))
pretty(I_2)
%%
Zin_1 = R_1+j*I_1
Zin_2 = R_2+j*I_2
%%
%|S11_Zin1 |^2=|(Z_in1-Z_0)/(Z_in1+Z_0 )|^2
syms abs_sqr_S11_Zin_1
abs_sqr_S11_Zin_1=(abs((Zin_1-Z_0)/(Zin_1+Z_0)))^2
%abs_sqr_S11_Zin_1=((R_1-50)^2+I_1^2)/((R_1+50)^2+I_1^2 )
pretty(abs_sqr_S11_Zin_1)
%%
%|S11_Zin2 |^2=|(Z_in2-Z_0)/(Z_in2+Z_0 )|^2
syms abs_sqr_S11_Zin_2
abs_sqr_S11_Zin_2=(abs((Zin_2-Z_0)/(Zin_2+Z_0)))^2
pretty(abs_sqr_S11_Zin_2)
%%
Y = solve(abs_sqr_S11_Zin_1==0.192,abs_sqr_S11_Zin_2==0.0941,[R_L,I_L])

Connectez-vous pour commenter.

 Réponse acceptée

I am not certain what problem you are having.
One option is to solve the equations and then use vpa on the solutions.
Example —
syms x
Eqn = x^5 + 2*x^4 + 10*x^3 - 3*x^2 - 110*x + 1
Eqn = 
xs = solve(Eqn,x)
xs = 
xsn = vpa(xs)
xsn = 
.

8 commentaires

hey! Thanks for the quick answer!
First, I got two variables, two equations. The main problem is the command I used "vpasolve" can't find a solution to this equations, and it happens (in my opinion) because the commend search for an absolute answer while I need the results to be "close enough" with solutions with 90% accuracy or more.
Thank you!
Torsten
Torsten le 22 Sep 2022
Modifié(e) : Torsten le 22 Sep 2022
and it happens (in my opinion) because the commend search for an absolute answer while I need the results to be "close enough" with solutions with 90% accuracy or more.
As I said: no, that's not the case.
We have to see your equations to find out the reason.
Usually, bad initial guesses for the solution variables is the key factor.
@sason yaakov bochnick — My pleasure!
In addition to @Torsten’s comment, if the solutions to your equations have symbolic variables in them, a purely numeric result is not possible. If that is the situation, the approach in my Answer will be as close as it is possible to get to a numeric result.
.
This was interesting!
My analysis —
clear all;close all;clc
%%
syms Z_0
Z_0 = 50;
x1 = 0.000365;
y1 = 0.51;
x2 = 3.51;
y2 = 0.8;
%%
syms I_L R_L
R_1 = ((Z_0^3)*x1+(Z_0^2)*R_L*x1^2+(Z_0)^2*R_L*y1^2+(Z_0)^2*R_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2 = 
abs_sqr_S11_Zin_2 = vpa(simplify(abs_sqr_S11_Zin_2, 500), 5)
abs_sqr_S11_Zin_2 = 
% pretty(abs_sqr_S11_Zin_2)
%%
Y = solve(abs_sqr_S11_Zin_1==0.192,abs_sqr_S11_Zin_2==0.0941,[R_L,I_L])
Y = struct with fields:
R_L: [0×1 sym] I_L: [0×1 sym]
V1 = symvar(abs_sqr_S11_Zin_1)
V1 = 
V2 = symvar(abs_sqr_S11_Zin_2)
V2 = 
figure
hfs1 = fsurf(abs_sqr_S11_Zin_1, [-0.75 0.75 -1 1.5]*1E+2);
hold on
fcontour(abs_sqr_S11_Zin_1, [-0.75 0.75 -1 1.5]*1E+2, '-r', 'LevelList',[1 1]*0.192, 'LineWidth',2)
hold off
grid on
xlabel(string(V1(1)))
ylabel(string(V1(2)))
% gethfs1 = get(hfs1)
% minZ1 = min(hfs1.ZData(:))
figure
hfs2 = fsurf(abs_sqr_S11_Zin_2, [-0.75 0.75 -1 1.5]*1E+2);
hold on
fcontour(abs_sqr_S11_Zin_2, [-0.75 0.75 -1 1.5]*1E+2, '-r', 'LevelList',[1 1]*0.0941, 'LineWidth',2)
hold off
grid on
xlabel(string(V2(1)))
ylabel(string(V2(2)))
figure
hf1 = fcontour(abs_sqr_S11_Zin_1, [-0.75 0.75 -1 1.5]*1E+2, '-g', 'LevelList',[1 1]*0.192, 'LineWidth',2, 'DisplayName','Z_{IN 1}');
hold on
hf2 = fcontour(abs_sqr_S11_Zin_2, [-0.75 0.75 -1 1.5]*1E+2, '-r', 'LevelList',[1 1]*0.0941, 'LineWidth',2, 'DisplayName','Z_{IN 2}');
hold off
grid
xlabel(string(V2(1)))
ylabel(string(V2(2)))
legend([hf1(1),hf2(1)],'Location','best')
There are solutions for and , however they are not the same solutions in both equations. Perhaps solving them for the same value would work. (I leave that to you.)
.
Wow what a beutiful work!
As you said, there are solutions but they are not the same solutions in both equations. But i dont need them to be the exact same solutions, but to be 90% same or so. Thats why i looked for a way to idenify a accuracy to "solve" commend, so it recognize solutions without 100% accuracy. For instance, 5+5j~=4.8+4.75j.
Thenks for the help!!
My pleasure!
It appears that the minimum for (where the values are closest) is where . So, set (using the subs function) in each equation (not both simultaneously, because there is no common solution), and solve for the minimum value of in each. Then resolve the difference between them however you wish, for example use both, or use the mean of them, in any subsequent calculations.
These are your equations and your project, so choose the best approach in that context.
ok thank you very much for everything! your answers help me a lot!!
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by