Some Problems related to linear equation and elliptic equation

1 回表示 (過去 30 日間)
浩思
浩思 2022 年 12 月 5 日
編集済み: Torsten 2022 年 12 月 9 日
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 件のコメント
浩思
浩思 2022 年 12 月 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];
expr = collect(eliminate(eqns,y))
expr1=eliminate(eqns,y);
p = coeffs(expr1(1),x);
discriminant=simplify((p(2)^2-4*p(1)*p(3)))
[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))
chord_length = simplify(sqrt((x(1)-x(2))^2+(y(1)-y(2))^2))
浩思
浩思 2022 年 12 月 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];
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
Torsten 2022 年 12 月 5 日
編集済み: 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 件のコメント
浩思
浩思 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]);
P1 = [x(1),y(1)];
P2 = [x(2),y(2)];
x1plusx2=simplify(x(1)+x(2))
x1plusx2 = 
x1x2=simplify(x(1)*x(2))
x1x2 = 
y1plus=simplify(y(1)+y(2))
y1plus = 
y1y2=simplify(y(1)*y(2))
y1y2 = 
浩思
浩思 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]);
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 件)

浩思
浩思 2022 年 12 月 5 日
The quadratic equation of one variable after the combination of elliptic equation and linear equation eliminates y. Why there is an error
  45 件のコメント
Torsten
Torsten 2022 年 12 月 9 日
@浩思 comment moved here:
The vector expr only contains one element. Why do you use expr (1), but use expr will report an error?
Does the software not regard the default variable as a vector with only one element?
Thank you very much for your help. I will carefully read the software documentation.
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 = eliminate(eqns,y)
expr = 
coeffs(expr,x)
Error using symengine
Polynomial expression expected.

Error in sym/coeffs (line 59)
cSym = mupadmex('symobj::coeffs',p.s, args{:});
Torsten
Torsten 2022 年 12 月 9 日
編集済み: 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.
And please don't add an answer if you want to make a comment.

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

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by