SOLUTION TO CUBIC EQUATION USING JAVA PROGRAMMING

2y ago
174 Views
6 Downloads
396.94 KB
9 Pages
Last View : 13d ago
Last Download : 2m ago
Upload by : Samir Mcswain
Transcription

European Journal of Mathematics and Computer ScienceVol. 7 No. 1, 2020ISSN 2059-9951SOLUTION TO CUBIC EQUATION USING JAVA PROGRAMMINGShouthiri PartheepanDepartment of MathematicsEastern UniversitySRI LANKAshouthirip@esn.ac.lkDisne SivalingamDepartment of MathematicsEastern UniversitySRI LANKAdisnesiva777@gmail.comABSTRACTSolving cubic equation is one of the non-linear Algebraic equation in mathematics. Many Cubicequations can be solved algebraically, however many cannot be solved, because of the complexity. Thediscriminant approach for solving cubic equation is adopted in this study to generate the solution. Thisstudy is used to design a programming solution to solve cubic equation using java programminglanguage. This solution was developed by using the Eclipse as integrated Development Environment(IDE) to compile, run and for finding the bugs in the program. Usually large errors in using mathematicalalgorithms are treated by using the cubic equations. Using this application, we can outline the way ofsolving this cubic equation. In the view of the implication of findings, it was recommended that there isa need for design and development of computational solution and utilization into classroom study.Finally, this programme can give solution to two problems such that we can able to generate the rootvalues for the given cubic equation. And also we can able to generate the cubic equation by giving thethree real root values. Many examples have been worked out, and in most cases, we found out the exactsolution.Keywords: Cubic Equation, nonlinear Algebraic equation, Discriminant approach, Eclipse, IntegratedDevelopment Environment.INTRODUCTIONIn the computational world, Computer programming touches almost every aspect of our lives. Solvingnon-linear algebraic equations such as cubic equation and solving solution to nonlinear system ofequation is the foundation of many scientific programming. Cubic equation is a special type ofpolynomial equation that is used in many fields of study. For example, a cubic equation is used to predictsurface tension and spinodal limits [1]. In modern technologies to get the accurate value and to get quickanswer, mathematics takes the form of computer applications. These kind of software applicationssupport to the cognitive process reducing the memory load of students and creating awareness to theproblem-solving process.A cubic equation can be written in the form of π‘Žπ‘₯ 3 𝑏π‘₯ 2 𝑐π‘₯ 𝑑 0. It must have the term in π‘₯ 3 orit would not be cubic (and so a 0), but any or all of b, c and d can be zero. Cubic equation can be solvedusing synthetic division, Cardano’s formula [6] or identifying discriminants by Cubic formula [3].However, this paper proposed computer programs of solving cubic equation based on discriminantmethod and generate cubic equation based on given real solutions. Discriminant ( ) of quadratic equationand cubic equation is a popular numerical method of evolutionary computing. Quadratic equations caneasily be solved, by using the quadratic formula. In particular, we have π‘Žπ‘₯ 2 𝑏π‘₯ 𝑐 0 if andonly if π‘₯ 𝑏 𝑏 2 4π‘Žπ‘2π‘Ž[2]. The expression 𝑏 2 4π‘Žπ‘ is known as the discriminant ( ) of the quadratic.Progressive Academic Publishing, UKge 20Page 20www.idpublications.orgwww.idpublications.org

European Journal of Mathematics and Computer ScienceVol. 7 No. 1, 2020ISSN 2059-9951According to discriminant ( ) three cases considered for the solution. Thus, the quadratic equation hastwo real solutions if 0, only one real solution if 0, and no real solutions if 0. Thecorresponding formula for solving cubic and quartic equations are significantly more complicated. Inthis study, the computer program with numerical formula using discriminant was used to get approximatesolutions for cubic equations. Moreover, an algorithm was proposed for a numerical method to determinethe cubic equation from given real solutions.JavaJava is a popular general-purpose programming language and computing platform. It is fast, reliable, andsecure. One of the reason why java widely used is because of the availability of huge standard library.The Java environment has hundreds of classes and methods under different packages to help softwaredevelopers. Java.util is a package, while Scanner is a class of this package and used to get user input.Java.lang package provides classes for performing basic numeric operations.EclipseIn computer programming, Eclipse is an integrated development environment (IDE) for developingapplications. The main use of Eclipse is for developing Java applications, but it may also be used todevelop applications in other programming languages such as C/C , Python, PERL, Ruby etc. Eclipsecontains a base workspace and an extensible plug-in system for customizing the environment. TheEclipse software development kit (SDK), which includes the Java development tools, is free and opensource software. Every year, since 2006, the Eclipse foundation releases the Eclipse Platform and anumber of other plug-ins in June [7].Cubic FormulaLet A, B, C and D be real constants such that A 0, then a cubic equation in x is given by,𝐴π‘₯ 3 𝐡π‘₯ 2 𝐢π‘₯ 𝐷 0 .(1.1)Rewrite the equation (1.1) as,π‘₯ 3 π‘Žπ‘₯ 2 𝑏π‘₯ 𝑐 0Where, a 𝐡,b 𝐴𝐢𝐴and c 𝐷𝐴 .(1.2).It is important to mention that a formula called the cubic formula for finding the roots of (1.2).The cubic formula for finding roots of (1.2) as contained is given by,Let p b π‘Ž23Discriminant ( ) and π‘ž π‘ž24 2π‘Ž327 π‘Žπ‘3 𝑐Then,𝑝327As noted earlier, the nature of the roots of a cubic equation depends on whether the associateddiscriminant is positive, negative or zero. The three cases are discussed in this section.Progressive Academic Publishing, UKge 21Page 21www.idpublications.orgwww.idpublications.org

European Journal of Mathematics and Computer ScienceVol. 7 No. 1, 2020ISSN 2059-9951Case 1: Roots of a cubic equation when 0 there is only one real solution.11 π‘ž π‘žπ‘Žπ‘₯1 ( 2 ) 3 ( 2 ) 3 3Case 2: Roots of a cubic equation when 0 there are repeated roots.1 3π‘žπ‘₯1 2 (2)π‘Ž-3π‘ž1 3π‘₯2 π‘₯3 (2)andπ‘Ž-3Case 3: Roots of a cubic equation when 0 there are three real solutions.π‘₯1 213 3π‘žπ‘Ž)) 𝑝 sin ( sin 1 (333 32( 𝑝)213 3π‘ž 𝑝 sin (3 sin 1 (2( 3π‘₯2 π‘₯3 𝑝)3πœ‹π‘Ž) 3) 3213 3π‘žπœ‹π‘Ž) ) 𝑝 cos ( sin 1 (3363 32( 𝑝)Generate Cubic Formula from the given SolutionLet a, b, c and d be real constants such that a 0, then a cubic equation in x is given by,π‘Žπ‘₯ 3 𝑏π‘₯ 2 𝑐π‘₯ 𝑑 0 .(2.1)Assume the cubic formula (2.1) has roots Ξ±, Ξ², and Ξ³.Then the cubic formula can represent by,(π‘₯ 𝛼)(π‘₯ 𝛽)(π‘₯ 𝛾) 0 . (2.2)Extract the equation (2.2) as,(π‘₯ 𝛼)(π‘₯ 𝛽)(π‘₯ 𝛾) 0(π‘₯ 𝛼)(π‘₯ 2 𝛾π‘₯ 𝛽π‘₯ 𝛽𝛾) 0π‘₯ 3 𝛾π‘₯ 2 𝛽π‘₯ 2 𝛽𝛾π‘₯ 𝛼π‘₯ 2 𝛼𝛾π‘₯ 𝛼𝛽π‘₯ 𝛼𝛽𝛾 0π‘₯ 3 ( 𝛽 𝛾)π‘₯ 2 (𝛼𝛽 𝛽𝛾 𝛼𝛾)π‘₯ 𝛼𝛽𝛾 0 . (2.3)Divide the equation (2.1) by a, then𝑏𝑐𝑑π‘₯ 3 π‘Ž π‘₯ 2 π‘Ž π‘₯ π‘Ž 0 . (2.4)Compare the coefficients in the equations (2.3) and (2.4),π‘π‘Ž ( 𝛽 𝛾),Progressive Academic Publishing, UKge 22Page 22www.idpublications.orgwww.idpublications.org

European Journal of Mathematics and Computer Scienceπ‘π‘Žπ‘‘π‘ŽVol. 7 No. 1, 2020ISSN 2059-9951 𝛼𝛽 𝛽𝛾 𝛼𝛾, (𝛼𝛽𝛾)METHODOLOGYA discriminant approach is being followed for development of this solution. The algorithm based ondiscriminant approach is implemented using β€˜Java’ programming language. The steps followed aredescribed in below.Algorithm for Find RootsStartinput the co-efficient values as A, B, C and D𝐡𝐢𝐷find a 𝐴 , b 𝐴 and c π΄π‘Ž22π‘Ž3π‘Žπ‘find p as b - 3 , q as 27 3 𝑐 and asif 0 then,find a real root x1else if 0 then,find real roots x1 and x2elsefind real roots x1, x2 and x3end ifprint root valuesπ‘ž24 𝑝327endAlgorithm for Find EquationStartinput the real root values as , 𝛽, and 𝛾find the value ( 𝛽 𝛾)find the value 𝛼𝛽 𝛽𝛾 𝛼𝛾find the value (𝛼𝛽𝛾)determine the cubic equationprint the cubic equationendFlow- ChartFlowchart to calculate the roots of cubic equation and construction of the cubic equation using the rootvalues is shown in Figure 1.Progressive Academic Publishing, UKge 23Page 23www.idpublications.orgwww.idpublications.org

European Journal of Mathematics and Computer ScienceVol. 7 No. 1, 2020ISSN 2059-9951StartRead ChoiceyesIfChoice 1Read a, b, c, dNoIs thecoefficientof x3 equalto one?NoIfChoice 2NoPrint: invalidYesyesDivide theequation bythecoefficientof x3Read Sol1, Sol2, Sol3Calculate thecoefficients of x3, x2, xPrint the equationCompute p, q, Is 0StopxNoNoIs 0yesyesyesCompute x1Compute x1, x2, x3Print realSolutionxStopCompute x1, x2Print realSolutionsPrint realSolutionsxxStopStopFigure 1: Flow chart for the solutionProgressive Academic Publishing, UKge 24Page 24www.idpublications.orgwww.idpublications.org

European Journal of Mathematics and Computer ScienceVol. 7 No. 1, 2020ISSN 2059-9951RESULTS AND DISCUSSIONTest Algorithm for Find RootsThe application for cubic solution tested using different cubic equations to find the real roots. Also thesame equations used to solve manually. For the Experiment the cubic equations used to test the resultsare given in table 1:Table 1: cubic equations used to test resultsx3 -6x2 11x-6 0-------(1)x3 -5x2 8x-4 0-------(2)x3 -3x2 3x-1 0-------(3)x3 -9x2 36x-80 0-------(4)3x3 5x2 4.5x 5.6 0-------(5)5x3 -98x2 96x-7 0-------(6)2x3 -7x2 9x 8 0-------(7)x3 -19x2 118.25x-242 0 -------(8)x3 -55x2 65x 8 0-------(9)6x3 -12x2 -64x 32 0-------(10)The application developed using Java programming language was tested by the given cubic equationsand the sample output interface illustrates by figure 2.Figure 2: Sample result for find roots using Eclipse IDEAccording to the comparison between computational solution and manual solution given in table 2, thedifference may not be considerable.Progressive Academic Publishing, UKge 25Page 25www.idpublications.orgwww.idpublications.org

European Journal of Mathematics and Computer ScienceVol. 7 No. 1, 2020ISSN 2059-9951Table 2: Computational and manual results for tested cubic equationsEquationComputational valueManually calculated 03100.4685-2.69414.22560.4685-2.69414.2256Test Algorithm for Find EquationThe tested algorithm has two parts, such as the application part for finding cubic equation was testedfor given three real root values given in table 3.Table 3: real root values used to test resultsSolution No.Root 1Root 2Root 9The application developed using Java programming language was tested by the given real root valuesand the sample output interface illustrates by figure 3.Figure 3: Sample result for find cubic equation using Eclipse IDEProgressive Academic Publishing, UKge 26Page 26www.idpublications.orgwww.idpublications.org

European Journal of Mathematics and Computer ScienceVol. 7 No. 1, 2020ISSN 2059-9951Comparing the Computational Cubic Equation with actual equation given in Table 4, there is nosignificant difference.Table 4: Computational and Actual cubic equation for given root valuesEquation NoComputational Cubic EquationActual Equation1x3 -3x2 3x-1 0x3 -3x2 3x-1 02x3 -6.5x2 12.87x-7.62 0x3 -6.5x2 12.87x-7.623 03x3 -0.01x2 -8.98x 3.95 0x3 - 9x 4 04x3 3x2 3x 1 0x3 3x2 3x 1 05x3 5x2 -1.01x-2.01 02x3 10x2 -2x-4 0In conclusion, the programming application for solving the cubic equation results and finding the cubicequation for given real solution in excellent performance level.CONCLUSIONSNowadays, although the technologies have been developed rapidly, its operations have to be increasedin the classroom studies. The use of a computer application to solve the mathematical calculation makesthe future generation more independent [4,5]. As this cubic equation is commonly used in mathematics,its actual use be expected to be one of the best understood of computer algorithms. The fundamentalcontribution of this paper is the establishment of computer application of finding the solution of a cubicequation using the concept of discriminant method. The general algorithm for the cubic equation usingdiscriminant method is established. The discriminant of a cubic equation, , which comprises p and q,such that is shown to depend on the nature of the roots of a given equation. In mathematics, a cubicequation has three distinct real roots if 0, if 0 one real root and if 0 either two equal real rootsor three equal real roots. Moreover, the programming solution of a cubic equation is implemented usingthe algorithm that depends on the corresponding discriminant method. Finally, numerical examples areused to substantiate the established application.REFERENCES[1] Biney P. O, Wei-guo Dong & Lienhard J. H. (1986). Use of a Cubic Equation to Predict SurfaceTension and Spinodal Limits. Journal of Heart Transfer, 108(2): 405–410.https://doi.org/10.1115/1.3246938[2] Blinn H. (2005). How to solve a quadratic equation?. IEEE Computer Graphics and Applications,25(6), 76-79. doi: 10.1109/MCG.2005.134[3] Blinn J. F. (2007). How to solve a cubic equation, Part 5: Back to numerics. IEEE Computer Graphicsand Applications, 27(3), 78–89. doi:10.1109/MCG.2007.60[4] Meera S. A. Deepthi Y. & Ramya N. (2018). Solving Quadratic Equations Using C ApplicationProgram. International Research Journal of Engineering and Technology (IRJET), 5(3), 17981801.Progressive Academic Publishing, UKge 27Page 27www.idpublications.orgwww.idpublications.org

European Journal of Mathematics and Computer ScienceVol. 7 No. 1, 2020ISSN 2059-9951[5] Nayak T. & Dash T. (2012). Solution to Quadratic Equation Using Genetic Algorithm. In: Conf.Proceedings of National Conference on Artificial Intelligence, Robotics and Embedded Systems(AIRES-2012). Andhra University, Vishakhapatnam, India, 29-30 June. pp. 10-13.[6] Okereke O. Iwueze I. & Ohakwe J. (2014). Some Contributions to the Solution of Cubic [7] Wikipedia The Free Encyclopedia (2019). Eclipse(Software) Wikimedia Foundation, Inc., a nonprofit organization. Available at https://en.wikipedia.org/wiki/Eclipse (software)Progressive Academic Publishing, UKge 28Page 28www.idpublications.orgwww.idpublications.org

study is used to design a programming solution to solve cubic equation using java programming language. This solution was developed by using the Eclipse as integrated Development Environment (IDE) to compile, run and for finding the bugs i

Related Documents:

(of hole length) m3 cubic meter Mcf thousand cubic feet cm centimeter cm3/g cubic centimeter per gram Mcfd thousand cubic feet per day ft foot m3/d cubic meter per day cubic foot per minute cubic foot per short ton gallon gallon per minute hour inch kilogram kilo pascal pound (m3/d)/m cubic meter per day per meter (of hole length) MMcf

Size of Container Depth Height Width 1 or 1.5 cubic yard 2 cubic yard bin 3 cubic yard bin 4 cubic yard bin 6 cubic yard bin 15 cubic yard box 20 cubic yard box 30 cubic yard box 34.5 in x 40.5 in x 45 in x 55 in x . enclosure plans should be designed to allow drivers to pull through. Facility roadways must be designed in such a manner that .

Softener 48K Grain 1.5 cubic foot size . 10” x 54” filter tank with distributor tube . 16 lbs. Filter gravel . 1.5 cubic foot of Softener resin media . Softener 62K Grain 2.0 cubic foot size . 12” x 52” filter tank with distributor tube . 20 lbs. Filter gravel . 2.0 cubic foot of Softener resin media . Softener 80K Grain 2.5 cubic foot size

To use the remainder theorem and the factor theorem to solve cubic equations. To find equations for given cubic graphs. To apply cubic and quartic functions to solving problems. To use finite difference tables to find rules of sequences generated by polynomial functions. In Chapter 4 we looked at second degree polynomials or quadratics. A third degree polynomial is called a cubic and is a .

Volume and capacity – cubic centimetres and cubic metres One cubic centimetre is 1 cm long, 1 cm wide and 1 cm high. The symbol we use for cubic cm is cm3. 1 cm 1 cm 1 cm 1 cm3 One cubic metre is 1 m long, 1 m wide and

How to Calculate DIM Pricing DETERMINE PACKAGE CUBIC INCHES Box size: length x width x height total cubic inches of package Example: 12" x 12" x 8" 1,152 cubic inches DIVIDE CUBIC INCHES BY DIM DIVISOR Divide total cubic inches by DIM Divisor. The divisor is a set number determined by each carrier.

cubic feet we have, and the enclosure is now 1.79 cubic feet. Since the recommended sealed enclosure for the Punch Power 12" DVC subwoofer is 1.25 cubic feet to 1.75 cubic feet, we're just about right on with the enclosure! However, if we were trying to make a ported enclosure that was 2.0 cubic feet, we'll need to make the enclosure

2. An aviary is an enclosure for keeping birds. There are 134 birds in the aviary shown in the diagram. What is the number of birds per cubic yard for this aviary? Round your answer to the nearest hundredth. A. 0.19 birds per cubic yard B. 0.25 birds per cubic yard C. 1.24 birds per cubic yard D. 4.03 birds per cubic yard 3.