Some Problems related to linear equation and elliptic equation

4 views (last 30 days)
My needs are shown in the picture is.
**1. Calculate the equation after a straight line and an ellipse are simultaneous (eliminate x)
  1. Calculating the discriminant of simultaneous equations
  2. Calculate Veda of simultaneous equations (x1+x2, x1 x2, y1+y2, y1 y2, x1 x2+y1 y2, x1 y2+x2 y1)
  3. Calculate the chord AB length where the ellipse intersects the line**
>> syms a b c x y x0 y0 x1 y1 x2 y2 k m t n
>> eqn1=x^2/a^2+y^2/b^2==1;
>> eqn2=y==k*x+m;
>> eqns = [eqn1 eqn2];
>> [(x1,y1) (x2,y2)]=solve([eqn1 eqn2,(x,y)]
  2 Comments
浩思
浩思 on 6 Dec 2022
syms a b x y k m
eqn1 = x^2/a^2+y^2/b^2==1;
eqn2 = y==k*x+m;
eqns = [eqn1 eqn2];
expr = collect(eliminate(eqns,y))
expr = 
expr1=eliminate(eqns,y);
p = coeffs(expr1(1),x);
discriminant=simplify((p(2)^2-4*p(1)*p(3)))
discriminant = 
[x,y] = solve(eqns,[x,y]);
P1 = [x(1),y(1)];
P2 = [x(2),y(2)];
x1plusx2=simplify(x(1)+x(2))
x1plusx2 = 
x1x2=simplify(x(1)*x(2))
x1x2 = 
y1plusy2=simplify(y(1)+y(2))
y1plusy2 = 
y1y2=simplify(y(1)*y(2))
y1y2 = 
chord_length = simplify(sqrt((x(1)-x(2))^2+(y(1)-y(2))^2))
chord_length = 

Sign in to comment.

Accepted Answer

Torsten
Torsten on 5 Dec 2022
Edited: Torsten on 5 Dec 2022
syms a b x y k m
eqn1 = x^2/a^2+y^2/b^2==1;
eqn2 = y==k*x+m;
eqns = [eqn1 eqn2];
[x,y] = solve(eqns,[x,y])
x = 
y = 
P1 = [x(1),y(1)]
P1 = 
P2 = [x(2),y(2)]
P2 = 
  7 Comments
浩思
浩思 on 5 Dec 2022
>> syms a b x y k m
eqn1 = x^2/a^2+y^2/b^2==1;
eqn2 = y==k*x+m;
eqns = [eqn1 eqn2];
[x,y] = solve(eqns,[x,y]);
P1 = [x(1),y(1)];
P2 = [x(2),y(2)];
x1plusx2=simplify(x(1)+x(2))
x1x2=simplify(x(1)*x(2))
y1plusy2=simplify(y(1)+y(2))
y1y2=simplify(y(1)*y(2))

Sign in to comment.

More Answers (1)

浩思
浩思 on 5 Dec 2022
The quadratic equation of one variable after the combination of elliptic equation and linear equation eliminates y. Why there is an error
  45 Comments
Torsten
Torsten on 9 Dec 2022
Edited: Torsten on 9 Dec 2022
"coeffs" works on polynomials.
"expr" is a vector. The first element of this vector is a polynomial.
Do you see the brackets [ ] around a^2b^2 - a^2k^2x^2 - 2a^2kmx - a^2m^2 - b^2x^2 ?
They indicate "expr" is a vector (of polynomial expressions), not the polynomial expression itself. Taking the first element of this vector gives the polynomial expression on which you can apply "coeffs".
But I already explained this in a previous comment:
No, expression is a vector with 1 element (as you can see by the brackets around it).
expr(1) accesses its first (and only) element.
To be honest: I don't know why this is necessary.
And please don't add an answer if you want to make a comment.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!