Too many solutions using solve function

I am trying to use the solve function to find the point where two hyperbolas intersect.
There should only be one solution (also possible to see that when lookin at a plot of the two hyperbolas)
However the slove function gives me 4 solution, one of them is the correct one.
What am I doing wrong that gets me 3 additional unrelated results?
syms x y
EQ1 = sqrt((x-4.5)^2 + (y-19.5)^2 )-sqrt((x-14)^2 + (y-25)^2) == -0.9;
EQ2 = sqrt((x-4.5)^2 + (y-1.5)^2 )-sqrt((x-4.5)^2 + (y-10.5)^2) == 0.999;
%you can see in the figure there should only be one intersect.
figure
ezplot(EQ1,[-100 100])
hold on
ezplot(EQ2,[-100 100])
R = solve(EQ1,EQ2,[x y]);
The results I get:
K>> R.x
ans =
21.9990
19.4080
16.2100
17.6200
K>> R.y
ans =
3.9830
7.7380
7.4000
4.4520
Only (16.2,7.4) is correct.
Thank you for the help

 Respuesta aceptada

madhan ravi
madhan ravi el 13 de En. de 2019
Editada: madhan ravi el 13 de En. de 2019
[x y] = vpasolve(EQ1,EQ2,[x y])
Gives:
x =
16.209551693222247107423390740782
y =
7.3999826408579772986633766002805

5 comentarios

Shachar Givon
Shachar Givon el 13 de En. de 2019
Great, thank you
madhan ravi
madhan ravi el 13 de En. de 2019
Anytime :)
In that case I have a follow up -
I have 2 new Hyperbolas.
this time they have two intersect. while the regular solve gives me again 4 results (2 correct and 2 additional) the vpasolve gives me only one.
why did it choose to give only that one and not the other correct one?
syms x y
EQ1 = sqrt((x-4.5)^2 + (y-19.5)^2 )-sqrt((x-14)^2 + (y-16.5)^2) == -1.2;
EQ2 = sqrt((x-4.5)^2 + (y-10.5)^2 )-sqrt((x-14)^2 + (y-7)^2) == -2.3977;
figure
ezplot(EQ1,[-100 100])
hold on
ezplot(EQ2,[-100 100])
hold on
R = vpasolve(EQ1,EQ2,[x y]);
Gives:
K>> R.x
ans =
-3.5590
K>> R.y
ans =
-10.0650
Walter Roberson
Walter Roberson el 13 de En. de 2019
When you use vpasolve() with a non-polynomial, it chooses a starting point for the search and uses it to find one solution. You have some control over the starting point: you can request a random starting point, or you can provide a range of values to search over.
If you need more than one solution of a non-polynomial then you need to either use solve() or else use vpasolve with different starting points or different constraints on the search range.
Shachar Givon
Shachar Givon el 13 de En. de 2019
Ok, thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 13 de En. de 2019

Comentada:

el 13 de En. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by