You are on page 1of 2

Identifying Conic Sections According to the Values of

Discriminant using MATLAB


John Carlo S. Tigue
Department of Electrical and Electronics Engineering
University of San Carlos
Nasipit,Talamban, Cebu City
tiguejohncarlo@gmail.com
Abstract - This paper shows detailed and step-by-step
codes on how to determine if the equation is Parabola,
Hyperbola, Circle or Ellipse given the inputs of A, B, C, D,
E, and F of the general-form conic equation in the form
Ax2 + Bxy + Cy2 + Dx + Ey + F = 0 using MATLAB.
Index Terms Hyperbola, Ellipse, Hyperbola, Circle
ConicEquation,MATLAB
I. INTRODUCTION
MATLAB is an interactive program for numerical
computation, data visualization, algorithm development and
data analysis; it is used extensively by control engineers for
analysis and design.

Frances Irah D. Sayson


Department of Electrical and Electronics Engineering
University of San Carlos
Nasipit,Talamban, Cebu City
cafraidasa11@gmail.com
Each conic has a "typical" equation form, sometimes
alongthelinesofthefollowing:
parabola:Ax2+Dx+Ey=0
circle:x2+y2+Dx+Ey+F=0
ellipse:Ax2+Cy2+Dx+Ey+F=0
hyperbola:Ax2Cy2+Dx+Ey+F=0
TheGeneralEquationforaConicSection:
Ax2+Bxy+Cy2+Dx+Ey+F=0
Thetypeofsectioncanbefoundfromthesignof:B 2
4AC
IfB24ACis... thenthecurveisa...
<0

ellipse,circle,pointornocurve.

So how do one identify if the given equation is a circle,


ellipse, parabola or hyperbola using matlab?

=0

parabola,2parallellines,1lineorno
curve.

By using conic sections, we can identify if the equation is


a circle, ellipse, parabola or hyperbola.

>0

hyperbolaor2intersectinglines.

A conic section is the intersection of a plane and a cone.


By changing the angle and location of intersection, we can
produce a circle, ellipse, parabola or hyperbola; or in the
special case when the plane touches the vertex: a point, line
or 2 intersecting lines.
Oneverybasicquestionthatcomesupprettyfrequently
is"Givenanequation,howdoIknowwhichsortofconicit
is?"Justaseachconichasatypicalshape:

II. METHODOLOGY
The students were tasked to create a program that will
identify whether the given equation is a parabola, hyperbola,
circle or ellipse.These are done using decision control
statement in c-programming. In decision control statements
(C if else and nested if), group of statements are executed
when condition is true. If condition is false, then else part
statements are executed.
There are 3 types of decision making control statements
in C language. They are,
if statements
if else statements
nested if statements
Nested if is used in this program.
The codes below were used in the experiment

Figure1TypesofConicSections

>>clear all; close all; clc;


>>disp('For equation, Ax^2 + Bxy + Cy^2 +
Dx + Ey + F = 0')
>>A = input('Enter the value of A: ');
>>B = input('Enter the value of B: ');

>>C
>>D
>>E
>>F

=
=
=
=

input('Enter
input('Enter
input('Enter
input('Enter

the
the
the
the

value
value
value
value

of
of
of
of

C:
D:
E:
F:

');
');
');
');

>>x = B^2 - 4*A*C


>>if x==0;
h=((-D)/(2*A));
k=(((D^2)-(4*A*F))/(4*A*E));
sprintf('The equation is a parabola
whose vertex is (%.f,%.f)',h,k)
>>elseif x>0;
h=((-D)/(2*A));
k=((-E)/(2*C));
sprintf('The equation is a hyperbola
whose center is (%.f,%.f)',h,k)
>>elseif x<0 && A==C;
h=((-D)/(2*A));
k=((-E)/(2*A));
r=(sqrt(((D^2)+(E^2)(4*A*F))/(4*(A^2))));
sprintf('The equation is a circle
whose center is (%.f,%.f) and whose radius
is %.f',h,k,r)
>>else x<0 && A~=C;
h=((-D)/(2*A));
k=((-E)/(2*C));
sprintf('The equation is an ellipse
whose center is (%.f,%.f)',h,k)
>>end
To verify, if the codes inputted are correct, the teacher has
given set of equations to check the validity of the program.
III. RESULTS AND DISCUSSIONS
The discriminant of an equation was very useful to
evaluate as to what conic section they do belong. Also, the
conditions in an if-else statement with corresponding
formulas of the parabola, hyperbola, ellipse and circle that
was mentioned in the methodology.
Testing the program if it is valid and to check if the
inputted codes are correct that will evaluate to what conic
section they do belong, here are the sample equations:
1.
2.
3.
4.

x2+y2-8x+2y-16 = 0
4x2+4x-24y+37 = 0
9x2+y2+18x-12y-180 = 0
5x2-4y2-20x-24y-36 = 0

For number 1 of the sample equations, after inputting the


values of A=1, B=0, C=1, D=-8, E=2 and F= -16, the
program evaluates that the equation is a circle because A and
C is equal and B is zero. Hence, the program is correct, For
number 2 of the sample equations, A=4, B=0, C=0, D=-4,
E=-24 and F= 37, inputting all these values the program
evaluates that the equation is a parabola. The program meets
the condition that the given equation is parabola because the

discriminant is equal to zero. For number 3 of the sample


equations, A=9, B=0, C=1, D=18, E=-12 and F= -180,
inputting all these values the program evaluates that the
equation is an ellipse. The program meets the condition that
the equation is an ellipse and is, therefore, correct because the
discriminant of the is less than zero. Lastly, for number 4,
A=5, B=0, C=-4, D=-20, E=-24 and F= -36, inputting all
these values the program evaluates that the equation is a
hyperbola. The program meets the condition that the equation
is a hyperbola and is, therefore, correct because the
discriminant is greater than zero.
Given a general-form conic equation in the
form Ax2 + Cy2 + Dx + Ey + F = 0, or after rearranging to
put the equation in this form (that is, after moving all the
terms to one side of the "equals" sign), this is the sequence of
tests one should keep in mind that if both variable are
squared, it is a parabola. Going to the the next test, if the
squared terms have opposite signs, it is therefore a
hyperobola. Lastly, if the squared terms are multiplied by the
same number, it is a circle.
IV. CONCLUSION
Therefore, Nested if and else-if statement are very
essential in determining the type of the conic such as
parabola, hyperbola, circle and ellipse according to the value
of its discriminant. These allow a choice to be made between
two possible alternatives and sometimes a choice must be
made between more than two possibilities.
MATLAB is very useful for making scientific and
engineering plots. One can create plots of known, analytical
functions, one can plot data from other sources such as
experimental measurements, you can analyze data, perhaps by
fitting it to a curve, and then plot a comparison. MATLAB
also has powerful built-in routines for drawing contour and
three-dimensional surface plots z = f(x,y) data.
ACKNOWLEDGMENT
The authors would like to thank God for helping them in
enlightening their minds in making this project. They would
also like to thank their classmates for guiding them and giving
them advices in how to make this project. Thank you also to
their parents for supporting them and helping in making this
project successful. Without them, this project would not be
successful.
REFERENCES
[1]
[2]

Gilat, Amos (2004). MATLAB: An Introduction with Applications 2nd


Edition. John Wiley & Sons. ISBN 978-0-471-69420-5.
Barnett, R.A.; Ziegler, M.R.; Byleen, K.E. (2008), College Mathematics
for Business, Economics, Life Sciences and the Social Sciences (11th ed.),
Upper Saddle River, N.J.: Pearson, ISBN 0-13-157225-3

You might also like