System of Multivariable Quadratics

I'm trying to find the intersection points for two ellipses which amounts to solving two equations that look like this:
(x/a1)^2 + (y/b1)^2 = 1
(x/a2)^2 + (y/b2)^2 = 1
I can't seem to figure out how to find a function that will return all points (x,y) real and imaginary.

Answers (1)

Star Strider
Star Strider on 20 Jul 2016
Edited: Star Strider on 20 Jul 2016
Your best option would be to use the Symbolic Math Toolbox.
It would yield:
syms a1 a2 b1 b2 x y
[x,y] = solve((x/a1)^2 + (y/b1)^2 == 1, (x/a2)^2 + (y/b2)^2 == 1, [x,y]);
x = simplify(x, 'steps',10)
y = simplify(y, 'steps',10)
x_fcn = matlabFunction(x)
y_fcn = matlabFunction(y)
x =
a1*a2*(-(b1^2 - b2^2)/(a1^2*b2^2 - a2^2*b1^2))^(1/2)
-a1*a2*(-(b1^2 - b2^2)/(a1^2*b2^2 - a2^2*b1^2))^(1/2)
a1*a2*(-(b1^2 - b2^2)/(a1^2*b2^2 - a2^2*b1^2))^(1/2)
-a1*a2*(-(b1^2 - b2^2)/(a1^2*b2^2 - a2^2*b1^2))^(1/2)
y =
b1*b2*((a1^2 - a2^2)/(a1^2*b2^2 - a2^2*b1^2))^(1/2)
b1*b2*((a1^2 - a2^2)/(a1^2*b2^2 - a2^2*b1^2))^(1/2)
-b1*b2*((a1^2 - a2^2)/(a1^2*b2^2 - a2^2*b1^2))^(1/2)
-b1*b2*((a1^2 - a2^2)/(a1^2*b2^2 - a2^2*b1^2))^(1/2)
x_fcn = @(a1,a2,b1,b2) [a1.*a2.*sqrt(-(b1.^2-b2.^2)./(a1.^2.*b2.^2-a2.^2.*b1.^2));-a1.*a2.*sqrt(-(b1.^2-b2.^2)./(a1.^2.*b2.^2-a2.^2.*b1.^2));a1.*a2.*sqrt(-(b1.^2-b2.^2)./(a1.^2.*b2.^2-a2.^2.*b1.^2));-a1.*a2.*sqrt(-(b1.^2-b2.^2)./(a1.^2.*b2.^2-a2.^2.*b1.^2))];
y_fcn = @(a1,a2,b1,b2) [b1.*b2.*sqrt((a1.^2-a2.^2)./(a1.^2.*b2.^2-a2.^2.*b1.^2));b1.*b2.*sqrt((a1.^2-a2.^2)./(a1.^2.*b2.^2-a2.^2.*b1.^2));-b1.*b2.*sqrt((a1.^2-a2.^2)./(a1.^2.*b2.^2-a2.^2.*b1.^2));-b1.*b2.*sqrt((a1.^2-a2.^2)./(a1.^2.*b2.^2-a2.^2.*b1.^2))];
If you wanted to address ‘(a1,a2,b1,b2)’ as a vector of parameters instead, you could add a second pair of anonymous functions to your code:
x_prms = @(b) x_fcn(b(1),b(2),b(3),b(4));
y_prms = @(b) y_fcn(b(1),b(2),b(3),b(4));

Categories

Find more on Mathematics in Help Center and File Exchange

Asked:

on 20 Jul 2016

Edited:

on 20 Jul 2016

Community Treasure Hunt

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

Start Hunting!