Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.5K Views
|
4 Replies
|
1 Total Like
View groups...
Share
Share this post:

Equation of conic section: what's wrong in this code?

Posted 10 years ago

I define a function that can calculate the equation of a conic section with five given points.

ConicThrough5Points[a_, b_, c_, d_, e_, x_, y_] := 
         Block[{conic, coniceqn, a1, b1, c1, d1, e1}, 
          conic = (a1 x^2 + b1 x y + c1 y^2 + d1 x + e1 y + 1 == 
              0) /. {{x -> a[[1]], y -> a[[2]]}, {x -> b[[1]], 
              y -> b[[2]]}, {x -> c[[1]], y -> c[[2]]}, {x -> d[[1]], 
              y -> d[[2]]}, {x -> e[[1]], y -> e[[2]]}}; 
          coniceqn = (a1 x^2 + b1 x y + c1 y^2 + d1 x + e1 y + 1 == 0) /. 
            Solve[conic, {a1, b1, c1, d1, e1}][[1]]; Return[coniceqn]];

then I calculate the function with five points, but it doesn't work. I don`t know why.

ConicThrough5Points[{0, 0}, {1, 0}, {0, 1}, {1, 1}, {-1/2, 3/2}, x, y]
Part::partw: Part 1 of {} does not exist. >>
ReplaceAll::reps: "{{}[[1]]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. 
ReplaceAll::reps: "{{}[[1]]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.
POSTED BY: hanxu xiao
4 Replies

Hello hanxu xiao,

I tried to replay step by step your procedure and then I get:

In[2]:= {a, b, c, d, e} =
 {{0, 0}, {1, 0}, {0, 1}, {1, 1}, {-1/2, 3/2}}

In[8]:= sub = {{x -> a[[1]], y -> a[[2]]}, {x -> b[[1]], 
   y -> b[[2]]}, {x -> c[[1]], y -> c[[2]]}, {x -> d[[1]], 
   y -> d[[2]]}, {x -> e[[1]], y -> e[[2]]}}

Out[8]= {{x -> 0, y -> 0}, {x -> 1, y -> 0}, {x -> 0, 
  y -> 1}, {x -> 1, y -> 1}, {x -> -(1/2), y -> 3/2}}

In[9]:= (a1 x^2 + b1 x y + c1 y^2 + d1 x + e1 y + 1 == 0) /. sub

Out[9]= {False, 1 + a1 + d1 == 0, 1 + c1 + e1 == 0, 
 1 + a1 + b1 + c1 + d1 + e1 == 0, 
 1 + a1/4 - (3 b1)/4 + (9 c1)/4 - d1/2 + (3 e1)/2 == 0}

So it means the form of your equation list called "conic" is not adequate (gives 1==0 when the point is {x->,y-0}

Best regards

Christian

POSTED BY: Christian Neel
conica=a x^2+b x y+c y^2+d x+e y+f==0;

cinquepunti={{0,-3},{-1,4},{-7,6},{3,8},{4,8}}

prima=conica/.{x->cinquepunti[[1,1]],y->cinquepunti[[1,2]]}

seconda=conica/.{x->cinquepunti[[2,1]],y->cinquepunti[[2,2]]}

terza=conica/.{x->cinquepunti[[3,1]],y->cinquepunti[[3,2]]}

quarta=conica/.{x->cinquepunti[[4,1]],y->cinquepunti[[4,2]]}

quinta=conica/.{x->cinquepunti[[5,1]],y->cinquepunti[[5,2]]}

sistemone=Normal[Solve[{prima,seconda,terza,quarta,quinta},{a,b,c,d,e,f},Integers]]/.C[1]->1

finalequation=Extract[conica/. sistemone,1]
POSTED BY: Mutatis Mutandis

Hello, I am interested in working solution... I solved the same problem with geo-Gebra that has a built-in function, but that does not show the steps or the string of calculation. after insertion of the 5-point coordinates, only it returns the equation of the conic curve and its graphical representation.

if I understand it in the general function: Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0 was the F value that caused the error ??

thank you

POSTED BY: Mutatis Mutandis
Posted 10 years ago

(°???°) oh.I forgot it ..... thanks for your answer .

POSTED BY: hanxu xiao
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard