How can I get more than one solution with solve()?

12 Ansichten (letzte 30 Tage)
Safwane Benbba
Safwane Benbba am 12 Nov. 2020
Kommentiert: Safwane Benbba am 12 Nov. 2020
This is my code:
syms x y;
vars = [x,y];
eqn = x^3 + y^2 == 0;
solve(eqn,vars, 'Real', true)
But it really gives me one solution: x=0 and y=0

Antworten (1)

John D'Errico
John D'Errico am 12 Nov. 2020
Bearbeitet: John D'Errico am 12 Nov. 2020
You have ONE equation, and TWO unknowns. There are infinitely many solutions. Do you expect MATLAB to generate them all? Get some coffee, a large cup, as this may take some time and memory.
Instead, the best you can do is to solve for one of the variables as a function of the other. For example, we might expect:
y = +/- sqrt(x^3);
which is what we get.
syms x y;
eqn = x^3 + y^2 == 0;
ysol = solve(eqn,y)
ysol =
(-x)^(3/2)
-(-x)^(3/2)
Or, we could parameterize it for x as a function of y.

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by