Solving system of 3 non-linear equations.

Hello, I'm trying to solve a system of equations using matlab.
The three variables are: xo2, xo, xar
I've entered the equations in as follows:
syms xo2 xo xar
eq1 = xo2 +xo +xar = 1
eq2 = 2*xo2 +xo -4*xar = 0
eq3 = 2.063E-4*xo2 = xo^2
Then, to solve the system for the variable xo I typed:
solve('eq1', 'eq2', 'eq3', xo)
and I get this message: Warning: Explicit solution could not be found.
What am I doing wrong? I'm fairly ceratain that this system is solvable.
is it because I am using symbolic algebra? For hte problem that I am solving, I dont need a general expression for the value, I just need a number.

2 Kommentare

YARA NABA
YARA NABA am 10 Mär. 2019
Verschoben: Dyuman Joshi am 4 Apr. 2024
syms x y z
eq1=exp(x)+sqrt(y)-z.^3-2
eq2=x.^2-y-z-5
eq3=x+exp(y-1)+z-7
sol=solve(eq1,eq2,eq3)
sol
how can i rewrite it
darova
darova am 10 Mär. 2019
Verschoben: Dyuman Joshi am 4 Apr. 2024
What it is wrong with it?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Oleg Komarov
Oleg Komarov am 13 Feb. 2011

3 Stimmen

Rewrite as:
syms xo2 xo xar
eq1 = xo2 +xo +xar - 1;
eq2 = 2*xo2 +xo -4*xar;
eq3 = 2.063E-4*xo2 - xo^2;
sol = solve(eq1,eq2,eq3);
sol.xo
Oleg

3 Kommentare

MJTHDSN
MJTHDSN am 12 Apr. 2018
Dear Oleg,
I have a similar question but a little bit confusing. Let`s assume we have 6 equations as below:
EQ1:a{{(L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)}}=(L^2)*(T^2)-2*L*(T^2)+ (T^2)-(2*L*T*B)+(T*B)+(B^2)
EQ2: b{{(L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)}}=(L^2)*(T^2)+(2*L*T*B)+(B^2)
EQ3: c{{(L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)}}=(T^2)+(2*T*B)+(B^2)
EQ4:d{{(L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)}}=(L^2)*(T^2)-2*L*(T^2)+ (T^2)-(2*L*T*B)-(T*B)+(B^2)
EQ5: e{{(L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)}}=(L^2)*(T^2)-(2*L*T*B)+(B^2)
EQ6: f{{(L^2)*(Z^2)+(L^2)*(M^2)-2*L*(Z^2)+(Z^2)}}=(T^2)-(2*T*B)+(B^2)
in the equations above a,b,c,d,e and f are the numerical known values (0.543 for example). So we have 6 equations with 5 unknowns as L, Z, M, T and B.
Can you please give me cues how to solve the equations to find these unknowns using MATLAB.
Best,
Adithya Valavi
Adithya Valavi am 24 Mär. 2020
Plz tell me if you knew how to solve this equations
Christopher Creutzig
Christopher Creutzig am 25 Mär. 2020
Adithya Valavi, did you try vpasolve?
It's usually a good idea to post a new problem in a new question, rather than adding a comment to something related.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

Pierce Brady
Pierce Brady am 30 Mär. 2011

2 Stimmen

the output class will be syms, so try casting the answer to a double
class(ans)
double(ans)
class(ans)
Pier Giorgio Petrolini
Pier Giorgio Petrolini am 23 Mär. 2020

1 Stimme

I hope it can be already helpfull...
syms x y z
eq1=exp(x)+sqrt(y)-z.^3-2
eq2=x.^2-y-z-5
eq3=x+exp(y-1)+z-7
eqs = [eq1, eq2, eq3]
[x,y,z]=vpasolve(eqs,[x,y,z])
% Reported results
x = -2.8;
y = 3.33;
z = -0.48;

1 Kommentar

Stephen Ofori
Stephen Ofori am 13 Jan. 2023
This is also working, but the approximations makes it unsuitable for solutions where very small errors are required. If your work require minimal error then it is better to use the solve or fsolve.

Melden Sie sich an, um zu kommentieren.

Tushar
Tushar am 13 Feb. 2011

0 Stimmen

Ah thanks, excellent.
Now the only problem is that when I use your code, matlab spits out a crazy number like this:
ans =
- 2995371679198674497313343284804110513^(1/2)/147573952589676412928 - 12685211008020935/147573952589676412928
how do I get it to something more readable.. like scientific notation or something

2 Kommentare

Walter Roberson
Walter Roberson am 14 Feb. 2011
Use vpa() or double() to get the number in decimal format.
Tushar
Tushar am 14 Feb. 2011
Thanks Walter

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by