Ellipse

Author

Eric W. Weisstein
July 23, 2014

This notebook downloaded from http://mathworld.wolfram.com/notebooks/PlaneCurves/Ellipse.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/Ellipse.html.

©2014 Wolfram Research, Inc. except for portions noted otherwise

Additional Authors

Elliptic gears animation by
Harry Calkins

Comments

The code for the Sangaku problems needs to be cleaned up a little

Code

EllipseDiscriminant[eqn_,{x_,y_}]:=Module[{a,b,c,d,f,g,coefs,aa,bb},
coefs=Flatten[Normal[CoefficientArrays[eqn,{x,y},Symmetric->True]]];
{a,b,c,d,f,g}=coefs[[{4,5,7,2,3,1}]]{1,1,1,1/2,1/2,1};
{Det[{{a,b,d},{b,c,f},{d,f,g}}],Det[{{a,b},{b,c}}],a+c}
]

(* doesn't correct for semimajor vs. semiminor axis *)

StandardEllipse0[eqn_,{x_,y_}]:=Module[{a,b,c,d,f,g,aa,bb,x0,y0,coefs},
coefs=Flatten[Normal[CoefficientArrays[eqn,{x,y},Symmetric->True]]];
{a,b,c,d,f,g}=coefs[[{4,5,7,2,3,1}]]{1,1,1,1/2,1/2,1};
{x0,y0}={(c*d-b*f)/(b^2-a*c),(-(b*d)+a*f)/(b^2-a*c)};
If[TrueQ[a==c],
Ellipse[{x0,y0},a{1,1},0],
Ellipse[{x0,y0},{aa=Sqrt[2]*Sqrt[(c*d^2-2*b*d*f+a*f^2+b^2*g-a*c*g)/((b^2-a*c)*(-a-c+Sqrt[1+(4*b^2)/(a-c)^2]*(-a+c)))],bb=Sqrt[2]*Sqrt[(c*d^2-2*b*d*f+a*f^2+b^2*g-a*c*g)/((-a+Sqrt[1+(4*b^2)/(a-c)^2]*(a-c)-c)*(b^2-a*c))]},If[b===0,0,ArcCot[(a-c)/(2*b)]/2]]
]
]

StandardEllipse::usage="StandardEllipse0[eqn, {x, y}] gives Ellipse[{x0, y0}, {a, b}, ϕ], where ϕ is the counterclockwise rotation from the x-axis.";

StandardEllipse[eqn_,{x_,y_}]:=Module[{a,b,c,d,f,g,aa,bb,x0,y0,coefs},
coefs=Flatten[Normal[CoefficientArrays[eqn,{x,y},Symmetric->True]]];
{a,b,c,d,f,g}=coefs[[{4,5,7,2,3,1}]]{1,1,1,1/2,1/2,1};
{x0,y0}={(c*d-b*f)/(b^2-a*c),(-(b*d)+a*f)/(b^2-a*c)};
Ellipse[{x0,y0},{aa=Sqrt[2]*Sqrt[(c*d^2-2*b*d*f+a*f^2+b^2*g-a*c*g)/((b^2-a c)((Sqrt[(((a-c))^2)+4(b^2)])-(a+c)))],bb=Sqrt[2]*Sqrt[(c*d^2-2*b*d*f+a*f^2+b^2*g-a*c*g)/((b^2-a c)(-(Sqrt[(((a-c))^2)+4(b^2)])-(a+c)))]},
If[b===0,0,ArcCot[(a-c)/(2*b)]/2]+If[TrueQ[a>c],π/2,0]

]
]

QuadraticParameters::usage="QuadraticParameters[eqn, {x, y}] gives {{x0, y0}, {a0, c0}, g0, θ}, where a0(x-x0)^2+c0+(y-y0)^2==g0 is the equation of the quadratic in standrad form and θ is the rotation angle.  See http://mathworld.wolfram.com/QuadraticCurve.html";

EllipseCoefficients[eqn_,{x_,y_}]:=Module[
{
coefs=Flatten[Normal[CoefficientArrays[eqn,{x,y},Symmetric->True]]]
},
coefs[[{4,5,7,2,3,1}]]{1,1,1,1/2,1/2,1}
]

EllipseParameters[eqn_,{x_,y_}]:=Module[{a,b,c,d,f,g},
{a,b,c,d,f,g}=EllipseCoefficients[eqn,{x,y}];
{Det[{{a,b,d},{b,c,f},{d,f,g}}],Det[{{a,b},{b,c}}],a+c}
]

QuadraticParameters[eqn_,{x_,y_}]:=Module[{a,b,c,d,f,g,coefs,q,a1,b1,c1,d1,f1,g1,g2},
{a,b,c,d,f,g}=EllipseCoefficients[eqn,{x,y}];
q=ArcCot[(c-a)/(2b)]/2;
{a1,b1,c1,d1,f1,g1}={
a Cos[q]^2-2b Cos[q]Sin[q]+c Sin[q]^2,
b (Cos[q]^2-Sin[q]^2)+(a-c)Sin[q]Cos[q],
a Sin[q]^2+2b Sin[q]Cos[q]+c Cos[q]^2,
d Cos[q]-f Sin[q],
d Sin[q]+f Cos[q],
g
};
(*
Print[{a1,b1,c1,d1,f1,g1}.{x^2,x y,y^2,2x,2 y, 1}/.Thread[{x,y}->{{Cos[q],-Sin[q]},{Sin[q],Cos[q]}}.{x,y}]//N//Expand];
*)
g2=-g1+d1^2/a1+f1^2/c1;
{-{d1/a1,f1/c1},{a1,c1},-g2,q}
]

ellipse[{a_,b_},t_]:={a Cos[t],b Sin[t]};

EllipseMovie[b_,n_]:=Module[{g=Circle[{0,0},{1,b}],f=Sqrt[1-b^2],pts,p,t},
pts={PointSize[.02],Point/@{{-f,0},{f,0}}};
Table[Show[Graphics[
{g,
{RGBColor[1,0,0],Line[{{-f,0},{Cos[t],b Sin[t]},{f,0}}]},
{PointSize[.02],pts,Point[{Cos[t],b Sin[t]}]}
},AspectRatio->Automatic]],{t,0,2Pi-2Pi/n,2Pi/n}]
]

EllipseNormalDistance[{a_,b_},t0_]:=Module[{tt,t,tp,v},
tp=Select[tt/.NSolve[(ellipse[{a,b},tt]-ellipse[{a,b},t0]).(D[ellipse[{a,b},t],t]/. t->t0)==0,tt],Abs[#-t0]>.01&][[1]];
v=ellipse[{a,b},t0]-ellipse[{a,b},tp];
Sqrt[v.v]
]

EllipseNormal[{a_,b_},t0_]:=Module[{tt,t,tp},
tp=Select[tt/.NSolve[(ellipse[{a,b},tt]-ellipse[{a,b},t0]).(D[ellipse[{a,b},t],t]/. t->t0)==0,tt],Abs[#-t0]>.01&][[1]];
tp
]

EllipseNormalPlot[{a_,b_},t_]:=Module[{tt=EllipseNormal[{a,b},t],p1,p2,dp,dpp},
p1=ellipse[{a,b},t];
p2=ellipse[{a,b},tt];
dp=p1-p2;
dpp={-dp[[2]],dp[[1]]};
{Circle[{0,0},{a,b}],
PerpSquare[{{p1,p2},{p1,p1+dpp}},.1,3],
Line[{p1,p2}],
{PointSize[.02],Point[p1],Point[p2]},
{Dashing[{.02,.02}],Line[{p1-Unit[dpp],p1+Unit[dpp]}]}
}]

Definitions

ineq=((x^2)/(a^2))+((y^2)/(b^2))≤1;

reg=Disk[{0,0},{a,b}];

implreg=ImplicitRegion[ineq,{x,y}];

assum=a>0&&b>0;

Plots

Diagram

LaminaData["FilledEllipse","Diagram"]

RegionPlot

Block[{a=1,b=1/2},RegionPlot[ineq,{x,-a,a},{y,-b,b},AspectRatio->Automatic]]

DiscretizeGraphics

Block[{a=1,b=1/2},DiscretizeGraphics[reg]]

Figures

Distances

With[{a=1,b=.7},With[{c=Sqrt[a^2-b^2]},Graphics[{
Circle[{0,0},{a,b}],
PointSize[.03],Point[{{-c,0},{0,0},{c,0}}],
Line[{{# c,-.1},{# c,-1.}}]&/@{-1,1},
Line[{{# a,-.15},{# a,-1.2}}]&/@{-1,1},
Line[{{.3,#b},{1.4,#b}}]&/@{-1,1},
Arrowheads[.04{-1,1}],
Arrow[{{-c,0},{.3,.67}}],
Arrow[{{.3,.67},{c,0}}],
Arrow[{{-c,-.9},{c,-.9}}],
Arrow[{{-a,-1.1},{a,-1.1}}],
Arrow[{{1.3,-b},{1.3,b}}],
Text[Style[Subscript[Style["r",Italic],1]],Mean[{{-c,0},{.3,.67}}],Background->White],
Text[Style[Subscript[Style["r",Italic],2]],Mean[{{.3,.67},{c,0}}],Background->White],
Text[Style[Subscript[Style["F",Italic],1]],{-c-.08,-.15},Background->White],
Text[Style[Subscript[Style["F",Italic],2]],{c+.1,-.15},Background->White],
Text[Style["C",Italic],{0,-.14}],
Text[Style["major axis",Italic],{0,-1.3}],
Text[Style["minor axis",Italic],{1.6,0},{0,0},{0,-1}],
Text[Style[Row[{" ",2,Style["a",Italic]," "}]],{0,-1.11},Background->White],
Text[Style[Row[{" ",2,Style["c",Italic]," "}]],{0,-.91},Background->White],
Text[Style[Row[{2,Style["b",Italic]}]],{1.3,0},Background->White]
}]]]

Periapsis/Apoapsis

With[{a=1,b=.7,off=.08},With[{c=Sqrt[a^2-b^2]},Graphics[{
Circle[{0,0},{a,b}],
PointSize[.03],Point[{c,0}],
Text[Style["F",Italic,18],{c,0}-off{1,1}],
Text[Style[Subscript[Style["r",Italic],"+"],18],{-a-off,0}],
Text[Style[Subscript[Style["r",Italic],"-"],18],{a+off,0}]
}]]]

Animations

<<Utilities`GIF`

Stretched String

Export[gif<>"ellipse.gif",EllipseMovie[.5,50]]//Timing

Elliptical Gears

Animation by Harry Calkins
Aug 23, 2004

Options[EllipticGears] = Options[ParametricPlot]/.{Rule[Epilog,_]:> Rule[Epilog, {RGBColor[0,0,1],Disk[focusOne,5 (maj-focdis)/8],Disk[focusTwo,5 (maj-focdis)/8]}],Rule[AspectRatio,_]:> Rule[AspectRatio,Automatic]};

EllipticGears[a_,c_,n_Integer,opts___?OptionQ]:= Module[{dang,rotmat,b,GetPhi,foc1,foc2},
dang = 2 π/n;
rotmat[t_]:= {{Cos[t],-Sin[t]},{Sin[t],Cos[t]}};
b= (Sqrt[(a^2)- (c^2)]);
GetPhi[aa_?Positive,cc_?Positive,θ_/;0≤ θ≤ 2 π]:=Module[{e,r},
e = cc/aa;
r = ((aa (1 -(e^2)))/(1 + e Cos[θ]));
ϕ =If[θ <π,ArcTan[2 c + r Cos[θ],r Sin[θ]],2 π + ArcTan[2 c + r Cos[θ],r Sin[θ]]]
];
xrange= {-2 a,2 a};
yrange = {-2 a,4 a};
foc1= {0,0};
foc2 = {0,2 a };
Table[ParametricPlot[{rotmat[i dang].({b Sin[t+π],a Cos[t+π]}+{0,-c}),rotmat[-GetPhi[a,c,i dang]].({b Sin[t+π],a Cos[t+π]}+{0,-c})+{0,2 a}},{t,0, 2 π},AspectRatio -> Automatic,PlotRange-> {xrange,yrange},opts,Evaluate@((Options[EllipticGears])/.{focusOne-> foc1,focusTwo-> foc2,maj-> a,focdis-> c})],{i,0,n-1}]
]

Length[movie=EllipticGears[6,4,48,Axes -> False]]//Timing

ListAnimate[movie]

GraphicsGrid[Partition[Take[movie,{1,-1,2}],6],ImageSize->400]

<<Utilities`GIF`

Export[$GIFDirectory<>"EllipticGears.gif",movie]//Timing

Directrix

With[{c=Sqrt[a^2-b^2],y=b Sqrt[1-x^2/a^2]},
FullSimplify[Solve[r==(a-c)/(d-a)==Sqrt[b^2+c^2]/d,{d,r}],0<b<a]
]

EllipseDirectrix[{a_,b_},n_]:=With[{c=Sqrt[a^2-b^2]},
Module[{d=a^2/c,y,eps=.05},
Show[Graphics[{
{RGBColor[1,0,0],
Table[Line[{{c,0},{a Sqrt[1-y^2/b^2],y},{d,y}}],{y,-b,b,2b/n}]},
Circle[{0,0},{1,b}],
{PointSize[.03],Point/@{{-c,0},{c,0}}},
Line[{{d,-b-eps},{d,b+eps}}]
},
AspectRatio->Automatic,PlotRange->All]
]
]
]

EllipseDirectrix[{1,.7},20]

With[{b=.5,a=1},
Module[{c=Sqrt[a^2-b^2]},
Table[{Sqrt[#.#]&[{Sqrt[1-y^2/b^2]-c,y}],a^2/c-Sqrt[1-y^2/b^2]},{y,-b+.1,b-.1,.05}]
]]

With[{b=.5,a=1},
{Fit[%,{1,t},t],a^2/c}
]

Ellipse through 4 Points

Ellipse[m_List,{x_,y_}]:=Det[Prepend[{#1^2,#2^2,#1,#2,1}&@@@m,{x^2,y^2,x,y,1}]]/;Dimensions[m]=={4,2}

pts=Table[Random[],{4},{2}]

<<Graphics`ImplicitPlot`
<<Graphics`Colors`

ImplicitPlot[Ellipse[pts,{x,y}]==0,{x,-3,3},Epilog->{Red,PointSize[.03],Point/@pts}]

Four Points Concyclic

Trott, TMGB Symbolics, p. 40

In Terms of Tan[t/2]

Simplify[Subtract@@{Cos[t],(1-Tan[t/2]^2)/(1+Tan[t/2]^2)}]

Simplify[Subtract@@{Sin[t],2 Tan[t/2]/(1+Tan[t/2]^2)}]

eqns=Table[Function[{x, y}, (x - X)^2 + (y - Y)^2 - r^2] @@ 
    ({a Cos[t], b Sin[t]} /. {Cos[t] -> (1 - s[i]^2)/(1 + s[i]^2), 
                              Sin[t] -> 2 s[i]/(1 + s[i]^2)}), {i, 4}]

(gb=GroebnerBasis[Numerator[Together[eqns]],
              {s[1], s[2], s[3], s[4], a, b}, {X, Y, r},
              MonomialOrder -> EliminationOrder] // Factor)//Timing

gb[[1,-1]]/.s[i_]:>2 Tan[t[i]/2]/(1+Tan[t[i]/2]^2)//Simplify//Factor

TraditionalForm[%/.t[n_]:>Subscript[t,n]]

In Terms of Sin[t]

eqns=Table[Function[{x, y}, (x - X)^2 + (y - Y)^2 - r^2] @@ 
    {a c[i], b s[i]}, {i, 4}]

(gb=GroebnerBasis[Join[eqns,Table[s[i]^2+c[i]^2-1,{i,4}]],{s[1],s[2],s[3],s[4],a,b},{X,Y,r,c[1],c[2],c[3],c[4]},MonomialOrder->EliminationOrder]//Factor)//Timing

gb[[1,-1]]/.s[i_]:>Sin[t[i]]//FullSimplify//Factor

TraditionalForm[ (((s[1])^4)-2 ((s[1])^2) ((s[2])^2)+((s[2])^4)-2 ((s[1])^2) ((s[3])^2)-2 ((s[2])^2) ((s[3])^2)+4 ((s[1])^2) ((s[2])^2) ((s[3])^2)+((s[3])^4)+8 s[1] s[2] s[3] s[4]-4 ((s[1])^3) s[2] s[3] s[4]-4 s[1] ((s[2])^3) s[3] s[4]-4 s[1] s[2] ((s[3])^3) s[4]-2 ((s[1])^2) ((s[4])^2)-2 ((s[2])^2) ((s[4])^2)+4 ((s[1])^2) ((s[2])^2) ((s[4])^2)-2 ((s[3])^2) ((s[4])^2)+4 ((s[1])^2) ((s[3])^2) ((s[4])^2)+4 ((s[2])^2) ((s[3])^2) ((s[4])^2)-4 s[1] s[2] s[3] ((s[4])^3)+((s[4])^4))/.s[n_]:>Sin[Subscript[t,n]]]

Equations

{focus,parametric,polar}=With[{a=1,b=.7},
Module[{e=Sqrt[1-b^2/a^2]},
{
PolarPlot[a(1-e^2)/(1+e Cos[t]),{t,0,2Pi},PlotStyle->Red],
ParametricPlot[{a Cos[t],b Sin[t]},{t,0,2Pi},PlotStyle->Red],
PolarPlot[a b/Sqrt[b^2 Cos[t]^2+a^2 Sin[t]^2],{t,0,2Pi},PlotStyle->Red]
}
]]

Cartesian

GroebnerBasis[Append[Thread[{x,y}=={a Cos[t],b Sin[t]}],Cos[t]^2+Sin[t]^2==1],{x,y},{Sin[t],Cos[t]}]

eqn=-(a^2) (b^2)+(b^2) (x^2)+(a^2) (y^2)

Polar Equation

About Focus

eqn=Numerator[Together[x^2/a^2+y^2/b^2-1/.{x->c+r Cos[θ],y->r Sin[θ]}]]

eqn2=Simplify[Expand[eqn/.{c->a e,b->a Sqrt[1-e^2],Sin[θ]->Sqrt[1-Cos[θ]^2]}]]

eqn3=eqn2/-a^2

Solve[eqn3==0,r]

With[{a=1,b=.7},With[{e=(Sqrt[1-((b^2)/(a^2))])},PolarPlot[((a(1-(e^2)))/(1+e Cos[θ])),{θ,0,2π},Epilog->Point[{{0,0},{a(1-e),0}}]]]]

About Center

FullSimplify[Solve[Simplify[Factor[((x^2)/(a^2))+((y^2)/(b^2))-1/.{x->r Cos[θ],y->r Sin[θ]}]==0],r]]

With[{a=1,b=.7},PolarPlot[a b/Sqrt[b^2 Cos[t]^2+a^2 Sin[t]^2],{t,0,2π}]]

FullSimplify[Expand[(1/(Sqrt[(((Cos[θ])^2)/(a^2))+(((Sin[θ])^2)/(b^2))]))/.Sin[θ]->(Sqrt[1-((Cos[θ])^2)])],a>0&&b>0&&θ>0]

FullSimplify[((a b)/(Sqrt[1+((b^2)-(a^2)) ((Cos[θ])^2)]))-(1/(Sqrt[(1/(b^2))+((1/(a^2))-(1/(b^2))) ((Cos[θ])^2)])),a>0&&b>0&&0<θ<2π]

With[{a=1,b=.7},PolarPlot[((a b)/(Sqrt[((b^2)-(a^2))((Cos[θ])^2)+(a^2)])),{θ,0,2π}]]

Ellipse Function

EllipseFn[t_,b_]:=ArcTan[b Tan[t]]+Floor[(t+Pi/2)/Pi]Pi
Plot[{EllipseFn[t,.6],t},{t,0,2Pi},PlotStyle->{{},Dashing[{.02}]}]

Bounding Box

?MaxValue

MaxValue[{x,a x^2+2b x y+c y^2+2d x+2f y+g==0},{x,y},Reals]

Quadratic Standard Form

((Subscript[x, 0]),(Subscript[y, 0]))==(1,2), (a',b')==(a,b), ϕ==3.3
Δ==1
J==2
I==3

MakeBoxes[label[eqn_,{x_,y_},Ellipse[{x0_,y0_},{a_,b_},ϕ_],{Δ_,J_,i_}],TraditionalForm]:=RowBox[{RowBox[{RowBox[{RowBox[{"(",RowBox[{SubscriptBox["x","0"],",",SubscriptBox["y","0"]}],")"}],"==",RowBox[{"(",RowBox[{MakeBoxes[x0,TraditionalForm],",",MakeBoxes[y0,TraditionalForm],")"}]}],","," ",RowBox[{RowBox[{"(","a","'",",","b", "'",")"}]}],"==",RowBox[{"(",RowBox[{MakeBoxes[a,TraditionalForm],",",MakeBoxes[b,TraditionalForm]}],")"}]}],","," ",RowBox[{"ϕ","==",MakeBoxes[ϕ,TraditionalForm]}]}],"
",RowBox[{"Δ","==",MakeBoxes[Δ,TraditionalForm]}],"
",RowBox[{"J","==",MakeBoxes[J,TraditionalForm]}],"
",RowBox[{"I","==",MakeBoxes[i,TraditionalForm]}]}]

label[ellipse,{x,y},StandardEllipse[ellipse,{x,y}],EllipseParameters[ellipse,{x,y}]]//TraditionalForm

EllipsePlot[eqn_,{x_,y_},opts___?OptionQ]:=Module[{e=StandardEllipse[eqn,{x,y}],dx,dy,xx,yy},
dx=MaxValue[{x,eqn==0},{x,y}]-e[[1,1]];
dy=MaxValue[{y,eqn==0},{x,y}]-e[[1,2]];
xx=RotationMatrix[e[[3]]].{e[[2,1]],0};
yy=RotationMatrix[π/2+e[[3]]].{e[[2,2]],0};
ContourPlot[eqn==0,{x,e[[1,1]]-dx,e[[1,1]]+dx},{y,e[[1,2]]-dy,e[[1,2]]+dy},opts,
ImageSize->{Automatic,200},
ContourStyle->Red,
Epilog->{
{Dashing[{.02}],Line[{{e[[1]]-xx,e[[1]]+xx},{e[[1]]-yy,e[[1]]+yy}}]},
Line[{{-100,0}+e[[1]],{100,0}+e[[1]]}],
PointSize[.03],{Red,Point[e[[1]]]},{Blue,Point[{xx+e[[1]],yy+e[[1]]}]}
},
PlotLabel->eqn==0,
AspectRatio->Automatic
]
]

Parabola

ellipse=2(x^2)+2(y^2)+4x y+3x-4y;

EllipseCoefficients[ellipse,{x,y}]

EllipseParameters[ellipse,{x,y}]

ContourPlot[ellipse==0,{x,-10,10},{y,-10,10},Epilog->Point[{1,0}],ImageSize->150]

StandardEllipse[ellipse,{x,y}]

Point w/ (b^2)==a c

ellipse=(x^2)+(y^2)+(1/2)x y;

ContourPlot[ellipse==0,{x,-10,10},{y,-10,10},Epilog->{Red,Point[{1,0}]},ImageSize->150]

StandardEllipse[ellipse,{x,y}]

Circle

ellipse=Numerator[Expand[((((x-1))^2)/1)+((y^2)/1)-1]]

EllipsePlot[ellipse,{x,y}]//TraditionalForm

EllipseDiscriminant[ellipse,{x,y}]

StandardEllipse0[ellipse,{x,y}]

StandardEllipse[ellipse,{x,y}]

Ellipse along x-axis

ellipse=Numerator[Expand[((((x-1))^2)/(2^2))+((y^2)/1)-1]]

EllipsePlot[ellipse,{x,y}]//TraditionalForm

StandardEllipse0[ellipse,{x,y}]

StandardEllipse[ellipse,{x,y}]

Ellipse along y-axis

ellipse=Numerator[Expand[((((x-1))^2)/(1^2))+((y^2)/2)-1]]

EllipsePlot[ellipse,{x,y}]

StandardEllipse0[ellipse,{x,y}]

StandardEllipse[ellipse,{x,y}]

Slightly CW Rotated Major-Axis-Oriented Ellipse

ellipse=Numerator[Expand[((x^2)/(2^2))+((y^2)/1)-1]/.Thread[{x,y}->RotationMatrix[.1].{x,y}]]

ellipse=-1+(1/4) (((x- y/10))^2)+(((1/10 x+y))^2)

EllipsePlot[ellipse,{x,y}]

ContourPlot[ellipse==0,{x,-2,2},{y,-2,2},Epilog->Point[{0,0}],ImageSize->150]

StandardEllipse0[Expand[ellipse],{x,y}]

StandardEllipse[Expand[ellipse],{x,y}]

Slightly CCW Rotated Major-Axis-Oriented Ellipse

ellipse=Numerator[Expand[((x^2)/(2^2))+((y^2)/1)-1]/.Thread[{x,y}->RotationMatrix[-.1].{x,y}]]

ContourPlot[ellipse==0,{x,-2,2},{y,-2,2},Epilog->Point[{0,0}],ImageSize->150]

StandardEllipse0[ellipse,{x,y}]

StandardEllipse[ellipse,{x,y}]

π/2 CCW Rotated Major-Axis-Oriented Ellipse

ellipse=Numerator[Expand[((x^2)/(2^2))+((y^2)/1)-1]/.Thread[{x,y}->RotationMatrix[-π/2].{x,y}]]

ContourPlot[ellipse==0,{x,-2,2},{y,-2,2},Epilog->Point[{0,0}],ImageSize->150]

StandardEllipse0[ellipse,{x,y}]

StandardEllipse[ellipse,{x,y}]

π/2 CW Rotated Major-Axis-Oriented Ellipse

ellipse=Numerator[Expand[((x^2)/(2^2))+((y^2)/1)-1]/.Thread[{x,y}->RotationMatrix[π/2].{x,y}]]

ContourPlot[ellipse==0,{x,-2,2},{y,-2,2},Epilog->Point[{0,0}],ImageSize->150]

StandardEllipse0[ellipse,{x,y}]

StandardEllipse[ellipse,{x,y}]

Slightly CW Rotated Minor-Axis-Oriented Ellipse

ellipse=Numerator[Expand[((x^2)/(1^2))+((y^2)/(2^2))-1]/.Thread[{x,y}->RotationMatrix[.1].{x,y}]]

ContourPlot[ellipse==0,{x,-2,2},{y,-2,2},Epilog->Point[{0,0}],ImageSize->150]

StandardEllipse0[ellipse,{x,y}]

StandardEllipse[ellipse,{x,y}]

Slightly CCW Rotated Minor-Axis-Oriented Ellipse

ellipse=Numerator[Expand[((x^2)/(1^2))+((y^2)/(2^2))-1]/.Thread[{x,y}->RotationMatrix[-.1].{x,y}]]

ContourPlot[ellipse==0,{x,-2,2},{y,-2,2},Epilog->Point[{0,0}],ImageSize->150]

StandardEllipse0[ellipse,{x,y}]

StandardEllipse[ellipse,{x,y}]

Almost π/2 CCW Rotated Minor-Axis-Oriented Ellipse

ellipse=Numerator[Expand[((x^2)/(1^2))+((y^2)/(2^2))-1]/.Thread[{x,y}->RotationMatrix[.1+π/2].{x,y}]]

ContourPlot[ellipse==0,{x,-2,2},{y,-2,2},Epilog->Point[{0,0}],ImageSize->150]

StandardEllipse0[ellipse,{x,y}]

StandardEllipse[ellipse,{x,y}]

Inclined Ellipse

(ellipse=3x^2+2y^2+4x y+4+16y)//N

ContourPlot[ellipse==0,{x,-10,20},{y,-30,10},Epilog->Point[{8,-12}],ImageSize->150]

StandardEllipse0[ellipse,{x,y}]//FullSimplify

N[%]

StandardEllipse[ellipse,{x,y}]//FullSimplify

N[%]

eqn=((((x/(2 (Sqrt[(46/(5+(Sqrt[17])))])))))^2)+((((y/(2 (Sqrt[(46/(5-(Sqrt[17])))])))))^2)/.Thread[{x,y}->RotationMatrix[-(1/2) ArcCot[(1/4)]].{x-8,y+12}]

ContourPlot[eqn==1,{x,-10,20},{y,-30,10},Epilog->Point[{8,-12}],ImageSize->150]

Simplification

StandardEllipse[a x^2+2b x y+c y^2+2d x+2f y+g,{x,y}]//TraditionalForm

StandardEllipse[a x^2+2b x y+c y^2+2d x+2f y+g,{x,y}]//FullSimplify

Simplify[(1/4)Expand[(a+a (Sqrt[1+((4 (b^2))/(((a-c))^2))])+c-(Sqrt[1+((4 (b^2))/(((a-c))^2))]) c) (((a-a (Sqrt[1+((4 (b^2))/(((a-c))^2))])+c+(Sqrt[1+((4 (b^2))/(((a-c))^2))]) c))^2)]]

myell=Ellipse[{((c d-b f)/((b^2)-a c)),((a f-b d)/((b^2)-a c))},{(Sqrt[2]) (Sqrt[((Factor[-2 b d f+a (f^2)+(b^2) g+c ((d^2)-a g)])/(((b^2)-a c) ((c-a)(Sqrt[1+((4 (b^2))/(((a-c))^2))])-(c+a))))]),(Sqrt[2]) (Sqrt[((Factor[-2 b d f+a (f^2)+(b^2) g+c ((d^2)-a g)])/(((b^2)-a c)  ((a-c)(Sqrt[1+((4 (b^2))/(((a-c))^2))])-(c+a))))])},(1/2) ArcCot[((-a+c)/(2 b))]]

(StandardEllipse0[ellipse=-7999600+8385498 x-165104 (x^2)-3836349 y+160804 x y-41651 (y^2),{x,y}]//FullSimplify)/.Sqrt[x_]:>ToRadicals[RootReduce[Sqrt[x]]]//Simplify//N

myell/.Thread[{a,b,c,d,f,g}->{-165104,160804/2,-41651,8385498/2,-3836349 /2,-7999600}]//N

General Form

StandardEllipse0[a x^2+2b x y+c y^2+2d x+2f y+g,{x,y}]//TraditionalForm

ecc=FullSimplify[With[{aa=(Sqrt[2]) (Sqrt[((g (b^2)-2 d f b+c (d^2)+a (f^2)-a c g)/(((b^2)-a c) (-a-c+(Sqrt[((4 (b^2))/(((a-c))^2))+1]) (c-a))))]),bb=(Sqrt[2]) (Sqrt[((g (b^2)-2 d f b+c (d^2)+a (f^2)-a c g)/((-a+(Sqrt[((4 (b^2))/(((a-c))^2))+1]) (a-c)-c) ((b^2)-a c)))])},
Sqrt[1-((bb^2)/(aa^2))]],(a|b|c)∈Reals]

FullSimplify[(Sqrt[1-((Expand[(a+(Sqrt[1+((4 (b^2))/(((a-c))^2))]) (a-c)+c)(a+c-(Sqrt[1+((4 (b^2))/(((a-c))^2))]) (-a+c))])/(Expand[(a+c+(Sqrt[1+((4 (b^2))/(((a-c))^2))]) (-a+c))(a+c-(Sqrt[1+((4 (b^2))/(((a-c))^2))]) (-a+c))]))]),(a|b|c)∈Reals]

Properties

ellipse={a Cos[t],b Sin[t]};

Inequality

ineq[x_,y_]:=x^2/a^2+y^2/b^2≤1

Arc Length Function

v4.2.1

ArcLength[ellipse,t]//Timing

ArcLength[ellipse,t,Assumptions->a>0&&b>0]//Timing

v5.0

ArcLength[ellipse,t]//Timing

ArcLength[ellipse,t,Assumptions->a>0&&b>0]//Timing

ArcLength[ellipse,{t,0,2π},Assumptions->0<b<a]//Timing

v5.1

ArcLength[ellipse,t]

ArcLength[ellipse,t,Assumptions->a>0&&b>0]//Timing

ArcLength[ellipse,t,Assumptions->0<b<a]

ArcLength[ellipse,t,Assumptions->0<b<a&&0<t<2π]

ArcLength[ellipse,t,GenerateConditions->False,Assumptions->0<b<a]//Timing

v5.2

ArcLength[ellipse,t]

ArcLength[ellipse,t,Assumptions->0<b<a]//Timing

ArcLength[ellipse,t,GenerateConditions->False,Assumptions->0<b<a]//Timing

v6

ArcLength[ellipse,t]//Timing

ArcLength[ellipse,t,Assumptions->0<b<a]//Timing

ArcLength[ellipse,t,GenerateConditions->False,Assumptions->0<b<a]//Timing

V6.1

ArcLength[ellipse,t,GenerateConditions->False,Assumptions->0<b<a]//Timing

ArcLength[ellipse,t,GenerateConditions->False,Assumptions->0<a<b]//Timing

ArcLength[ellipse,t,GenerateConditions->False,Assumptions->a>0&&b>0]//Timing

b EllipticE[t,1-((a^2)/(b^2))]/.t->2π

FullSimplify[b EllipticE[1-((a^2)/(b^2))]-a EllipticE[1-((b^2)/(a^2))],a>0&&b>0]

Table[b EllipticE[1-((a^2)/(b^2))]-a EllipticE[1-((b^2)/(a^2))]/.{a->RandomReal[],b->RandomReal[]},{20}]//Chop

Table[b EllipticE[t,1-((a^2)/(b^2))]-a EllipticE[t,1-((b^2)/(a^2))]/.{a->RandomReal[],b->RandomReal[],t->2π RandomReal[]},{20}]

Arc Length

v4.2

ArcLength[ellipse,{t,0,2π},Assumptions->0<b<a]//Timing

4ArcLength[ellipse,{t,0,π/2},Assumptions->0<b<a]//Timing

v5.0.1

ArcLength[ellipse,{t,0,2π},Assumptions->0<b<a]//Timing

4ArcLength[ellipse,{t,0,π/2},Assumptions->0<b<a]//Timing

v5.1

ArcLength[ellipse,{t,0,2π},Assumptions->0<b<a]//Timing

4ArcLength[ellipse,{t,0,π/2},Assumptions->0<b<a]//Timing

Area

Area

Assuming[assum,Area[reg]]

Assuming[assum,Area[implreg]]

Integrate

Assuming[a>0&&b>0,FullSimplify[Area[ineq[x,y],{x,y}]]]//Timing

RegionMeasure

Assuming[assum,RegionMeasure[reg]]

Assuming[assum,RegionMeasure[implreg]]

Area Moment of Inertia

Assuming[a>0&&b>0,FullSimplify[AreaInertiaTensor[ineq[x,y],{x,y}]]]//Timing

Centroid

Integrate

Assuming[a>0&&b>0,FullSimplify[Centroid[ineq[x,y],{x,y}]]]//Timing

RegionCentroid

Assuming[assum,RegionCentroid[reg]]

Assuming[assum,RegionCentroid[implreg]]

Curvature

Parametric

FullSimplify[Curvature[ellipse,t]]

Polar

FullSimplify[Curvature[(a b)/Sqrt[a^2+(b^2-a^2) Cos[q]^2],q],a>0&&b>0&&0<q<2π]

Implciit

SortBy[FullSimplify[Curvature[eqn,{x,y}],a>0&&b>0&&(x|y)∈Reals],ByteCount]

ByteCount/@%

Differential Equation

xy=Numerator[Factor[(((x-x0)^2)/(a^2))+(((y[x]-y0)^2)/(b^2))-1/.{x->c x+s y,y->-s x+c y}]]

eqs=Table[D[xy,{x,i}],{i,0,5}]

gb=GroebnerBasis[Join[eqs,{c^2+s^2-1}],{x,y[x],y'[x],y''[x],y'''[x],y''''[x],y'''''[x]},{x0,y0,a,b},MonomialOrder->EliminationOrder]//InputForm

gb=GroebnerBasis[Join[eqs,{c^2+s^2-1}],{},{x0,y0,a,b,c},MonomialOrder->EliminationOrder]//Factor

(3 ((y''[x])^2) Derivative[3][y][x]+4 y'[x] ((Derivative[3][y][x])^2)-3 y'[x] y''[x] Derivative[4][y][x])//InputForm

RadiiOfGyration

Assuming[a>0&&b>0,FullSimplify[RadiiOfGyration[ineq[x,y],{x,y}]]]//Timing

Slope

Slope[{a Cos[t],b Sin[t]},t]//FullSimplify

Slope[With[{e=Sqrt[1-b^2/a^2]},a (1-e^2)/(1+e Cos[q])],q]//FullSimplify

Slope[x^2/a^2+y^2/b^2==1,{x,y}]//FullSimplify

SpecialAffineCurvature

FullSimplify[SpecialAffineCurvature[ellipse,t],a>0&&b>0]

Tangential Angle

v5

TangentialAngle[ellipse,t,Assumptions->0<b<a&&0<t<π]

FullSimplify[%50,0<b<a&&0<t<π]//Timing

v5.1

TangentialAngle[ellipse,t,Assumptions->0<b<a&&0<t<2π]//Timing

Perimeter

Series

V6

Sum[Binomial[1/2,n]^2  h^n,{n,0,Infinity}]

FullSimplify[%]

V7

Sum[Binomial[1/2,n]^2  h^n,{n,0,Infinity}]

SeriesCoefficient

Series[HypergeometricPFQ[{-(1/2),-(1/2)},{1},h],{h,0,10}]

SeriesCoefficient[Hypergeometric2F1[-(1/2),-(1/2),1,h],{h,0,n}]//InputForm

FullSimplify[%,n≥0&&n∈Integers]

FullSimplify[FunctionExpand[Hypergeometric2F1[-(1/2),-(1/2),1,(h^2)]],n≥0&&n∈Integers]

With[{a=1.3,b=.2},{4b EllipticE[1-a^2/b^2],Pi(a+b)Hypergeometric2F1[-1/2,-1/2,1,((a-b)/(a+b))^2]}]

coef=CoefficientList[Series[HypergeometricPFQ[{-(1/2),-(1/2)},{1},(h^2)],{h,0,20}],h]

{Numerator[coef],Denominator[coef]}

With[{h=((a-b)/(a+b))^2},
		Pi(a+b) HypergeometricPFQ[{-(1/2),-(1/2)},{1},h]
		]//FullSimplify

FullSimplify[FunctionExpand[Pi(a+b) HypergeometricPFQ[{-(1/2),-(1/2)},{1},h]]]

Series[%/(π(a+b)),{h,0,10}]

p[n_,{a_,b_}]:=p[n,a,b]
p[0,a_,b_]:=4b EllipticE[(b^2-a^2)/b^2]
p[1,a_,b_]:=Pi Sqrt[2(a^2+b^2)]
p[2,a_,b_]:=Pi(3(a+b)-Sqrt[(a+3b)(3a+b)])
p[3,a_,b_]:=Module[{t=((a-b)/(a+b))^2},
Pi(a+b)(1+3t/(10+Sqrt[4-3t]))
]

Show[GraphicsArray[Table[Plot3D[p[0,a,b]-p[n,a,b],{a,.01,2},{b,.01,2},DisplayFunction->Identity],
{n,3}]]]

l={{1.,.7},{.5,.3},{2.,.2}};
Table[p[i,l[[j]]],{j,Length[l]},{i,0,4}]

l={{1.,.7},{.5,.3},{2.,.2}};
Table[p[i,l[[j]]],{j,Length[l]},{i,0,4}]

Normal (Sangaku Problem)

pts={ellipse[{1.5,1.},.5],"P",ellipse[{1.5,1.},EllipseNormal[{1.5,1.},.5]],"Q"};
Show[Graphics[{
EllipseNormalPlot[{1.5,1},.5],
PointLabels[pts]
}],AspectRatio->Automatic]

soln=t'/.Solve[(ellipse[{a,b},t']-ellipse[{a,b},t]).D[ellipse[{a,b},t],t]==0,t']

FullSimplify[soln]

PowerExpand[%]

normsq[x_]:=x.x

Simplify[normsq[{a Cos[t],b Sin[t]}-{a Cos[soln[[1]]],b Sin[soln[[1]]]}]]

FullSimplify[PowerExpand[Sqrt[FullSimplify[PowerExpand[Simplify[PowerExpand[((a^2) ((b^4) ((Cos[t])^3)+(1/2) (Sqrt[(b^4) ((Cos[t])^2) ((((a^2)+(b^2)+(-(a^2)+(b^2)) Cos[2 t]))^2)])+(a^2) (b^2) Cos[t] ((Sin[t])^2))^2)/((((b^4) ((Cos[t])^2)+(a^4) ((Sin[t])^2)))^2)+(b^2) (Sin[t]+√Together[(1-(√((b^4) ((Cos[t])^2) ((((a^2)+(b^2)+(-(a^2)+(b^2)) Cos[2 t]))^2))-2 (a^2) ((a^2)-(b^2)) Cos[t] ((Sin[t])^2))^2/(4 ((((b^4) ((Cos[t])^2)+(a^4) ((Sin[t])^2)))^2)))])^2]]]]]]]

d[1,{a_,b_},t_]:=((Sqrt[2]) (b^2) Cos[t] √(((a^2)+(b^2)) (3 (a^4)+(b^4)-4 (a^2) (a-b) (a+b) Cos[2 t])+((((a^2)-(b^2)))^3) Cos[4 t]))/((a^4)+(b^4)+(-(a^4)+(b^4)) Cos[2 t])

Simplify[PowerExpand//@normsq[{a Cos[t],b Sin[t]}-{a Cos[soln[[2]]],b Sin[soln[[2]]]}]]

FullSimplify[PowerExpand[Sqrt[FullSimplify[PowerExpand[Simplify[PowerExpand[((a^2) ((b^4) ((Cos[t])^3)+(1/2) (Sqrt[(b^4) ((Cos[t])^2) ((((a^2)+(b^2)+(-(a^2)+(b^2)) Cos[2 t]))^2)])+(a^2) (b^2) Cos[t] ((Sin[t])^2))^2)/((((b^4) ((Cos[t])^2)+(a^4) ((Sin[t])^2)))^2)+(b^2) (Sin[t]-√Together[(1-(√((b^4) ((Cos[t])^2) ((((a^2)+(b^2)+(-(a^2)+(b^2)) Cos[2 t]))^2))-2 (a^2) ((a^2)-(b^2)) Cos[t] ((Sin[t])^2))^2/(4 ((((b^4) ((Cos[t])^2)+(a^4) ((Sin[t])^2)))^2)))])^2]]]]]]]

d[2,{a_,b_},t_]:=(((Sqrt[2]) a b ((((a^2)+(b^2)+(-(a^2)+(b^2)) Cos[2 t]))^(3/2)))/((a^4)+(b^4)+(-(a^4)+(b^4)) Cos[2 t]))

Simplify[PowerExpand//@normsq[{a Cos[t],b Sin[t]}-{a Cos[soln[[3]]],b Sin[soln[[3]]]}]]

FullSimplify[PowerExpand[Sqrt[FullSimplify[PowerExpand[Simplify[PowerExpand[((a^2) (-2 (b^4) ((Cos[t])^3)+(Sqrt[(b^4) ((Cos[t])^2) ((((a^2)+(b^2)+(-(a^2)+(b^2)) Cos[2 t]))^2)])-2 (a^2) (b^2) Cos[t] ((Sin[t])^2))^2)/(4 ((((b^4) ((Cos[t])^2)+(a^4) ((Sin[t])^2)))^2))+(b^2) (Sin[t]+√Together[(1-(√((b^4) ((Cos[t])^2) ((((a^2)+(b^2)+(-(a^2)+(b^2)) Cos[2 t]))^2))+2 (a^2) ((a^2)-(b^2)) Cos[t] ((Sin[t])^2))^2/(4 ((((b^4) ((Cos[t])^2)+(a^4) ((Sin[t])^2)))^2)))])^2]]]]]]]

d[3,{a_,b_},t_]:=2 b Sin[t]

Simplify[PowerExpand//@normsq[{a Cos[t],b Sin[t]}-{a Cos[soln[[4]]],b Sin[soln[[4]]]}]]

FullSimplify[PowerExpand[Sqrt[FullSimplify[PowerExpand[Simplify[PowerExpand[((a^2) (-2 (b^4) ((Cos[t])^3)+(Sqrt[(b^4) ((Cos[t])^2) ((((a^2)+(b^2)+(-(a^2)+(b^2)) Cos[2 t]))^2)])-2 (a^2) (b^2) Cos[t] ((Sin[t])^2))^2)/(4 ((((b^4) ((Cos[t])^2)+(a^4) ((Sin[t])^2)))^2))+(b^2) (Sin[t]-√Together[(1-(√((b^4) ((Cos[t])^2) ((((a^2)+(b^2)+(-(a^2)+(b^2)) Cos[2 t]))^2))+2 (a^2) ((a^2)-(b^2)) Cos[t] ((Sin[t])^2))^2/(4 ((((b^4) ((Cos[t])^2)+(a^4) ((Sin[t])^2)))^2)))])^2]]]]]]]

d[4,{a_,b_},t_]:=0

d[0,{a_,b_},t_]:=EllipseNormalDistance[{a,b},t]

d[5,{a_,b_},t_]:=2a b(a^2 Sin[t]^2+b^2 Cos[t]^2)^(3/2)/(a^4 Sin[t]^2+b^4 Cos[t]^2)

Table[d[n,{a,b},t],{n,1,5}]

Table[d[n,{1.5,1},0.0],{n,0,5}]

Table[d[n,{1.5,1},.5],{n,0,5}]

Table[d[n,{1.5,1},1.],{n,0,5}]

Table[d[n,{1.5,1},2.],{n,0,5}]

Table[d[n,{1,1},0.001],{n,0,5}]

Table[d[n,{1,1},Pi/2.],{n,0,5}]

d[2,{a,b},t]

d[5,{a,b},t]

Simplify[d[2,{a,b},t]-d[5,{a,b},t]]

D[d[2,{a,b},t],t]

Factor[Together[D[d[5,{a,b},t],t]]]

Simplify[-(2 a b (-a+b) (a+b) Cos[t] Sin[t] (Sqrt[(b^2) ((Cos[t])^2)+(a^2) ((Sin[t])^2)]) (-2 (a^2) (b^2) +(b^4) ((Cos[t])^2)+(a^4) ((Sin[t])^2)))/((((b^4) ((Cos[t])^2)+(a^4) ((Sin[t])^2)))^2)]

x/.FullSimplify[Solve[(-2 (a^2) (b^2)+(b^4) x+(a^4) (1-x))==0,x]][[1,1]]

Simplify[Together[1-((((a^4)-2 (a^2) (b^2))/((a^4)-(b^4))))]]

Simplify[PowerExpand[Together[d[5,{a,b},t] /. {Cos[t]^2->(((a^4)-2 (a^2) (b^2))/((a^4)-(b^4))),Sin[t]^2->((2 (a^2) (b^2)-(b^4))/((a^4)-(b^4)))}]]]

Rotated Ellipse

TiltedEllipse[b_,ang_]:=ParametricPlot[
	Evaluate[{{Cos[ang],Sin[ang]},{-Sin[ang],Cos[ang]}}.{ Cos[t],b Sin[t]}],{t,0,2Pi},Ticks->None,DisplayFunction->Identity]

Show[GraphicsArray[{
TiltedEllipse[.5,0],TiltedEllipse[.5,.2]}]]

Tangent and Normal Vectors

TangentVector[{a Cos[t],b Sin[t]},t]

Simplify[{a Cos[t],b Sin[t]}+TangentVector[{a Cos[t],b Sin[t]},t]]

Simplify[{a Cos[t],b Sin[t]}+NormalVector[{a Cos[t],b Sin[t]},t]]

NormalTangentPlot[{Cos[t],.6Sin[t]},{t,0,2Pi,Pi/16},2]

Vector Properties

VectorLength

parm ={a Cos[t],b Sin[t]};

Assuming[a>0&&b>0&&t∈Reals,FullSimplify[Norm[parm]]]/.Abs[x_]^(n_/;Mod[n,2]==0):>x^n

NormalVector

Assuming[a>0&&b>0&&t∈Reals,FullSimplify[NormalVector[parm,t]]]/.Abs[x_]^(n_/;Mod[n,2]==0):>x^n

TangentVector

Assuming[a>0&&b>0&&t∈Reals,FullSimplify[TangentVector[parm,t]]]/.Abs[x_]^(n_/;Mod[n,2]==0):>x^n

Visualization

With[{a=1,b=1.5},Manipulate[
Show[{
ParametricPlot[{a Cos[t],b Sin[t]},{t,0,2π},Method->{"AxesInFront"->False}],
Graphics[{
Red,Arrow[{{a Cos[t],b Sin[t]},{a Cos[t],b Sin[t]}+{-((b Cos[t])/(Sqrt[(b^2) ((Cos[t])^2)+(a^2) ((Sin[t])^2)])),-((a Sin[t])/(Sqrt[(b^2) ((Cos[t])^2)+(a^2) ((Sin[t])^2)]))}}],
Blue,Arrow[{{a Cos[t],b Sin[t]},{a Cos[t],b Sin[t]}+{-((a Sin[t])/(Sqrt[(b^2) ((Cos[t])^2)+(a^2) ((Sin[t])^2)])),((b Cos[t])/(Sqrt[(b^2) ((Cos[t])^2)+(a^2) ((Sin[t])^2)]))}}]
}]
},PlotRange->2],{{t,0},0,2π}
]]