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

11 views (last 30 days)
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

Answers (1)

John D'Errico
John D'Errico on 12 Nov 2020
Edited: John D'Errico on 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.

Categories

Find more on Mathematics in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!