# for centrally symmetric ellipse:
restart:
with(linalg):M:= matrix([[a,h],[h,b]]);inverse(M);e1:= vector([1,0]);
e2:= vector([0,1]);evalm(transpose(e1) &* inverse(M) &* e1);
evalm(transpose(e2) &* inverse(M) &* e2);# for general ellipse:
restart:
with(linalg):
with(plottools):M:= matrix([[a,h],[h,b]]);
m:= vector([u,v]);
Mn:= simplify(
evalm(M/evalm(transpose(m) &* inverse(M) &* m/4-mu)));
e1:= vector([1,0]);
e2:= vector([0,1]);simplify(evalm(transpose(e1) &* inverse(Mn) &* e1));
evalm(transpose(e2) &* inverse(Mn) &* e2);center:= evalm(-1/2*inverse(M) &* m);
hoff:= simplify(center[1]);
voff:= simplify(center[2]);a:= 56: h:= -20: b:= 28: u:= -5: v:= 4: mu:= -2:
tmp:= vector([x,y]):
eqn:= evalm( transpose(tmp) &* M &* tmp + transpose(tmp)&*m + mu);
horiz:= sqrt(evalm(transpose(e1) &* inverse(Mn) &* e1));
vert:= sqrt(evalm(transpose(e2) &* inverse(Mn) &* e2));
xr:= -1.1*horiz+hoff..horiz*1.1+hoff:
yr:= -1.1*vert+voff..vert*1.1+voff:
plots[display](
{
plots[implicitplot](eqn=0,x=xr,y=yr,numpoints=10000),
plots[implicitplot](x=horiz+hoff,x=xr,y=yr),
plots[implicitplot](x=-horiz+hoff,x=xr,y=yr),
plots[implicitplot](y=vert+voff,x=xr,y=yr),
plots[implicitplot](y=-vert+voff,x=xr,y=yr)
},scaling=CONSTRAINED);