# Some Problems related to linear equation and elliptic equation

6 ビュー (過去 30 日間)

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 件のコメント表示非表示 1 件の古いコメント

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 =

サインインしてコメントする。

### 採用された回答

Torsten 2022 年 12 月 5 日

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 件のコメント表示非表示 6 件の古いコメント

>> 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))

サインインしてコメントする。

### その他の回答 (1 件)

The quadratic equation of one variable after the combination of elliptic equation and linear equation eliminates y. Why there is an error
##### 45 件のコメント表示非表示 44 件の古いコメント
Torsten 2022 年 12 月 9 日

"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.

サインインしてコメントする。

### カテゴリ

Find more on Symbolic Variables, Expressions, Functions, and Preferences in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by