Conic sections are curves created by the intersection of a plane and a cone. There are six types of conic section: the circle, ellipse, hyperbola, parabola, a pair of intersecting straight lines and a single point.
All conics (as they are known) have at least two foci, although the two may coincide or one may be at infinity. They may also be defined as the locus of a point moving between a point and a line, a directrix, such that the ratio between the distances is constant. This ratio is known as "e", or eccentricity.
Animation showing distance from the foci of an ellipse to several different points on the ellipse.
An ellipse is a locus where the sum of the distances to two foci is kept constant. This sum is also equivalent to the major axis of the ellipse - the major axis being longer of the two lines of symmetry of the ellipse, running through both foci. The eccentricity of an ellipse is less than one.
In Cartesian coordinates, if an ellipse is centered at (h,k), the equation for the ellipse is
(equation 1)
The lengths of the major and minor axes (also known as the conjugate and transverse) are "a" and "b" respectively.
A circle circumscribed about the ellipse, touching at the two end points of the major axis, is known as the auxiliary circle. The latus rectum of an ellipse passes through the foci and is perpendicular to the major axis.
From a point P(, ) tangents will have the equation:
S and S' are typically regarded as the two foci of the ellipse. Where , these become (ae, 0) and (-ae, 0) respectively. Where these become (0, be) and (0, -be) respectively.
A point P on the ellipse will move about these two foci ut
Where a > b, which is to say the Ellipse will have a major-axes parallel to the x-axis:
Figure 1: Hyperbola at origin with transverse axis horizontal.
Origin at point . Foci are points Vertices are points Line segment is the
In cartesian geometry in two dimensions hyperbola is locus of a point that moves relative to two fixed points called
The distance from one to the other is non-zero. The absolute difference of the distances from point to foci is constant.
See figure 1.
Center of hyperbola is located at the origin and the foci are on the
at distance from
has coordinates has coordinates . Line segments
Each point where the curve intersects the transverse axis is called a are the vertices of the ellipse.
# python codeimportdecimaldD=decimal.Decimal# Decimal object is like float with (almost) infinite precision.dgt=decimal.getcontext()Precision=dgt.prec=28# Adjust as necessary.Tolerance=dD("1e-"+str(Precision-2))# Adjust as necessary.# # sum_zero(input) is function that calculates sum of all values in input.# However, if sum is non-zero but very close to 0 and Tolerance permits,# sum is returned as 0.# For example sum of (2, -1.99999_99999_99999_99999_99999_99) is# returned as 0.#defhyperbola_ABCF(a,pq,flag=0):'''Ax^2 + By^2 + Cxy + Dx + Ey + F = 0for hyperbola at origin, D = E = 0.ABCF = hyperbola_ABCF( a, pq [, flag] )(2)a is length of transverse axis.(p,q) are one focus. Other focus is (-p,-q) '''thisName='hyperbola_ABCF(a,pq, {}) :'.format(bool(flag))p,q=pqa,p,q=[dD(str(v))forvin(a,p,q)]ifa==0:print(thisName)print(' For hyperbola, a must be non-zero.')returnNoneaa,pp,qq=a**2,p**2,q**2cc=pp+qq# c = cc.sqrt() and (2)c is distance between foci.ifcc>aa:passelse:print(thisName)print(' For hyperbola, c must be > a.')returnNoneA=aa-ppB=aa-qqC=-2*p*q# F = aa*( pp + qq - aa )F=aa*(cc-aa)# F = aa*bbifflag:# Print results:str1='({})x^2 + ({})y^2 + ({})xy + ({}) = 0'str2=str1.format(A,B,C,F)print(str2)# Equation of small circle, used to display points on grapher.str3='({},{}) (x - ({}))^2 + (y - ({}))^2 = 1'print(' F1:',str3.format(p,q,p,q))print(' F2:',str3.format(-p,-q,-p,-q))print(' axis: ({})y = ({})x'.format(p,q))print(' aa,a =',aa,a)bb=cc-aa;b=bb.sqrt()print(' bb,b =',bb,b)c=cc.sqrt()print(' cc,c =',cc,c)ifC==0:# Display intercept form of equation.ifF>0:A,B,C,F=[-vforvin(A,B,C,F)]str1a='({})x^2 + ({})y^2 + ({}) = 0'str4=str1a.format(A,B,F)print(' ',str4)if(A==bb)and(B==-aa):# (225)x^2 + (-400)y^2 + (-90000) = 0str5='xx/(({})^2) - yy/(({})^2) = 1'top1_='x^2';top2_='y^2'elif(A==-aa)and(B==bb):# (-400)x^2 + (225)y^2 + (-90000) = 0str5='yy/(({})^2) - xx/(({})^2) = 1'top1_='y^2';top2_='x^2'else:({}[2])str6=str5.format(a,b)print(' ',str6)str5='\\frac{{ {} }}{{ {}^2 }} - \\frac{{ {} }}{{ {}^2 }} = 1'print(' ','<math>',str5.format(top1_,a,top2_,b),'</math>')bottom1,bottom2=['({})^2'.format(v)forvin(a,b)]len1,len2=[len(v)forvin(bottom1,bottom2)]len1a=(len1-3)>>1;len1b=(len1-3)-len1alen2a=(len2-3)>>1;len2b=(len2-3)-len2atop1='{}{}{}'.format(' '*len1a,top1_,' '*len1b)top2='{}{}'.format(' '*len2a,top2_)print(' ',top1,' ',top2)print(' ','-'*len1,'-','-'*len2,'= 1')print(' ',bottom1,' ',bottom2)returnA,B,C,F
The expression "reversing the process" means calculating the values of when given
equation of hyperbola at origin, the familiar values
Consider the equation of a hyperbola at origin:
This is a hyperbola where
This hyperbola may be expressed as
or
or where is any real, non-zero number.
However, when this hyperbola is expressed as this format is the hyperbola expressed in "standard form,"
a notation that greatly simplifies the calculation of
Modify the equations for slightly:
There are four simultaneous equations with four known values and four unknown:
# python codedefhyperbola_a_pq(ABCF,flag=0):'''Ax^2 + By^2 + Cxy + Dx + Ey + F = 0Here D = E = 0.a,(p,q) = hyperbola_a_pq (ABCF [, flag])ABCF implies hyperbola with center at origin (0,0).if flag : print info about hyperbola. '''thisName='hyperbola_a_pq (ABCF, {}) :'.format(bool(flag))A1,B1,C1,F1=[dD(str(v))forvinABCF]K=4*F1/(C1**2-4*A1*B1)A,B,C,F=[K*vforvin(A1,B1,C1,F1)]# Standard form.# # A = aa - pp ; pp = aa-A# B = aa - qq ; qq = aa - B# F = aa(pp + qq - aa)# F = aa((aa-A) + (aa-B) - aa)# F = aaaa-aaA + aaaa-aaB - aaaa# F = aaaa - aaA - aaB# aaaa - aaA - aaB - F = 0# aaaa -(A + B)aa - F = 0# # We have a quadratic function in aa.# (a_)(aa)(aa) + (b_)(aa) + (c_) = 0# Coefficients of quadratic function:a_,b_,c_=1,-(A+B),-Fdiscr=b_**2-4*a_*c_root=discr.sqrt()aa,X=(-b_+root)/2,(-b_-root)/2# X positive: ellipse# X negative: hyperbolaifX<0:passelse:print(thisName)print(' For hyperbola, X must be < 0. ',)returnNonea=aa.sqrt();pp=aa-A;p=pp.sqrt()ifp:q=-C/(2*p)else:qq=aa-B;q=qq.sqrt()ifflag:# Print results.print()print(thisName)str1='({})x^2 + ({})y^2 + ({})xy + ({}) = 0'str2=str1.format(A1,B1,C1,F1)print(str2)ifK!=1:str2a=str1.format(A,B,C,F)print(str2a,'Standard form.')str3='({}, {}) (x - ({}))^2 + (y - ({}))^2 = 1'print(' F1:',str3.format(p,q,p,q))print(' F2:',str3.format(-p,-q,-p,-q))cc=pp+q**2;c=cc.sqrt()bb=cc-aa;b=bb.sqrt()forxin'K A B C F X a b c'.split():print(' ',x,'=',eval(x))returna,(p,q)
Proving that . Graph is part of curve At point distance to Directrix2 base =
As expressed above in statement second definition of hyperbola states that hyperbola is path of point that moves so that ratio of distance to
fixed point and distance to fixed line is constant.
This section proves that this definition is true for any point on hyperbola.
At point
base
Similar calculations can be used to prove the case for Focus1 and Directrix1
in which case:
Therefore: where
Second definition of hyperbola has been proven valid:
Hyperbola is path of point that moves so that ratio of distance to fixed point and distance to fixed line is constant,
called eccentricity
To calculate the general equation three values must be known:
Focus1
Focus2
Length of transverse axis or two_a.
Calculate center of hyperbola
Calculate
Calculate equation of hyperbola at origin
Move hyperbola from origin to point
# python codedefhyperbola_ABCDEF(two_a,F1,F2,flag=0):'''Ax^2 + By^2 + Cxy + Dx + Ey + F = 0A,B,C,D,E,F = hyperbola_ABCDEF (two_a, F1, F2 [, flag])two_a is length of transverse axisF1 is Focus1: (F1x,F1y)F2 is Focus2: (F2x,F2y)if flag : print info about hyperbola. '''thisName='hyperbola_ABCDEF (two_a, F1, F2, {}) :'.format(bool(flag))F1x,F1y=F1;F2x,F2y=F2two_a,F1x,F1y,F2x,F2y=[dD(str(v))forvin(two_a,F1x,F1y,F2x,F2y)]a=two_a/2ifa==0:print(thisName)print(' For hyperbola a must be non-zero.')returnNoneG=(F1x+F2x)/2;H=(F1y+F2y)/2p=F2x-G;q=F2y-Haa,pp,qq=a**2,p**2,q**2cc=pp+qqifcc>aa:passelse:print(thisName)print(' For hyperbola c must be greater than a.')returnNoneA00,B00,C00,F00=hyperbola_ABCF(a,(p,q))# Hyperbola at origin.A,B,C,D,E,F=move_section_relative((A00,B00,C00,0,0,F00),(G,H))({A==A00,B==B00,C==C00}=={True})or({}[2])ifflag:print()print(thisName)str1='({})x^2 + ({})y^2 + ({})xy + ({})x + ({})y + ({}) = 0'print(str1.format(A,B,C,D,E,F))print(' ',str1.format(A,B,C,0,0,F00))str3='({},{}) (x - ({}))^2 + (y - ({}))^2 = 1'print(' F1:',str3.format(F1x,F1y,F1x,F1y))print(' F2:',str3.format(F2x,F2y,F2x,F2y))print(' GH:',str3.format(G,H,G,H))print(' f1:',str3.format(p,q,p,q))print(' f2:',str3.format(-p,-q,-p,-q))bb=cc-aab=bb.sqrt();c=cc.sqrt()print(' a =',a)print(' b =',b)print(' c =',c)print(' eccentricity e =',c/a)# Axis:Dx=F1x-F2x;Dy=F1y-F2y# Dy x - Dx y + c = 0a,b=Dy,-Dx# ax + by + c = 0c=-(a*F1x+b*F1y)print(' axis: ({})x + ({})y + ({}) = 0'.format(a,b,c))returnA,B,C,D,E,F
The expression "reversing the process" means calculating the values of and length of transverse axis
when given
equation of general hyperbola, the familiar values
Graph of hyperbola where . Blue lines are asymptotes of hyperbola. Hyperbola and asymptotes do not intersect. Any line parallel to asymptote intersects hyperbola in exactly one place.
We are familiar with values where:
Length of transverse axis
Distance between foci
And we have said: Let What is ?
Value defines the
In diagram, line segment is conjugate axis with length
Box at origin with length and width contains two special lines (blue lines) called
Let asymptote1 have equation
Hyperbola has equation
Calculate point of intersection of
From
Substitute for in
This does not make sense. There is no real point of intersection of
Let any line parallel to asymptote have equation:
Calculate point of intersection of
Provided that are non-zero, is a real number.
Asymptote is line whose position is as close as possible to hyperbola (both sides) without touching it.
Any line parallel to asymptote intersects hyperbola in exactly one place.
# python codedefhyperbola_and_line(ABCDEF,line_abc,flag=0):'''This function calculates point/s of intersection (if any) of hyperbola and line.hyperbola is: Ax^2 + By^2 + Cxy + Dx + Ey + F = 0line is: ax + by + c = 0To invoke:[] = hyperbola_and_line (ABCDEF, line_abc[, flag]) [point1] = hyperbola_and_line (ABCDEF, line_abc[, flag]) [point1,point2] = hyperbola_and_line (ABCDEF, line_abc[, flag])if line is asymptote or parallel to asymptote, output is type tuple.if flag : check results.if flag==2 : print results. '''(2>=flag>=0)or({}[1])thisName='hyperbola_and_line (ABCDEF, line_abc, {}) :'.format(flag)a,b,c=[dD(str(v))forvinline_abc]# a,b,c refer to line ax + by + c = 0.ifa==b==0:print(thisName)print(' At least one of a,b must be non-zero.')returnNoneA,B,C,D,E,F=[dD(str(v))forvinABCDEF]output=[]ifb==0:# Reverse x,y going in.result=hyperbola_and_line((B,A,C,E,D,F),(b,a,c))# Reverse x,y coming out.output=(type(result))([v[::-1]forvinresult])# output is same type as result.else:# Axx + Byy + Cxy + Dx + Ey + F = 0# ax + by + c = 0 ; by = (- (ax + c))# Multiply equation of hyperbola by bb:# Abbxx + Bbyby + Cxbby + Dbbx + Ebby + Fbb = 0# For 'by' substitute '(- (ax + c))'.# Abbxx + B(-(ax+c))(-(ax+c)) + Cxb(-(ax+c)) + Dbbx + Eb(-(ax+c)) + Fbb = 0# Expand and result is quadratic function in x, (a_)xx + (b_)x + (c_) = 0 wherea_=A*b*b,+B*a*a,-C*a*bb_=B*2*a*c,+D*b*b,-C*b*c,-E*b*ac_=B*c*c,+F*b*b,-E*b*ca_,b_,c_=[sum_zero(v)forvin(a_,b_,c_)]while1:ifa_==0:# Line is parallel to asymptote.# values_of_x is of type tuple.ifb_==0:# Line is asymptote. Return empty tuple.values_of_x=tuple([]);breakvalues_of_x=(-c_/b_,);break# values_of_x is of type list.two_a=2*a_;discr=sum_zero((b_**2,-4*a_*c_))ifdiscr==0:# discr is 0 or very close to 0.values_of_x=[-b_/two_a];breakifdiscr<0:values_of_x=[];breakroot=discr.sqrt()values_of_x=[(-b_-root)/two_a,(-b_+root)/two_a];breakforxinvalues_of_x:by=-(a*x+c);y=by/b# Here is why b must be non-zero.output+=[(x,y)]# output is same type as values_of_x.output=(type(values_of_x))(output)ifflag:# Check results.errors=[]forx,yinoutput:sum1=sum_zero((A*x**2,B*y**2,C*x*y,D*x,E*y,F))ifsum1:errors+=['bad sum1: {} for point ({},{})'.format(sum1,x,y)]sum2=sum_zero((a*x,b*y,c))ifsum2:errors+=['bad sum2: {} for point ({},{})'.format(sum2,x,y)]iferrorsor(flag==2):# Print results.print()print(thisName)str1='({})x^2 + ({})y^2 + ({})xy + ({})x + ({})y + ({}) = 0'print(str1.format(A,B,C,D,E,F))str3='({})x + ({})y + ({}) = 0'.format(a,b,c)print(str3)print('ABCDEF = A,B,C,D,E,F = {}, {}, {}, {}, {}, {}'.format(A,B,C,D,E,F))print('abc = a,b,c = {}, {}, {}'.format(a,b,c))str4='output[{}]: ({},{}), (x - ({}))^2 + (y - ({}))^2 = 1'forpinrange(0,len(output)):x,y=output[p]print(' ',str4.format(p,x,y,x,y))forvinerrors:print(' ',v)# output may be empty: [] or (). () means asymptote.# or output may contain one point:# [ (x1,y1) ] or ( (x1,y1), ). ( (x1,y1), ) means line is parallel to asymptote.# or output may contain two points: [ (x1,y1), (x2,y2) ]returnoutput
Diagram of hyperbola and two lines. Each line and hyperbola have one common point. Line 1 (blue) is parallel to asymptote. Line 2 (orange) is not parallel to asymptote.
Diagram of hyperbola and line. Line and hyperbola have two common points. When line and hyperbola have two common points, line cannot be parallel to asymptote.
Within the two dimensional space of Cartesian Coordinate Geometry a conic section may be located anywhere
and have any orientation.
This section examines the parabola, ellipse and hyperbola, showing how to calculate the equation of
the conic section, and also how to calculate the foci and directrices given the equation.
The curve is defined as a point whose distance to the focus and distance to a line, the directrix,
have a fixed ratio, eccentricity Distance from focus to directrix must be non-zero.
Let the point have coordinates
Let the focus have coordinates
Let the directrix have equation where
Then
Square both sides:
Rearrange:
Expand simplify, gather like terms and result is:
where:
Note that values depend on:
non-zero. This method is not suitable for circle where
Sign of is not significant.
or and produce same result.
For example, directrix and directrix
produce same result.
# python codeimportdecimaldD=decimal.Decimal# Decimal object is like a float with (almost) unlimited precision.dgt=decimal.getcontext()Precision=dgt.prec=22defreduce_Decimal_number(number):# This function improves appearance of numbers.# The technique used here is to perform the calculations using precision of 22,# then convert to float or int to display result.# -1e-22 becomes 0.# 12.34999999999999999999 becomes 12.35# -1.000000000000000000001 becomes -1.# 1E+1 becomes 10.# 0.3333333333333333333333 is unchanged.#thisName='reduce_Decimal_number(number) :'iftype(number)!=dD:number=dD(str(number))f1=float(number)if(f1+1)==1:returndD(0)ifint(f1)==f1:returndD(int(f1))dD1=dD(str(f1))t1=dD1.normalize().as_tuple()if(len(t1[1])<12):# if number == 12.34999999999999999999, dD1 = 12.35returndD1returnnumberdefABCDEF_from_abc_epq(abc,epq,flag=0):'''ABCDEF = ABCDEF_from_abc_epq (abc,epq[,flag]) '''thisName='ABCDEF_from_abc_epq (abc,epq, {}) :'.format(bool(flag))a,b,c=[dD(str(v))forvinabc]e,p,q=[dD(str(v))forvinepq]divider=a**2+b**2ifdivider==0:print(thisName,'At least one of (a,b) must be non-zero.')returnNoneifdivider!=1:root=divider.sqrt()a,b,c=[(v/root)forvin(a,b,c)]distance_from_focus_to_directrix=a*p+b*q+cifdistance_from_focus_to_directrix==0:print(thisName,'distance_from_focus_to_directrix must be non-zero.')returnNoneX=e*eA=X*a**2-1B=X*b**2-1C=2*X*a*bD=2*p+2*X*a*cE=2*q+2*X*b*cF=X*c**2-p*p-q*qA,B,C,D,E,F=[reduce_Decimal_number(v)forvin(A,B,C,D,E,F)]ifflag:print(thisName)str1='({})x^2 + ({})y^2 + ({})xy + ({})x + ({})y + ({}) = 0'.format(A,B,C,D,E,F)print(' ',str1)return(A,B,C,D,E,F)
Quadratic function complies with definition of parabola. Distance from point to focus = distance from point to directrix = 10. Distance from point to focus = distance from point to directrix = 1.
For a quick check select some random points on the curve:
# python codeforxin(-2,4,6):y=x**2/4print('\nFrom point ({}, {}):'.format(x,y))distance_to_focus=((x-p)**2+(y-q)**2)**.5distance_to_directrix=a*x+b*y+cs1='distance_to_focus';print(s1,eval(s1))s1='distance_to_directrix';print(s1,eval(s1))
From point (-2, 1.0):
distance_to_focus 2.0
distance_to_directrix 2.0
From point (4, 4.0):
distance_to_focus 5.0
distance_to_directrix 5.0
From point (6, 9.0):
distance_to_focus 10.0
distance_to_directrix 10.0
# python codepoints=((-4,0),(-3.5,-1.875),(3.5,1.875),(-1,3.75),(1,-3.75),)A,B,F=-0.9375,-1,15for(x,y)inpoints:# Verify that point is on curve.(A*x**2+B*y**2+F)and1/0# Create exception if sum != 0.distance_to_focus=((x-p)**2+(y-q)**2)**.5distance_to_directrix=a*x+b*y+ce=distance_to_focus/distance_to_directrixs1='x,y';print(s1,eval(s1))s1=' distance_to_focus, distance_to_directrix, e';print(s1,eval(s1))
x,y (-4, 0)
distance_to_focus, distance_to_directrix, e (3.0, 12, 0.25)
x,y (-3.5, -1.875)
distance_to_focus, distance_to_directrix, e (3.125, 12.5, 0.25)
x,y (3.5, 1.875)
distance_to_focus, distance_to_directrix, e (4.875, 19.5, 0.25)
x,y (-1, 3.75)
distance_to_focus, distance_to_directrix, e (3.75, 15.0, 0.25)
x,y (1, -3.75)
distance_to_focus, distance_to_directrix, e (4.25, 17.0, 0.25)
Ellipses with ecccentricities from 0.1 to 0.9. As eccentricity approaches shape of ellipse approaches shape of circle. As eccentricity approaches shape of ellipse approaches shape of parabola.
The effect of eccentricity.
All ellipses in diagram have:
Focus at point
Directrix with equation
Five ellipses are shown with eccentricities varying from to
# python codefour_points=pt1,pt2,pt3,pt4=(-7.5,9),(-7.5,-9),(22.5,21),(22.5,-21)for(x,y)infour_points:# Verify that point is on curve.sum=1.25*y**2-x**2-45sumand1/0# Create exception if sum != 0.distance_to_focus=((x-p)**2+(y-q)**2)**.5distance_to_directrix=a*x+b*y+ce=distance_to_focus/distance_to_directrixs1='x,y';print(s1,eval(s1))s1=' distance_to_focus, distance_to_directrix, e';print(s1,eval(s1))
x,y (-7.5, 9)
distance_to_focus, distance_to_directrix, e (19.5, 13.0, 1.5)
x,y (-7.5, -9)
distance_to_focus, distance_to_directrix, e (7.5, -5.0, -1.5)
x,y (22.5, 21)
distance_to_focus, distance_to_directrix, e (37.5, 25.0, 1.5)
x,y (22.5, -21)
distance_to_focus, distance_to_directrix, e (25.5, -17.0, -1.5)
Hyperbolas with ecccentricities from 1.5 to 20. As eccentricity increases, curve approaches directrix: As eccentricity approaches shape of curve approaches shape of parabola.
The effect of eccentricity.
All hyperbolas in diagram have:
Focus at point
Directrix with equation
Six hyperbolas are shown with eccentricities varying from to
The expression "reversing the process" means calculating the values of focus and directrix when given
the equation of the conic section, the familiar values
Consider the equation of a simple ellipse:
This is a conic section where
This ellipse may be expressed as a format more appealing to the eye
than numbers containing fractions or decimals.
However, when this ellipse is expressed as this format is the ellipse expressed in "standard form,"
a notation that greatly simplifies the calculation of
Modify the equations for slightly:
or
or
In substitute for
is a quadratic equation in where:
Because is a quadratic equation, the solution of may contain an unwanted value of
that will be eliminated later.
# python codedefsolve_quadratic(abc):'''result = solve_quadratic (abc)result may be : [] [ root1 ] [ root1, root2 ]'''a,b,c=abcifa==0:return[-c/b]disc=b**2-4*a*cifdisc<0:return[]two_a=2*aifdisc==0:return[-b/two_a]root=disc.sqrt()r1,r2=(-b-root)/two_a,(-b+root)/two_areturn[r1,r2]defcalculate_Kab(ABC,flag=0):'''result = calculate_Kab (ABC)result may be : [] [tuple1] [tuple1,tuple2]'''thisName='calculate_Kab (ABC, {}) :'.format(bool(flag))A_,B_,C_=[dD(str(v))forvinABC]# Quadratic function in K: (a_)K**2 + (b_)K + (c_) = 0a_=4*A_*B_-C_*C_b_=4*(A_+B_)c_=4values_of_K=solve_quadratic((a_,b_,c_))ifflag:print(thisName)str1=' A_,B_,C_';print(str1,eval(str1))str1=' a_,b_,c_';print(str1,eval(str1))print(' y = ({})x^2 + ({})x + ({})'.format(float(a_),float(b_),float(c_)))str1=' values_of_K';print(str1,eval(str1))output=[]forKinvalues_of_K:A,B,C=[reduce_Decimal_number(v*K)forvin(A_,B_,C_)]X=A+B+2ifX<=0:# Here is one place where the spurious value of K may be eliminated.ifflag:print(' K = {}, X = {}, continuing.'.format(K,X))continueaa=reduce_Decimal_number((A+1)/X)ifflag:print(' K =',K)forstrxin('A','B','C','X','aa'):print(' ',strx,eval(strx))ifaa==0:a=dD(0);b=dD(1)else:a=aa.sqrt();b=C/(2*X*a)Kab=[reduce_Decimal_number(v)forvin(K,a,b)]output+=[Kab]ifflag:print(thisName)fortinrange(0,len(output)):str1=' output[{}] = {}'.format(t,output[t])print(str1)returnoutput
# python codedefcompare_ABCDEF1_ABCDEF2(ABCDEF1,ABCDEF2):'''status = compare_ABCDEF1_ABCDEF2 (ABCDEF1, ABCDEF2)This function compares the two conic sections."0.75x^2 + y^2 + 3 = 0" and "3x^2 + 4y^2 + 12 = 0" compare as equal."0.75x^2 + y^2 + 3 = 0" and "3x^2 + 4y^2 + 10 = 0" compare as not equal.(0.24304)x^2 + (1.49296)y^2 + (-4.28544)xy + (159.3152)x + (-85.1136)y + (2858.944) = 0 and(-0.0784)x^2 + (-0.4816)y^2 + (1.3824)xy + (-51.392)x + (27.456)y + (-922.24) = 0 are verified as the same curve.>>> abcdef1 = (0.24304, 1.49296, -4.28544, 159.3152, -85.1136, 2858.944)>>> abcdef2 = (-0.0784, -0.4816, 1.3824, -51.392, 27.456, -922.24)>>> [ (v[0]/v[1]) for v in zip(abcdef1, abcdef2) ][-3.1, -3.1, -3.1, -3.1, -3.1, -3.1]set ([-3.1, -3.1, -3.1, -3.1, -3.1, -3.1]) = {-3.1}'''thisName='compare_ABCDEF1_ABCDEF2 (ABCDEF1, ABCDEF2) :'# For each value in ABCDEF1, ABCDEF2, both value1 and value2 must be 0# or both value1 and value2 must be non-zero.forv1,v2inzip(ABCDEF1,ABCDEF2):status=(bool(v1)==bool(v2))ifnotstatus:print(thisName)print(' mismatch:',v1,v2)returnstatus# Results of v1/v2 must all be the same.set1={(v1/v2)for(v1,v2)inzip(ABCDEF1,ABCDEF2)ifv2}status=(len(set1)==1)ifstatus:quotient,=list(set1)else:quotient='??'L1=[];L2=[];L3=[]forminrange(0,6):bottom=ABCDEF2[m]ifnotbottom:continuetop=ABCDEF1[m]L1+=[str(top)];L3+=[str(bottom)]forminrange(0,len(L1)):L2+=[(sorted([len(v)forvin(L1[m],L3[m])]))[-1]]# maximum value.forminrange(0,len(L1)):max=L2[m]L1[m]=((' '*max)+L1[m])[-max:]# string right justified.L2[m]=('-'*max)L3[m]=((' '*max)+L3[m])[-max:]# string right justified.print(' ',' '.join(L1))print(' ',' = '.join(L2),'=',quotient)print(' ',' '.join(L3))returnstatusdefcalculate_abc_epq(ABCDEF_,flag=0):'''result = calculate_abc_epq (ABCDEF_ [, flag])For parabola, result is: [((a,b,c), (e,p,q))]For ellipse or hyperbola, result is: [((a1,b1,c1), (e,p1,q1)), ((a2,b2,c2), (e,p2,q2))]'''thisName='calculate_abc_epq (ABCDEF, {}) :'.format(bool(flag))ABCDEF=[dD(str(v))forvinABCDEF_]ifflag:v1,v2,v3,v4,v5,v6=ABCDEFstr1='({})x^2 + ({})y^2 + ({})xy + ({})x + ({})y + ({}) = 0'.format(v1,v2,v3,v4,v5,v6)print('\n'+thisName,'enter')print(str1)result=calculate_Kab(ABCDEF[:3],flag)output=[]for(K,a,b)inresult:A,B,C,D,E,F=[reduce_Decimal_number(K*v)forvinABCDEF]X=A+B+2e=X.sqrt()# Quadratic function in c: (a_)c**2 + (b_)c + (c_) = 0# Directrix has equation: ax + by + c = 0.a_=4*X*(1-X)b_=4*X*(D*a+E*b)c_=-D*D-E*E-4*Fvalues_of_c=solve_quadratic((a_,b_,c_))# values_of_c may be empty in which case this value of K is not used.forcinvalues_of_c:p=(D-2*X*a*c)/2q=(E-2*X*b*c)/2abc=[reduce_Decimal_number(v)forvin(a,b,c)]epq=[reduce_Decimal_number(v)forvin(e,p,q)]output+=[(abc,epq)]ifflag:print(thisName)str1=' ({})x^2 + ({})y^2 + ({})xy + ({})x + ({})y + ({}) = 0'.format(A,B,C,D,E,F)print(str1)ifvalues_of_c:str1=' K = {}. values_of_c = {}'.format(K,values_of_c)else:str1=' K = {}. values_of_c = {}'.format(K,'EMPTY')print(str1)iflen(output)notin(1,2):# This should be impossible.print(thisName)print(' Internal error: len(output) =',len(output))1/0ifflag:# Check output and print results.L1=[]for((a,b,c),(e,p,q))inoutput:print(' e =',e)print(' directrix: ({})x + ({})y + ({}) = 0'.format(a,b,c))print(' for focus : p, q = {}, {}'.format(p,q))# A small circle at focus for grapher.print(' (x - ({}))^2 + (y - ({}))^2 = 1'.format(p,q))# normal through focus :a_,b_=b,-a# normal through focus : a_ x + b_ y + c_ = 0c_=reduce_Decimal_number(-(a_*p+b_*q))print(' normal through focus: ({})x + ({})y + ({}) = 0'.format(a_,b_,c_))L1+=[(a_,b_,c_)]_ABCDEF=ABCDEF_from_abc_epq((a,b,c),(e,p,q))# This line checks that values _ABCDEF, ABCDEF make sense when compared against each other.ifnotcompare_ABCDEF1_ABCDEF2(_ABCDEF,ABCDEF):print(' _ABCDEF =',_ABCDEF)print(' ABCDEF =',ABCDEF)2/0# This piece of code checks that normal through one focus is same as normal through other focus.# Both of these normals, if there are 2, should be same line.# It also checks that 2 directrices, if there are 2, are parallel.set2=set(L1)iflen(set2)!=1:print(' set2 =',set2)3/0returnoutput
Because curve is hyperbola, there are two directrices and two foci.
For more insight into the method of calculation and also to check the calculation:
calculate_abc_epq(input,1)# Set flag to 1.
calculate_abc_epq (ABCDEF, True) : enter
# Given equation is not in standard form.
(7)x^2 + (0)y^2 + (-24)xy + (90)x + (216)y + (-81) = 0
calculate_Kab (ABC, True) :
A_,B_,C_ (Decimal('7'), Decimal('0'), Decimal('-24'))
a_,b_,c_ (Decimal('-576'), Decimal('28'), 4)
y = (-576.0)x^2 + (28.0)x + (4.0)
values_of_K [Decimal('0.1111111111111111111111'), Decimal('-0.0625')]
K = 0.1111111111111111111111
A 0.7777777777777777777777
B 0
C -2.666666666666666666666
X 2.777777777777777777778
aa 0.64
K = -0.0625
A -0.4375
B 0
C 1.5
X 1.5625
aa 0.36
calculate_Kab (ABC, True) :
output[0] = [Decimal('0.1111111111111111111111'), Decimal('0.8'), Decimal('-0.6')]
output[1] = [Decimal('-0.0625'), Decimal('0.6'), Decimal('0.8')]
calculate_abc_epq (ABCDEF, True) :
# Here is where unwanted value of K is rejected.
(0.7777777777777777777777)x^2 + (0)y^2 + (-2.666666666666666666666)xy + (10)x + (24)y + (-9) = 0
K = 0.1111111111111111111111. values_of_c = EMPTY
calculate_abc_epq (ABCDEF, True) :
# Equation of hyperbola in standard form.
(-0.4375)x^2 + (0)y^2 + (1.5)xy + (-5.625)x + (-13.5)y + (5.0625) = 0
K = -0.0625. values_of_c = [Decimal('-3'), Decimal('-22.2')]
e = 1.25
directrix: (0.6)x + (0.8)y + (-3) = 0
for focus : p, q = 0, -3
(x - (0))^2 + (y - (-3))^2 = 1
normal through focus: (0.8)x + (-0.6)y + (-1.8) = 0
# Method calculates equation of hyperbola using these values of directrix, eccentricity and focus.
# Method then verifies that calculated and given values are the same curve.
-0.4375 1.5 -5.625 -13.5 5.0625
------- = --- = ------ = ----- = ------ = -0.0625 # K
7 -24 90 216 -81
e = 1.25
directrix: (0.6)x + (0.8)y + (-22.2) = 0
for focus : p, q = 18, 21
(x - (18))^2 + (y - (21))^2 = 1
normal through focus: (0.8)x + (-0.6)y + (-1.8) = 0 # Same as normal above.
# Method calculates equation of hyperbola using these values of directrix, eccentricity and focus.
# Method then verifies that calculated and given values are the same curve.
-0.4375 1.5 -5.625 -13.5 5.0625
------- = --- = ------ = ----- = ------ = -0.0625 # K
7 -24 90 216 -81
Graph of quadratic function At intersection of and curve, slope is vertical. At intersection of and curve, slope = . Slope of curve is never horizontal.
Consider conic section:
This is quadratic function:
Slope of this curve:
Produce values for slope horizontal, slope vertical and slope
# python codeABCDEF=A,B,C,D,E,F=0,-1,0,-4,-14,-5# quadratic x = f(y)three_slopes(ABCDEF,0.5,1)
(0)x^2 + (-1)y^2 + (0)xy + (-4)x + (-14)y + (-5) = 0
For slope horizontal: (0)x + (0)y + (-4) = 0 # This does not make sense.
# Slope is never horizontal.
For slope vertical: (0)x + (-2)y + (-14) = 0 # y = -7
For slope 0.5: (0.0)x + (-1.0)y + (-11.0) = 0 # y = -11
Graph of parabola At intersection of and curve, slope is horizontal. At intersection of and curve, slope is vertical. At intersection of and curve, slope = . Slope of curve is never because axis has slope and curve is never parallel to axis.
Consider conic section:
This curve is a parabola.
Produce values for slope horizontal, slope vertical and slope
Graph of ellipse At intersection of and curve, slope is horizontal. At intersection of and curve, slope is vertical. At intersection of and curve, slope =
Consider conic section:
This curve is an ellipse.
Produce values for slope horizontal, slope vertical and slope
Graph of hyperbola At intersection of and curve, slope is horizontal. and curve do not intersect. Slope is never vertical. At intersection of and curve, slope =
Consider conic section:
This curve is a hyperbola.
Produce values for slope horizontal, slope vertical and slope
"Latus rectum" is a Latin expression meaning "straight side."
According to Google, the Latin plural of "latus rectum" is "latera recta,"
but English allows "latus rectums" or possibly "lati rectums."
The title of this section is poetry to the eyes and music to the ears of a Latin student
and this author hopes that the gentle reader will permit such poetic licence in a mathematical topic.
The translation of the title is "Latus rectums and other things." This section describes the calculation of interesting items
associated with the ellipse: latus rectums, major axis, minor axis, focal chords, directrices and various points on these lines.
When given the equation of an ellipse, the first thing is to calculate eccentricity, foci and directrices as shown above.
Then verify that the curve is in fact an ellipse.
From these values everything about the ellipse may be calculated. For example:
P = (20.30821052631578947368, -15.61094736842105263158) Q = (10.53708406832736953616, -8.018239580333420216299) R = (5.984, 3.488) S = (10.016, 6.512) T = (19.78712645798841993752, -1.080707788087632415281) U = (24.34021052631578947368, -12.58694736842105263158)
Distance between directrices: = 29.47368421052631578947 Length of major axis: = 26.52631578947368421052 Distance between foci: = 23.87368421052631578947 Length of minor axis: QT = 11.56255298707631300170 Length of latus rectum: RS = PU = 5.04
Consider conic section:
This curve is ellipse with random orientation.
# python codeABCDEF=A,B,C,D,E,F=1771,1204,1944,-44860,-18520,214400# ellipseresult=calculate_abc_epq(ABCDEF)(len(result)==2)or1/0# ellipse or hyperbola(abc1,epq1),(abc2,epq2)=resulta1,b1,c1=abc1;e1,p1,q1=epq1a2,b2,c2=abc2;e2,p2,q2=epq2(e1==e2)or2/0(1>e1>0)or3/0print('({})x^2 + ({})y^2 + ({})xy + ({})x + ({})y + ({}) = 0'.format(A,B,C,D,E,F))A,B,C,D,E,F=ABCDEF_from_abc_epq(abc1,epq1)print('Equation of ellipse in standard form:')print('({})x^2 + ({})y^2 + ({})xy + ({})x + ({})y + ({}) = 0'.format(A,B,C,D,E,F))
# python codedefsum_zero(input):'''sum = sum_zero(input)If sum is close to 0 and Tolerance permits, sum is returned as 0.For example: if input contains (2, -1.999999999999999999999)this function returns sum of these 2 values as 0. '''globalTolerancesump=sumn=0forvininput:ifv>0:sump+=velifv<0:sumn-=vsum=sump-sumnifabs(sum)<Tolerance:return(type(Tolerance))(0)min,max=sorted((sumn,sump))ifabs(sum)<=Tolerance*min:return(type(Tolerance))(0)returnsum
# direction cosines along latus rectum.dlx,dly=-dy,dx# # distance from U to F1 half_latus_rectum# ------------------------------ = ----------------------- = e1# distance from U to directrix 1 distance_from_F1_to_ID1# half_latus_rectum=reduce_Decimal_number(e1*distance_from_F1_to_ID1)# latus rectum 1# Focal chord has equation (afc)x + (bfc)y + (cfc) = 0.afc,bfc=a1,b1cfc=reduce_Decimal_number(-(afc*p1+bfc*q1))print(' Focal chord PU : ({})x + ({})y + ({}) = 0'.format(afc,bfc,cfc))P=xP,yP=p1+dlx*half_latus_rectum,q1+dly*half_latus_rectumprint(' Point P : ({}, {})'.format(xP,yP))U=xU,yU=p1-dlx*half_latus_rectum,q1-dly*half_latus_rectumprint(' Point U : ({}, {})'.format(xU,yU))distance=reduce_Decimal_number(((xP-xU)**2+(yP-yU)**2).sqrt())print(' Length PU =',distance)print(' half_latus_rectum =',half_latus_rectum)
Focal chord PU : (0.6)x + (-0.8)y + (-24.67368421052631578947) = 0
Point P : (20.30821052631578947368, -15.61094736842105263158)
Point U : (24.34021052631578947368, -12.58694736842105263158)
Length PU = 5.04
half_latus_rectum = 2.52
Techniques similar to above can be used to calculate points
All interesting points have been calculated without using equations of any of the relevant lines.
However, equations of relevant lines are very useful for testing, for example:
Check that points are on axis.
Check that points are on latus rectum through
Check that points are on minor axis through
Check that points are on latus rectum through
Test below checks that 8 points are on ellipse and satisfy eccentricity
t1=(('I1'),('I2'),('P'),('Q'),('R'),('S'),('T'),('U'),)fornameint1:value=eval(name)x,y=[reduce_Decimal_number(v)forvinvalue]print('{} : ({}, {})'.format((name+' ')[:2],x,y))values=A*x**2,B*y**2,C*x*y,D*x,E*y,Fsum_zero(values)and3/0# Relative to Directrix 1 and Focus 1:distance_to_F1=((x-p1)**2+(y-q1)**2).sqrt()distance_to_directrix1=a1*x+b1*y+c1e1=distance_to_F1/distance_to_directrix1print(' e1 =',e1)# Raw value is printed.# Relative to Directrix 2 and Focus 2:distance_to_F2=((x-p2)**2+(y-q2)**2).sqrt()distance_to_directrix2=a2*x+b2*y+c2e2=distance_to_F2/distance_to_directrix2e2=reduce_Decimal_number(e2)print(' e2 =',e2)# Clean value is printed.
Note the differences between "raw" values of and "clean" values of