last revision study_conic



This is the new version of study_conic.
Features:
Type of conic also non-real or lines, 
mnewton only if solve not-works,
axis equation, half-axes lenght,
canonical-form (simple mode) 
and plots of conic and axes.
I include file with some examples.

conic(a,b,c,d,e,f):=block([m,m1,detm,detm1,c1,c2,centro,s,k,sem,assi,eq,vert],
m:matrix([a,b/2,d/2],[b/2,c,e/2],[d/2,e/2,f]),
m1:matrix([a,b/2],[b/2,c]),
detm:determinant(m),detm1:determinant(m1),
if detm#0 then(print("Real Conic"),
detm2:b^2-4*a*c,
if detm2<0 then print("Ellipse"),
if detm2<0 and a=c and b=0 then print("Circle"),
if detm2>0 then print("Hyperbola"),
if detm1#0 then 
(c1:a*x+b/2*y+d/2,
c2:b/2*x+c*y+e/2, 
(if detm1 #0 then centro:first(solve([c1,c2],[x,y])),
print("center",centro),
if b=0 and a =c and detm2<0 then return(["radius",1/2*sqrt(d^2+e^2-4*f)]),
load(eigen),
s:first(eivals(m1)),
k:-detm/detm1,
sem:[k/first(s),k/second(s)],
if detm2>0 and  abs(first(sem))=abs(second(sem)) then print("Equilater Hyperbola"),
print("Canonical equation",rhs((x-first(centro))^2/first(sem)+(y-second(centro))^2/second(sem))=1,
"or",rhs((x-first(centro))^2/second(sem)+(y-second(centro))^2/first(sem))=1),
k1:float(sqrt(abs(sem))),print("half-axis",sqrt(abs(sem)),"->", k1),
if detm2<0 and second(sem)<first(sem) then ecc:sqrt(1-abs(second(sem)/first(sem))),
if detm2<0 and second(sem)>first(sem) then ecc:sqrt(1-abs(first(sem)/second(sem))),
if detm2>0 and second(sem)<first(sem) then ecc:sqrt(1+abs(second(sem)/first(sem))),
if detm2>0 and second(sem)>first(sem) then ecc:sqrt(1+abs(first(sem)/second(sem))),
assi:1/2*b*(x-first(centro))^2-(a-c)*(x-first(centro))*(y-second(centro))-
b/2*(y-second(centro))^2,
print("axes-equations",rhs(factor(assi))),
eq:a*x^2+b*x*y+c*y^2+d*x+e*y+f,
vert:(solve([eq,assi],[x,y])),
print("eccentricity",ecc,"->", float(ecc)),
print("vertexes",vert,"->",float(vert)),
load(mnewton),
if vert=[]  then
(v1:mnewton([assi,eq],[x,y],[first(sem),second(sem)]),
v2:mnewton([assi,eq],[x,y],[first(sem),-second(sem)]),
v3:mnewton([assi,eq],[x,y],[-first(sem),second(sem)]),
v4:mnewton([assi,eq],[x,y],[-first(sem),second(sem)]),
print(v1,v2,v3,v4)),
k2:abs(first(sem)-second(sem)),
feq:k2=rhs((x-first(centro))^2+(y-second(centro))^2),
fuochi:solve([assi,feq],[x,y]),
print("foci",fuochi,"->",float(fuochi)),
if fuochi=[]  then
(f1:mnewton([assi,feq],[x,y],[first(sem),second(sem)]),
f2:mnewton([assi,feq],[x,y],[first(sem),-second(sem)]),
f3:mnewton([assi,feq],[x,y],[-first(sem),second(sem)]),
f4:mnewton([assi,feq],[x,y],[-first(sem),-second(sem)]),
print(f1,f2,f3,f4))),
load (draw),
wxdraw2d(xrange = [-4*first(k1),4*first(k1)], yrange = [-4*second(k1),4*second(k1)],
         xaxis = true, yaxis = true,
         title = "Conic",
         color = red,
         implicit(assi,x,-4*first(k1),4*first(k1),y,-4*second(k1),4*second(k1)),
         color =blue,      
         implicit(eq,x,-4*first(k1),4*first(k1),y,-4*second(k1),4*second(k1)))),
if detm1=0 then (print("Parabola"),
eq:a*x^2+b*x*y+c*y^2+d*x+e*y+f,
asse:a*diff(eq,x)+b/2*diff(eq,y),
print("axis-equation",expand(asse)),
ve:first(solve([eq,asse],[x,y])),
print("vertex",ve),
p:sqrt(-detm/(a+c)^3),
print("Parameter p:",p,"->",float(p)),
print("Canonical equation",y^2=2*p*x),
fp:rhs(expand((x-first(ve))^2+(y-second(ve))^2)),
fp1:fp=(p/2)^2,
fu:solve([fp1,asse],[x,y]),
print("focus",fu)),
load (draw),
if detm1=0 then wxdraw2d(xrange = [-8,8], yrange = [-8,8],
         xaxis = true, yaxis = true,
         title = "Conic",
         color = red,
         implicit(asse,x,-8,8,y,-8,8),
         color =blue,      
         implicit(eq,x,-8,8,y,-8,8))),
if detm=0 then (print("Non real or lines"),
if detm1#0 then(
c1:a*x+b/2*y+d/2,c2:b/2*x+c*y+e/2,
centro:solve([c1,c2],[x,y]),
print("intersection of lines to",centro )),
if detm1=0 then print("parallel lines"), 
eq:a*x^2+b*x*y+c*y^2+d*x+e*y+f,
sol:solve(eq,y),print(sol)),
return(done))$
-------------- next part --------------
A non-text attachment was scrubbed...
Name: studio_conic_1.wxm
Type: application/octet-stream
Size: 7394 bytes
Desc: not available
Url : http://www.math.utexas.edu/pipermail/maxima/attachments/20090311/6245b756/attachment-0001.obj