Some Problems related to linear equation and elliptic equation

조회 수: 3 (최근 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 CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by