Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Ellipse equation simplification on Mathematica:


On 30 May 2007, at 18:29, Narasimham wrote:

> On May 29, 2:19 pm, Andrzej Kozlowski <a... at mimuw.edu.pl> wrote:
>> On 29 May 2007, at 12:15, Andrzej Kozlowski wrote:
>>
>>
>>
>>
>>
>>> On 29 May 2007, at 10:53, Andrzej Kozlowski wrote:
>>
>>
>>>> On 28 May 2007, at 14:00, Narasimham wrote:
>>
>>>>> On May 19, 1:54 pm, Andrzej Kozlowski <a... at mimuw.edu.pl> wrote:
>>>>>> On 18 May 2007, at 19:06, Narasimham wrote:
>>
>>>>>>>  Reference is made to:
>>
>>>>>>> http://groups.google.co.in/group/geometry.puzzles/browse_thread/
>>>>>>> threa...
>>
>>>>>>>  Constant[c,d th,ph] ;
>>
>>>>>>>  (*  th, ph are spherical cords of tip of tube  *)  ;
>>
>>>>>>>  cp = Cos[ph] ; sp = Sin[ph] ; cth = Cos[th] ; sth = Sin[th] ;
>>
>>>>>>> (*  earlier typo corrected *)
>>
>>>>>>>  d1 = Sqrt[(x + d cp cth + c )^2 + ( y + d cp sth )^2 + (d sp) 
>>>>>>> ^2 ]
>>
>>>>>>>  d2 =Sqrt[(x - d cp cth - c )^2 + ( y - d cp sth )^2 + (d sp) 
>>>>>>> ^2 ]
>>
>>>>>>>  FullSimplify[ d1 + d2 + 2 d - 2 a == 0] ;
>>
>>>>>>>  When d = 0, algebraic/trigonometric simplification brings about
>>>>>>> common ellipse form:
>>
>>>>>>> (x/a)^2 + y^2/(a^2-c^2) = 1
>>
>>>>>>>  Request help for bringing to standard form involving constants
>>>>>>> a,c
>>>>>>> and the new tube length constant d.
>>
>>>>>>>  Regards,
>>>>>>>  Narasimham
>>
>>>>>> I don't think such a form exists. Consider the following.
>>
>>>>>> id1 = {d1^2 - ((x + d*cp*cth + c)^2 + (y + d*cp*sth)^2 + (d*sp) 
>>>>>> ^2),
>>>>>>     d2^2 - ((x - d*cp*cth - c)^2 + (y - d*cp*sth)^2 + (d*sp)^2),
>>>>>>         sp^2 + cp^2 - 1, sth^2 + cth^2 - 1};
>>
>>>>>> id = Prepend[id1, d1 + d2 + 2 d - 2 a];
>>
>>>>>> Now consdier first the case of the ellipse:
>>
>>>>>> d = 0;
>>
>>>>>>   gr = GroebnerBasis[id, {x, y, a, c}, {cp, sp, cth, sth, d1,  
>>>>>> d2},
>>>>>>    MonomialOrder -> EliminationOrder]
>>>>>>   {-a^4 + c^2 a^2 + x^2 a^2 + y^2 a^2 - c^2 x^2}
>>
>>>>>> This tells us that
>>
>>>>>> First[%] == 0
>>>>>> -a^4 + c^2*a^2 + x^2*a^2 + y^2*a^2 - c^2*x^2 == 0
>>
>>>>>> is the equation of the ellipse, and this can be easily brought to
>>>>>> standard form by hand. But now consider your "general" case:
>>
>>>>>>   Clear[d]
>>>>>>   gr = GroebnerBasis[id, {x, y, a, c, d}, {cp, sp, cth, sth, d1,
>>>>>> d2},
>>>>>>    MonomialOrder -> EliminationOrder]
>>>>>>   {}
>>
>>>>>> This means that elimination cannot be performed and no "standard
>>>>>> form"
>>>>>> of the kind you had in mind exists. Unless of course there is  
>>>>>> a bug
>>>>>> in GroebnerBasis (v. unlikely) or I have misunderstood what  
>>>>>> you had
>>>>>> in mind.
>>
>>>>>> Andrzej Kozlowski
>>
>>>>> I checked for case of tube parallel to x- or y-axis produces
>>>>> ellipses
>>>>> and suspected validity even in 3-D general case.
>>
>>>>> Narasimham
>>
>>>>  OK., now I see that I misundertood you and  you wrote that cd,th,
>>>> ph (and presumably a) are supposed to be constants, so you do not
>>>> wish to eliminate them. But now one can easily prove that what you
>>>> get is not, in general, an ellipse. In this situation Groebner
>>>> basis works and you can obtain a rather  horrible quartic equation
>>>> of your surface:
>>
>>>> id1 = {d1^2 - ((x + d*cp*cth + c)^2 + (y + d*cp*sth)^2 + (d*sp)^2),
>>>>     d2^2 - ((x - d*cp*cth - c)^2 + (y - d*cp*sth)^2 + (d*sp)^2),
>>>>         sp^2 + cp^2 - 1, sth^2 + cth^2 - 1};
>>
>>>> id = Prepend[id1, d1 + d2 + 2*d - 2*a];
>>
>>>> v = GroebnerBasis[id, {x, y, a, c, cp, cth}, {sth, sp, d1, d2},
>>>>     MonomialOrder -> EliminationOrder][[1]];
>>
>>>> First[v] == 0
>>
>>>> is the equation (I prefer not to include the output here).
>>
>>>> Looking at v see that the non zero coefficients are only the free
>>>> coefficient, the coefficients of x^2, y^2, x^2 y^2, x^4 and y^4.
>>>> So only in some cases  you will get a quadratic (for example when
>>>> the quartic happens to be a perfect square as in the case d=0,  or
>>>> when the free coefficient vanishes, as in the trivial case a=d,
>>>> or when the coefficients of 4-degree terms vanish). One can work
>>>> out all the cases when gets a quadratic but it is also easy to
>>>> find those when one does not. For example, taking both th and ph
>>>> to be 60 degrees (so that cth and cph are both 1/2) we get:
>>
>>>> v /. {cp -> 1/2, cth -> 1/2, d -> 4, a -> 2, c -> 1}
>>
>>>>  y^4 - 48 x^2 y^2 + 120 y^2 + 3600
>>
>>>> This is certianly is not the equation of an ellipse.
>>
>>>> Andrzej Kozlowski
>>
>>> Sorry; that last example was a bad one, because with these
>>> parameters (d>a)  the original equations do not have solutions. The
>>> point is that the equations that we get after elimination will have
>>> more solutions than the ones we start with, but all the solutions
>>> of the original ones will satisfy the new ones. So to see that we
>>> do not normally get an ellipse we need a different choice of
>>> parameters, with a>d. So take
>>> instead
>>
>>> w = First[v ]/. {cp -> 1/2, cth -> 1/2, sp -> Sqrt[3]/2, sth -> Sqrt
>>> [3]/2, d -> 1,
>>>    a -> 3, c -> 1}
>>
>>> (1521*x^4)/256 + (2229*y^2*x^2)/128 - (117*x^2)/4 + (3721*y^4)/256
>>> - (183*y^2)/4 + 36
>>
>>> Now, this is clearly not the equation of an ellipse. We can see now
>>> the relationship between this and your original equation. With the
>>> above values of the parameters your equation takes the form:
>>
>>> eq = d1 + d2 + 2*d - 2*a == 0 /. {cp -> 1/2, cth -> 1/2, sp -> Sqrt
>>> [3]/2,
>>>    sth -> Sqrt[3]/2, d -> 1, a -> 3,
>>>        c -> 1}
>>> Sqrt[(x - 5/4)^2 + (y - Sqrt[3]/4)^2 + 3/4] +
>>>   Sqrt[(x + 5/4)^2 + (y + Sqrt[3]/4)^2 + 3/4] - 4 == 0
>>
>>> So now look at the graph:
>>
>>> gr1=ContourPlot[
>>>  Sqrt[(x - 5/4)^2 + (y - Sqrt[3]/4)^2 + 3/4] +
>>>    Sqrt[(x + 5/4)^2 + (y + Sqrt[3]/4)^2 + 3/4] - 4 == 0, {x, -5,
>>> 5}, {y, -5,
>>>   5}]
>>
>>> Looks like a nice ellipse, right? Unfortunately it is only a part
>>> of the graph of
>>
>>> w =First[v]
>>
>>> gr2 = ContourPlot[Evaluate[w == 0], {x, -5, 5}, {y, -5, 5}]
>>
>>> The picture is not quite convincing, because the latter contour
>>> plot is not very accurate but when you see them together:
>>
>>> Show[gr1, gr2]
>>
>>> the relationship becomes obvious. In any case, what you get a
>>> quartic curve that looks of course like an ellipse but isn't.
>>
>>> Andrzej Kozlowski
>>
>> Sorry, a small correction is needed. I wrote:
>>
>>>  w=First[v]
>>
>>> gr2 = ContourPlot[Evaluate[w == 0], {x, -5, 5}, {y, -5, 5}]
>>
>> Ignore the first line (w=First[v]) in the above since it will prevent
>> the plot from working. Just evaluate the second line with the value
>> of w defined earlier.
>>
>> Andrzej Kozlowski
>
> Thanks Andrzej so much for all the cumbersome & involved
> verifications.
>
> Ok,are we now in a situation to find out what exhaustively all
> situations/conditions give ellipses?
>
> Should coefficients of third and fourth order term vanish,or should it
> have repeated roots etc.?
>
> At least don't we get ellipses for tube center when th = 0,?
> (inclusive when the tube is parallel or perpendicular to x- axis, th =
> 0,ph = 0,Pi/2? For this case new a,b need to be defined in terms of
> c,a and d).
>
> Regards,
> Narasimham
>
>

Yes, indeed you do get ellipses in various special cases. For  
example, as you say,  when th=0 you can easily find ellipses that are  
solutions. In fact it could be that all solutions in this case are  
ellipses. (see below).
Here is how one can investigate this.

cth = 1; sth = 0;

id1 = {d1^2 - ((x + d*cp*cth + c)^2 + (y + d*cp*sth)^2 + (d*sp)^2),
     d2^2 - ((x - d*cp*cth - c)^2 + (y - d*cp*sth)^2 + (d*sp)^2),
         sp^2 + cp^2 - 1};

id = Prepend[id1, d1 + d2 + 2*d - 2*a];

v = GroebnerBasis[id, {x, y, a, c, cp}, { sp, d1, d2},
     MonomialOrder -> EliminationOrder][[1]]

w = Collect[v, {x, y}, Simplify]


(-y^2)*(a - d)^2 + (a^2 - 2*d*a - c*(c + 2*cp*d))*(a - d)^2 +
   (-a^2 + 2*d*a + c^2 + (cp^2 - 1)*d^2 + 2*c*cp*d)*x^2


We got a quadratic which we hope is the equation of an ellipse. For  
this to be an ellipse one of two things has to happen. Either the  
coefficients of x^2 and y^2 are both positive and the free  
coefficient non-positive or the coefficients of x^2 and y^2 are both  
negative and the free coefficient non-negative. Lets write down two  
conditions:

cond1 = Reduce[
     0 <= cp <= 1 &&
        Coefficient[w, x^2] <
            0 && Coefficient[w, y^2] < 0 && (w /. {x -> 0, y -> 0})  
 >= 0 &&
          a >= d];

cond2 = Reduce[
     0 <= cp <= 1 &&
        Coefficient[w, x^2] >
            0 && Coefficient[w, y^2] > 0 && (w /. {x -> 0, y -> 0})  
<= 0 &&
          a >= d];



cond = Reduce[cond1 || cond2];

Now, let's ask Mathematica to find an example satisfying cond:


ex1 = Flatten[FindInstance[cond, {d, a, cp, c}]]


{d -> 9800/149, a -> 149, cp -> 0, c -> 51}

Let's see the equation:


Simplify[(v /. ex1) == 0]

96040000*x^2 + 153784801*y^2 == 0

well, yes, this is an ellipse but a rather trivial one. Let's try to  
make it find something with a non zero value of cp


ex2 = Flatten[FindInstance[cond && a != 0 && 0 < cp < 1, {d, a, cp, c}]]


{d -> -1, a -> 1, cp -> 1/2, c -> -1}


Simplify[(v /. ex2) == 0]


(7*x^2)/4 + 4*y^2 == 4


This time we got a nice ellipse. So certainly, in the case th=0 you  
get lots of elliptical solutions.
The question is: are all possible solutions in this case elliptical?  
I tried telling Mathematica to find a solution for which the  
following holds:

ex3 = Flatten[FindInstance[Not[cond] && a!=0 && 0 <= cp <=1, {d, a, c}]]


but since after quite a long time Mathematica was still unable to  
find an example and as I need to use it for another purpose I had to  
abort. So I suspect the case th==0 all solutions are elliptical (and  
the same for ph==0) but Reduce will probably not be able to prove it  
(or FindInstance find a counterexample).  I can't spend any more time  
on this but I think you can now see what can be (and what probably  
can't) be done with Mathematica in connection with this problem.













  • Prev by Date: Re: Tracking point on a plot
  • Next by Date: Recursive FindRoot with initial values as a list
  • Previous by thread: Re: Re: Ellipse equation simplification on Mathematica:
  • Next by thread: Re: Ellipse equation simplification on Mathematica: